# HG changeset patch # User Adam Chlipala # Date 1233068031 18000 # Node ID 5145181b02fa848b2a3df1e2c840c93d956b99ce # Parent 1a9171e31fd18c127461245a141be47ab5d76716 Use normal fields of ctextboxes diff -r 1a9171e31fd1 -r 5145181b02fa lib/js/urweb.js --- a/lib/js/urweb.js Sat Jan 17 09:55:12 2009 -0500 +++ b/lib/js/urweb.js Tue Jan 27 09:53:51 2009 -0500 @@ -87,6 +87,7 @@ addNode(x); s.h = cons(function() { x.value = s.v }, s.h); x.onkeyup = function() { sv(s, x.value) }; + return x; } function eh(x) { diff -r 1a9171e31fd1 -r 5145181b02fa src/monoize.sml --- a/src/monoize.sml Sat Jan 17 09:55:12 2009 -0500 +++ b/src/monoize.sml Tue Jan 27 09:53:51 2009 -0500 @@ -1777,12 +1777,12 @@ L'.ERecord xes => xes | _ => raise Fail "Non-record attributes!" + fun lowercaseFirst "" = "" + | lowercaseFirst s = String.str (Char.toLower (String.sub (s, 0))) + ^ String.extract (s, 1, NONE) + fun tagStart tag = let - fun lowercaseFirst "" = "" - | lowercaseFirst s = String.str (Char.toLower (String.sub (s, 0))) - ^ String.extract (s, 1, NONE) - val s = (L'.EPrim (Prim.String (String.concat ["<", tag])), loc) in foldl (fn (("Action", _, _), acc) => acc @@ -1897,6 +1897,26 @@ normal () | _ => normal () end + + fun setAttrs jexp = + let + val s = (L'.EPrim (Prim.String (String.concat ["<", tag])), loc) + + val assgns = List.mapPartial + (fn ("Source", _, _) => NONE + | (x, e, _) => + SOME (strcat [str ("d." ^ lowercaseFirst x ^ "="), + (L'.EJavaScript (L'.Script, e, NONE), loc), + str ";"])) + attrs + in + case assgns of + [] => jexp + | _ => strcat (str "var d=" + :: jexp + :: str ";" + :: assgns) + end in case tag of "body" => normal ("body", NONE, @@ -2002,12 +2022,17 @@ loc), fm) end | SOME (_, src, _) => - (strcat [str ""], - fm)) - - | "option" => normal ("option", NONE, NONE) + let + val sc = strcat [str "inp(\"input\",", + (L'.EJavaScript (L'.Script, src, NONE), loc), + str ")"] + val sc = setAttrs sc + in + (strcat [str ""], + fm) + end) | "tabl" => normal ("table", NONE, NONE) | _ => normal (tag, NONE, NONE) diff -r 1a9171e31fd1 -r 5145181b02fa tests/ctextbox.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ctextbox.ur Tue Jan 27 09:53:51 2009 -0500 @@ -0,0 +1,7 @@ +fun main () : transaction page = + s <- source "Initial"; + return + + + + diff -r 1a9171e31fd1 -r 5145181b02fa tests/ctextbox.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ctextbox.urp Tue Jan 27 09:53:51 2009 -0500 @@ -0,0 +1,3 @@ +debug + +ctextbox