summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-21 10:18:20 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-21 10:18:20 -0400
commitc0b8071a49ce472ff915ba3ea3387c29edbebfc1 (patch)
tree9b952c226cd5d3a119b00f2643f6bf2e969ef417
parent268a152731498e58f38da0a4f1dc5046ae2fbf3f (diff)
Split JavaScript inp() into separate functions
-rw-r--r--lib/js/urweb.js27
-rw-r--r--src/monoize.sml10
2 files changed, 23 insertions, 14 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 8890c446..25ed2f7a 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -295,7 +295,7 @@ function dyn(s) {
populate(x);
}
-function inp(t, s, content) {
+function input(t, s) {
var x = document.createElement(t);
x.dead = false;
x.signal = ss(s);
@@ -303,14 +303,23 @@ function inp(t, s, content) {
x.recreate = function(v) { if (x.value != v) x.value = v; };
populate(x);
addNode(x);
- if (t == "select") {
- x.innerHTML = content;
- x.value = s.data;
- x.onchange = function() { sv(s, x.value) };
- } else {
- x.value = s.data;
- x.onkeyup = function() { sv(s, x.value) };
- }
+
+ return x;
+}
+
+function inp(s) {
+ var x = input("input", s);
+ x.value = s.data;
+ x.onkeyup = function() { sv(s, x.value) };
+
+ return x;
+}
+
+function sel(s, content) {
+ var x = input("select", s);
+ x.innerHTML = content;
+ x.value = s.data;
+ x.onchange = function() { sv(s, x.value) };
return x;
}
diff --git a/src/monoize.sml b/src/monoize.sml
index 6c41de21..2ed7c3f8 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -2565,9 +2565,9 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
loc)), loc), fm)
end
| SOME (_, src, _) =>
- (strcat [str "<span><script type=\"text/javascript\">inp(\"input\",",
+ (strcat [str "<span><script type=\"text/javascript\">inp(",
(L'.EJavaScript (L'.Script, src), loc),
- str ",\"\")</script></span>"],
+ str ")</script></span>"],
fm))
| _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs);
raise Fail "No name passed to textbox tag"))
@@ -2637,9 +2637,9 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
end
| SOME (_, src, _) =>
let
- val sc = strcat [str "inp(\"input\",",
+ val sc = strcat [str "inp(",
(L'.EJavaScript (L'.Script, src), loc),
- str ",\"\")"]
+ str ")"]
val sc = setAttrs sc
in
(strcat [str "<span><script type=\"text/javascript\">",
@@ -2662,7 +2662,7 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
let
val (xml, fm) = monoExp (env, st, fm) xml
- val sc = strcat [str "inp(\"select\",",
+ val sc = strcat [str "sel(",
(L'.EJavaScript (L'.Script, src), loc),
str ",",
(L'.EJavaScript (L'.Script, xml), loc),