comparison lib/js/urweb.js @ 816:26e911ee924c

Split JavaScript inp() into separate functions
author Adam Chlipala <adamc@hcoop.net>
date Thu, 21 May 2009 10:18:20 -0400
parents 2fbd1ac2f04b
children 4585f744574a
comparison
equal deleted inserted replaced
815:493f44759879 816:26e911ee924c
293 }; 293 };
294 addNode(x); 294 addNode(x);
295 populate(x); 295 populate(x);
296 } 296 }
297 297
298 function inp(t, s, content) { 298 function input(t, s) {
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 = function(v) { if (x.value != v) x.value = v; };
304 populate(x); 304 populate(x);
305 addNode(x); 305 addNode(x);
306 if (t == "select") { 306
307 x.innerHTML = content; 307 return x;
308 x.value = s.data; 308 }
309 x.onchange = function() { sv(s, x.value) }; 309
310 } else { 310 function inp(s) {
311 x.value = s.data; 311 var x = input("input", s);
312 x.onkeyup = function() { sv(s, x.value) }; 312 x.value = s.data;
313 } 313 x.onkeyup = function() { sv(s, x.value) };
314
315 return x;
316 }
317
318 function sel(s, content) {
319 var x = input("select", s);
320 x.innerHTML = content;
321 x.value = s.data;
322 x.onchange = function() { sv(s, x.value) };
314 323
315 return x; 324 return x;
316 } 325 }
317 326
318 function addOnChange(x, f) { 327 function addOnChange(x, f) {