Mercurial > hg > webaudioevaluationtool
changeset 2564:26045169b4b5
Completing adding of <condition> nodes to test_creator #5
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Thu, 08 Sep 2016 10:54:57 +0100 |
parents | b2df2be58fc2 |
children | bc6edd2c8772 |
files | test_create/attributes.json test_create/test_core.js |
diffstat | 2 files changed, 93 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/test_create/attributes.json Fri Sep 02 14:56:01 2016 +0100 +++ b/test_create/attributes.json Thu Sep 08 10:54:57 2016 +0100 @@ -27,5 +27,9 @@ "postSilence": "Post Silence", "poolSize": "Pool Size", "alwaysInclude": "Always Include", - "crossFade": "Cross Fade" + "crossFade": "Cross Fade", + "check": "Check", + "value": "Value", + "jumpToOnPass": "Jump To ID On Pass", + "jumpToOnFail": "Jump To ID On Fail" }
--- a/test_create/test_core.js Fri Sep 02 14:56:01 2016 +0100 +++ b/test_create/test_core.js Thu Sep 08 10:54:57 2016 +0100 @@ -1965,6 +1965,88 @@ } this.build(); + var Conditional = function(parent, rootObject) { + this.type = "surveyEntryConditionalNode"; + this.rootDOM = document.createElement("div"); + this.titleDOM = document.createElement("span"); + this.attributeDOM = document.createElement("div"); + this.attributes = []; + this.childrenDOM = document.createElement("div"); + this.children = []; + this.buttonDOM = document.createElement("div"); + this.parent = parent; + this.specification = rootObject; + this.schema = specification.schema.getAllElementsByName("conditional")[0]; + + this.rootDOM.className = "node"; + this.rootDOM.style.minWidth = "50%"; + + var titleDiv = document.createElement('div'); + titleDiv.className = "node-title"; + this.titleDOM.className = "node-title"; + titleDiv.appendChild(this.titleDOM); + + this.attributeDOM.className = "node-attributes"; + this.childrenDOM.className = "node-children"; + this.buttonDOM.className = "node-buttons"; + + this.rootDOM.appendChild(titleDiv); + this.rootDOM.appendChild(this.attributeDOM); + this.rootDOM.appendChild(this.childrenDOM); + this.rootDOM.appendChild(this.buttonDOM); + + var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); + + for (var i=0; i<attributeList.length; i++) { + var attributeName = attributeList[i].getAttribute("name"); + var attribute = convert.convertAttributeToDOM(this.specification,this.schema.getAllElementsByName(attributeName)[0]); + this.attributes.push(attribute); + this.attributeDOM.appendChild(attribute.holder); + } + + this.build = function() { + } + + this.deleteNode = { + root: document.createElement("button"), + parent: this, + handleEvent: function(event) { + this.root.parentElement.removeChild(this.root); + this.parent.parent.addConditional.root.disabled = false; + var index = this.parent.parent.children.findIndex(function(element){ + if (this == element) {return true;} return false; + },this.parent); + if (index >= 0) { + this.parent.parent.children.splice(index,1); + } + } + } + this.deleteNode.root.textContent = "Delete"; + this.deleteNode.root.addEventListener("click",this.deleteNode); + + this.buttonDOM.appendChild(this.deleteNode.root); + } + + this.addConditional = { + root: document.createElement("button"), + parent: this, + handleEvent: function(event) { + var spec = { + check: null, + value: null, + jumpToOnPass: null, + jumpToOnFail: null + }; + this.parent.specification.conditions.push(spec); + var condition = new Conditional(this.parent,spec); + this.parent.children.push(condition); + this.parent.childrenDOM.appendChild(condition.rootDOM); + } + } + this.addConditional.root.addEventListener("click",this.addConditional); + this.addConditional.root.textContent = "Add Condition"; + this.buttonDOM.appendChild(this.addConditional.root); + this.editNode = { root: document.createElement("button"), parent: this, @@ -2073,6 +2155,12 @@ this.moveButtons.root_down.textContent = "Move Down"; this.buttonDOM.appendChild(this.moveButtons.root_up); this.buttonDOM.appendChild(this.moveButtons.root_down); + + for (var condition of this.specification.conditions) { + var newNode = new Conditional(this,condition); + this.children.push(newNode); + this.childrenDOM.appendChild(newNode.rootDOM); + } } this.addNode = { root: document.createElement("button"),