nickjillings@1306: var interfaceSpecs; nickjillings@1306: var xmlHttp; nickjillings@1306: var popupObject; nickjillings@1306: var popupStateNodes; nickjillings@1306: var specification; nickjillings@1306: var convert; nickjillings@1306: var attributeText; nickjillings@1306: nickjillings@1306: // Firefox does not have an XMLDocument.prototype.getElementsByName nickjillings@1306: // and there is no searchAll style command, this custom function will nickjillings@1306: // search all children recusrively for the name. Used for XSD where all nickjillings@1306: // element nodes must have a name and therefore can pull the schema node nickjillings@1306: XMLDocument.prototype.getAllElementsByName = function(name) nickjillings@1306: { nickjillings@1306: name = String(name); nickjillings@1306: var selected = this.documentElement.getAllElementsByName(name); nickjillings@1306: return selected; nickjillings@1306: } nickjillings@1306: nickjillings@1306: Element.prototype.getAllElementsByName = function(name) nickjillings@1306: { nickjillings@1306: name = String(name); nickjillings@1306: var selected = []; nickjillings@1306: var node = this.firstElementChild; nickjillings@1306: while(node != null) nickjillings@1306: { nickjillings@1306: if (node.getAttribute('name') == name) nickjillings@1306: { nickjillings@1306: selected.push(node); nickjillings@1306: } nickjillings@1306: if (node.childElementCount > 0) nickjillings@1306: { nickjillings@1306: selected = selected.concat(node.getAllElementsByName(name)); nickjillings@1306: } nickjillings@1306: node = node.nextElementSibling; nickjillings@1306: } nickjillings@1306: return selected; nickjillings@1306: } nickjillings@1306: nickjillings@1306: XMLDocument.prototype.getAllElementsByTagName = function(name) nickjillings@1306: { nickjillings@1306: name = String(name); nickjillings@1306: var selected = this.documentElement.getAllElementsByTagName(name); nickjillings@1306: return selected; nickjillings@1306: } nickjillings@1306: nickjillings@1306: Element.prototype.getAllElementsByTagName = function(name) nickjillings@1306: { nickjillings@1306: name = String(name); nickjillings@1306: var selected = []; nickjillings@1306: var node = this.firstElementChild; nickjillings@1306: while(node != null) nickjillings@1306: { nickjillings@1306: if (node.nodeName == name) nickjillings@1306: { nickjillings@1306: selected.push(node); nickjillings@1306: } nickjillings@1306: if (node.childElementCount > 0) nickjillings@1306: { nickjillings@1306: selected = selected.concat(node.getAllElementsByTagName(name)); nickjillings@1306: } nickjillings@1306: node = node.nextElementSibling; nickjillings@1306: } nickjillings@1306: return selected; nickjillings@1306: } nickjillings@1306: nickjillings@1306: // Firefox does not have an XMLDocument.prototype.getElementsByName nickjillings@1306: if (typeof XMLDocument.prototype.getElementsByName != "function") { nickjillings@1306: XMLDocument.prototype.getElementsByName = function(name) nickjillings@1306: { nickjillings@1306: name = String(name); nickjillings@1306: var node = this.documentElement.firstElementChild; nickjillings@1306: var selected = []; nickjillings@1306: while(node != null) nickjillings@1306: { nickjillings@1306: if (node.getAttribute('name') == name) nickjillings@1306: { nickjillings@1306: selected.push(node); nickjillings@1306: } nickjillings@1306: node = node.nextElementSibling; nickjillings@1306: } nickjillings@1306: return selected; nickjillings@1306: } nickjillings@1306: } nickjillings@1306: nickjillings@1306: window.onload = function() nickjillings@1306: { nickjillings@1306: specification = new Specification(); nickjillings@1306: convert = new SpecificationToHTML(); nickjillings@1306: xmlHttp = new XMLHttpRequest(); nickjillings@1306: xmlHttp.open("GET","./interface-specs.xml",true); nickjillings@1306: xmlHttp.onload = function() nickjillings@1306: { nickjillings@1306: var parse = new DOMParser(); nickjillings@1306: interfaceSpecs = parse.parseFromString(xmlHttp.response,'text/xml'); nickjillings@1306: buildPage(); nickjillings@1306: popupObject.postNode(popupStateNodes.state[0]) nickjillings@1306: } nickjillings@1306: xmlHttp.send(); nickjillings@1306: nickjillings@1306: var xsdGet = new XMLHttpRequest(); nickjillings@1306: xsdGet.open("GET","../test-schema.xsd",true); nickjillings@1306: xsdGet.onload = function() nickjillings@1306: { nickjillings@1306: var parse = new DOMParser(); nickjillings@1306: specification.schema = parse.parseFromString(xsdGet.response,'text/xml');; nickjillings@1306: } nickjillings@1306: xsdGet.send(); nickjillings@1306: nickjillings@1306: var jsonAttribute = new XMLHttpRequest(); nickjillings@1306: jsonAttribute.open("GET","./attributes.json",true); nickjillings@1306: jsonAttribute.onload = function() nickjillings@1306: { nickjillings@1306: attributeText = JSON.parse(jsonAttribute.response) nickjillings@1306: } nickjillings@1306: jsonAttribute.send(); nickjillings@1306: } nickjillings@1306: nickjillings@1306: function buildPage() nickjillings@1306: { nickjillings@1306: popupObject = new function() { nickjillings@1306: this.object = document.getElementById("popupHolder"); nickjillings@1306: this.blanket = document.getElementById("blanket"); nickjillings@1306: nickjillings@1306: this.popupTitle = document.createElement("div"); nickjillings@1306: this.popupTitle.id = "popup-title-holder"; nickjillings@1306: this.popupTitle.align = "center"; nickjillings@1306: this.titleDOM = document.createElement("span"); nickjillings@1306: this.titleDOM.id = "popup-title"; nickjillings@1306: this.popupTitle.appendChild(this.titleDOM); nickjillings@1306: this.object.appendChild(this.popupTitle); nickjillings@1306: nickjillings@1306: this.popupContent = document.createElement("div"); nickjillings@1306: this.popupContent.id = "popup-content"; nickjillings@1306: this.object.appendChild(this.popupContent); nickjillings@1306: nickjillings@1306: this.proceedButton = document.createElement("button"); nickjillings@1306: this.proceedButton.id = "popup-proceed"; nickjillings@1306: this.proceedButton.textContent = "Next"; nickjillings@1306: this.proceedButton.onclick = function() nickjillings@1306: { nickjillings@1306: popupObject.popupContent.innerHTML = null; nickjillings@1306: popupObject.shownObject.continue(); nickjillings@1306: }; nickjillings@1306: this.object.appendChild(this.proceedButton); nickjillings@1306: nickjillings@1306: this.shownObject; nickjillings@1306: nickjillings@1306: this.resize = function() nickjillings@1306: { nickjillings@1306: var w = window.innerWidth; nickjillings@1306: var h = window.innerHeight; nickjillings@1306: this.object.style.left = Math.floor((w-750)/2) + 'px'; nickjillings@1306: this.object.style.top = Math.floor((h-500)/2) + 'px'; nickjillings@1306: } nickjillings@1306: nickjillings@1306: this.show = function() nickjillings@1306: { nickjillings@1306: this.object.style.visibility = "visible"; nickjillings@1306: this.blanket.style.visibility = "visible"; nickjillings@1306: } nickjillings@1306: nickjillings@1306: this.hide = function() nickjillings@1306: { nickjillings@1306: this.object.style.visibility = "hidden"; nickjillings@1306: this.blanket.style.visibility = "hidden"; nickjillings@1306: } nickjillings@1306: nickjillings@1306: this.postNode = function(postObject) nickjillings@1306: { nickjillings@1306: this.show(); nickjillings@1306: //Passed object must have the following: nickjillings@1306: // Title: text to show in the title nickjillings@1306: // Content: HTML DOM to show on the page nickjillings@1306: // On complete this HTML DOM is destroyed so make sure it is referenced elsewhere for processing nickjillings@1306: this.titleDOM.textContent = postObject.title; nickjillings@1306: this.popupContent.appendChild(postObject.content); nickjillings@1306: this.shownObject = postObject; nickjillings@1306: } nickjillings@1306: nickjillings@1306: this.resize(); nickjillings@1306: this.hide(); nickjillings@1306: }; nickjillings@1306: nickjillings@1306: popupStateNodes = new function() nickjillings@1306: { nickjillings@1306: // This defines the several popup states wanted nickjillings@1306: this.state = []; nickjillings@1306: this.state[0] = new function() nickjillings@1306: { nickjillings@1306: this.title = "Welcome"; nickjillings@1306: this.content = document.createElement("div"); nickjillings@1306: this.content.id = "state-0"; nickjillings@1306: var span = document.createElement("span"); nickjillings@1306: span.textContent = "Welcome to the WAET test creator tool. This will allow you to create a new test from scratch to suit your testing needs. If you wish to update a test file, please drag and drop the XML document into the area below for processing, otherwise press 'Next' to start a new test. This tool generates files for the WAET 1.2.0 version." nickjillings@1306: this.content.appendChild(span); nickjillings@1306: this.dragArea = document.createElement("div"); nickjillings@1306: this.dragArea.className = "drag-area"; nickjillings@1306: this.dragArea.id = "project-drop"; nickjillings@1306: this.content.appendChild(this.dragArea); nickjillings@1306: nickjillings@1306: this.dragArea.addEventListener('dragover',function(e){ nickjillings@1306: e.stopPropagation(); nickjillings@1306: e.preventDefault(); nickjillings@1306: e.dataTransfer.dropEffect = 'copy'; nickjillings@1306: e.currentTarget.className = "drag-area drag-over"; nickjillings@1306: }); nickjillings@1306: nickjillings@1306: this.dragArea.addEventListener('dragexit',function(e){ nickjillings@1306: e.stopPropagation(); nickjillings@1306: e.preventDefault(); nickjillings@1306: e.dataTransfer.dropEffect = 'copy'; nickjillings@1306: e.currentTarget.className = "drag-area"; nickjillings@1306: }); nickjillings@1306: nickjillings@1306: this.dragArea.addEventListener('drop',function(e){ nickjillings@1306: e.stopPropagation(); nickjillings@1306: e.preventDefault(); nickjillings@1306: e.currentTarget.className = "drag-area drag-dropped"; nickjillings@1306: var files = e.dataTransfer.files[0]; nickjillings@1306: var reader = new FileReader(); nickjillings@1306: reader.onload = function(decoded) { nickjillings@1306: var parse = new DOMParser(); nickjillings@1306: specification.decode(parse.parseFromString(decoded.target.result,'text/xml')); nickjillings@1306: popupObject.hide(); nickjillings@1306: popupObject.popupContent.innerHTML = null; nickjillings@1306: convert.convert(document.getElementById('content')); nickjillings@1306: } nickjillings@1306: reader.readAsText(files); nickjillings@1306: }); nickjillings@1306: nickjillings@1306: nickjillings@1306: this.continue = function() nickjillings@1306: { nickjillings@1306: popupObject.postNode(popupStateNodes.state[1]); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.state[1] = new function() nickjillings@1306: { nickjillings@1306: this.title = "Select your interface"; nickjillings@1306: this.content = document.createElement("div"); nickjillings@1306: this.content.id = "state-1"; nickjillings@1306: var spnH = document.createElement('div'); nickjillings@1306: var span = document.createElement("span"); nickjillings@1306: span.textContent = "Please select your interface from the list shown below. This will define the various options which are available. This can later be changed."; nickjillings@1306: spnH.appendChild(span); nickjillings@1306: this.content.appendChild(spnH); nickjillings@1306: this.select = document.createElement("select"); nickjillings@1306: this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].children; nickjillings@1306: for (var i=0; i 0) nickjillings@1306: { nickjillings@1306: testNode = this.testXML[0].getAllElementsByName(checkName); nickjillings@1306: if(testNode.length != 0) {testNode = testNode[0];} nickjillings@1306: else {testNode = undefined;} nickjillings@1306: } else { nickjillings@1306: testNode = undefined; nickjillings@1306: } nickjillings@1306: var optH = document.createElement('div'); nickjillings@1306: optH.className = "popup-checkbox"; nickjillings@1306: var checkbox = document.createElement('input'); nickjillings@1306: checkbox.type = "checkbox"; nickjillings@1306: var text = document.createElement('span'); nickjillings@1306: checkbox.setAttribute('name',checkName); nickjillings@1306: if (interfaceNode.getAttribute('default') == 'on') nickjillings@1306: { nickjillings@1306: checkbox.checked = true; nickjillings@1306: } nickjillings@1306: if (interfaceNode.getAttribute('support') == "none") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = false; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } else if (interfaceNode.getAttribute('support') == "mandatory") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = true; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } nickjillings@1306: if(testNode != undefined) nickjillings@1306: { nickjillings@1306: if (interfaceNode.getAttribute('default') == 'on') nickjillings@1306: { nickjillings@1306: checkbox.checked = true; nickjillings@1306: } nickjillings@1306: if (testNode.getAttribute('support') == "none") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = false; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: }else if (interfaceNode.getAttribute('support') == "mandatory") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = true; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } nickjillings@1306: } nickjillings@1306: text.textContent = popupStateNodes.state[2].checkText.getAllElementsByName(checkName)[0].textContent; nickjillings@1306: optH.appendChild(checkbox); nickjillings@1306: optH.appendChild(text); nickjillings@1306: this.options.push(optH); nickjillings@1306: this.content.appendChild(optH); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.continue = function() nickjillings@1306: { nickjillings@1306: if (specification.interfaces == null) nickjillings@1306: { nickjillings@1306: specification.interfaces = new specification.interfaceNode(); nickjillings@1306: } nickjillings@1306: for (var object of this.options) nickjillings@1306: { nickjillings@1306: var checkbox = object.children[0]; nickjillings@1306: if (checkbox.checked) nickjillings@1306: { nickjillings@1306: var option = { nickjillings@1306: type: "check", nickjillings@1306: name: checkbox.getAttribute('name') nickjillings@1306: }; nickjillings@1306: specification.interfaces.options.push(option); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: popupStateNodes.state[3].generate(); nickjillings@1306: popupObject.postNode(popupStateNodes.state[3]); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.state[3] = new function() nickjillings@1306: { nickjillings@1306: this.title = "Test Metrics"; nickjillings@1306: this.content = document.createElement("div"); nickjillings@1306: this.content.id = "state-1"; nickjillings@1306: var spnH = document.createElement('div'); nickjillings@1306: var span = document.createElement("span"); nickjillings@1306: span.textContent = "Select which data points to include in the exported results XML. Some of this is required for certain post script analysis. See the documentation for further details"; nickjillings@1306: spnH.appendChild(span); nickjillings@1306: this.content.appendChild(spnH); nickjillings@1306: this.options = []; nickjillings@1306: this.checkText; nickjillings@1306: this.testXML; nickjillings@1306: this.interfaceXML; nickjillings@1306: this.generate = function() nickjillings@1306: { nickjillings@1306: var interfaceName = popupStateNodes.state[1].select.value; nickjillings@1306: this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0]; nickjillings@1306: this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; nickjillings@1306: this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0]; nickjillings@1306: this.testXML = this.testXML.getAllElementsByTagName("metrics"); nickjillings@1306: for (var i=0; i 0) nickjillings@1306: { nickjillings@1306: testNode = this.testXML[0].getAllElementsByName(checkName); nickjillings@1306: if(testNode.length != 0) {testNode = testNode[0];} nickjillings@1306: else {testNode = undefined;} nickjillings@1306: } else { nickjillings@1306: testNode = undefined; nickjillings@1306: } nickjillings@1306: var optH = document.createElement('div'); nickjillings@1306: optH.className = "popup-checkbox"; nickjillings@1306: var checkbox = document.createElement('input'); nickjillings@1306: checkbox.type = "checkbox"; nickjillings@1306: var text = document.createElement('span'); nickjillings@1306: checkbox.setAttribute('name',checkName); nickjillings@1306: if (interfaceNode.getAttribute('default') == 'on') nickjillings@1306: { nickjillings@1306: checkbox.checked = true; nickjillings@1306: } nickjillings@1306: if (interfaceNode.getAttribute('support') == "none") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = false; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } else if (interfaceNode.getAttribute('support') == "mandatory") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = true; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } nickjillings@1306: if(testNode != undefined) nickjillings@1306: { nickjillings@1306: if (interfaceNode.getAttribute('default') == 'on') nickjillings@1306: { nickjillings@1306: checkbox.checked = true; nickjillings@1306: } nickjillings@1306: if (testNode.getAttribute('support') == "none") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = false; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: }else if (interfaceNode.getAttribute('support') == "mandatory") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = true; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } nickjillings@1306: } nickjillings@1306: text.textContent = popupStateNodes.state[3].checkText.getAllElementsByName(checkName)[0].textContent; nickjillings@1306: optH.appendChild(checkbox); nickjillings@1306: optH.appendChild(text); nickjillings@1306: this.options.push(optH); nickjillings@1306: this.content.appendChild(optH); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.continue = function() nickjillings@1306: { nickjillings@1306: if (specification.metrics == null) { nickjillings@1306: specification.metrics = new specification.metricNode(); nickjillings@1306: } nickjillings@1306: for (var object of this.options) nickjillings@1306: { nickjillings@1306: var checkbox = object.children[0]; nickjillings@1306: if (checkbox.checked) nickjillings@1306: { nickjillings@1306: specification.metrics.enabled.push(checkbox.getAttribute('name')); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: popupStateNodes.state[4].generate(); nickjillings@1306: popupObject.postNode(popupStateNodes.state[4]); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.state[4] = new function() nickjillings@1306: { nickjillings@1306: this.title = "Test Visuals"; nickjillings@1306: this.content = document.createElement("div"); nickjillings@1306: this.content.id = "state-1"; nickjillings@1306: var spnH = document.createElement('div'); nickjillings@1306: var span = document.createElement("span"); nickjillings@1306: span.textContent = "You can display extra visual content with your interface for the test user to interact with. Select from the available options below. Greyed out options are unavailable for your selected interface"; nickjillings@1306: spnH.appendChild(span); nickjillings@1306: this.content.appendChild(spnH); nickjillings@1306: this.options = []; nickjillings@1306: this.checkText; nickjillings@1306: this.testXML; nickjillings@1306: this.interfaceXML; nickjillings@1306: this.generate = function() nickjillings@1306: { nickjillings@1306: var interfaceName = popupStateNodes.state[1].select.value; nickjillings@1306: this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0]; nickjillings@1306: this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; nickjillings@1306: this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0]; nickjillings@1306: this.testXML = this.testXML.getAllElementsByTagName("metrics"); nickjillings@1306: for (var i=0; i 0) nickjillings@1306: { nickjillings@1306: testNode = this.testXML[0].getAllElementsByName(checkName); nickjillings@1306: if(testNode.length != 0) {testNode = testNode[0];} nickjillings@1306: else {testNode = undefined;} nickjillings@1306: } else { nickjillings@1306: testNode = undefined; nickjillings@1306: } nickjillings@1306: var optH = document.createElement('div'); nickjillings@1306: optH.className = "popup-checkbox"; nickjillings@1306: var checkbox = document.createElement('input'); nickjillings@1306: checkbox.type = "checkbox"; nickjillings@1306: var text = document.createElement('span'); nickjillings@1306: checkbox.setAttribute('name',checkName); nickjillings@1306: if (interfaceNode.getAttribute('default') == 'on') nickjillings@1306: { nickjillings@1306: checkbox.checked = true; nickjillings@1306: } nickjillings@1306: if (interfaceNode.getAttribute('support') == "none") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = false; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } else if (interfaceNode.getAttribute('support') == "mandatory") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = true; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } nickjillings@1306: if(testNode != undefined) nickjillings@1306: { nickjillings@1306: if (interfaceNode.getAttribute('default') == 'on') nickjillings@1306: { nickjillings@1306: checkbox.checked = true; nickjillings@1306: } nickjillings@1306: if (testNode.getAttribute('support') == "none") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = false; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: }else if (interfaceNode.getAttribute('support') == "mandatory") nickjillings@1306: { nickjillings@1306: checkbox.disabled = true; nickjillings@1306: checkbox.checked = true; nickjillings@1306: optH.className = "popup-checkbox disabled"; nickjillings@1306: } nickjillings@1306: } nickjillings@1306: text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; nickjillings@1306: optH.appendChild(checkbox); nickjillings@1306: optH.appendChild(text); nickjillings@1306: this.options.push(optH); nickjillings@1306: this.content.appendChild(optH); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.continue = function() nickjillings@1306: { nickjillings@1306: if (specification.interfaces == null) nickjillings@1306: { nickjillings@1306: specification.interfaces = new specification.interfaceNode(); nickjillings@1306: } nickjillings@1306: for (var object of this.options) nickjillings@1306: { nickjillings@1306: var checkbox = object.children[0]; nickjillings@1306: if (checkbox.checked) nickjillings@1306: { nickjillings@1306: var option = { nickjillings@1306: type: "show", nickjillings@1306: name: checkbox.getAttribute('name') nickjillings@1306: }; nickjillings@1306: specification.interfaces.options.push(option); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: popupObject.hide(); nickjillings@1306: convert.convert(document.getElementById('content')); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.state[5] = new function() { nickjillings@1306: this.title = "Add/Edit Survey Element"; nickjillings@1306: this.content = document.createElement("div"); nickjillings@1306: this.content.id = "state-1"; nickjillings@1306: var spnH = document.createElement('div'); nickjillings@1306: var span = document.createElement("span"); nickjillings@1306: span.textContent = "You can configure your survey element here. Press 'Continue' to complete your changes."; nickjillings@1306: spnH.appendChild(span); nickjillings@1306: this.content.appendChild(spnH); nickjillings@1306: this.dynamic = document.createElement("div"); nickjillings@1306: this.option = null; nickjillings@1306: this.parent = null; nickjillings@1306: this.optionLists = []; nickjillings@1306: var select = document.createElement("select"); nickjillings@1306: select.setAttribute("name","type"); nickjillings@1306: select.addEventListener("change",this,false); nickjillings@1306: this.content.appendChild(select); nickjillings@1306: this.content.appendChild(this.dynamic); nickjillings@1306: this.generate = function(option, parent) nickjillings@1306: { nickjillings@1306: this.option = option; nickjillings@1306: this.parent = parent; nickjillings@1306: var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); nickjillings@1306: for (var i=0; i= 0) { nickjillings@1306: var aeList = this.parent.parent.specification.audioElements; nickjillings@1306: if (i < aeList.length-1) { nickjillings@1306: aeList = aeList.slice(0,i).concat(aeList.slice(i+1)); nickjillings@1306: } else { nickjillings@1306: aeList = aeList.slice(0,i); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: i = this.parent.parent.children.findIndex(function(element,index,array){ nickjillings@1306: if (element == this.parent) nickjillings@1306: return true; nickjillings@1306: else nickjillings@1306: return false; nickjillings@1306: },this); nickjillings@1306: if (i >= 0) { nickjillings@1306: var childList = this.parent.children; nickjillings@1306: if (i < aeList.length-1) { nickjillings@1306: childList = childList.slice(0,i).concat(childList.slice(i+1)); nickjillings@1306: } else { nickjillings@1306: childList = childList.slice(0,i); nickjillings@1306: } nickjillings@1306: this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM); nickjillings@1306: } nickjillings@1306: }, nickjillings@1306: findNode: function(element,index,array){ nickjillings@1306: if (element == this.parent.specification) nickjillings@1306: return true; nickjillings@1306: else nickjillings@1306: return false; nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.deleteNode.root.textContent = "Delete Entry"; nickjillings@1306: this.deleteNode.root.addEventListener("click",this.deleteNode,false); nickjillings@1306: this.buttonDOM.appendChild(this.deleteNode.root); nickjillings@1306: } nickjillings@1306: nickjillings@1306: this.commentQuestionNode = function(parent,rootObject) nickjillings@1306: { nickjillings@1306: this.type = "commentQuestionNode"; nickjillings@1306: this.rootDOM = document.createElement("div"); nickjillings@1306: this.titleDOM = document.createElement("span"); nickjillings@1306: this.attributeDOM = document.createElement("div"); nickjillings@1306: this.attributes = []; nickjillings@1306: this.childrenDOM = document.createElement("div"); nickjillings@1306: this.children = []; nickjillings@1306: this.buttonDOM = document.createElement("div"); nickjillings@1306: this.parent = parent; nickjillings@1306: this.specification = rootObject; nickjillings@1306: this.schema = specification.schema.getAllElementsByName("page")[0]; nickjillings@1306: this.rootDOM.className = "node"; nickjillings@1306: nickjillings@1306: var titleDiv = document.createElement('div'); nickjillings@1306: titleDiv.className = "node-title"; nickjillings@1306: this.titleDOM.className = "node-title"; nickjillings@1306: this.titleDOM.textContent = "Test Page"; nickjillings@1306: titleDiv.appendChild(this.titleDOM); nickjillings@1306: nickjillings@1306: this.attributeDOM.className = "node-attributes"; nickjillings@1306: this.childrenDOM.className = "node-children"; nickjillings@1306: this.buttonDOM.className = "node-buttons"; nickjillings@1306: nickjillings@1306: this.rootDOM.appendChild(titleDiv); nickjillings@1306: this.rootDOM.appendChild(this.attributeDOM); nickjillings@1306: this.rootDOM.appendChild(this.childrenDOM); nickjillings@1306: this.rootDOM.appendChild(this.buttonDOM); nickjillings@1306: nickjillings@1306: } nickjillings@1306: nickjillings@1306: // Build the components nickjillings@1306: for (var interfaceObj of this.specification.interfaces) nickjillings@1306: { nickjillings@1306: var newInterface = new this.parent.interfaceNode(this.parent,interfaceObj); nickjillings@1306: newInterface.build("Interface",""+this.specification.id+"-interface",this.childrenDOM); nickjillings@1306: this.children.push(newInterface); nickjillings@1306: this.interfaces.push(newInterface); nickjillings@1306: } nickjillings@1306: nickjillings@1306: for (var elements of this.specification.audioElements) nickjillings@1306: { nickjillings@1306: var audioElementDOM = new this.audioElementNode(this,elements); nickjillings@1306: this.children.push(audioElementDOM); nickjillings@1306: this.childrenDOM.appendChild(audioElementDOM.rootDOM); nickjillings@1306: } nickjillings@1306: nickjillings@1306: this.addInterface = { nickjillings@1306: root: document.createElement("button"), nickjillings@1306: parent: this, nickjillings@1306: handleEvent: function() { nickjillings@1306: var InterfaceObj = new specification.interfaceNode(); nickjillings@1306: var newInterface = new this.parent.parent.interfaceNode(this.parent.parent,InterfaceObj); nickjillings@1306: newInterface.build("Interface",""+this.parent.specification.id+"-interface",this.parent.childrenDOM); nickjillings@1306: this.parent.children.push(newInterface); nickjillings@1306: this.parent.specification.interfaces.push(InterfaceObj); nickjillings@1306: this.parent.interfaces.push(newInterface); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.addInterface.root.textContent = "Add Interface"; nickjillings@1306: this.addInterface.root.addEventListener("click",this.addInterface,false); nickjillings@1306: this.buttonDOM.appendChild(this.addInterface.root); nickjillings@1306: nickjillings@1306: this.addAudioElement = { nickjillings@1306: root: document.createElement("button"), nickjillings@1306: parent: this, nickjillings@1306: handleEvent: function() { nickjillings@1306: var audioElementObject = new this.parent.specification.audioElementNode(); nickjillings@1306: var audioElementDOM = new this.parent.audioElementNode(this.parent,audioElementObject); nickjillings@1306: this.parent.specification.audioElements.push(audioElementObject); nickjillings@1306: this.parent.children.push(audioElementDOM); nickjillings@1306: this.parent.childrenDOM.appendChild(audioElementDOM.rootDOM); nickjillings@1306: } nickjillings@1306: } nickjillings@1306: this.addAudioElement.root.textContent = "Add Audio Element"; nickjillings@1306: this.addAudioElement.root.addEventListener("click",this.addAudioElement,false); nickjillings@1306: this.buttonDOM.appendChild(this.addAudioElement.root); nickjillings@1306: } nickjillings@1306: }