# HG changeset patch # User Nicholas Jillings # Date 1433760974 -3600 # Node ID a41d8efee6dbd2c37b314b633eec1f6b75649c49 # Parent 75f47f1c6cbea73efa4c9259710445375fd18a1e Feature #1224: Added number box diff -r 75f47f1c6cbe -r a41d8efee6db core.js --- a/core.js Mon Jun 08 11:17:26 2015 +0100 +++ b/core.js Mon Jun 08 11:56:14 2015 +0100 @@ -187,6 +187,17 @@ optHold.appendChild(hold); } this.popupContent.appendChild(optHold); + } else if (node.type == 'number') { + var span = document.createElement('span'); + span.textContent = node.statement; + this.popupContent.appendChild(span); + this.popupContent.appendChild(document.createElement('br')); + var input = document.createElement('input'); + input.type = 'number'; + if (node.min != null) {input.min = node.min;} + if (node.max != null) {input.max = node.max;} + if (node.step != null) {input.step = node.step;} + this.popupContent.appendChild(input); } this.popupContent.appendChild(this.popupButton); }; @@ -262,6 +273,16 @@ hold.setAttribute('name',node.options[responseID].name); hold.textContent = node.options[responseID].text; this.responses.appendChild(hold); + } else if (node.type == "number") { + var input = this.popupContent.getElementsByTagName('input')[0]; + if (node.mandatory == true && input.value.length == 0) { + alert('This question is mandatory'); + return; + } + var hold = document.createElement('number'); + hold.id = node.id; + hold.textContent = input.value; + this.responses.appendChild(hold); } this.currentIndex++; if (this.currentIndex < this.popupOptions.length) { @@ -1152,6 +1173,12 @@ element = element.nextElementSibling; } } + } else if (child.nodeName == "number") { + this.statement = child.textContent; + this.id = child.id; + this.min = child.getAttribute('min'); + this.max = child.getAttribute('max'); + this.step = child.getAttribute('step'); } }; diff -r 75f47f1c6cbe -r a41d8efee6db example_eval/project.xml --- a/example_eval/project.xml Mon Jun 08 11:17:26 2015 +0100 +++ b/example_eval/project.xml Mon Jun 08 11:56:14 2015 +0100 @@ -11,6 +11,11 @@ + Please enter your age + Please listen to all mixes + + + Please enter your name. Please rate this interface @@ -18,10 +23,6 @@ - Please listen to all mixes - - - Please enter your name. Thank you for taking this listening test.