Mercurial > hg > webaudioevaluationtool
changeset 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 | c4f9299295db |
files | core.js example_eval/project.xml |
diffstat | 2 files changed, 32 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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'); } };
--- 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 @@ <option id="studio">Studio Mixing</option> <option id="player">Play an instrument</option> </checkbox> + <number id="age">Please enter your age</number> + <statement>Please listen to all mixes</statement> + </PreTest> + <PostTest> + <question id="SessionID" mandatory="true">Please enter your name.</question> <radio id="rating"> <statement>Please rate this interface</statement> <option name="bad">Bad</option> @@ -18,10 +23,6 @@ <option name="Good">Good</option> <option name="Great">Great</option> </radio> - <statement>Please listen to all mixes</statement> - </PreTest> - <PostTest> - <question id="SessionID" mandatory="true">Please enter your name.</question> <statement>Thank you for taking this listening test.</statement> </PostTest> <Metric>