comparison lib/js/urweb.js @ 817:4585f744574a

ccheckbox
author Adam Chlipala <adamc@hcoop.net>
date Thu, 21 May 2009 10:34:56 -0400
parents 26e911ee924c
children 395a5d450cc0
comparison
equal deleted inserted replaced
816:26e911ee924c 817:4585f744574a
293 }; 293 };
294 addNode(x); 294 addNode(x);
295 populate(x); 295 populate(x);
296 } 296 }
297 297
298 function input(t, s) { 298 function input(t, s, recreate) {
299 var x = document.createElement(t); 299 var x = document.createElement(t);
300 x.dead = false; 300 x.dead = false;
301 x.signal = ss(s); 301 x.signal = ss(s);
302 x.sources = null; 302 x.sources = null;
303 x.recreate = function(v) { if (x.value != v) x.value = v; }; 303 x.recreate = recreate(x);
304 populate(x); 304 populate(x);
305 addNode(x); 305 addNode(x);
306 306
307 return x; 307 return x;
308 } 308 }
309 309
310 function inp(s) { 310 function inp(s) {
311 var x = input("input", s); 311 var x = input("input", s, function(x) { return function(v) { if (x.value != v) x.value = v; }; });
312 x.value = s.data; 312 x.value = s.data;
313 x.onkeyup = function() { sv(s, x.value) }; 313 x.onkeyup = function() { sv(s, x.value) };
314 314
315 return x; 315 return x;
316 } 316 }
317 317
318 function sel(s, content) { 318 function sel(s, content) {
319 var x = input("select", s); 319 var x = input("select", s, function(x) { return function(v) { if (x.value != v) x.value = v; }; });
320 x.innerHTML = content; 320 x.innerHTML = content;
321 x.value = s.data; 321 x.value = s.data;
322 x.onchange = function() { sv(s, x.value) }; 322 x.onchange = function() { sv(s, x.value) };
323
324 return x;
325 }
326
327 function chk(s) {
328 var x = input("input", s, function(x) { return function(v) { if (x.checked != v) x.checked = v; }; });
329 x.type = "checkbox";
330 x.checked = s.data;
331 x.onchange = function() { sv(s, x.checked) };
323 332
324 return x; 333 return x;
325 } 334 }
326 335
327 function addOnChange(x, f) { 336 function addOnChange(x, f) {