Mercurial > hg > webaudioevaluationtool
comparison test_create/test_core.js @ 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 | 9c167c0d6c26 |
children | bc6edd2c8772 |
comparison
equal
deleted
inserted
replaced
2563:b2df2be58fc2 | 2564:26045169b4b5 |
---|---|
1963 break; | 1963 break; |
1964 } | 1964 } |
1965 } | 1965 } |
1966 this.build(); | 1966 this.build(); |
1967 | 1967 |
1968 var Conditional = function(parent, rootObject) { | |
1969 this.type = "surveyEntryConditionalNode"; | |
1970 this.rootDOM = document.createElement("div"); | |
1971 this.titleDOM = document.createElement("span"); | |
1972 this.attributeDOM = document.createElement("div"); | |
1973 this.attributes = []; | |
1974 this.childrenDOM = document.createElement("div"); | |
1975 this.children = []; | |
1976 this.buttonDOM = document.createElement("div"); | |
1977 this.parent = parent; | |
1978 this.specification = rootObject; | |
1979 this.schema = specification.schema.getAllElementsByName("conditional")[0]; | |
1980 | |
1981 this.rootDOM.className = "node"; | |
1982 this.rootDOM.style.minWidth = "50%"; | |
1983 | |
1984 var titleDiv = document.createElement('div'); | |
1985 titleDiv.className = "node-title"; | |
1986 this.titleDOM.className = "node-title"; | |
1987 titleDiv.appendChild(this.titleDOM); | |
1988 | |
1989 this.attributeDOM.className = "node-attributes"; | |
1990 this.childrenDOM.className = "node-children"; | |
1991 this.buttonDOM.className = "node-buttons"; | |
1992 | |
1993 this.rootDOM.appendChild(titleDiv); | |
1994 this.rootDOM.appendChild(this.attributeDOM); | |
1995 this.rootDOM.appendChild(this.childrenDOM); | |
1996 this.rootDOM.appendChild(this.buttonDOM); | |
1997 | |
1998 var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); | |
1999 | |
2000 for (var i=0; i<attributeList.length; i++) { | |
2001 var attributeName = attributeList[i].getAttribute("name"); | |
2002 var attribute = convert.convertAttributeToDOM(this.specification,this.schema.getAllElementsByName(attributeName)[0]); | |
2003 this.attributes.push(attribute); | |
2004 this.attributeDOM.appendChild(attribute.holder); | |
2005 } | |
2006 | |
2007 this.build = function() { | |
2008 } | |
2009 | |
2010 this.deleteNode = { | |
2011 root: document.createElement("button"), | |
2012 parent: this, | |
2013 handleEvent: function(event) { | |
2014 this.root.parentElement.removeChild(this.root); | |
2015 this.parent.parent.addConditional.root.disabled = false; | |
2016 var index = this.parent.parent.children.findIndex(function(element){ | |
2017 if (this == element) {return true;} return false; | |
2018 },this.parent); | |
2019 if (index >= 0) { | |
2020 this.parent.parent.children.splice(index,1); | |
2021 } | |
2022 } | |
2023 } | |
2024 this.deleteNode.root.textContent = "Delete"; | |
2025 this.deleteNode.root.addEventListener("click",this.deleteNode); | |
2026 | |
2027 this.buttonDOM.appendChild(this.deleteNode.root); | |
2028 } | |
2029 | |
2030 this.addConditional = { | |
2031 root: document.createElement("button"), | |
2032 parent: this, | |
2033 handleEvent: function(event) { | |
2034 var spec = { | |
2035 check: null, | |
2036 value: null, | |
2037 jumpToOnPass: null, | |
2038 jumpToOnFail: null | |
2039 }; | |
2040 this.parent.specification.conditions.push(spec); | |
2041 var condition = new Conditional(this.parent,spec); | |
2042 this.parent.children.push(condition); | |
2043 this.parent.childrenDOM.appendChild(condition.rootDOM); | |
2044 } | |
2045 } | |
2046 this.addConditional.root.addEventListener("click",this.addConditional); | |
2047 this.addConditional.root.textContent = "Add Condition"; | |
2048 this.buttonDOM.appendChild(this.addConditional.root); | |
2049 | |
1968 this.editNode = { | 2050 this.editNode = { |
1969 root: document.createElement("button"), | 2051 root: document.createElement("button"), |
1970 parent: this, | 2052 parent: this, |
1971 handleEvent: function() | 2053 handleEvent: function() |
1972 { | 2054 { |
2071 this.moveButtons.root_down.addEventListener("click",this.moveButtons,false); | 2153 this.moveButtons.root_down.addEventListener("click",this.moveButtons,false); |
2072 this.moveButtons.root_up.textContent = "Move Up"; | 2154 this.moveButtons.root_up.textContent = "Move Up"; |
2073 this.moveButtons.root_down.textContent = "Move Down"; | 2155 this.moveButtons.root_down.textContent = "Move Down"; |
2074 this.buttonDOM.appendChild(this.moveButtons.root_up); | 2156 this.buttonDOM.appendChild(this.moveButtons.root_up); |
2075 this.buttonDOM.appendChild(this.moveButtons.root_down); | 2157 this.buttonDOM.appendChild(this.moveButtons.root_down); |
2158 | |
2159 for (var condition of this.specification.conditions) { | |
2160 var newNode = new Conditional(this,condition); | |
2161 this.children.push(newNode); | |
2162 this.childrenDOM.appendChild(newNode.rootDOM); | |
2163 } | |
2076 } | 2164 } |
2077 this.addNode = { | 2165 this.addNode = { |
2078 root: document.createElement("button"), | 2166 root: document.createElement("button"), |
2079 parent: this, | 2167 parent: this, |
2080 handleEvent: function() | 2168 handleEvent: function() |