diff options
author | 2009-05-21 10:18:20 -0400 | |
---|---|---|
committer | 2009-05-21 10:18:20 -0400 | |
commit | c0b8071a49ce472ff915ba3ea3387c29edbebfc1 (patch) | |
tree | 9b952c226cd5d3a119b00f2643f6bf2e969ef417 /lib/js/urweb.js | |
parent | 268a152731498e58f38da0a4f1dc5046ae2fbf3f (diff) |
Split JavaScript inp() into separate functions
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r-- | lib/js/urweb.js | 27 |
1 files changed, 18 insertions, 9 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; } |