Mercurial > hg > webaudioevaluationtool
changeset 1891:d8afd1a44002
Test Create fixes for #1597 #1598 #1656 #1657
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Mon, 14 Mar 2016 12:34:36 +0000 |
parents | 1d0936cfa1d4 |
children | d6411f7c9bc1 |
files | test-schema.xsd test_create/attributes.json test_create/test_core.js |
diffstat | 3 files changed, 46 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/test-schema.xsd Thu Mar 10 17:08:10 2016 +0000 +++ b/test-schema.xsd Mon Mar 14 12:34:36 2016 +0000 @@ -44,7 +44,7 @@ <xs:element ref="interface" maxOccurs="1"/> </xs:sequence> <xs:attribute name="interface" type="xs:string" use="required"/> - <xs:attribute name="projectReturn" type="xs:string" use="required"/> + <xs:attribute name="projectReturn" type="xs:string" use="optional" default=""/> <xs:attribute name="randomiseOrder" type="xs:boolean" default="false"/> <xs:attribute name="testPages" type="xs:nonNegativeInteger" default="0"/> <xs:attribute name="loudness" type="xs:nonPositiveInteger" use="optional"/>
--- a/test_create/attributes.json Thu Mar 10 17:08:10 2016 +0000 +++ b/test_create/attributes.json Mon Mar 14 12:34:36 2016 +0000 @@ -3,7 +3,7 @@ "mandatory": "Mandatory", "name": "Name", "interface": "Interface Module", - "projectReturn": "Results Return URL", + "projectReturn": "Save URL", "randomiseOrder": "Randomise Order", "testPages": "Test Pages", "loudness": "Target Loudness (LUFS)", @@ -19,5 +19,9 @@ "url": "URL", "gain": "Gain (dB)", "marker": "Marker", - "boxsize": "Box Size" + "boxsize": "Box Size", + "label": "Label", + "calibration": "Perform Calibration", + "preSilence": "Pre Silence", + "postSilence": "Post Silence" }
--- a/test_create/test_core.js Thu Mar 10 17:08:10 2016 +0000 +++ b/test_create/test_core.js Mon Mar 14 12:34:36 2016 +0000 @@ -699,27 +699,29 @@ this.option = null; this.parent = null; this.optionLists = []; - var select = document.createElement("select"); - select.setAttribute("name","type"); - select.addEventListener("change",this,false); - this.content.appendChild(select); + this.select = document.createElement("select"); + this.select.setAttribute("name","type"); + this.select.addEventListener("change",this,false); + this.content.appendChild(this.select); this.content.appendChild(this.dynamic); this.generate = function(option, parent) { this.option = option; this.parent = parent; - var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); - for (var i=0; i<optionList.length; i++) - { - var selectOption = document.createElement("option"); - selectOption.value = optionList[i].getAttribute("value"); - selectOption.textContent = selectOption.value; - select.appendChild(selectOption); + if (this.select.childElementCount == 0) { + var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); + for (var i=0; i<optionList.length; i++) + { + var selectOption = document.createElement("option"); + selectOption.value = optionList[i].getAttribute("value"); + selectOption.textContent = selectOption.value; + this.select.appendChild(selectOption); + } } if (this.option.type != undefined){ - select.value = this.option.type + this.select.value = this.option.type } else { - select.value = "statement"; + this.select.value = "statement"; this.option.type = "statement"; } @@ -745,12 +747,13 @@ idEntry.setAttribute("name","id"); idEntry.value = this.option.id; + this.dynamic.appendChild(id); + switch(this.option.type) { case "statement": break; case "question": - this.dynamic.appendChild(id); var boxsizeSelect = document.createElement("select"); var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration"); for (var i=0; i<optionList.length; i++) @@ -884,6 +887,21 @@ this.deleteEntry.root.addEventListener("click",this.deleteEntry,false); this.rootDOM.appendChild(this.deleteEntry.root); } + this.addEntry = { + parent: this, + root: document.createElement("button"), + handleEvent: function() { + var node = {name: "name", text: "text"}; + var optionsList = this.parent.option.options; + optionsList.push(node); + var obj = new optionObject(this.parent,optionsList[optionsList.length-1]); + this.parent.optionLists.push(obj); + document.getElementById("popup-option-holder").appendChild(obj.rootDOM); + } + } + this.addEntry.root.textContent = "Add Option"; + this.addEntry.root.addEventListener("click",this.addEntry); + this.dynamic.appendChild(this.addEntry.root); for (var i=0; i<this.option.options.length; i++) { var obj = new optionObject(this,this.option.options[i]); @@ -1142,6 +1160,13 @@ this.name = schema.getAttribute('name'); this.default = schema.getAttribute('default'); this.dataType = schema.getAttribute('type'); + if (this.dataType == undefined) { + if (schema.childElementCount > 0) { + if (schema.children[0].nodeName == "xs:simpleType") { + this.dataType = schema.getAllElementsByTagName("xs:restriction")[0].getAttribute("base"); + } + } + } if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);} else {this.dataType = "string";} var minVar = undefined;