aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-21 10:34:56 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-21 10:34:56 -0400
commitc53470daa7b350ac8545d8934cedbcb1aae49bd0 (patch)
tree760d2417c0ab43fa13f59fb41f6303656c9446c0 /lib/js/urweb.js
parentc0b8071a49ce472ff915ba3ea3387c29edbebfc1 (diff)
ccheckbox
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js17
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 (); };