diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 17 | ||||
-rw-r--r-- | lib/ur/basis.urs | 2 |
2 files changed, 15 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 (); }; diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 45f36ef8..c5251bb8 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -631,6 +631,8 @@ con cformTag = fn (attrs :: {Type}) (inner :: {Unit}) => val ctextbox : cformTag [Value = string, Size = int, Source = source string] [] val button : cformTag [Value = string, Onclick = transaction unit] [] +val ccheckbox : cformTag [Value = bool, Size = int, Source = source bool] [] + con cselect = [Cselect] val cselect : cformTag [Source = source string, Onchange = transaction unit] cselect |