comparison lib/js/urweb.js @ 2079:e1879ded8095

Textual HTML5 AJAX widgets
author Adam Chlipala <adam@chlipala.net>
date Sun, 16 Nov 2014 15:03:29 -0500
parents 7c2229aa22fc
children f05fcb206571
comparison
equal deleted inserted replaced
2078:6d126af2e1cb 2079:e1879ded8095
1036 populate(x); 1036 populate(x);
1037 1037
1038 return x; 1038 return x;
1039 } 1039 }
1040 1040
1041 function inp(s, name) { 1041 function inpt(type, s, name) {
1042 if (suspendScripts) 1042 if (suspendScripts)
1043 return; 1043 return;
1044 1044
1045 var x = input(document.createElement("input"), s, 1045 var x = input(document.createElement("input"), s,
1046 function(x) { return function(v) { if (x.value != v) x.value = v; }; }, "text", name); 1046 function(x) { return function(v) { if (x.value != v) x.value = v; }; }, type, name);
1047 x.value = s.data; 1047 x.value = s.data;
1048 x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; 1048 x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) };
1049 1049
1050 return x; 1050 return x;
1051 } 1051 }
1052 1052
1053 function inp(s, name) {
1054 return inpt("text", s, name);
1055 }
1056
1053 function password(s, name) { 1057 function password(s, name) {
1054 if (suspendScripts) 1058 return inpt("password", s, name);
1055 return; 1059 }
1056 1060
1057 var x = input(document.createElement("input"), s, 1061 function email(s, name) {
1058 function(x) { return function(v) { if (x.value != v) x.value = v; }; }, "password", name); 1062 return inpt("email", s, name);
1059 x.value = s.data; 1063 }
1060 x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; 1064
1061 1065 function search(s, name) {
1062 return x; 1066 return inpt("search", s, name);
1067 }
1068
1069 function url(s, name) {
1070 return inpt("url", s, name);
1071 }
1072
1073 function tel(s, name) {
1074 return inpt("tel", s, name);
1075 }
1076
1077 function color(s, name) {
1078 return inpt("color", s, name);
1063 } 1079 }
1064 1080
1065 function selectValue(x) { 1081 function selectValue(x) {
1066 if (x.options.length == 0) 1082 if (x.options.length == 0)
1067 return ""; 1083 return "";