diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-05-21 10:34:56 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-05-21 10:34:56 -0400 |
commit | 0f7c2c431c9871cdffcde7fc0c8a86815a72e89f (patch) | |
tree | 760d2417c0ab43fa13f59fb41f6303656c9446c0 /lib/js | |
parent | 7b95b3208e776e2fa66142df858464cfbc5137be (diff) |
ccheckbox
Diffstat (limited to 'lib/js')
-rw-r--r-- | lib/js/urweb.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 25ed2f7a..c031678a 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -295,12 +295,12 @@ function dyn(s) { populate(x); } -function input(t, s) { +function input(t, s, recreate) { var x = document.createElement(t); x.dead = false; x.signal = ss(s); x.sources = null; - x.recreate = function(v) { if (x.value != v) x.value = v; }; + x.recreate = recreate(x); populate(x); addNode(x); @@ -308,7 +308,7 @@ function input(t, s) { } function inp(s) { - var x = input("input", s); + var x = input("input", s, function(x) { return function(v) { if (x.value != v) x.value = v; }; }); x.value = s.data; x.onkeyup = function() { sv(s, x.value) }; @@ -316,7 +316,7 @@ function inp(s) { } function sel(s, content) { - var x = input("select", s); + var x = input("select", s, function(x) { return function(v) { if (x.value != v) x.value = v; }; }); x.innerHTML = content; x.value = s.data; x.onchange = function() { sv(s, x.value) }; @@ -324,6 +324,15 @@ function sel(s, content) { return x; } +function chk(s) { + var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; }); + x.type = "checkbox"; + x.checked = s.data; + x.onchange = function() { sv(s, x.checked) }; + + return x; +} + function addOnChange(x, f) { var old = x.onchange; x.onchange = function() { old(); f (); }; |