Mercurial > hg > webaudioevaluationtool
comparison test_create/test_core.js @ 632:9e4fb381944e Dev_main
Fix Bug #1669, #1594.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Tue, 22 Mar 2016 11:21:45 +0000 |
parents | e0934138c676 |
children | df6c09f5835d |
comparison
equal
deleted
inserted
replaced
631:d63600ad574b | 632:9e4fb381944e |
---|---|
1201 maxVar = 65536; | 1201 maxVar = 65536; |
1202 break; | 1202 break; |
1203 default: | 1203 default: |
1204 break; | 1204 break; |
1205 } | 1205 } |
1206 | 1206 |
1207 this.input = document.createElement('input'); | 1207 this.enumeration = schema.getAllElementsByTagName("xs:enumeration"); |
1208 switch(this.dataType) | 1208 if (this.enumeration.length == 0) { |
1209 { | 1209 this.input = document.createElement('input'); |
1210 case "boolean": | 1210 switch(this.dataType) |
1211 this.input.type = "checkbox"; | 1211 { |
1212 break; | 1212 case "boolean": |
1213 case "negativeInteger": | 1213 this.input.type = "checkbox"; |
1214 case "positiveInteger": | 1214 break; |
1215 case "nonNegativeInteger": | 1215 case "negativeInteger": |
1216 case "nonPositiveInteger": | 1216 case "positiveInteger": |
1217 case "integer": | 1217 case "nonNegativeInteger": |
1218 case "short": | 1218 case "nonPositiveInteger": |
1219 case "byte": | 1219 case "integer": |
1220 this.input.step = 1; | 1220 case "short": |
1221 case "decimal": | 1221 case "byte": |
1222 this.input.type = "number"; | 1222 this.input.step = 1; |
1223 this.input.min = minVar; | 1223 case "decimal": |
1224 this.input.max = maxVar; | 1224 this.input.type = "number"; |
1225 break; | 1225 this.input.min = minVar; |
1226 default: | 1226 this.input.max = maxVar; |
1227 break; | 1227 break; |
1228 default: | |
1229 break; | |
1230 } | |
1231 } else { | |
1232 this.input = document.createElement("select"); | |
1233 for (var i=0; i<this.enumeration.length; i++) | |
1234 { | |
1235 var option = document.createElement("option"); | |
1236 var value = this.enumeration[i].getAttribute("value"); | |
1237 option.setAttribute("value",value); | |
1238 option.textContent = value; | |
1239 this.input.appendChild(option); | |
1240 } | |
1228 } | 1241 } |
1229 var value; | 1242 var value; |
1230 eval("value = node."+this.name) | 1243 eval("value = node."+this.name) |
1231 if (value != undefined) | 1244 if (this.default != undefined && value == undefined) |
1232 { | 1245 { |
1246 value = this.default; | |
1247 } | |
1248 if (this.input.type == "checkbox") { | |
1249 this.input.checked = value; | |
1250 } else { | |
1233 this.input.value = value; | 1251 this.input.value = value; |
1234 } else if (this.default != undefined) | |
1235 { | |
1236 this.input.value = this.default; | |
1237 } | 1252 } |
1238 this.handleEvent = function(event) | 1253 this.handleEvent = function(event) |
1239 { | 1254 { |
1240 var value; | 1255 var value; |
1241 switch(this.input.type) | 1256 if (this.input.nodeName == "INPUT") |
1242 { | 1257 { |
1243 case "checkbox": | 1258 switch(this.input.type) |
1244 value = event.currentTarget.checked; | 1259 { |
1245 break; | 1260 case "checkbox": |
1246 case "number": | 1261 value = event.currentTarget.checked; |
1247 value = Number(event.currentTarget.value); | 1262 break; |
1248 break; | 1263 case "number": |
1249 default: | 1264 value = Number(event.currentTarget.value); |
1250 value = event.currentTarget.value; | 1265 break; |
1251 break; | 1266 default: |
1267 value = event.currentTarget.value; | |
1268 break; | |
1269 } | |
1270 } else if (this.input.nodeName == "SELECT") { | |
1271 value = event.currentTarget.value; | |
1252 } | 1272 } |
1253 eval("this.owner."+this.name+" = value"); | 1273 eval("this.owner."+this.name+" = value"); |
1254 } | 1274 } |
1255 this.holder = document.createElement('div'); | 1275 this.holder = document.createElement('div'); |
1256 this.holder.className = "attribute"; | 1276 this.holder.className = "attribute"; |