Mercurial > urweb
changeset 606:5145181b02fa
Use normal fields of ctextboxes
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 27 Jan 2009 09:53:51 -0500 |
parents | 1a9171e31fd1 |
children | 0dd40b6bfdf3 |
files | lib/js/urweb.js src/monoize.sml tests/ctextbox.ur tests/ctextbox.urp |
diffstat | 4 files changed, 46 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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) {
--- 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 "<script type=\"text/javascript\">inp(\"input\",", - (L'.EJavaScript (L'.Script, src, NONE), loc), - str ")</script>"], - 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 "<script type=\"text/javascript\">", + sc, + str "</script>"], + fm) + end) | "tabl" => normal ("table", NONE, NONE) | _ => normal (tag, NONE, NONE)