Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1573:a41d8efee6db
Feature #1224: Added number box
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Mon, 08 Jun 2015 11:56:14 +0100 |
parents | 75f47f1c6cbe |
children | b94bb53ce4ac |
comparison
equal
deleted
inserted
replaced
1572:75f47f1c6cbe | 1573:a41d8efee6db |
---|---|
185 hold.appendChild(input); | 185 hold.appendChild(input); |
186 hold.appendChild(span); | 186 hold.appendChild(span); |
187 optHold.appendChild(hold); | 187 optHold.appendChild(hold); |
188 } | 188 } |
189 this.popupContent.appendChild(optHold); | 189 this.popupContent.appendChild(optHold); |
190 } else if (node.type == 'number') { | |
191 var span = document.createElement('span'); | |
192 span.textContent = node.statement; | |
193 this.popupContent.appendChild(span); | |
194 this.popupContent.appendChild(document.createElement('br')); | |
195 var input = document.createElement('input'); | |
196 input.type = 'number'; | |
197 if (node.min != null) {input.min = node.min;} | |
198 if (node.max != null) {input.max = node.max;} | |
199 if (node.step != null) {input.step = node.step;} | |
200 this.popupContent.appendChild(input); | |
190 } | 201 } |
191 this.popupContent.appendChild(this.popupButton); | 202 this.popupContent.appendChild(this.popupButton); |
192 }; | 203 }; |
193 | 204 |
194 this.initState = function(node) { | 205 this.initState = function(node) { |
259 i++; | 270 i++; |
260 } | 271 } |
261 hold.id = node.id; | 272 hold.id = node.id; |
262 hold.setAttribute('name',node.options[responseID].name); | 273 hold.setAttribute('name',node.options[responseID].name); |
263 hold.textContent = node.options[responseID].text; | 274 hold.textContent = node.options[responseID].text; |
275 this.responses.appendChild(hold); | |
276 } else if (node.type == "number") { | |
277 var input = this.popupContent.getElementsByTagName('input')[0]; | |
278 if (node.mandatory == true && input.value.length == 0) { | |
279 alert('This question is mandatory'); | |
280 return; | |
281 } | |
282 var hold = document.createElement('number'); | |
283 hold.id = node.id; | |
284 hold.textContent = input.value; | |
264 this.responses.appendChild(hold); | 285 this.responses.appendChild(hold); |
265 } | 286 } |
266 this.currentIndex++; | 287 this.currentIndex++; |
267 if (this.currentIndex < this.popupOptions.length) { | 288 if (this.currentIndex < this.popupOptions.length) { |
268 this.postNode(); | 289 this.postNode(); |
1150 this.options.push(new this.childOption(element)); | 1171 this.options.push(new this.childOption(element)); |
1151 } | 1172 } |
1152 element = element.nextElementSibling; | 1173 element = element.nextElementSibling; |
1153 } | 1174 } |
1154 } | 1175 } |
1176 } else if (child.nodeName == "number") { | |
1177 this.statement = child.textContent; | |
1178 this.id = child.id; | |
1179 this.min = child.getAttribute('min'); | |
1180 this.max = child.getAttribute('max'); | |
1181 this.step = child.getAttribute('step'); | |
1155 } | 1182 } |
1156 }; | 1183 }; |
1157 | 1184 |
1158 // On construction: | 1185 // On construction: |
1159 if (Collection.length != 0) { | 1186 if (Collection.length != 0) { |