Mercurial > hg > webaudioevaluationtool
comparison test_create/test_core.js @ 2535:dd5290724a76
Format test_core.js
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 14 Nov 2016 12:11:24 +0000 |
parents | 23bbd100b403 |
children | 527020a63203 |
comparison
equal
deleted
inserted
replaced
2533:370a82784c71 | 2535:dd5290724a76 |
---|---|
9 | 9 |
10 // Firefox does not have an XMLDocument.prototype.getElementsByName | 10 // Firefox does not have an XMLDocument.prototype.getElementsByName |
11 // and there is no searchAll style command, this custom function will | 11 // and there is no searchAll style command, this custom function will |
12 // search all children recusrively for the name. Used for XSD where all | 12 // search all children recusrively for the name. Used for XSD where all |
13 // element nodes must have a name and therefore can pull the schema node | 13 // element nodes must have a name and therefore can pull the schema node |
14 XMLDocument.prototype.getAllElementsByName = function(name) | 14 XMLDocument.prototype.getAllElementsByName = function (name) { |
15 { | |
16 name = String(name); | 15 name = String(name); |
17 var selected = this.documentElement.getAllElementsByName(name); | 16 var selected = this.documentElement.getAllElementsByName(name); |
18 return selected; | 17 return selected; |
19 } | 18 } |
20 | 19 |
21 Element.prototype.getAllElementsByName = function(name) | 20 Element.prototype.getAllElementsByName = function (name) { |
22 { | |
23 name = String(name); | 21 name = String(name); |
24 var selected = []; | 22 var selected = []; |
25 var node = this.firstElementChild; | 23 var node = this.firstElementChild; |
26 while(node != null) | 24 while (node != null) { |
27 { | 25 if (node.getAttribute('name') == name) { |
28 if (node.getAttribute('name') == name) | |
29 { | |
30 selected.push(node); | 26 selected.push(node); |
31 } | 27 } |
32 if (node.childElementCount > 0) | 28 if (node.childElementCount > 0) { |
33 { | |
34 selected = selected.concat(node.getAllElementsByName(name)); | 29 selected = selected.concat(node.getAllElementsByName(name)); |
35 } | 30 } |
36 node = node.nextElementSibling; | 31 node = node.nextElementSibling; |
37 } | 32 } |
38 return selected; | 33 return selected; |
39 } | 34 } |
40 | 35 |
41 XMLDocument.prototype.getAllElementsByTagName = function(name) | 36 XMLDocument.prototype.getAllElementsByTagName = function (name) { |
42 { | |
43 name = String(name); | 37 name = String(name); |
44 var selected = this.documentElement.getAllElementsByTagName(name); | 38 var selected = this.documentElement.getAllElementsByTagName(name); |
45 return selected; | 39 return selected; |
46 } | 40 } |
47 | 41 |
48 Element.prototype.getAllElementsByTagName = function(name) | 42 Element.prototype.getAllElementsByTagName = function (name) { |
49 { | |
50 name = String(name); | 43 name = String(name); |
51 var selected = []; | 44 var selected = []; |
52 var node = this.firstElementChild; | 45 var node = this.firstElementChild; |
53 while(node != null) | 46 while (node != null) { |
54 { | 47 if (node.nodeName == name) { |
55 if (node.nodeName == name) | |
56 { | |
57 selected.push(node); | 48 selected.push(node); |
58 } | 49 } |
59 if (node.childElementCount > 0) | 50 if (node.childElementCount > 0) { |
60 { | |
61 selected = selected.concat(node.getAllElementsByTagName(name)); | 51 selected = selected.concat(node.getAllElementsByTagName(name)); |
62 } | 52 } |
63 node = node.nextElementSibling; | 53 node = node.nextElementSibling; |
64 } | 54 } |
65 return selected; | 55 return selected; |
66 } | 56 } |
67 | 57 |
68 // Firefox does not have an XMLDocument.prototype.getElementsByName | 58 // Firefox does not have an XMLDocument.prototype.getElementsByName |
69 if (typeof XMLDocument.prototype.getElementsByName != "function") { | 59 if (typeof XMLDocument.prototype.getElementsByName != "function") { |
70 XMLDocument.prototype.getElementsByName = function(name) | 60 XMLDocument.prototype.getElementsByName = function (name) { |
71 { | |
72 name = String(name); | 61 name = String(name); |
73 var node = this.documentElement.firstElementChild; | 62 var node = this.documentElement.firstElementChild; |
74 var selected = []; | 63 var selected = []; |
75 while(node != null) | 64 while (node != null) { |
76 { | 65 if (node.getAttribute('name') == name) { |
77 if (node.getAttribute('name') == name) | |
78 { | |
79 selected.push(node); | 66 selected.push(node); |
80 } | 67 } |
81 node = node.nextElementSibling; | 68 node = node.nextElementSibling; |
82 } | 69 } |
83 return selected; | 70 return selected; |
84 } | 71 } |
85 } | 72 } |
86 | 73 |
87 window.onload = function() | 74 window.onload = function () { |
88 { | |
89 specification = new Specification(); | 75 specification = new Specification(); |
90 convert = new SpecificationToHTML(); | 76 convert = new SpecificationToHTML(); |
91 xmlHttp = new XMLHttpRequest(); | 77 xmlHttp = new XMLHttpRequest(); |
92 xmlHttp.open("GET","test_create/interface-specs.xml",true); | 78 xmlHttp.open("GET", "test_create/interface-specs.xml", true); |
93 xmlHttp.onload = function() | 79 xmlHttp.onload = function () { |
94 { | |
95 var parse = new DOMParser(); | 80 var parse = new DOMParser(); |
96 interfaceSpecs = parse.parseFromString(xmlHttp.response,'text/xml'); | 81 interfaceSpecs = parse.parseFromString(xmlHttp.response, 'text/xml'); |
97 buildPage(); | 82 buildPage(); |
98 popupObject.postNode(popupStateNodes.state[0]) | 83 popupObject.postNode(popupStateNodes.state[0]) |
99 } | 84 } |
100 xmlHttp.send(); | 85 xmlHttp.send(); |
101 | 86 |
102 var xsdGet = new XMLHttpRequest(); | 87 var xsdGet = new XMLHttpRequest(); |
103 xsdGet.open("GET","xml/test-schema.xsd",true); | 88 xsdGet.open("GET", "xml/test-schema.xsd", true); |
104 xsdGet.onload = function() | 89 xsdGet.onload = function () { |
105 { | |
106 var parse = new DOMParser(); | 90 var parse = new DOMParser(); |
107 specification.schema = parse.parseFromString(xsdGet.response,'text/xml');; | 91 specification.schema = parse.parseFromString(xsdGet.response, 'text/xml');; |
108 } | 92 } |
109 xsdGet.send(); | 93 xsdGet.send(); |
110 | 94 |
111 var jsonAttribute = new XMLHttpRequest(); | 95 var jsonAttribute = new XMLHttpRequest(); |
112 jsonAttribute.open("GET","test_create/attributes.json",true); | 96 jsonAttribute.open("GET", "test_create/attributes.json", true); |
113 jsonAttribute.onload = function() | 97 jsonAttribute.onload = function () { |
114 { | |
115 attributeText = JSON.parse(jsonAttribute.response) | 98 attributeText = JSON.parse(jsonAttribute.response) |
116 } | 99 } |
117 jsonAttribute.send(); | 100 jsonAttribute.send(); |
118 } | 101 } |
119 | 102 |
120 function buildPage() | 103 function buildPage() { |
121 { | 104 popupObject = new function () { |
122 popupObject = new function() { | |
123 this.object = document.getElementById("popupHolder"); | 105 this.object = document.getElementById("popupHolder"); |
124 this.blanket = document.getElementById("blanket"); | 106 this.blanket = document.getElementById("blanket"); |
125 | 107 |
126 this.popupTitle = document.createElement("div"); | 108 this.popupTitle = document.createElement("div"); |
127 this.popupTitle.id = "popup-title-holder"; | 109 this.popupTitle.id = "popup-title-holder"; |
132 this.object.appendChild(this.popupTitle); | 114 this.object.appendChild(this.popupTitle); |
133 | 115 |
134 this.popupContent = document.createElement("div"); | 116 this.popupContent = document.createElement("div"); |
135 this.popupContent.id = "popup-content"; | 117 this.popupContent.id = "popup-content"; |
136 this.object.appendChild(this.popupContent); | 118 this.object.appendChild(this.popupContent); |
137 | 119 |
138 this.proceedButton = document.createElement("button"); | 120 this.proceedButton = document.createElement("button"); |
139 this.proceedButton.id = "popup-proceed"; | 121 this.proceedButton.id = "popup-proceed"; |
140 this.proceedButton.className = "popup-button"; | 122 this.proceedButton.className = "popup-button"; |
141 this.proceedButton.textContent = "Next"; | 123 this.proceedButton.textContent = "Next"; |
142 this.proceedButton.onclick = function() | 124 this.proceedButton.onclick = function () { |
143 { | |
144 popupObject.popupContent.innerHTML = null; | 125 popupObject.popupContent.innerHTML = null; |
145 if(typeof popupObject.shownObject.continue == "function") { | 126 if (typeof popupObject.shownObject.continue == "function") { |
146 popupObject.shownObject.continue(); | 127 popupObject.shownObject.continue(); |
147 } else { | 128 } else { |
148 popupObject.hide(); | 129 popupObject.hide(); |
149 } | 130 } |
150 }; | 131 }; |
151 this.object.appendChild(this.proceedButton); | 132 this.object.appendChild(this.proceedButton); |
152 | 133 |
153 this.backButton = document.createElement("button"); | 134 this.backButton = document.createElement("button"); |
154 this.backButton.id = "popup-back"; | 135 this.backButton.id = "popup-back"; |
155 this.backButton.className = "popup-button"; | 136 this.backButton.className = "popup-button"; |
156 this.backButton.textContent = "Back"; | 137 this.backButton.textContent = "Back"; |
157 this.backButton.onclick = function() | 138 this.backButton.onclick = function () { |
158 { | |
159 popupObject.popupContent.innerHTML = null; | 139 popupObject.popupContent.innerHTML = null; |
160 popupObject.shownObject.back(); | 140 popupObject.shownObject.back(); |
161 }; | 141 }; |
162 this.object.appendChild(this.backButton); | 142 this.object.appendChild(this.backButton); |
163 | 143 |
164 this.shownObject; | 144 this.shownObject; |
165 | 145 |
166 this.resize = function() | 146 this.resize = function () { |
167 { | |
168 var w = window.innerWidth; | 147 var w = window.innerWidth; |
169 var h = window.innerHeight; | 148 var h = window.innerHeight; |
170 this.object.style.left = Math.floor((w-750)/2) + 'px'; | 149 this.object.style.left = Math.floor((w - 750) / 2) + 'px'; |
171 this.object.style.top = Math.floor((h-500)/2) + 'px'; | 150 this.object.style.top = Math.floor((h - 500) / 2) + 'px'; |
172 } | 151 } |
173 | 152 |
174 this.show = function() | 153 this.show = function () { |
175 { | |
176 this.object.style.visibility = "visible"; | 154 this.object.style.visibility = "visible"; |
177 this.blanket.style.visibility = "visible"; | 155 this.blanket.style.visibility = "visible"; |
178 if (typeof this.shownObject.back == "function") { | 156 if (typeof this.shownObject.back == "function") { |
179 this.backButton.style.visibility = "visible"; | 157 this.backButton.style.visibility = "visible"; |
180 } else { | 158 } else { |
181 this.backButton.style.visibility = "hidden"; | 159 this.backButton.style.visibility = "hidden"; |
182 } | 160 } |
183 } | 161 } |
184 | 162 |
185 this.hide = function() | 163 this.hide = function () { |
186 { | |
187 this.object.style.visibility = "hidden"; | 164 this.object.style.visibility = "hidden"; |
188 this.blanket.style.visibility = "hidden"; | 165 this.blanket.style.visibility = "hidden"; |
189 this.backButton.style.visibility = "hidden"; | 166 this.backButton.style.visibility = "hidden"; |
190 } | 167 } |
191 | 168 |
192 this.postNode = function(postObject) | 169 this.postNode = function (postObject) { |
193 { | |
194 //Passed object must have the following: | 170 //Passed object must have the following: |
195 // Title: text to show in the title | 171 // Title: text to show in the title |
196 // Content: HTML DOM to show on the page | 172 // Content: HTML DOM to show on the page |
197 // On complete this HTML DOM is destroyed so make sure it is referenced elsewhere for processing | 173 // On complete this HTML DOM is destroyed so make sure it is referenced elsewhere for processing |
198 this.titleDOM.textContent = postObject.title; | 174 this.titleDOM.textContent = postObject.title; |
212 } | 188 } |
213 | 189 |
214 this.resize(); | 190 this.resize(); |
215 this.hide(); | 191 this.hide(); |
216 }; | 192 }; |
217 | 193 |
218 popupStateNodes = new function() | 194 popupStateNodes = new function () { |
219 { | |
220 // This defines the several popup states wanted | 195 // This defines the several popup states wanted |
221 this.state = []; | 196 this.state = []; |
222 this.state[0] = new function() | 197 this.state[0] = new function () { |
223 { | |
224 this.title = "Welcome"; | 198 this.title = "Welcome"; |
225 this.content = document.createElement("div"); | 199 this.content = document.createElement("div"); |
226 this.content.id = "state-0"; | 200 this.content.id = "state-0"; |
227 var span = document.createElement("span"); | 201 var span = document.createElement("span"); |
228 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." | 202 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." |
229 this.content.appendChild(span); | 203 this.content.appendChild(span); |
230 this.dragArea = document.createElement("div"); | 204 this.dragArea = document.createElement("div"); |
231 this.dragArea.className = "drag-area"; | 205 this.dragArea.className = "drag-area"; |
232 this.dragArea.id = "project-drop"; | 206 this.dragArea.id = "project-drop"; |
233 this.content.appendChild(this.dragArea); | 207 this.content.appendChild(this.dragArea); |
234 | 208 |
235 this.dragArea.addEventListener('dragover',function(e){ | 209 this.dragArea.addEventListener('dragover', function (e) { |
236 e.stopPropagation(); | 210 e.stopPropagation(); |
237 e.preventDefault(); | 211 e.preventDefault(); |
238 e.dataTransfer.dropEffect = 'copy'; | 212 e.dataTransfer.dropEffect = 'copy'; |
239 e.currentTarget.className = "drag-area drag-over"; | 213 e.currentTarget.className = "drag-area drag-over"; |
240 }); | 214 }); |
241 | 215 |
242 this.dragArea.addEventListener('dragexit',function(e){ | 216 this.dragArea.addEventListener('dragexit', function (e) { |
243 e.stopPropagation(); | 217 e.stopPropagation(); |
244 e.preventDefault(); | 218 e.preventDefault(); |
245 e.dataTransfer.dropEffect = 'copy'; | 219 e.dataTransfer.dropEffect = 'copy'; |
246 e.currentTarget.className = "drag-area"; | 220 e.currentTarget.className = "drag-area"; |
247 }); | 221 }); |
248 | 222 |
249 this.dragArea.addEventListener('drop',function(e){ | 223 this.dragArea.addEventListener('drop', function (e) { |
250 e.stopPropagation(); | 224 e.stopPropagation(); |
251 e.preventDefault(); | 225 e.preventDefault(); |
252 e.currentTarget.className = "drag-area drag-dropped"; | 226 e.currentTarget.className = "drag-area drag-dropped"; |
253 var files = e.dataTransfer.files[0]; | 227 var files = e.dataTransfer.files[0]; |
254 var reader = new FileReader(); | 228 var reader = new FileReader(); |
255 reader.onload = function(decoded) { | 229 reader.onload = function (decoded) { |
256 var parse = new DOMParser(); | 230 var parse = new DOMParser(); |
257 specification.decode(parse.parseFromString(decoded.target.result,'text/xml')); | 231 specification.decode(parse.parseFromString(decoded.target.result, 'text/xml')); |
258 popupObject.hide(); | 232 popupObject.hide(); |
259 popupObject.popupContent.innerHTML = null; | 233 popupObject.popupContent.innerHTML = null; |
260 convert.convert(document.getElementById('content')); | 234 convert.convert(document.getElementById('content')); |
261 } | 235 } |
262 reader.readAsText(files); | 236 reader.readAsText(files); |
263 }); | 237 }); |
264 | 238 |
265 | 239 |
266 this.continue = function() | 240 this.continue = function () { |
267 { | |
268 popupObject.postNode(popupStateNodes.state[1]); | 241 popupObject.postNode(popupStateNodes.state[1]); |
269 } | 242 } |
270 } | 243 } |
271 this.state[1] = new function() | 244 this.state[1] = new function () { |
272 { | |
273 this.title = "Select your interface"; | 245 this.title = "Select your interface"; |
274 this.content = document.createElement("div"); | 246 this.content = document.createElement("div"); |
275 this.content.id = "state-1"; | 247 this.content.id = "state-1"; |
276 var spnH = document.createElement('div'); | 248 var spnH = document.createElement('div'); |
277 var span = document.createElement("span"); | 249 var span = document.createElement("span"); |
281 this.select = document.createElement("select"); | 253 this.select = document.createElement("select"); |
282 this.content.appendChild(this.select); | 254 this.content.appendChild(this.select); |
283 this.description = document.createElement("p"); | 255 this.description = document.createElement("p"); |
284 this.content.appendChild(this.description); | 256 this.content.appendChild(this.description); |
285 this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].getElementsByTagName('test'); | 257 this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].getElementsByTagName('test'); |
286 for (var i=0; i<this.testsXML.length; i++) | 258 for (var i = 0; i < this.testsXML.length; i++) { |
287 { | |
288 var option = document.createElement('option'); | 259 var option = document.createElement('option'); |
289 option.value = this.testsXML[i].getAttribute('name'); | 260 option.value = this.testsXML[i].getAttribute('name'); |
290 option.textContent = this.testsXML[i].getAttribute('name'); | 261 option.textContent = this.testsXML[i].getAttribute('name'); |
291 this.select.appendChild(option); | 262 this.select.appendChild(option); |
292 } | 263 } |
293 this.handleEvent = function(event) { | 264 this.handleEvent = function (event) { |
294 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0]; | 265 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0]; |
295 var descriptors = testXML.getAllElementsByTagName("description"); | 266 var descriptors = testXML.getAllElementsByTagName("description"); |
296 this.description.textContent = ""; | 267 this.description.textContent = ""; |
297 for (var i=0; i<descriptors.length; i++) { | 268 for (var i = 0; i < descriptors.length; i++) { |
298 if (descriptors[i].getAttribute("lang") == page_lang) { | 269 if (descriptors[i].getAttribute("lang") == page_lang) { |
299 this.description.textContent = descriptors[i].textContent; | 270 this.description.textContent = descriptors[i].textContent; |
300 } | 271 } |
301 } | 272 } |
302 } | 273 } |
303 this.select.addEventListener("change",this); | 274 this.select.addEventListener("change", this); |
304 this.handleEvent(); | 275 this.handleEvent(); |
305 this.continue = function() | 276 this.continue = function () { |
306 { | |
307 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0]; | 277 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0]; |
308 specification.interface = testXML.getAttribute("interface"); | 278 specification.interface = testXML.getAttribute("interface"); |
309 if (specification.interfaces == null) | 279 if (specification.interfaces == null) { |
310 { | |
311 specification.interfaces = new specification.interfaceNode(specification); | 280 specification.interfaces = new specification.interfaceNode(specification); |
312 } | 281 } |
313 if (specification.metrics == null) { | 282 if (specification.metrics == null) { |
314 specification.metrics = new specification.metricNode(); | 283 specification.metrics = new specification.metricNode(); |
315 } | 284 } |
316 popupStateNodes.state[2].generate(); | 285 popupStateNodes.state[2].generate(); |
317 popupObject.postNode(popupStateNodes.state[2]); | 286 popupObject.postNode(popupStateNodes.state[2]); |
318 } | 287 } |
319 this.back = function() { | 288 this.back = function () { |
320 popupObject.postNode(popupStateNodes.state[0]); | 289 popupObject.postNode(popupStateNodes.state[0]); |
321 } | 290 } |
322 } | 291 } |
323 this.state[2] = new function() | 292 this.state[2] = new function () { |
324 { | |
325 this.title = "Test Checks & Restrictions"; | 293 this.title = "Test Checks & Restrictions"; |
326 this.content = document.createElement("div"); | 294 this.content = document.createElement("div"); |
327 this.content.id = "state-1"; | 295 this.content.id = "state-1"; |
328 var spnH = document.createElement('div'); | 296 var spnH = document.createElement('div'); |
329 var span = document.createElement("span"); | 297 var span = document.createElement("span"); |
334 this.options = []; | 302 this.options = []; |
335 this.testXML = null; | 303 this.testXML = null; |
336 this.interfaceXML = null; | 304 this.interfaceXML = null; |
337 this.dynamicContent = document.createElement("div"); | 305 this.dynamicContent = document.createElement("div"); |
338 this.content.appendChild(this.dynamicContent); | 306 this.content.appendChild(this.dynamicContent); |
339 this.generate = function() | 307 this.generate = function () { |
340 { | |
341 this.options = []; | 308 this.options = []; |
342 this.dynamicContent.innerHTML = null; | 309 this.dynamicContent.innerHTML = null; |
343 var interfaceName = popupStateNodes.state[1].select.value; | 310 var interfaceName = popupStateNodes.state[1].select.value; |
344 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0]; | 311 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0]; |
345 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; | 312 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; |
346 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0]; | 313 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0]; |
347 this.testXML = this.testXML.getAllElementsByTagName("checks"); | 314 this.testXML = this.testXML.getAllElementsByTagName("checks"); |
348 var interfaceXMLChildren = this.interfaceXML.getElementsByTagName('entry'); | 315 var interfaceXMLChildren = this.interfaceXML.getElementsByTagName('entry'); |
349 for (var i=0; i<interfaceXMLChildren.length; i++) | 316 for (var i = 0; i < interfaceXMLChildren.length; i++) { |
350 { | |
351 var interfaceNode = interfaceXMLChildren[i]; | 317 var interfaceNode = interfaceXMLChildren[i]; |
352 var checkName = interfaceNode.getAttribute('name'); | 318 var checkName = interfaceNode.getAttribute('name'); |
353 var testNode | 319 var testNode |
354 if (this.testXML.length > 0) | 320 if (this.testXML.length > 0) { |
355 { | |
356 testNode = this.testXML[0].getAllElementsByName(checkName); | 321 testNode = this.testXML[0].getAllElementsByName(checkName); |
357 if(testNode.length != 0) {testNode = testNode[0];} | 322 if (testNode.length != 0) { |
358 else {testNode = undefined;} | 323 testNode = testNode[0]; |
324 } else { | |
325 testNode = undefined; | |
326 } | |
359 } else { | 327 } else { |
360 testNode = undefined; | 328 testNode = undefined; |
361 } | 329 } |
362 var obj = { | 330 var obj = { |
363 root: document.createElement("div"), | 331 root: document.createElement("div"), |
364 text: document.createElement("label"), | 332 text: document.createElement("label"), |
365 input: document.createElement("input"), | 333 input: document.createElement("input"), |
366 parent: this, | 334 parent: this, |
367 name: checkName, | 335 name: checkName, |
368 handleEvent: function(event) { | 336 handleEvent: function (event) { |
369 if (this.input.checked) { | 337 if (this.input.checked) { |
370 // Add to specification.interfaces.option | 338 // Add to specification.interfaces.option |
371 var included = specification.interfaces.options.find(function(element,index,array){ | 339 var included = specification.interfaces.options.find(function (element, index, array) { |
372 if (element.name == this.name) {return true;} else {return false;} | 340 if (element.name == this.name) { |
373 },this); | 341 return true; |
342 } else { | |
343 return false; | |
344 } | |
345 }, this); | |
374 if (included == null) { | 346 if (included == null) { |
375 specification.interfaces.options.push({type:"check",name:this.name}); | 347 specification.interfaces.options.push({ |
348 type: "check", | |
349 name: this.name | |
350 }); | |
376 } | 351 } |
377 } else { | 352 } else { |
378 // Remove from specification.interfaces.option | 353 // Remove from specification.interfaces.option |
379 var position = specification.interfaces.options.findIndex(function(element,index,array){ | 354 var position = specification.interfaces.options.findIndex(function (element, index, array) { |
380 if (element.name == this.name) {return true;} else {return false;} | 355 if (element.name == this.name) { |
381 },this); | 356 return true; |
357 } else { | |
358 return false; | |
359 } | |
360 }, this); | |
382 if (position >= 0) { | 361 if (position >= 0) { |
383 specification.interfaces.options.splice(position,1); | 362 specification.interfaces.options.splice(position, 1); |
384 } | 363 } |
385 } | 364 } |
386 } | 365 } |
387 } | 366 } |
388 | 367 |
389 obj.input.addEventListener("click",obj); | 368 obj.input.addEventListener("click", obj); |
390 obj.root.className = "popup-checkbox"; | 369 obj.root.className = "popup-checkbox"; |
391 obj.input.type = "checkbox"; | 370 obj.input.type = "checkbox"; |
392 obj.input.setAttribute('id',checkName); | 371 obj.input.setAttribute('id', checkName); |
393 obj.text.setAttribute("for",checkName); | 372 obj.text.setAttribute("for", checkName); |
394 obj.text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; | 373 obj.text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; |
395 obj.root.appendChild(obj.input); | 374 obj.root.appendChild(obj.input); |
396 obj.root.appendChild(obj.text); | 375 obj.root.appendChild(obj.text); |
397 if(testNode != undefined) | 376 if (testNode != undefined) { |
398 { | 377 if (testNode.getAttribute('default') == 'on') { |
399 if (testNode.getAttribute('default') == 'on') | |
400 { | |
401 obj.input.checked = true; | 378 obj.input.checked = true; |
402 } | 379 } |
403 if (testNode.getAttribute('support') == "none") | 380 if (testNode.getAttribute('support') == "none") { |
404 { | |
405 obj.input.disabled = true; | 381 obj.input.disabled = true; |
406 obj.input.checked = false; | 382 obj.input.checked = false; |
407 obj.root.className = "popup-checkbox disabled"; | 383 obj.root.className = "popup-checkbox disabled"; |
408 }else if (interfaceNode.getAttribute('support') == "mandatory") | 384 } else if (interfaceNode.getAttribute('support') == "mandatory") { |
409 { | |
410 obj.input.disabled = true; | 385 obj.input.disabled = true; |
411 obj.input.checked = true; | 386 obj.input.checked = true; |
412 obj.root.className = "popup-checkbox disabled"; | 387 obj.root.className = "popup-checkbox disabled"; |
413 } | 388 } |
414 } else { | 389 } else { |
415 if (interfaceNode.getAttribute('default') == 'on') | 390 if (interfaceNode.getAttribute('default') == 'on') { |
416 { | |
417 obj.input.checked = true; | 391 obj.input.checked = true; |
418 } | 392 } |
419 if (interfaceNode.getAttribute('support') == "none") | 393 if (interfaceNode.getAttribute('support') == "none") { |
420 { | |
421 obj.input.disabled = true; | 394 obj.input.disabled = true; |
422 obj.input.checked = false; | 395 obj.input.checked = false; |
423 obj.root.className = "popup-checkbox disabled"; | 396 obj.root.className = "popup-checkbox disabled"; |
424 } else if (interfaceNode.getAttribute('support') == "mandatory") | 397 } else if (interfaceNode.getAttribute('support') == "mandatory") { |
425 { | |
426 obj.input.disabled = true; | 398 obj.input.disabled = true; |
427 obj.input.checked = true; | 399 obj.input.checked = true; |
428 obj.root.className = "popup-checkbox disabled"; | 400 obj.root.className = "popup-checkbox disabled"; |
429 } | 401 } |
430 } | 402 } |
431 var included = specification.interfaces.options.find(function(element,index,array){ | 403 var included = specification.interfaces.options.find(function (element, index, array) { |
432 if (element.name == this.name) {return true;} else {return false;} | 404 if (element.name == this.name) { |
433 },obj); | 405 return true; |
406 } else { | |
407 return false; | |
408 } | |
409 }, obj); | |
434 if (included != undefined) { | 410 if (included != undefined) { |
435 obj.input.checked = true; | 411 obj.input.checked = true; |
436 } | 412 } |
437 obj.handleEvent(); | 413 obj.handleEvent(); |
438 this.options.push(obj); | 414 this.options.push(obj); |
439 this.dynamicContent.appendChild(obj.root); | 415 this.dynamicContent.appendChild(obj.root); |
440 } | 416 } |
441 } | 417 } |
442 this.continue = function() | 418 this.continue = function () { |
443 { | |
444 popupStateNodes.state[3].generate(); | 419 popupStateNodes.state[3].generate(); |
445 popupObject.postNode(popupStateNodes.state[3]); | 420 popupObject.postNode(popupStateNodes.state[3]); |
446 } | 421 } |
447 this.back = function() { | 422 this.back = function () { |
448 popupObject.postNode(popupStateNodes.state[1]); | 423 popupObject.postNode(popupStateNodes.state[1]); |
449 } | 424 } |
450 } | 425 } |
451 this.state[3] = new function() | 426 this.state[3] = new function () { |
452 { | |
453 this.title = "Test Metrics"; | 427 this.title = "Test Metrics"; |
454 this.content = document.createElement("div"); | 428 this.content = document.createElement("div"); |
455 this.content.id = "state-1"; | 429 this.content.id = "state-1"; |
456 var spnH = document.createElement('div'); | 430 var spnH = document.createElement('div'); |
457 var span = document.createElement("span"); | 431 var span = document.createElement("span"); |
462 this.checkText; | 436 this.checkText; |
463 this.testXML; | 437 this.testXML; |
464 this.interfaceXML; | 438 this.interfaceXML; |
465 this.dynamicContent = document.createElement("div"); | 439 this.dynamicContent = document.createElement("div"); |
466 this.content.appendChild(this.dynamicContent); | 440 this.content.appendChild(this.dynamicContent); |
467 this.generate = function() | 441 this.generate = function () { |
468 { | |
469 this.options = []; | 442 this.options = []; |
470 this.dynamicContent.innerHTML = null; | 443 this.dynamicContent.innerHTML = null; |
471 var interfaceName = popupStateNodes.state[1].select.value; | 444 var interfaceName = popupStateNodes.state[1].select.value; |
472 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0]; | 445 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0]; |
473 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; | 446 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; |
474 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0]; | 447 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0]; |
475 this.testXML = this.testXML.getAllElementsByTagName("metrics"); | 448 this.testXML = this.testXML.getAllElementsByTagName("metrics"); |
476 var interfaceXMLChildren = this.interfaceXML.getElementsByTagName('entry'); | 449 var interfaceXMLChildren = this.interfaceXML.getElementsByTagName('entry'); |
477 for (var i=0; i<interfaceXMLChildren.length; i++) | 450 for (var i = 0; i < interfaceXMLChildren.length; i++) { |
478 { | |
479 var interfaceNode = interfaceXMLChildren[i]; | 451 var interfaceNode = interfaceXMLChildren[i]; |
480 var checkName = interfaceNode.getAttribute('name'); | 452 var checkName = interfaceNode.getAttribute('name'); |
481 var testNode | 453 var testNode |
482 if (this.testXML.length > 0) | 454 if (this.testXML.length > 0) { |
483 { | |
484 testNode = this.testXML[0].getAllElementsByName(checkName); | 455 testNode = this.testXML[0].getAllElementsByName(checkName); |
485 if(testNode.length != 0) {testNode = testNode[0];} | 456 if (testNode.length != 0) { |
486 else {testNode = undefined;} | 457 testNode = testNode[0]; |
458 } else { | |
459 testNode = undefined; | |
460 } | |
487 } else { | 461 } else { |
488 testNode = undefined; | 462 testNode = undefined; |
489 } | 463 } |
490 var obj = { | 464 var obj = { |
491 root: document.createElement("div"), | 465 root: document.createElement("div"), |
492 text: document.createElement("label"), | 466 text: document.createElement("label"), |
493 input: document.createElement("input"), | 467 input: document.createElement("input"), |
494 parent: this, | 468 parent: this, |
495 name: checkName, | 469 name: checkName, |
496 handleEvent: function(event) { | 470 handleEvent: function (event) { |
497 if (this.input.checked) { | 471 if (this.input.checked) { |
498 // Add to specification.interfaces.option | 472 // Add to specification.interfaces.option |
499 var included = specification.metrics.enabled.find(function(element,index,array){ | 473 var included = specification.metrics.enabled.find(function (element, index, array) { |
500 if (element == this.name) {return true;} else {return false;} | 474 if (element == this.name) { |
501 },this); | 475 return true; |
476 } else { | |
477 return false; | |
478 } | |
479 }, this); | |
502 if (included == null) { | 480 if (included == null) { |
503 specification.metrics.enabled.push(this.name); | 481 specification.metrics.enabled.push(this.name); |
504 } | 482 } |
505 } else { | 483 } else { |
506 // Remove from specification.interfaces.option | 484 // Remove from specification.interfaces.option |
507 var position = specification.metrics.enabled.findIndex(function(element,index,array){ | 485 var position = specification.metrics.enabled.findIndex(function (element, index, array) { |
508 if (element == this.name) {return true;} else {return false;} | 486 if (element == this.name) { |
509 },this); | 487 return true; |
488 } else { | |
489 return false; | |
490 } | |
491 }, this); | |
510 if (position >= 0) { | 492 if (position >= 0) { |
511 specification.metrics.enabled.splice(position,1); | 493 specification.metrics.enabled.splice(position, 1); |
512 } | 494 } |
513 } | 495 } |
514 } | 496 } |
515 } | 497 } |
516 | 498 |
517 obj.input.addEventListener("click",obj); | 499 obj.input.addEventListener("click", obj); |
518 obj.root.className = "popup-checkbox"; | 500 obj.root.className = "popup-checkbox"; |
519 obj.input.type = "checkbox"; | 501 obj.input.type = "checkbox"; |
520 obj.input.setAttribute('id',checkName); | 502 obj.input.setAttribute('id', checkName); |
521 obj.text.setAttribute("for",checkName); | 503 obj.text.setAttribute("for", checkName); |
522 obj.text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; | 504 obj.text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; |
523 obj.root.appendChild(obj.input); | 505 obj.root.appendChild(obj.input); |
524 obj.root.appendChild(obj.text); | 506 obj.root.appendChild(obj.text); |
525 if(testNode != undefined) | 507 if (testNode != undefined) { |
526 { | 508 if (testNode.getAttribute('default') == 'on') { |
527 if (testNode.getAttribute('default') == 'on') | |
528 { | |
529 obj.input.checked = true; | 509 obj.input.checked = true; |
530 } | 510 } |
531 if (testNode.getAttribute('support') == "none") | 511 if (testNode.getAttribute('support') == "none") { |
532 { | |
533 obj.input.disabled = true; | 512 obj.input.disabled = true; |
534 obj.input.checked = false; | 513 obj.input.checked = false; |
535 obj.root.className = "popup-checkbox disabled"; | 514 obj.root.className = "popup-checkbox disabled"; |
536 }else if (interfaceNode.getAttribute('support') == "mandatory") | 515 } else if (interfaceNode.getAttribute('support') == "mandatory") { |
537 { | |
538 obj.input.disabled = true; | 516 obj.input.disabled = true; |
539 obj.input.checked = true; | 517 obj.input.checked = true; |
540 obj.root.className = "popup-checkbox disabled"; | 518 obj.root.className = "popup-checkbox disabled"; |
541 } | 519 } |
542 } else { | 520 } else { |
543 if (interfaceNode.getAttribute('default') == 'on') | 521 if (interfaceNode.getAttribute('default') == 'on') { |
544 { | |
545 obj.input.checked = true; | 522 obj.input.checked = true; |
546 } | 523 } |
547 if (interfaceNode.getAttribute('support') == "none") | 524 if (interfaceNode.getAttribute('support') == "none") { |
548 { | |
549 obj.input.disabled = true; | 525 obj.input.disabled = true; |
550 obj.input.checked = false; | 526 obj.input.checked = false; |
551 obj.root.className = "popup-checkbox disabled"; | 527 obj.root.className = "popup-checkbox disabled"; |
552 } else if (interfaceNode.getAttribute('support') == "mandatory") | 528 } else if (interfaceNode.getAttribute('support') == "mandatory") { |
553 { | |
554 obj.input.disabled = true; | 529 obj.input.disabled = true; |
555 obj.input.checked = true; | 530 obj.input.checked = true; |
556 obj.root.className = "popup-checkbox disabled"; | 531 obj.root.className = "popup-checkbox disabled"; |
557 } | 532 } |
558 } | 533 } |
559 var included = specification.metrics.enabled.find(function(element,index,array){ | 534 var included = specification.metrics.enabled.find(function (element, index, array) { |
560 if (element == this.name) {return true;} else {return false;} | 535 if (element == this.name) { |
561 },obj); | 536 return true; |
537 } else { | |
538 return false; | |
539 } | |
540 }, obj); | |
562 obj.handleEvent(); | 541 obj.handleEvent(); |
563 if (included != undefined) { | 542 if (included != undefined) { |
564 obj.input.checked = true; | 543 obj.input.checked = true; |
565 } | 544 } |
566 this.options.push(obj); | 545 this.options.push(obj); |
567 this.dynamicContent.appendChild(obj.root); | 546 this.dynamicContent.appendChild(obj.root); |
568 } | 547 } |
569 } | 548 } |
570 this.continue = function() | 549 this.continue = function () { |
571 { | |
572 popupStateNodes.state[4].generate(); | 550 popupStateNodes.state[4].generate(); |
573 popupObject.postNode(popupStateNodes.state[4]); | 551 popupObject.postNode(popupStateNodes.state[4]); |
574 } | 552 } |
575 this.back = function() { | 553 this.back = function () { |
576 popupObject.postNode(popupStateNodes.state[2]); | 554 popupObject.postNode(popupStateNodes.state[2]); |
577 } | 555 } |
578 } | 556 } |
579 this.state[4] = new function() | 557 this.state[4] = new function () { |
580 { | |
581 this.title = "Test Visuals"; | 558 this.title = "Test Visuals"; |
582 this.content = document.createElement("div"); | 559 this.content = document.createElement("div"); |
583 this.content.id = "state-1"; | 560 this.content.id = "state-1"; |
584 var spnH = document.createElement('div'); | 561 var spnH = document.createElement('div'); |
585 var span = document.createElement("span"); | 562 var span = document.createElement("span"); |
590 this.checkText; | 567 this.checkText; |
591 this.testXML; | 568 this.testXML; |
592 this.interfaceXML; | 569 this.interfaceXML; |
593 this.dynamicContent = document.createElement("div"); | 570 this.dynamicContent = document.createElement("div"); |
594 this.content.appendChild(this.dynamicContent); | 571 this.content.appendChild(this.dynamicContent); |
595 this.generate = function() | 572 this.generate = function () { |
596 { | |
597 this.options = []; | 573 this.options = []; |
598 this.dynamicContent.innerHTML = null; | 574 this.dynamicContent.innerHTML = null; |
599 var interfaceName = popupStateNodes.state[1].select.value; | 575 var interfaceName = popupStateNodes.state[1].select.value; |
600 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0]; | 576 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0]; |
601 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; | 577 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; |
602 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0]; | 578 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0]; |
603 this.testXML = this.testXML.getAllElementsByTagName("show"); | 579 this.testXML = this.testXML.getAllElementsByTagName("show"); |
604 var interfaceXMLChildren = this.interfaceXML.getElementsByTagName('entry'); | 580 var interfaceXMLChildren = this.interfaceXML.getElementsByTagName('entry'); |
605 for (var i=0; i<interfaceXMLChildren.length; i++) | 581 for (var i = 0; i < interfaceXMLChildren.length; i++) { |
606 { | |
607 var interfaceNode = interfaceXMLChildren[i]; | 582 var interfaceNode = interfaceXMLChildren[i]; |
608 var checkName = interfaceNode.getAttribute('name'); | 583 var checkName = interfaceNode.getAttribute('name'); |
609 var testNode | 584 var testNode |
610 if (this.testXML.length > 0) | 585 if (this.testXML.length > 0) { |
611 { | |
612 testNode = this.testXML[0].getAllElementsByName(checkName); | 586 testNode = this.testXML[0].getAllElementsByName(checkName); |
613 if(testNode.length != 0) {testNode = testNode[0];} | 587 if (testNode.length != 0) { |
614 else {testNode = undefined;} | 588 testNode = testNode[0]; |
589 } else { | |
590 testNode = undefined; | |
591 } | |
615 } else { | 592 } else { |
616 testNode = undefined; | 593 testNode = undefined; |
617 } | 594 } |
618 var obj = { | 595 var obj = { |
619 root: document.createElement("div"), | 596 root: document.createElement("div"), |
620 text: document.createElement("label"), | 597 text: document.createElement("label"), |
621 input: document.createElement("input"), | 598 input: document.createElement("input"), |
622 parent: this, | 599 parent: this, |
623 name: checkName, | 600 name: checkName, |
624 handleEvent: function(event) { | 601 handleEvent: function (event) { |
625 if (this.input.checked) { | 602 if (this.input.checked) { |
626 // Add to specification.interfaces.option | 603 // Add to specification.interfaces.option |
627 var included = specification.interfaces.options.find(function(element,index,array){ | 604 var included = specification.interfaces.options.find(function (element, index, array) { |
628 if (element.name == this.name) {return true;} else {return false;} | 605 if (element.name == this.name) { |
629 },this); | 606 return true; |
607 } else { | |
608 return false; | |
609 } | |
610 }, this); | |
630 if (included == null) { | 611 if (included == null) { |
631 specification.interfaces.options.push({type:"show",name:this.name}); | 612 specification.interfaces.options.push({ |
613 type: "show", | |
614 name: this.name | |
615 }); | |
632 } | 616 } |
633 } else { | 617 } else { |
634 // Remove from specification.interfaces.option | 618 // Remove from specification.interfaces.option |
635 var position = specification.interfaces.options.findIndex(function(element,index,array){ | 619 var position = specification.interfaces.options.findIndex(function (element, index, array) { |
636 if (element.name == this.name) {return true;} else {return false;} | 620 if (element.name == this.name) { |
637 },this); | 621 return true; |
622 } else { | |
623 return false; | |
624 } | |
625 }, this); | |
638 if (position >= 0) { | 626 if (position >= 0) { |
639 specification.interfaces.options.splice(position,1); | 627 specification.interfaces.options.splice(position, 1); |
640 } | 628 } |
641 } | 629 } |
642 } | 630 } |
643 } | 631 } |
644 | 632 |
645 obj.input.addEventListener("click",obj); | 633 obj.input.addEventListener("click", obj); |
646 obj.root.className = "popup-checkbox"; | 634 obj.root.className = "popup-checkbox"; |
647 obj.input.type = "checkbox"; | 635 obj.input.type = "checkbox"; |
648 obj.input.setAttribute('id',checkName); | 636 obj.input.setAttribute('id', checkName); |
649 obj.text.setAttribute("for",checkName); | 637 obj.text.setAttribute("for", checkName); |
650 obj.text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; | 638 obj.text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent; |
651 obj.root.appendChild(obj.input); | 639 obj.root.appendChild(obj.input); |
652 obj.root.appendChild(obj.text); | 640 obj.root.appendChild(obj.text); |
653 if(testNode != undefined) | 641 if (testNode != undefined) { |
654 { | 642 if (testNode.getAttribute('default') == 'on') { |
655 if (testNode.getAttribute('default') == 'on') | |
656 { | |
657 obj.input.checked = true; | 643 obj.input.checked = true; |
658 } | 644 } |
659 if (testNode.getAttribute('support') == "none") | 645 if (testNode.getAttribute('support') == "none") { |
660 { | |
661 obj.input.disabled = true; | 646 obj.input.disabled = true; |
662 obj.input.checked = false; | 647 obj.input.checked = false; |
663 obj.root.className = "popup-checkbox disabled"; | 648 obj.root.className = "popup-checkbox disabled"; |
664 }else if (interfaceNode.getAttribute('support') == "mandatory") | 649 } else if (interfaceNode.getAttribute('support') == "mandatory") { |
665 { | |
666 obj.input.disabled = true; | 650 obj.input.disabled = true; |
667 obj.input.checked = true; | 651 obj.input.checked = true; |
668 obj.root.className = "popup-checkbox disabled"; | 652 obj.root.className = "popup-checkbox disabled"; |
669 } | 653 } |
670 } else { | 654 } else { |
671 if (interfaceNode.getAttribute('default') == 'on') | 655 if (interfaceNode.getAttribute('default') == 'on') { |
672 { | |
673 obj.input.checked = true; | 656 obj.input.checked = true; |
674 } | 657 } |
675 if (interfaceNode.getAttribute('support') == "none") | 658 if (interfaceNode.getAttribute('support') == "none") { |
676 { | |
677 obj.input.disabled = true; | 659 obj.input.disabled = true; |
678 obj.input.checked = false; | 660 obj.input.checked = false; |
679 obj.root.className = "popup-checkbox disabled"; | 661 obj.root.className = "popup-checkbox disabled"; |
680 } else if (interfaceNode.getAttribute('support') == "mandatory") | 662 } else if (interfaceNode.getAttribute('support') == "mandatory") { |
681 { | |
682 obj.input.disabled = true; | 663 obj.input.disabled = true; |
683 obj.input.checked = true; | 664 obj.input.checked = true; |
684 obj.root.className = "popup-checkbox disabled"; | 665 obj.root.className = "popup-checkbox disabled"; |
685 } | 666 } |
686 } | 667 } |
687 var included = specification.interfaces.options.find(function(element,index,array){ | 668 var included = specification.interfaces.options.find(function (element, index, array) { |
688 if (element.name == this.name) {return true;} else {return false;} | 669 if (element.name == this.name) { |
689 },obj); | 670 return true; |
671 } else { | |
672 return false; | |
673 } | |
674 }, obj); | |
690 if (included != undefined) { | 675 if (included != undefined) { |
691 obj.input.checked = true; | 676 obj.input.checked = true; |
692 } | 677 } |
693 obj.handleEvent(); | 678 obj.handleEvent(); |
694 this.options.push(obj); | 679 this.options.push(obj); |
695 this.dynamicContent.appendChild(obj.root); | 680 this.dynamicContent.appendChild(obj.root); |
696 } | 681 } |
697 } | 682 } |
698 this.continue = function() | 683 this.continue = function () { |
699 { | |
700 popupObject.hide(); | 684 popupObject.hide(); |
701 convert.convert(document.getElementById('content')); | 685 convert.convert(document.getElementById('content')); |
702 } | 686 } |
703 this.back = function() { | 687 this.back = function () { |
704 popupObject.postNode(popupStateNodes.state[3]); | 688 popupObject.postNode(popupStateNodes.state[3]); |
705 } | 689 } |
706 } | 690 } |
707 this.state[5] = new function() { | 691 this.state[5] = new function () { |
708 this.title = "Add/Edit Survey Element"; | 692 this.title = "Add/Edit Survey Element"; |
709 this.content = document.createElement("div"); | 693 this.content = document.createElement("div"); |
710 this.content.id = "state-1"; | 694 this.content.id = "state-1"; |
711 var spnH = document.createElement('div'); | 695 var spnH = document.createElement('div'); |
712 var span = document.createElement("span"); | 696 var span = document.createElement("span"); |
716 this.dynamic = document.createElement("div"); | 700 this.dynamic = document.createElement("div"); |
717 this.option = null; | 701 this.option = null; |
718 this.parent = null; | 702 this.parent = null; |
719 this.optionLists = []; | 703 this.optionLists = []; |
720 this.select = document.createElement("select"); | 704 this.select = document.createElement("select"); |
721 this.select.setAttribute("name","type"); | 705 this.select.setAttribute("name", "type"); |
722 this.select.addEventListener("change",this,false); | 706 this.select.addEventListener("change", this, false); |
723 this.content.appendChild(this.select); | 707 this.content.appendChild(this.select); |
724 this.content.appendChild(this.dynamic); | 708 this.content.appendChild(this.dynamic); |
725 this.generate = function(option, parent) | 709 this.generate = function (option, parent) { |
726 { | |
727 this.option = option; | 710 this.option = option; |
728 this.parent = parent; | 711 this.parent = parent; |
729 if (this.select.childElementCount == 0) { | 712 if (this.select.childElementCount == 0) { |
730 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); | 713 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration"); |
731 for (var i=0; i<optionList.length; i++) | 714 for (var i = 0; i < optionList.length; i++) { |
732 { | |
733 var selectOption = document.createElement("option"); | 715 var selectOption = document.createElement("option"); |
734 selectOption.value = optionList[i].getAttribute("value"); | 716 selectOption.value = optionList[i].getAttribute("value"); |
735 selectOption.textContent = selectOption.value; | 717 selectOption.textContent = selectOption.value; |
736 this.select.appendChild(selectOption); | 718 this.select.appendChild(selectOption); |
737 } | 719 } |
738 } | 720 } |
739 if (this.option.type != undefined){ | 721 if (this.option.type != undefined) { |
740 this.select.value = this.option.type | 722 this.select.value = this.option.type |
741 } else { | 723 } else { |
742 this.select.value = "statement"; | 724 this.select.value = "statement"; |
743 this.option.type = "statement"; | 725 this.option.type = "statement"; |
744 } | 726 } |
745 | 727 |
746 this.dynamic.innerHTML = null; | 728 this.dynamic.innerHTML = null; |
747 var statement = document.createElement("div"); | 729 var statement = document.createElement("div"); |
748 var statementText = document.createElement("span"); | 730 var statementText = document.createElement("span"); |
749 var statementEntry = document.createElement("input"); | 731 var statementEntry = document.createElement("input"); |
750 statement.appendChild(statementText); | 732 statement.appendChild(statementText); |
751 statement.appendChild(statementEntry); | 733 statement.appendChild(statementEntry); |
752 statement.className = "survey-entry-attribute"; | 734 statement.className = "survey-entry-attribute"; |
753 statementText.textContent = "Statement/Question"; | 735 statementText.textContent = "Statement/Question"; |
754 statementEntry.style.width = "500px"; | 736 statementEntry.style.width = "500px"; |
755 statementEntry.addEventListener("change",this,false); | 737 statementEntry.addEventListener("change", this, false); |
756 statementEntry.setAttribute("name","statement"); | 738 statementEntry.setAttribute("name", "statement"); |
757 statementEntry.value = this.option.statement; | 739 statementEntry.value = this.option.statement; |
758 this.dynamic.appendChild(statement); | 740 this.dynamic.appendChild(statement); |
759 | 741 |
760 var id = document.createElement("div"); | 742 var id = document.createElement("div"); |
761 var idText = document.createElement("span"); | 743 var idText = document.createElement("span"); |
762 var idEntry = document.createElement("input"); | 744 var idEntry = document.createElement("input"); |
763 id.appendChild(idText); | 745 id.appendChild(idText); |
764 id.appendChild(idEntry); | 746 id.appendChild(idEntry); |
765 id.className = "survey-entry-attribute"; | 747 id.className = "survey-entry-attribute"; |
766 idText.textContent = "ID: "; | 748 idText.textContent = "ID: "; |
767 idEntry.addEventListener("change",this,false); | 749 idEntry.addEventListener("change", this, false); |
768 idEntry.setAttribute("name","id"); | 750 idEntry.setAttribute("name", "id"); |
769 idEntry.value = this.option.id; | 751 idEntry.value = this.option.id; |
770 | 752 |
771 this.dynamic.appendChild(id); | 753 this.dynamic.appendChild(id); |
772 | 754 |
773 switch(this.option.type) | 755 switch (this.option.type) { |
774 { | |
775 case "statement": | 756 case "statement": |
776 break; | 757 break; |
777 case "question": | 758 case "question": |
778 var boxsizeSelect = document.createElement("select"); | 759 var boxsizeSelect = document.createElement("select"); |
779 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration"); | 760 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration"); |
780 for (var i=0; i<optionList.length; i++) | 761 for (var i = 0; i < optionList.length; i++) { |
781 { | |
782 var selectOption = document.createElement("option"); | 762 var selectOption = document.createElement("option"); |
783 selectOption.value = optionList[i].getAttribute("value"); | 763 selectOption.value = optionList[i].getAttribute("value"); |
784 selectOption.textContent = selectOption.value; | 764 selectOption.textContent = selectOption.value; |
785 boxsizeSelect.appendChild(selectOption); | 765 boxsizeSelect.appendChild(selectOption); |
786 } | 766 } |
787 if(this.option.boxsize != undefined) { | 767 if (this.option.boxsize != undefined) { |
788 boxsizeSelect.value = this.option.boxsize; | 768 boxsizeSelect.value = this.option.boxsize; |
789 } else { | 769 } else { |
790 boxsizeSelect.value = "normal"; | 770 boxsizeSelect.value = "normal"; |
791 this.option.boxsize = "normal"; | 771 this.option.boxsize = "normal"; |
792 } | 772 } |
793 boxsizeSelect.setAttribute("name","boxsize"); | 773 boxsizeSelect.setAttribute("name", "boxsize"); |
794 boxsizeSelect.addEventListener("change",this,false); | 774 boxsizeSelect.addEventListener("change", this, false); |
795 var boxsize = document.createElement("div"); | 775 var boxsize = document.createElement("div"); |
796 var boxsizeText = document.createElement("span"); | 776 var boxsizeText = document.createElement("span"); |
797 boxsizeText.textContent = "Entry Size: "; | 777 boxsizeText.textContent = "Entry Size: "; |
798 boxsize.appendChild(boxsizeText); | 778 boxsize.appendChild(boxsizeText); |
799 boxsize.appendChild(boxsizeSelect); | 779 boxsize.appendChild(boxsizeSelect); |
800 boxsize.className = "survey-entry-attribute"; | 780 boxsize.className = "survey-entry-attribute"; |
801 this.dynamic.appendChild(boxsize); | 781 this.dynamic.appendChild(boxsize); |
802 | 782 |
803 var mandatory = document.createElement("div"); | 783 var mandatory = document.createElement("div"); |
804 var mandatoryInput = document.createElement("input"); | 784 var mandatoryInput = document.createElement("input"); |
805 var mandatoryText = document.createElement("span"); | 785 var mandatoryText = document.createElement("span"); |
806 mandatoryText.textContent = "Mandatory: "; | 786 mandatoryText.textContent = "Mandatory: "; |
807 mandatory.appendChild(mandatoryText); | 787 mandatory.appendChild(mandatoryText); |
808 mandatory.appendChild(mandatoryInput); | 788 mandatory.appendChild(mandatoryInput); |
809 mandatory.className = "survey-entry-attribute"; | 789 mandatory.className = "survey-entry-attribute"; |
810 mandatoryInput.type = "checkbox"; | 790 mandatoryInput.type = "checkbox"; |
811 if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;} | 791 if (this.option.mandatory) { |
812 mandatoryInput.setAttribute("name","mandatory"); | 792 mandatoryInput.checked = true; |
813 mandatoryInput.addEventListener("change",this,false); | 793 } else { |
794 mandatoryInput.checked = false; | |
795 } | |
796 mandatoryInput.setAttribute("name", "mandatory"); | |
797 mandatoryInput.addEventListener("change", this, false); | |
814 this.dynamic.appendChild(mandatory); | 798 this.dynamic.appendChild(mandatory); |
815 break; | 799 break; |
816 case "number": | 800 case "number": |
817 this.dynamic.appendChild(id); | 801 this.dynamic.appendChild(id); |
818 | 802 |
819 var mandatory = document.createElement("div"); | 803 var mandatory = document.createElement("div"); |
820 var mandatoryInput = document.createElement("input"); | 804 var mandatoryInput = document.createElement("input"); |
821 var mandatoryText = document.createElement("span"); | 805 var mandatoryText = document.createElement("span"); |
822 mandatoryText.textContent = "Mandatory: "; | 806 mandatoryText.textContent = "Mandatory: "; |
823 mandatory.appendChild(mandatoryText); | 807 mandatory.appendChild(mandatoryText); |
824 mandatory.appendChild(mandatoryInput); | 808 mandatory.appendChild(mandatoryInput); |
825 mandatory.className = "survey-entry-attribute"; | 809 mandatory.className = "survey-entry-attribute"; |
826 mandatoryInput.type = "checkbox"; | 810 mandatoryInput.type = "checkbox"; |
827 if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;} | 811 if (this.option.mandatory) { |
828 mandatoryInput.setAttribute("name","mandatory"); | 812 mandatoryInput.checked = true; |
829 mandatoryInput.addEventListener("change",this,false); | 813 } else { |
814 mandatoryInput.checked = false; | |
815 } | |
816 mandatoryInput.setAttribute("name", "mandatory"); | |
817 mandatoryInput.addEventListener("change", this, false); | |
830 this.dynamic.appendChild(mandatory); | 818 this.dynamic.appendChild(mandatory); |
831 | 819 |
832 var minimum = document.createElement("div"); | 820 var minimum = document.createElement("div"); |
833 var minimumEntry = document.createElement("input"); | 821 var minimumEntry = document.createElement("input"); |
834 var minimumText = document.createElement("span"); | 822 var minimumText = document.createElement("span"); |
835 minimumText.textContent = "Minimum: "; | 823 minimumText.textContent = "Minimum: "; |
836 minimum.appendChild(minimumText); | 824 minimum.appendChild(minimumText); |
837 minimum.appendChild(minimumEntry); | 825 minimum.appendChild(minimumEntry); |
838 minimum.className = "survey-entry-attribute"; | 826 minimum.className = "survey-entry-attribute"; |
839 minimumEntry.type = "number"; | 827 minimumEntry.type = "number"; |
840 minimumEntry.setAttribute("name","min"); | 828 minimumEntry.setAttribute("name", "min"); |
841 minimumEntry.addEventListener("change",this,false); | 829 minimumEntry.addEventListener("change", this, false); |
842 minimumEntry.value = this.option.min; | 830 minimumEntry.value = this.option.min; |
843 this.dynamic.appendChild(minimum); | 831 this.dynamic.appendChild(minimum); |
844 | 832 |
845 var maximum = document.createElement("div"); | 833 var maximum = document.createElement("div"); |
846 var maximumEntry = document.createElement("input"); | 834 var maximumEntry = document.createElement("input"); |
847 var maximumText = document.createElement("span"); | 835 var maximumText = document.createElement("span"); |
848 maximumText.textContent = "Maximum: "; | 836 maximumText.textContent = "Maximum: "; |
849 maximum.appendChild(maximumText); | 837 maximum.appendChild(maximumText); |
850 maximum.appendChild(maximumEntry); | 838 maximum.appendChild(maximumEntry); |
851 maximum.className = "survey-entry-attribute"; | 839 maximum.className = "survey-entry-attribute"; |
852 maximumEntry.type = "number"; | 840 maximumEntry.type = "number"; |
853 maximumEntry.setAttribute("name","max"); | 841 maximumEntry.setAttribute("name", "max"); |
854 maximumEntry.addEventListener("change",this,false); | 842 maximumEntry.addEventListener("change", this, false); |
855 maximumEntry.value = this.option.max; | 843 maximumEntry.value = this.option.max; |
856 this.dynamic.appendChild(maximum); | 844 this.dynamic.appendChild(maximum); |
857 break; | 845 break; |
858 case "checkbox": | 846 case "checkbox": |
859 case "radio": | 847 case "radio": |
860 this.dynamic.appendChild(id); | 848 this.dynamic.appendChild(id); |
861 var optionHolder = document.createElement("div"); | 849 var optionHolder = document.createElement("div"); |
862 optionHolder.className = 'node'; | 850 optionHolder.className = 'node'; |
863 optionHolder.id = 'popup-option-holder'; | 851 optionHolder.id = 'popup-option-holder'; |
864 var optionObject = function(parent,option) { | 852 var optionObject = function (parent, option) { |
865 this.rootDOM = document.createElement("div"); | 853 this.rootDOM = document.createElement("div"); |
866 this.rootDOM.className = "popup-option-entry"; | 854 this.rootDOM.className = "popup-option-entry"; |
867 this.inputName = document.createElement("input"); | 855 this.inputName = document.createElement("input"); |
868 this.inputName.setAttribute("name","name"); | 856 this.inputName.setAttribute("name", "name"); |
869 this.inputLabel = document.createElement("input"); | 857 this.inputLabel = document.createElement("input"); |
870 this.inputLabel.setAttribute("name","text"); | 858 this.inputLabel.setAttribute("name", "text"); |
871 this.specification = option; | 859 this.specification = option; |
872 this.parent = parent; | 860 this.parent = parent; |
873 this.handleEvent = function() | 861 this.handleEvent = function () { |
874 { | |
875 var target = event.currentTarget.getAttribute("name"); | 862 var target = event.currentTarget.getAttribute("name"); |
876 eval("this.specification."+target+" = event.currentTarget.value"); | 863 eval("this.specification." + target + " = event.currentTarget.value"); |
877 }; | 864 }; |
878 | 865 |
879 var nameText = document.createElement("span"); | 866 var nameText = document.createElement("span"); |
880 nameText.textContent = "Name: "; | 867 nameText.textContent = "Name: "; |
881 var labelText = document.createElement("span"); | 868 var labelText = document.createElement("span"); |
882 labelText.textContent = "Label: "; | 869 labelText.textContent = "Label: "; |
883 this.rootDOM.appendChild(nameText); | 870 this.rootDOM.appendChild(nameText); |
884 this.rootDOM.appendChild(this.inputName); | 871 this.rootDOM.appendChild(this.inputName); |
885 this.rootDOM.appendChild(labelText); | 872 this.rootDOM.appendChild(labelText); |
886 this.rootDOM.appendChild(this.inputLabel); | 873 this.rootDOM.appendChild(this.inputLabel); |
887 this.inputName.addEventListener("change",this,false); | 874 this.inputName.addEventListener("change", this, false); |
888 this.inputLabel.addEventListener("change",this,false); | 875 this.inputLabel.addEventListener("change", this, false); |
889 this.inputName.value = this.specification.name; | 876 this.inputName.value = this.specification.name; |
890 this.inputLabel.value = this.specification.text; | 877 this.inputLabel.value = this.specification.text; |
891 this.inputLabel.style.width = "350px"; | 878 this.inputLabel.style.width = "350px"; |
892 | 879 |
893 this.deleteEntry = { | 880 this.deleteEntry = { |
894 root: document.createElement("button"), | 881 root: document.createElement("button"), |
895 parent: this, | 882 parent: this, |
896 handleEvent: function() { | 883 handleEvent: function () { |
897 document.getElementById("popup-option-holder").removeChild(this.parent.rootDOM); | 884 document.getElementById("popup-option-holder").removeChild(this.parent.rootDOM); |
898 var index = this.parent.parent.option.options.findIndex(function(element,index,array){ | 885 var index = this.parent.parent.option.options.findIndex(function (element, index, array) { |
899 if (element == this.parent.specification) | 886 if (element == this.parent.specification) |
900 return true; | 887 return true; |
901 else | 888 else |
902 return false; | 889 return false; |
903 },this); | 890 }, this); |
904 var optionList = this.parent.parent.option.options; | 891 var optionList = this.parent.parent.option.options; |
905 if (index == optionList.length-1) { | 892 if (index == optionList.length - 1) { |
906 optionList = optionList.slice(0,index); | 893 optionList = optionList.slice(0, index); |
907 } else { | 894 } else { |
908 optionList = optionList.slice(0,index).concat(optionList.slice(index+1)); | 895 optionList = optionList.slice(0, index).concat(optionList.slice(index + 1)); |
909 } | 896 } |
910 this.parent.parent.option.options = optionList; | 897 this.parent.parent.option.options = optionList; |
911 } | 898 } |
912 }; | 899 }; |
913 this.deleteEntry.root.textContent = "Delete Option"; | 900 this.deleteEntry.root.textContent = "Delete Option"; |
914 this.deleteEntry.root.addEventListener("click",this.deleteEntry,false); | 901 this.deleteEntry.root.addEventListener("click", this.deleteEntry, false); |
915 this.rootDOM.appendChild(this.deleteEntry.root); | 902 this.rootDOM.appendChild(this.deleteEntry.root); |
916 } | 903 } |
917 this.addEntry = { | 904 this.addEntry = { |
918 parent: this, | 905 parent: this, |
919 root: document.createElement("button"), | 906 root: document.createElement("button"), |
920 handleEvent: function() { | 907 handleEvent: function () { |
921 var node = {name: "name", text: "text"}; | 908 var node = { |
909 name: "name", | |
910 text: "text" | |
911 }; | |
922 var optionsList = this.parent.option.options; | 912 var optionsList = this.parent.option.options; |
923 optionsList.push(node); | 913 optionsList.push(node); |
924 var obj = new optionObject(this.parent,optionsList[optionsList.length-1]); | 914 var obj = new optionObject(this.parent, optionsList[optionsList.length - 1]); |
925 this.parent.optionLists.push(obj); | 915 this.parent.optionLists.push(obj); |
926 document.getElementById("popup-option-holder").appendChild(obj.rootDOM); | 916 document.getElementById("popup-option-holder").appendChild(obj.rootDOM); |
927 } | 917 } |
928 } | 918 } |
929 this.addEntry.root.textContent = "Add Option"; | 919 this.addEntry.root.textContent = "Add Option"; |
930 this.addEntry.root.addEventListener("click",this.addEntry); | 920 this.addEntry.root.addEventListener("click", this.addEntry); |
931 this.dynamic.appendChild(this.addEntry.root); | 921 this.dynamic.appendChild(this.addEntry.root); |
932 for (var i=0; i<this.option.options.length; i++) | 922 for (var i = 0; i < this.option.options.length; i++) { |
933 { | 923 var obj = new optionObject(this, this.option.options[i]); |
934 var obj = new optionObject(this,this.option.options[i]); | |
935 this.optionLists.push(obj); | 924 this.optionLists.push(obj); |
936 optionHolder.appendChild(obj.rootDOM); | 925 optionHolder.appendChild(obj.rootDOM); |
937 } | 926 } |
938 this.dynamic.appendChild(optionHolder); | 927 this.dynamic.appendChild(optionHolder); |
939 } | 928 } |
940 } | 929 } |
941 this.handleEvent = function() | 930 this.handleEvent = function () { |
942 { | |
943 var name = event.currentTarget.getAttribute("name"); | 931 var name = event.currentTarget.getAttribute("name"); |
944 var nodeName = event.currentTarget.nodeName; | 932 var nodeName = event.currentTarget.nodeName; |
945 if (name == "type" && nodeName == "SELECT") { | 933 if (name == "type" && nodeName == "SELECT") { |
946 // If type has changed, we may need to rebuild the entire state node | 934 // If type has changed, we may need to rebuild the entire state node |
947 if (event.currentTarget.value != this.option.name) | 935 if (event.currentTarget.value != this.option.name) { |
948 { | |
949 this.option.type = event.currentTarget.value; | 936 this.option.type = event.currentTarget.value; |
950 this.generate(this.option,this.parent); | 937 this.generate(this.option, this.parent); |
951 } | 938 } |
952 return; | 939 return; |
953 } | 940 } |
954 switch(event.currentTarget.getAttribute("type")) { | 941 switch (event.currentTarget.getAttribute("type")) { |
955 case "checkbox": | 942 case "checkbox": |
956 eval("this.option."+name+" = event.currentTarget.checked"); | 943 eval("this.option." + name + " = event.currentTarget.checked"); |
957 break; | 944 break; |
958 default: | 945 default: |
959 eval("this.option."+name+" = event.currentTarget.value"); | 946 eval("this.option." + name + " = event.currentTarget.value"); |
960 break; | 947 break; |
961 } | 948 } |
962 } | 949 } |
963 this.continue = function() | 950 this.continue = function () { |
964 { | 951 if (this.parent.type == "surveyNode") { |
965 if (this.parent.type == "surveyNode") | 952 var newNode = new this.parent.surveyEntryNode(this.parent, this.option); |
966 { | |
967 var newNode = new this.parent.surveyEntryNode(this.parent,this.option); | |
968 this.parent.children.push(newNode); | 953 this.parent.children.push(newNode); |
969 this.parent.childrenDOM.appendChild(newNode.rootDOM); | 954 this.parent.childrenDOM.appendChild(newNode.rootDOM); |
970 } else if (this.parent.type == "surveyEntryNode") { | 955 } else if (this.parent.type == "surveyEntryNode") { |
971 this.parent.build(); | 956 this.parent.build(); |
972 } | 957 } |
973 popupObject.hide(); | 958 popupObject.hide(); |
974 } | 959 } |
975 } | 960 } |
976 this.state[6] = new function() { | 961 this.state[6] = new function () { |
977 this.title = "Edit Scale Markers"; | 962 this.title = "Edit Scale Markers"; |
978 this.content = document.createElement("div"); | 963 this.content = document.createElement("div"); |
979 this.content.id = "state-6"; | 964 this.content.id = "state-6"; |
980 var spnH = document.createElement('div'); | 965 var spnH = document.createElement('div'); |
981 var span = document.createElement("span"); | 966 var span = document.createElement("span"); |
982 span.textContent = "You can edit your scale markers here for the selected interface."; | 967 span.textContent = "You can edit your scale markers here for the selected interface."; |
983 spnH.appendChild(span); | 968 spnH.appendChild(span); |
984 this.scaleRoot; | 969 this.scaleRoot; |
985 this.parent; | 970 this.parent; |
986 this.markerNodes =[]; | 971 this.markerNodes = []; |
987 this.preset = { | 972 this.preset = { |
988 input: document.createElement("select"), | 973 input: document.createElement("select"), |
989 parent: this, | 974 parent: this, |
990 handleEvent: function(event) { | 975 handleEvent: function (event) { |
991 this.parent.scaleRoot.scales = []; | 976 this.parent.scaleRoot.scales = []; |
992 var protoScale = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].getAllElementsByName(event.currentTarget.value)[0]; | 977 var protoScale = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].getAllElementsByName(event.currentTarget.value)[0]; |
993 var protoMarkers = protoScale.getElementsByTagName("scale"); | 978 var protoMarkers = protoScale.getElementsByTagName("scale"); |
994 for (var i=0; i<protoMarkers.length; i++) | 979 for (var i = 0; i < protoMarkers.length; i++) { |
995 { | |
996 var marker = { | 980 var marker = { |
997 position: protoMarkers[i].getAttribute("position"), | 981 position: protoMarkers[i].getAttribute("position"), |
998 text: protoMarkers[i].textContent | 982 text: protoMarkers[i].textContent |
999 } | 983 } |
1000 this.parent.scaleRoot.scales.push(marker); | 984 this.parent.scaleRoot.scales.push(marker); |
1001 } | 985 } |
1002 this.parent.buildMarkerList(); | 986 this.parent.buildMarkerList(); |
1003 } | 987 } |
1004 } | 988 } |
1005 this.preset.input.addEventListener("change",this.preset); | 989 this.preset.input.addEventListener("change", this.preset); |
1006 this.content.appendChild(this.preset.input); | 990 this.content.appendChild(this.preset.input); |
1007 var optionHolder = document.createElement("div"); | 991 var optionHolder = document.createElement("div"); |
1008 optionHolder.className = 'node'; | 992 optionHolder.className = 'node'; |
1009 optionHolder.id = 'popup-option-holder'; | 993 optionHolder.id = 'popup-option-holder'; |
1010 this.content.appendChild(optionHolder); | 994 this.content.appendChild(optionHolder); |
1011 this.generate = function(scaleRoot,parent) | 995 this.generate = function (scaleRoot, parent) { |
1012 { | |
1013 this.scaleRoot = scaleRoot; | 996 this.scaleRoot = scaleRoot; |
1014 this.parent = parent; | 997 this.parent = parent; |
1015 | 998 |
1016 // Generate Pre-Set dropdown | 999 // Generate Pre-Set dropdown |
1017 var protoScales = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].getElementsByTagName("scale"); | 1000 var protoScales = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].getElementsByTagName("scale"); |
1018 this.preset.input.innerHTML = ""; | 1001 this.preset.input.innerHTML = ""; |
1019 | 1002 |
1020 for (var i=0; i<protoScales.length; i++) | 1003 for (var i = 0; i < protoScales.length; i++) { |
1021 { | |
1022 var selectOption = document.createElement("option"); | 1004 var selectOption = document.createElement("option"); |
1023 var scaleName = protoScales[i].getAttribute("name"); | 1005 var scaleName = protoScales[i].getAttribute("name"); |
1024 selectOption.setAttribute("name",scaleName); | 1006 selectOption.setAttribute("name", scaleName); |
1025 selectOption.textContent = scaleName; | 1007 selectOption.textContent = scaleName; |
1026 this.preset.input.appendChild(selectOption); | 1008 this.preset.input.appendChild(selectOption); |
1027 } | 1009 } |
1028 | 1010 |
1029 this.addMarker = { | 1011 this.addMarker = { |
1030 root: document.createElement("button"), | 1012 root: document.createElement("button"), |
1031 parent: this, | 1013 parent: this, |
1032 handleEvent: function() { | 1014 handleEvent: function () { |
1033 var marker = { | 1015 var marker = { |
1034 position: 0, | 1016 position: 0, |
1035 text: "text" | 1017 text: "text" |
1036 }; | 1018 }; |
1037 this.parent.scaleRoot.scales.push(marker); | 1019 this.parent.scaleRoot.scales.push(marker); |
1038 var markerNode = new this.parent.buildMarkerNode(this.parent,marker); | 1020 var markerNode = new this.parent.buildMarkerNode(this.parent, marker); |
1039 document.getElementById("popup-option-holder").appendChild(markerNode.root); | 1021 document.getElementById("popup-option-holder").appendChild(markerNode.root); |
1040 this.parent.markerNodes.push(markerNode); | 1022 this.parent.markerNodes.push(markerNode); |
1041 } | 1023 } |
1042 }; | 1024 }; |
1043 this.addMarker.root.textContent = "Add Marker"; | 1025 this.addMarker.root.textContent = "Add Marker"; |
1044 this.addMarker.root.addEventListener("click",this.addMarker); | 1026 this.addMarker.root.addEventListener("click", this.addMarker); |
1045 this.content.appendChild(this.addMarker.root); | 1027 this.content.appendChild(this.addMarker.root); |
1046 | 1028 |
1047 // Create Marker List | 1029 // Create Marker List |
1048 this.buildMarkerList(); | 1030 this.buildMarkerList(); |
1049 } | 1031 } |
1050 this.buildMarkerList = function() { | 1032 this.buildMarkerList = function () { |
1051 var markerInject = document.getElementById("popup-option-holder"); | 1033 var markerInject = document.getElementById("popup-option-holder"); |
1052 markerInject.innerHTML = ""; | 1034 markerInject.innerHTML = ""; |
1053 this.markerNodes = []; | 1035 this.markerNodes = []; |
1054 for (var i=0; i<this.scaleRoot.scales.length; i++) | 1036 for (var i = 0; i < this.scaleRoot.scales.length; i++) { |
1055 { | 1037 var markerNode = new this.buildMarkerNode(this, this.scaleRoot.scales[i]); |
1056 var markerNode = new this.buildMarkerNode(this,this.scaleRoot.scales[i]); | |
1057 markerInject.appendChild(markerNode.root); | 1038 markerInject.appendChild(markerNode.root); |
1058 this.markerNodes.push(markerNode); | 1039 this.markerNodes.push(markerNode); |
1059 | 1040 |
1060 } | 1041 } |
1061 } | 1042 } |
1062 | 1043 |
1063 this.buildMarkerNode = function(parent,specification) { | 1044 this.buildMarkerNode = function (parent, specification) { |
1064 this.root = document.createElement("div"); | 1045 this.root = document.createElement("div"); |
1065 this.root.className = "popup-option-entry"; | 1046 this.root.className = "popup-option-entry"; |
1066 this.positionInput = document.createElement("input"); | 1047 this.positionInput = document.createElement("input"); |
1067 this.positionInput.min = 0; | 1048 this.positionInput.min = 0; |
1068 this.positionInput.max = 100; | 1049 this.positionInput.max = 100; |
1069 this.positionInput.value = specification.position; | 1050 this.positionInput.value = specification.position; |
1070 this.positionInput.setAttribute("name","position"); | 1051 this.positionInput.setAttribute("name", "position"); |
1071 this.textInput = document.createElement("input"); | 1052 this.textInput = document.createElement("input"); |
1072 this.textInput.setAttribute("name","text"); | 1053 this.textInput.setAttribute("name", "text"); |
1073 this.textInput.style.width = "300px"; | 1054 this.textInput.style.width = "300px"; |
1074 this.textInput.value = specification.text; | 1055 this.textInput.value = specification.text; |
1075 this.specification = specification; | 1056 this.specification = specification; |
1076 this.parent = parent; | 1057 this.parent = parent; |
1077 this.handleEvent = function(event) { | 1058 this.handleEvent = function (event) { |
1078 switch(event.currentTarget.getAttribute("name")) | 1059 switch (event.currentTarget.getAttribute("name")) { |
1079 { | |
1080 case "position": | 1060 case "position": |
1081 this.specification.position = Number(event.currentTarget.value); | 1061 this.specification.position = Number(event.currentTarget.value); |
1082 break; | 1062 break; |
1083 case "text": | 1063 case "text": |
1084 this.specification.text = event.currentTarget.value; | 1064 this.specification.text = event.currentTarget.value; |
1085 break; | 1065 break; |
1086 } | 1066 } |
1087 } | 1067 } |
1088 this.positionInput.addEventListener("change",this,false); | 1068 this.positionInput.addEventListener("change", this, false); |
1089 this.textInput.addEventListener("change",this,false); | 1069 this.textInput.addEventListener("change", this, false); |
1090 | 1070 |
1091 var posText = document.createElement("span"); | 1071 var posText = document.createElement("span"); |
1092 posText.textContent = "Position: "; | 1072 posText.textContent = "Position: "; |
1093 var textText = document.createElement("span"); | 1073 var textText = document.createElement("span"); |
1094 textText.textContent = "Text: "; | 1074 textText.textContent = "Text: "; |
1098 this.root.appendChild(this.textInput); | 1078 this.root.appendChild(this.textInput); |
1099 | 1079 |
1100 this.deleteMarker = { | 1080 this.deleteMarker = { |
1101 root: document.createElement("button"), | 1081 root: document.createElement("button"), |
1102 parent: this, | 1082 parent: this, |
1103 handleEvent: function() { | 1083 handleEvent: function () { |
1104 var index = this.parent.parent.scaleRoot.scales.findIndex(function(element,index,array){ | 1084 var index = this.parent.parent.scaleRoot.scales.findIndex(function (element, index, array) { |
1105 if (element == this) {return true;} else {return false;} | 1085 if (element == this) { |
1106 },this.parent.specification) | 1086 return true; |
1087 } else { | |
1088 return false; | |
1089 } | |
1090 }, this.parent.specification) | |
1107 if (index >= 0) { | 1091 if (index >= 0) { |
1108 this.parent.parent.scaleRoot.scales.splice(index,1); | 1092 this.parent.parent.scaleRoot.scales.splice(index, 1); |
1109 } | 1093 } |
1110 document.getElementById("popup-option-holder").removeChild(this.parent.root); | 1094 document.getElementById("popup-option-holder").removeChild(this.parent.root); |
1111 } | 1095 } |
1112 } | 1096 } |
1113 this.deleteMarker.root.addEventListener("click",this.deleteMarker); | 1097 this.deleteMarker.root.addEventListener("click", this.deleteMarker); |
1114 this.deleteMarker.root.textContent = "Delete Marker" | 1098 this.deleteMarker.root.textContent = "Delete Marker" |
1115 this.root.appendChild(this.deleteMarker.root); | 1099 this.root.appendChild(this.deleteMarker.root); |
1116 } | 1100 } |
1117 } | 1101 } |
1118 } | 1102 } |
1119 } | 1103 } |
1120 | 1104 |
1121 function SpecificationToHTML() | 1105 function SpecificationToHTML() { |
1122 { | |
1123 // This takes the specification node and converts it to an on-page HTML object | 1106 // This takes the specification node and converts it to an on-page HTML object |
1124 // Each Specification Node is given its own JS object which listens to the XSD for instant verification | 1107 // Each Specification Node is given its own JS object which listens to the XSD for instant verification |
1125 // Once generated, it directly binds into the specification object to update with changes | 1108 // Once generated, it directly binds into the specification object to update with changes |
1126 // Fixed DOM entries | 1109 // Fixed DOM entries |
1127 this.injectDOM; | 1110 this.injectDOM; |
1128 this.setupDOM; | 1111 this.setupDOM; |
1129 this.pages = []; | 1112 this.pages = []; |
1130 | 1113 |
1131 // Self-contained generators | 1114 // Self-contained generators |
1132 this.createGeneralNodeDOM = function(name,id,parent) | 1115 this.createGeneralNodeDOM = function (name, id, parent) { |
1133 { | |
1134 this.type = name; | 1116 this.type = name; |
1135 var root = document.createElement('div'); | 1117 var root = document.createElement('div'); |
1136 root.id = id; | 1118 root.id = id; |
1137 root.className = "node"; | 1119 root.className = "node"; |
1138 | 1120 |
1167 buttonDOM: buttonsDiv, | 1149 buttonDOM: buttonsDiv, |
1168 parent: parent | 1150 parent: parent |
1169 } | 1151 } |
1170 return obj; | 1152 return obj; |
1171 } | 1153 } |
1172 | 1154 |
1173 this.convertAttributeToDOM = function(node,schema) | 1155 this.convertAttributeToDOM = function (node, schema) { |
1174 { | |
1175 // This takes an attribute schema node and returns an object with the input node and any bindings | 1156 // This takes an attribute schema node and returns an object with the input node and any bindings |
1176 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined) | 1157 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined) { |
1177 { | 1158 schema = specification.schema.getAllElementsByName(schema.getAttribute('ref'))[0]; |
1178 schema = specification.schema.getAllElementsByName(schema.getAttribute('ref'))[0]; | 1159 } |
1179 } | 1160 var obj = new function () { |
1180 var obj = new function() | |
1181 { | |
1182 this.input; | 1161 this.input; |
1183 this.name; | 1162 this.name; |
1184 this.owner; | 1163 this.owner; |
1185 this.holder; | 1164 this.holder; |
1186 | 1165 |
1187 this.name = schema.getAttribute('name'); | 1166 this.name = schema.getAttribute('name'); |
1188 this.default = schema.getAttribute('default'); | 1167 this.default = schema.getAttribute('default'); |
1189 this.dataType = schema.getAttribute('type'); | 1168 this.dataType = schema.getAttribute('type'); |
1190 if (this.dataType == undefined) { | 1169 if (this.dataType == undefined) { |
1191 if (schema.childElementCount > 0) { | 1170 if (schema.childElementCount > 0) { |
1192 if (schema.firstElementChild.nodeName == "xs:simpleType") { | 1171 if (schema.firstElementChild.nodeName == "xs:simpleType") { |
1193 this.dataType = schema.getAllElementsByTagName("xs:restriction")[0].getAttribute("base"); | 1172 this.dataType = schema.getAllElementsByTagName("xs:restriction")[0].getAttribute("base"); |
1194 } | 1173 } |
1195 } | 1174 } |
1196 } | 1175 } |
1197 if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);} | 1176 if (typeof this.dataType == "string") { |
1198 else {this.dataType = "string";} | 1177 this.dataType = this.dataType.substr(3); |
1178 } else { | |
1179 this.dataType = "string"; | |
1180 } | |
1199 var minVar = undefined; | 1181 var minVar = undefined; |
1200 var maxVar = undefined; | 1182 var maxVar = undefined; |
1201 switch(this.dataType) | 1183 switch (this.dataType) { |
1202 { | |
1203 case "negativeInteger": | 1184 case "negativeInteger": |
1204 maxVar = -1; | 1185 maxVar = -1; |
1205 break; | 1186 break; |
1206 case "positiveInteger": | 1187 case "positiveInteger": |
1207 minVar = 1; | 1188 minVar = 1; |
1221 maxVar = 65536; | 1202 maxVar = 65536; |
1222 break; | 1203 break; |
1223 default: | 1204 default: |
1224 break; | 1205 break; |
1225 } | 1206 } |
1226 | 1207 |
1227 this.enumeration = schema.getAllElementsByTagName("xs:enumeration"); | 1208 this.enumeration = schema.getAllElementsByTagName("xs:enumeration"); |
1228 if (this.enumeration.length == 0) { | 1209 if (this.enumeration.length == 0) { |
1229 this.input = document.createElement('input'); | 1210 this.input = document.createElement('input'); |
1230 switch(this.dataType) | 1211 switch (this.dataType) { |
1231 { | |
1232 case "boolean": | 1212 case "boolean": |
1233 this.input.type = "checkbox"; | 1213 this.input.type = "checkbox"; |
1234 break; | 1214 break; |
1235 case "negativeInteger": | 1215 case "negativeInteger": |
1236 case "positiveInteger": | 1216 case "positiveInteger": |
1248 default: | 1228 default: |
1249 break; | 1229 break; |
1250 } | 1230 } |
1251 } else { | 1231 } else { |
1252 this.input = document.createElement("select"); | 1232 this.input = document.createElement("select"); |
1253 for (var i=0; i<this.enumeration.length; i++) | 1233 for (var i = 0; i < this.enumeration.length; i++) { |
1254 { | |
1255 var option = document.createElement("option"); | 1234 var option = document.createElement("option"); |
1256 var value = this.enumeration[i].getAttribute("value"); | 1235 var value = this.enumeration[i].getAttribute("value"); |
1257 option.setAttribute("value",value); | 1236 option.setAttribute("value", value); |
1258 option.textContent = value; | 1237 option.textContent = value; |
1259 this.input.appendChild(option); | 1238 this.input.appendChild(option); |
1260 } | 1239 } |
1261 } | 1240 } |
1262 var value; | 1241 var value; |
1263 eval("value = node."+this.name) | 1242 eval("value = node." + this.name) |
1264 if (this.default != undefined && value == undefined) | 1243 if (this.default != undefined && value == undefined) { |
1265 { | |
1266 value = this.default; | 1244 value = this.default; |
1267 } | 1245 } |
1268 if (this.input.type == "checkbox") { | 1246 if (this.input.type == "checkbox") { |
1269 if (value == "true" || value == "True") {this.input.checked = false;} | 1247 if (value == "true" || value == "True") { |
1270 else {this.input.checked = false;} | 1248 this.input.checked = false; |
1249 } else { | |
1250 this.input.checked = false; | |
1251 } | |
1271 } else { | 1252 } else { |
1272 this.input.value = value; | 1253 this.input.value = value; |
1273 } | 1254 } |
1274 this.handleEvent = function(event) | 1255 this.handleEvent = function (event) { |
1275 { | |
1276 var value; | 1256 var value; |
1277 if (this.input.nodeName == "INPUT") | 1257 if (this.input.nodeName == "INPUT") { |
1278 { | 1258 switch (this.input.type) { |
1279 switch(this.input.type) | |
1280 { | |
1281 case "checkbox": | 1259 case "checkbox": |
1282 value = event.currentTarget.checked; | 1260 value = event.currentTarget.checked; |
1283 break; | 1261 break; |
1284 case "number": | 1262 case "number": |
1285 if (event.currentTarget.value != "") { | 1263 if (event.currentTarget.value != "") { |
1292 if (event.currentTarget.value != "") { | 1270 if (event.currentTarget.value != "") { |
1293 value = event.currentTarget.value; | 1271 value = event.currentTarget.value; |
1294 } else { | 1272 } else { |
1295 value = undefined; | 1273 value = undefined; |
1296 } | 1274 } |
1297 break; | 1275 break; |
1298 } | 1276 } |
1299 } else if (this.input.nodeName == "SELECT") { | 1277 } else if (this.input.nodeName == "SELECT") { |
1300 value = event.currentTarget.value; | 1278 value = event.currentTarget.value; |
1301 } | 1279 } |
1302 eval("this.owner."+this.name+" = value"); | 1280 eval("this.owner." + this.name + " = value"); |
1303 } | 1281 } |
1304 this.holder = document.createElement('div'); | 1282 this.holder = document.createElement('div'); |
1305 this.holder.className = "attribute"; | 1283 this.holder.className = "attribute"; |
1306 this.holder.setAttribute('name',this.name); | 1284 this.holder.setAttribute('name', this.name); |
1307 var text = document.createElement('span'); | 1285 var text = document.createElement('span'); |
1308 eval("text.textContent = attributeText."+this.name+"+': '"); | 1286 eval("text.textContent = attributeText." + this.name + "+': '"); |
1309 this.holder.appendChild(text); | 1287 this.holder.appendChild(text); |
1310 this.holder.appendChild(this.input); | 1288 this.holder.appendChild(this.input); |
1311 this.owner = node; | 1289 this.owner = node; |
1312 this.input.addEventListener("change",this,false); | 1290 this.input.addEventListener("change", this, false); |
1313 } | 1291 } |
1314 if (obj.attribute != null) | 1292 if (obj.attribute != null) { |
1315 { | |
1316 obj.input.value = obj.attribute; | 1293 obj.input.value = obj.attribute; |
1317 } | 1294 } |
1318 return obj; | 1295 return obj; |
1319 } | 1296 } |
1320 | 1297 |
1321 this.convert = function(root) | 1298 this.convert = function (root) { |
1322 { | |
1323 //Performs the actual conversion using the given root DOM as the root | 1299 //Performs the actual conversion using the given root DOM as the root |
1324 this.injectDOM = root; | 1300 this.injectDOM = root; |
1325 | 1301 |
1326 // Build the export button | 1302 // Build the export button |
1327 var exportButton = document.createElement("button"); | 1303 var exportButton = document.createElement("button"); |
1328 exportButton.textContent = "Export to XML"; | 1304 exportButton.textContent = "Export to XML"; |
1329 exportButton.onclick = function() | 1305 exportButton.onclick = function () { |
1330 { | |
1331 var doc = specification.encode(); | 1306 var doc = specification.encode(); |
1332 var obj = {}; | 1307 var obj = {}; |
1333 obj.title = "Export"; | 1308 obj.title = "Export"; |
1334 obj.content = document.createElement("div"); | 1309 obj.content = document.createElement("div"); |
1335 obj.content.id = "finish"; | 1310 obj.content.id = "finish"; |
1340 span.textContent = "NOTE FOR SAFARI! You cannot right click on the below link and save it as a file, Safari does not like that at all. Instead click on it to open the XML, the Press Cmd+S to open the save dialogue. Make sure you have 'save as Page Source' selected on the bottom of the window. Currently Safari has no plans to support the HTML 'download' attribute which causes this problem"; | 1315 span.textContent = "NOTE FOR SAFARI! You cannot right click on the below link and save it as a file, Safari does not like that at all. Instead click on it to open the XML, the Press Cmd+S to open the save dialogue. Make sure you have 'save as Page Source' selected on the bottom of the window. Currently Safari has no plans to support the HTML 'download' attribute which causes this problem"; |
1341 obj.content.appendChild(span); | 1316 obj.content.appendChild(span); |
1342 var link = document.createElement("div"); | 1317 var link = document.createElement("div"); |
1343 link.appendChild(doc.firstChild); | 1318 link.appendChild(doc.firstChild); |
1344 var file = [link.innerHTML]; | 1319 var file = [link.innerHTML]; |
1345 var bb = new Blob(file,{type : 'application/xml'}); | 1320 var bb = new Blob(file, { |
1321 type: 'application/xml' | |
1322 }); | |
1346 var dnlk = window.URL.createObjectURL(bb); | 1323 var dnlk = window.URL.createObjectURL(bb); |
1347 var a = document.createElement("a"); | 1324 var a = document.createElement("a"); |
1348 a.hidden = ''; | 1325 a.hidden = ''; |
1349 a.href = dnlk; | 1326 a.href = dnlk; |
1350 a.download = "project-specification.xml"; | 1327 a.download = "project-specification.xml"; |
1352 obj.content.appendChild(a); | 1329 obj.content.appendChild(a); |
1353 popupObject.show(); | 1330 popupObject.show(); |
1354 popupObject.postNode(obj); | 1331 popupObject.postNode(obj); |
1355 } | 1332 } |
1356 this.injectDOM.appendChild(exportButton); | 1333 this.injectDOM.appendChild(exportButton); |
1357 | 1334 |
1358 // First perform the setupNode; | 1335 // First perform the setupNode; |
1359 var setupSchema = specification.schema.getAllElementsByName('setup')[0]; | 1336 var setupSchema = specification.schema.getAllElementsByName('setup')[0]; |
1360 this.setupDOM = new this.createGeneralNodeDOM('Global Configuration','setup',null); | 1337 this.setupDOM = new this.createGeneralNodeDOM('Global Configuration', 'setup', null); |
1361 this.injectDOM.appendChild(this.setupDOM.rootDOM); | 1338 this.injectDOM.appendChild(this.setupDOM.rootDOM); |
1362 var setupAttributes = setupSchema.getAllElementsByTagName('xs:attribute'); | 1339 var setupAttributes = setupSchema.getAllElementsByTagName('xs:attribute'); |
1363 for (var i=0; i<setupAttributes.length; i++) | 1340 for (var i = 0; i < setupAttributes.length; i++) { |
1364 { | |
1365 var attributeName = setupAttributes[i].getAttribute('name'); | 1341 var attributeName = setupAttributes[i].getAttribute('name'); |
1366 var attrObject = this.convertAttributeToDOM(specification,setupAttributes[i]); | 1342 var attrObject = this.convertAttributeToDOM(specification, setupAttributes[i]); |
1367 this.setupDOM.attributeDOM.appendChild(attrObject.holder); | 1343 this.setupDOM.attributeDOM.appendChild(attrObject.holder); |
1368 this.setupDOM.attributes.push(attrObject); | 1344 this.setupDOM.attributes.push(attrObject); |
1369 } | 1345 } |
1370 | 1346 |
1371 // Build the exit Text node | 1347 // Build the exit Text node |
1372 var exitText = new this.createGeneralNodeDOM("Exit Text","exit-test",this.setupDOM); | 1348 var exitText = new this.createGeneralNodeDOM("Exit Text", "exit-test", this.setupDOM); |
1373 exitText.rootDOM.removeChild(exitText.attributeDOM); | 1349 exitText.rootDOM.removeChild(exitText.attributeDOM); |
1374 this.setupDOM.children.push(exitText); | 1350 this.setupDOM.children.push(exitText); |
1375 this.setupDOM.childrenDOM.appendChild(exitText.rootDOM); | 1351 this.setupDOM.childrenDOM.appendChild(exitText.rootDOM); |
1376 var obj = { | 1352 var obj = { |
1377 rootDOM: document.createElement("div"), | 1353 rootDOM: document.createElement("div"), |
1378 labelDOM: document.createElement("label"), | 1354 labelDOM: document.createElement("label"), |
1379 inputDOM: document.createElement("textarea"), | 1355 inputDOM: document.createElement("textarea"), |
1380 parent: exitText, | 1356 parent: exitText, |
1381 specification: specification, | 1357 specification: specification, |
1382 handleEvent: function(event) { | 1358 handleEvent: function (event) { |
1383 this.specification.exitText = this.inputDOM.value; | 1359 this.specification.exitText = this.inputDOM.value; |
1384 } | 1360 } |
1385 } | 1361 } |
1386 var exitWarning = document.createElement("div"); | 1362 var exitWarning = document.createElement("div"); |
1387 obj.rootDOM.appendChild(exitWarning); | 1363 obj.rootDOM.appendChild(exitWarning); |
1388 exitWarning.textContent = "Only visible when the above 'On complete redirect URL' field is empty."; | 1364 exitWarning.textContent = "Only visible when the above 'On complete redirect URL' field is empty."; |
1389 obj.rootDOM.appendChild(obj.labelDOM); | 1365 obj.rootDOM.appendChild(obj.labelDOM); |
1390 obj.rootDOM.appendChild(obj.inputDOM); | 1366 obj.rootDOM.appendChild(obj.inputDOM); |
1391 obj.labelDOM.textContent = "Text: "; | 1367 obj.labelDOM.textContent = "Text: "; |
1392 obj.inputDOM.value = obj.specification.exitText; | 1368 obj.inputDOM.value = obj.specification.exitText; |
1393 obj.inputDOM.addEventListener("change",obj); | 1369 obj.inputDOM.addEventListener("change", obj); |
1394 exitText.children.push(obj); | 1370 exitText.children.push(obj); |
1395 exitText.childrenDOM.appendChild(obj.rootDOM); | 1371 exitText.childrenDOM.appendChild(obj.rootDOM); |
1396 | 1372 |
1397 // Now we must build the interface Node | 1373 // Now we must build the interface Node |
1398 this.interfaceDOM = new this.interfaceNode(this,specification.interfaces); | 1374 this.interfaceDOM = new this.interfaceNode(this, specification.interfaces); |
1399 this.interfaceDOM.build("Interface","setup-interface",this.setupDOM.rootDOM); | 1375 this.interfaceDOM.build("Interface", "setup-interface", this.setupDOM.rootDOM); |
1400 | 1376 |
1401 // Now build the Metrics selection node | 1377 // Now build the Metrics selection node |
1402 var metric = this.createGeneralNodeDOM("Session Metrics","setup-metric",this.setupDOM); | 1378 var metric = this.createGeneralNodeDOM("Session Metrics", "setup-metric", this.setupDOM); |
1403 metric.rootDOM.removeChild(metric.attributeDOM); | 1379 metric.rootDOM.removeChild(metric.attributeDOM); |
1404 this.setupDOM.children.push(metric); | 1380 this.setupDOM.children.push(metric); |
1405 this.setupDOM.childrenDOM.appendChild(metric.rootDOM); | 1381 this.setupDOM.childrenDOM.appendChild(metric.rootDOM); |
1406 var interfaceName = popupStateNodes.state[1].select.value; | 1382 var interfaceName = popupStateNodes.state[1].select.value; |
1407 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0]; | 1383 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0]; |
1408 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; | 1384 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; |
1409 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0]; | 1385 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0]; |
1410 testXML = testXML.getAllElementsByTagName("metrics"); | 1386 testXML = testXML.getAllElementsByTagName("metrics"); |
1411 var interfaceXMLChild = interfaceXML.firstElementChild; | 1387 var interfaceXMLChild = interfaceXML.firstElementChild; |
1412 while(interfaceXMLChild) | 1388 while (interfaceXMLChild) { |
1413 { | |
1414 var obj = { | 1389 var obj = { |
1415 input: document.createElement('input'), | 1390 input: document.createElement('input'), |
1416 root: document.createElement('div'), | 1391 root: document.createElement('div'), |
1417 text: document.createElement('span'), | 1392 text: document.createElement('span'), |
1418 specification: specification.metrics.enabled, | 1393 specification: specification.metrics.enabled, |
1419 name: interfaceXMLChild.getAttribute("name"), | 1394 name: interfaceXMLChild.getAttribute("name"), |
1420 handleEvent: function() | 1395 handleEvent: function () { |
1421 { | 1396 for (var i = 0; i < this.specification.length; i++) { |
1422 for (var i=0; i<this.specification.length; i++) | 1397 if (this.specification[i] == this.name) { |
1423 { | |
1424 if (this.specification[i] == this.name) | |
1425 { | |
1426 var options = this.specification; | 1398 var options = this.specification; |
1427 if (this.input.checked == false) { | 1399 if (this.input.checked == false) { |
1428 if (i == options.length) | 1400 if (i == options.length) { |
1429 {options = options.slice(0,i);} | 1401 options = options.slice(0, i); |
1430 else { | 1402 } else { |
1431 options = options.slice(0,i).concat(options.slice(i+1)); | 1403 options = options.slice(0, i).concat(options.slice(i + 1)); |
1432 } | 1404 } |
1433 } else { | 1405 } else { |
1434 return; | 1406 return; |
1435 } | 1407 } |
1436 this.specification = options; | 1408 this.specification = options; |
1447 obj.root.appendChild(obj.text); | 1419 obj.root.appendChild(obj.text); |
1448 obj.root.appendChild(obj.input); | 1420 obj.root.appendChild(obj.input); |
1449 obj.text.textContent = checkText.getAllElementsByName(interfaceXMLChild.getAttribute("name"))[0].textContent; | 1421 obj.text.textContent = checkText.getAllElementsByName(interfaceXMLChild.getAttribute("name"))[0].textContent; |
1450 metric.children.push(obj); | 1422 metric.children.push(obj); |
1451 metric.childrenDOM.appendChild(obj.root); | 1423 metric.childrenDOM.appendChild(obj.root); |
1452 for (var j=0; j<specification.metrics.enabled.length; j++) | 1424 for (var j = 0; j < specification.metrics.enabled.length; j++) { |
1453 { | 1425 if (specification.metrics.enabled[j] == obj.name) { |
1454 if (specification.metrics.enabled[j] == obj.name) | |
1455 { | |
1456 obj.input.checked = true; | 1426 obj.input.checked = true; |
1457 break; | 1427 break; |
1458 } | 1428 } |
1459 } | 1429 } |
1460 interfaceXMLChild = interfaceXMLChild.nextElementSibling; | 1430 interfaceXMLChild = interfaceXMLChild.nextElementSibling; |
1461 } | 1431 } |
1462 | 1432 |
1463 // Now both before and after surveys | 1433 // Now both before and after surveys |
1464 if (specification.preTest == undefined){ | 1434 if (specification.preTest == undefined) { |
1465 specification.preTest = new specification.surveyNode(specification); | 1435 specification.preTest = new specification.surveyNode(specification); |
1466 specification.preTest.location = "pre"; | 1436 specification.preTest.location = "pre"; |
1467 } | 1437 } |
1468 if (specification.postTest == undefined){ | 1438 if (specification.postTest == undefined) { |
1469 specification.postTest = new specification.surveyNode(specification); | 1439 specification.postTest = new specification.surveyNode(specification); |
1470 specification.postTest.location = "post"; | 1440 specification.postTest.location = "post"; |
1471 } | 1441 } |
1472 var surveyBefore = new this.surveyNode(this,specification.preTest,"Pre"); | 1442 var surveyBefore = new this.surveyNode(this, specification.preTest, "Pre"); |
1473 var surveyAfter = new this.surveyNode(this,specification.postTest,"Post"); | 1443 var surveyAfter = new this.surveyNode(this, specification.postTest, "Post"); |
1474 this.setupDOM.children.push(surveyBefore); | 1444 this.setupDOM.children.push(surveyBefore); |
1475 this.setupDOM.children.push(surveyAfter); | 1445 this.setupDOM.children.push(surveyAfter); |
1476 this.setupDOM.childrenDOM.appendChild(surveyBefore.rootDOM); | 1446 this.setupDOM.childrenDOM.appendChild(surveyBefore.rootDOM); |
1477 this.setupDOM.childrenDOM.appendChild(surveyAfter.rootDOM); | 1447 this.setupDOM.childrenDOM.appendChild(surveyAfter.rootDOM); |
1478 | 1448 |
1479 // Add in the page creator button | 1449 // Add in the page creator button |
1480 this.addPage = { | 1450 this.addPage = { |
1481 root: document.createElement("button"), | 1451 root: document.createElement("button"), |
1482 parent: this, | 1452 parent: this, |
1483 handleEvent: function() | 1453 handleEvent: function () { |
1484 { | |
1485 var pageObj = new specification.page(specification); | 1454 var pageObj = new specification.page(specification); |
1486 specification.pages.push(pageObj); | 1455 specification.pages.push(pageObj); |
1487 var newPage = new this.parent.pageNode(this.parent,pageObj); | 1456 var newPage = new this.parent.pageNode(this.parent, pageObj); |
1488 document.getElementById("page-holder").appendChild(newPage.rootDOM); | 1457 document.getElementById("page-holder").appendChild(newPage.rootDOM); |
1489 this.parent.pages.push(newPage); | 1458 this.parent.pages.push(newPage); |
1490 } | 1459 } |
1491 } | 1460 } |
1492 this.addPage.root.textContent = "Add Page"; | 1461 this.addPage.root.textContent = "Add Page"; |
1493 this.addPage.root.id = "new-page-button"; | 1462 this.addPage.root.id = "new-page-button"; |
1494 this.addPage.root.style.float = "left"; | 1463 this.addPage.root.style.float = "left"; |
1495 this.addPage.root.addEventListener("click",this.addPage,false); | 1464 this.addPage.root.addEventListener("click", this.addPage, false); |
1496 | 1465 |
1497 var pageHolder = document.createElement("div"); | 1466 var pageHolder = document.createElement("div"); |
1498 pageHolder.id ="page-holder"; | 1467 pageHolder.id = "page-holder"; |
1499 this.injectDOM.appendChild(pageHolder); | 1468 this.injectDOM.appendChild(pageHolder); |
1500 | 1469 |
1501 // Build each page | 1470 // Build each page |
1502 for (var page of specification.pages) | 1471 for (var page of specification.pages) { |
1503 { | 1472 var newPage = new this.pageNode(this, page); |
1504 var newPage = new this.pageNode(this,page); | |
1505 pageHolder.appendChild(newPage.rootDOM); | 1473 pageHolder.appendChild(newPage.rootDOM); |
1506 this.pages.push(newPage); | 1474 this.pages.push(newPage); |
1507 } | 1475 } |
1508 | 1476 |
1509 this.injectDOM.appendChild(this.addPage.root); | 1477 this.injectDOM.appendChild(this.addPage.root); |
1510 } | 1478 } |
1511 | 1479 |
1512 this.interfaceNode = function(parent,rootObject) | 1480 this.interfaceNode = function (parent, rootObject) { |
1513 { | |
1514 this.type = "interfaceNode"; | 1481 this.type = "interfaceNode"; |
1515 this.rootDOM; | 1482 this.rootDOM; |
1516 this.titleDOM; | 1483 this.titleDOM; |
1517 this.attributeDOM; | 1484 this.attributeDOM; |
1518 this.attributes = []; | 1485 this.attributes = []; |
1521 this.buttonDOM; | 1488 this.buttonDOM; |
1522 this.parent = parent; | 1489 this.parent = parent; |
1523 this.HTMLPoint; | 1490 this.HTMLPoint; |
1524 this.specification = rootObject; | 1491 this.specification = rootObject; |
1525 this.schema = specification.schema.getAllElementsByName("interface")[1]; | 1492 this.schema = specification.schema.getAllElementsByName("interface")[1]; |
1526 | 1493 |
1527 this.createIOasAttr = function(name,specification,parent,type) { | 1494 this.createIOasAttr = function (name, specification, parent, type) { |
1528 this.root = document.createElement('div'); | 1495 this.root = document.createElement('div'); |
1529 this.input = document.createElement("input"); | 1496 this.input = document.createElement("input"); |
1530 this.name = name; | 1497 this.name = name; |
1531 this.type = type; | 1498 this.type = type; |
1532 this.parent = parent; | 1499 this.parent = parent; |
1533 this.specification = specification; | 1500 this.specification = specification; |
1534 this.handleEvent = function(event) { | 1501 this.handleEvent = function (event) { |
1535 for (var i=0; i<this.specification.options.length; i++) | 1502 for (var i = 0; i < this.specification.options.length; i++) { |
1536 { | 1503 if (this.specification.options[i].name == this.name) { |
1537 if (this.specification.options[i].name == this.name) | |
1538 { | |
1539 var options = this.specification.options; | 1504 var options = this.specification.options; |
1540 if (this.input.checked == false) { | 1505 if (this.input.checked == false) { |
1541 if (i == options.length) | 1506 if (i == options.length) { |
1542 {options = options.slice(0,i);} | 1507 options = options.slice(0, i); |
1543 else { | 1508 } else { |
1544 options = options.slice(0,i).concat(options.slice(i+1)); | 1509 options = options.slice(0, i).concat(options.slice(i + 1)); |
1545 } | 1510 } |
1546 } else { | 1511 } else { |
1547 return; | 1512 return; |
1548 } | 1513 } |
1549 this.specification.options = options; | 1514 this.specification.options = options; |
1555 name: this.name, | 1520 name: this.name, |
1556 type: this.type | 1521 type: this.type |
1557 }; | 1522 }; |
1558 this.specification.options.push(obj); | 1523 this.specification.options.push(obj); |
1559 } | 1524 } |
1560 if (this.parent.HTMLPoint.id == "setup") | 1525 if (this.parent.HTMLPoint.id == "setup") { |
1561 { | |
1562 // We've changed a global setting, must update all child 'interfaces' and disable them | 1526 // We've changed a global setting, must update all child 'interfaces' and disable them |
1563 for (pages of convert.pages) | 1527 for (pages of convert.pages) { |
1564 { | 1528 for (interface of pages.interfaces) { |
1565 for (interface of pages.interfaces) | 1529 if (this.type == "check") { |
1566 { | 1530 for (node of interface.children[0].attributes) { |
1567 if (this.type == "check") | |
1568 { | |
1569 for (node of interface.children[0].attributes) | |
1570 { | |
1571 if (node.name == this.name) { | 1531 if (node.name == this.name) { |
1572 if (this.input.checked) { | 1532 if (this.input.checked) { |
1573 node.input.disabled = true; | 1533 node.input.disabled = true; |
1574 node.input.checked = false; | 1534 node.input.checked = false; |
1575 } else { | 1535 } else { |
1576 node.input.disabled = false; | 1536 node.input.disabled = false; |
1577 } | 1537 } |
1578 break; | 1538 break; |
1579 } | 1539 } |
1580 } | 1540 } |
1581 } else if (this.type == "show") | 1541 } else if (this.type == "show") { |
1582 { | 1542 for (node of interface.children[1].attributes) { |
1583 for (node of interface.children[1].attributes) | |
1584 { | |
1585 if (node.name == this.name) { | 1543 if (node.name == this.name) { |
1586 if (this.input.checked) { | 1544 if (this.input.checked) { |
1587 node.input.disabled = true; | 1545 node.input.disabled = true; |
1588 } else { | 1546 } else { |
1589 node.input.disabled = false; | 1547 node.input.disabled = false; |
1594 } | 1552 } |
1595 } | 1553 } |
1596 } | 1554 } |
1597 } | 1555 } |
1598 }; | 1556 }; |
1599 this.findIndex = function(element,index,array){ | 1557 this.findIndex = function (element, index, array) { |
1600 if (element.name == this.name) | 1558 if (element.name == this.name) |
1601 return true; | 1559 return true; |
1602 else | 1560 else |
1603 return false; | 1561 return false; |
1604 }; | 1562 }; |
1605 this.findNode = function(element,index,array){ | 1563 this.findNode = function (element, index, array) { |
1606 if (element.name == this.name) | 1564 if (element.name == this.name) |
1607 return true; | 1565 return true; |
1608 else | 1566 else |
1609 return false; | 1567 return false; |
1610 }; | 1568 }; |
1611 this.input.type = "checkbox"; | 1569 this.input.type = "checkbox"; |
1612 this.input.setAttribute("name",name); | 1570 this.input.setAttribute("name", name); |
1613 this.input.addEventListener("change",this,false); | 1571 this.input.addEventListener("change", this, false); |
1614 this.root.appendChild(this.input); | 1572 this.root.appendChild(this.input); |
1615 this.root.className = "attribute"; | 1573 this.root.className = "attribute"; |
1616 return this; | 1574 return this; |
1617 } | 1575 } |
1618 | 1576 |
1619 this.build = function(name,id,parent) | 1577 this.build = function (name, id, parent) { |
1620 { | 1578 var obj = this.parent.createGeneralNodeDOM(name, id, parent); |
1621 var obj = this.parent.createGeneralNodeDOM(name,id,parent); | 1579 |
1622 | |
1623 this.rootDOM = obj.rootDOM; | 1580 this.rootDOM = obj.rootDOM; |
1624 this.titleDOM = obj.titleDOM; | 1581 this.titleDOM = obj.titleDOM; |
1625 this.attributeDOM = obj.attributeDOM; | 1582 this.attributeDOM = obj.attributeDOM; |
1626 this.childrenDOM = obj.childrenDOM; | 1583 this.childrenDOM = obj.childrenDOM; |
1627 this.buttonDOM = obj.buttonsDOM; | 1584 this.buttonDOM = obj.buttonsDOM; |
1632 this.titleNode = { | 1589 this.titleNode = { |
1633 root: document.createElement("div"), | 1590 root: document.createElement("div"), |
1634 label: document.createElement("span"), | 1591 label: document.createElement("span"), |
1635 input: document.createElement("input"), | 1592 input: document.createElement("input"), |
1636 parent: this, | 1593 parent: this, |
1637 handleEvent: function(event) { | 1594 handleEvent: function (event) { |
1638 this.parent.specification.title = event.currentTarget.value; | 1595 this.parent.specification.title = event.currentTarget.value; |
1639 } | 1596 } |
1640 } | 1597 } |
1641 this.titleNode.label.textContent = "Axis Title:"; | 1598 this.titleNode.label.textContent = "Axis Title:"; |
1642 this.titleNode.root.className = "node-children"; | 1599 this.titleNode.root.className = "node-children"; |
1643 this.titleNode.root.appendChild(this.titleNode.label); | 1600 this.titleNode.root.appendChild(this.titleNode.label); |
1644 this.titleNode.root.appendChild(this.titleNode.input); | 1601 this.titleNode.root.appendChild(this.titleNode.input); |
1645 this.titleNode.input.addEventListener("change",this.titleNode,false); | 1602 this.titleNode.input.addEventListener("change", this.titleNode, false); |
1646 this.titleNode.input.value = this.specification.title; | 1603 this.titleNode.input.value = this.specification.title; |
1647 this.children.push(this.titleNode); | 1604 this.children.push(this.titleNode); |
1648 this.childrenDOM.appendChild(this.titleNode.root); | 1605 this.childrenDOM.appendChild(this.titleNode.root); |
1649 } | 1606 } |
1650 | 1607 |
1651 // Put in the check / show options as individual children | 1608 // Put in the check / show options as individual children |
1652 var checks = this.parent.createGeneralNodeDOM("Checks","setup-interface-checks",this); | 1609 var checks = this.parent.createGeneralNodeDOM("Checks", "setup-interface-checks", this); |
1653 | 1610 |
1654 var interfaceName = popupStateNodes.state[1].select.value; | 1611 var interfaceName = popupStateNodes.state[1].select.value; |
1655 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0]; | 1612 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0]; |
1656 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; | 1613 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; |
1657 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0]; | 1614 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0]; |
1658 testXML = testXML.getAllElementsByTagName("checks"); | 1615 testXML = testXML.getAllElementsByTagName("checks"); |
1659 var interfaceXMLChild = interfaceXML.firstElementChild; | 1616 var interfaceXMLChild = interfaceXML.firstElementChild; |
1660 while (interfaceXMLChild) | 1617 while (interfaceXMLChild) { |
1661 { | 1618 var obj = new this.createIOasAttr(interfaceXMLChild.getAttribute("name"), this.specification, this, "check"); |
1662 var obj = new this.createIOasAttr(interfaceXMLChild.getAttribute("name"),this.specification,this,"check"); | 1619 for (var option of this.specification.options) { |
1663 for (var option of this.specification.options) | 1620 if (option.name == obj.name) { |
1664 { | |
1665 if (option.name == obj.name) | |
1666 { | |
1667 obj.input.checked = true; | 1621 obj.input.checked = true; |
1668 break; | 1622 break; |
1669 } | 1623 } |
1670 } | 1624 } |
1671 if (parent.id != "setup") { | 1625 if (parent.id != "setup") { |
1672 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj); | 1626 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode, obj); |
1673 if (node != undefined) { | 1627 if (node != undefined) { |
1674 if (node.input.checked) { | 1628 if (node.input.checked) { |
1675 obj.input.checked = false; | 1629 obj.input.checked = false; |
1676 obj.input.disabled = true; | 1630 obj.input.disabled = true; |
1677 } | 1631 } |
1685 interfaceXMLChild = interfaceXMLChild.nextElementSibling; | 1639 interfaceXMLChild = interfaceXMLChild.nextElementSibling; |
1686 } | 1640 } |
1687 this.children.push(checks); | 1641 this.children.push(checks); |
1688 this.childrenDOM.appendChild(checks.rootDOM); | 1642 this.childrenDOM.appendChild(checks.rootDOM); |
1689 | 1643 |
1690 var show = this.parent.createGeneralNodeDOM("Show","setup-interface-show",this); | 1644 var show = this.parent.createGeneralNodeDOM("Show", "setup-interface-show", this); |
1691 interfaceName = popupStateNodes.state[1].select.value; | 1645 interfaceName = popupStateNodes.state[1].select.value; |
1692 checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0]; | 1646 checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0]; |
1693 testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; | 1647 testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0]; |
1694 interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0]; | 1648 interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0]; |
1695 testXML = testXML.getAllElementsByTagName("show"); | 1649 testXML = testXML.getAllElementsByTagName("show"); |
1696 interfaceXMLChild = interfaceXML.firstElementChild; | 1650 interfaceXMLChild = interfaceXML.firstElementChild; |
1697 while(interfaceXMLChild) | 1651 while (interfaceXMLChild) { |
1698 { | 1652 var obj = new this.createIOasAttr(interfaceXMLChild.getAttribute("name"), this.specification, this, "show"); |
1699 var obj = new this.createIOasAttr(interfaceXMLChild.getAttribute("name"),this.specification,this,"show"); | 1653 for (var option of this.specification.options) { |
1700 for (var option of this.specification.options) | 1654 if (option.name == obj.name) { |
1701 { | |
1702 if (option.name == obj.name) | |
1703 { | |
1704 obj.input.checked = true; | 1655 obj.input.checked = true; |
1705 break; | 1656 break; |
1706 } | 1657 } |
1707 } | 1658 } |
1708 if (parent.id != "setup") { | 1659 if (parent.id != "setup") { |
1709 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj); | 1660 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode, obj); |
1710 if (node != undefined) { | 1661 if (node != undefined) { |
1711 if (node.input.checked) { | 1662 if (node.input.checked) { |
1712 obj.input.checked = false; | 1663 obj.input.checked = false; |
1713 obj.input.disabled = true; | 1664 obj.input.disabled = true; |
1714 } | 1665 } |
1721 show.attributes.push(obj); | 1672 show.attributes.push(obj); |
1722 interfaceXMLChild = interfaceXMLChild.nextElementSibling; | 1673 interfaceXMLChild = interfaceXMLChild.nextElementSibling; |
1723 } | 1674 } |
1724 this.children.push(show); | 1675 this.children.push(show); |
1725 this.childrenDOM.appendChild(show.rootDOM); | 1676 this.childrenDOM.appendChild(show.rootDOM); |
1726 | 1677 |
1727 if (parent.id == "setup") | 1678 if (parent.id == "setup") {} else { |
1728 { | 1679 var nameAttr = this.parent.convertAttributeToDOM(this, specification.schema.getAllElementsByName("name")[0]); |
1729 } else { | |
1730 var nameAttr = this.parent.convertAttributeToDOM(this,specification.schema.getAllElementsByName("name")[0]); | |
1731 this.attributeDOM.appendChild(nameAttr.holder); | 1680 this.attributeDOM.appendChild(nameAttr.holder); |
1732 this.attributes.push(nameAttr); | 1681 this.attributes.push(nameAttr); |
1733 var scales = new this.scalesNode(this,this.specification); | 1682 var scales = new this.scalesNode(this, this.specification); |
1734 this.children.push(scales); | 1683 this.children.push(scales); |
1735 this.childrenDOM.appendChild(scales.rootDOM); | 1684 this.childrenDOM.appendChild(scales.rootDOM); |
1736 } | 1685 } |
1737 if (parent != undefined) | 1686 if (parent != undefined) { |
1738 { | |
1739 parent.appendChild(this.rootDOM); | 1687 parent.appendChild(this.rootDOM); |
1740 } | 1688 } |
1741 } | 1689 } |
1742 | 1690 |
1743 this.scalesNode = function(parent,rootObject) | 1691 this.scalesNode = function (parent, rootObject) { |
1744 { | |
1745 this.type = "scalesNode"; | 1692 this.type = "scalesNode"; |
1746 this.rootDOM = document.createElement("div"); | 1693 this.rootDOM = document.createElement("div"); |
1747 this.titleDOM = document.createElement("span"); | 1694 this.titleDOM = document.createElement("span"); |
1748 this.attributeDOM = document.createElement("div"); | 1695 this.attributeDOM = document.createElement("div"); |
1749 this.attributes = []; | 1696 this.attributes = []; |
1767 | 1714 |
1768 this.rootDOM.appendChild(titleDiv); | 1715 this.rootDOM.appendChild(titleDiv); |
1769 this.rootDOM.appendChild(this.attributeDOM); | 1716 this.rootDOM.appendChild(this.attributeDOM); |
1770 this.rootDOM.appendChild(this.childrenDOM); | 1717 this.rootDOM.appendChild(this.childrenDOM); |
1771 this.rootDOM.appendChild(this.buttonDOM); | 1718 this.rootDOM.appendChild(this.buttonDOM); |
1772 | 1719 |
1773 this.editButton = { | 1720 this.editButton = { |
1774 button: document.createElement("button"), | 1721 button: document.createElement("button"), |
1775 parent: this, | 1722 parent: this, |
1776 handleEvent: function(event) { | 1723 handleEvent: function (event) { |
1777 popupObject.show(); | 1724 popupObject.show(); |
1778 popupObject.postNode(popupStateNodes.state[6]); | 1725 popupObject.postNode(popupStateNodes.state[6]); |
1779 popupStateNodes.state[6].generate(this.parent.specification,this.parent); | 1726 popupStateNodes.state[6].generate(this.parent.specification, this.parent); |
1780 } | 1727 } |
1781 }; | 1728 }; |
1782 this.editButton.button.textContent = "Edit Scales/Markers"; | 1729 this.editButton.button.textContent = "Edit Scales/Markers"; |
1783 this.editButton.button.addEventListener("click",this.editButton,false); | 1730 this.editButton.button.addEventListener("click", this.editButton, false); |
1784 this.buttonDOM.appendChild(this.editButton.button); | 1731 this.buttonDOM.appendChild(this.editButton.button); |
1785 } | 1732 } |
1786 } | 1733 } |
1787 | 1734 |
1788 this.surveyNode = function(parent,rootObject,location) | 1735 this.surveyNode = function (parent, rootObject, location) { |
1789 { | |
1790 this.type = "surveyNode"; | 1736 this.type = "surveyNode"; |
1791 this.rootDOM = document.createElement("div"); | 1737 this.rootDOM = document.createElement("div"); |
1792 this.titleDOM = document.createElement("span"); | 1738 this.titleDOM = document.createElement("span"); |
1793 this.attributeDOM = document.createElement("div"); | 1739 this.attributeDOM = document.createElement("div"); |
1794 this.attributes = []; | 1740 this.attributes = []; |
1803 var titleDiv = document.createElement('div'); | 1749 var titleDiv = document.createElement('div'); |
1804 titleDiv.className = "node-title"; | 1750 titleDiv.className = "node-title"; |
1805 this.titleDOM.className = "node-title"; | 1751 this.titleDOM.className = "node-title"; |
1806 this.titleDOM.textContent = "Survey"; | 1752 this.titleDOM.textContent = "Survey"; |
1807 titleDiv.appendChild(this.titleDOM); | 1753 titleDiv.appendChild(this.titleDOM); |
1808 | 1754 |
1809 this.attributeDOM.className = "node-attributes"; | 1755 this.attributeDOM.className = "node-attributes"; |
1810 var locationAttr = document.createElement("span"); | 1756 var locationAttr = document.createElement("span"); |
1811 this.attributeDOM.appendChild(locationAttr); | 1757 this.attributeDOM.appendChild(locationAttr); |
1812 if (location == "Pre" || location == "pre") { | 1758 if (location == "Pre" || location == "pre") { |
1813 locationAttr.textContent = "Location: Before"; | 1759 locationAttr.textContent = "Location: Before"; |
1819 | 1765 |
1820 this.rootDOM.appendChild(titleDiv); | 1766 this.rootDOM.appendChild(titleDiv); |
1821 this.rootDOM.appendChild(this.attributeDOM); | 1767 this.rootDOM.appendChild(this.attributeDOM); |
1822 this.rootDOM.appendChild(this.childrenDOM); | 1768 this.rootDOM.appendChild(this.childrenDOM); |
1823 this.rootDOM.appendChild(this.buttonDOM); | 1769 this.rootDOM.appendChild(this.buttonDOM); |
1824 | 1770 |
1825 this.surveyEntryNode = function(parent,rootObject) | 1771 this.surveyEntryNode = function (parent, rootObject) { |
1826 { | |
1827 this.type = "surveyEntryNode"; | 1772 this.type = "surveyEntryNode"; |
1828 this.rootDOM = document.createElement("div"); | 1773 this.rootDOM = document.createElement("div"); |
1829 this.titleDOM = document.createElement("span"); | 1774 this.titleDOM = document.createElement("span"); |
1830 this.attributeDOM = document.createElement("div"); | 1775 this.attributeDOM = document.createElement("div"); |
1831 this.attributes = []; | 1776 this.attributes = []; |
1850 | 1795 |
1851 this.rootDOM.appendChild(titleDiv); | 1796 this.rootDOM.appendChild(titleDiv); |
1852 this.rootDOM.appendChild(this.attributeDOM); | 1797 this.rootDOM.appendChild(this.attributeDOM); |
1853 this.rootDOM.appendChild(this.childrenDOM); | 1798 this.rootDOM.appendChild(this.childrenDOM); |
1854 this.rootDOM.appendChild(this.buttonDOM); | 1799 this.rootDOM.appendChild(this.buttonDOM); |
1855 | 1800 |
1856 this.build = function() | 1801 this.build = function () { |
1857 { | |
1858 this.attributeDOM.innerHTML = null; | 1802 this.attributeDOM.innerHTML = null; |
1859 this.childrenDOM.innerHTML = null; | 1803 this.childrenDOM.innerHTML = null; |
1860 var statementRoot = document.createElement("div"); | 1804 var statementRoot = document.createElement("div"); |
1861 var statement = document.createElement("span"); | 1805 var statement = document.createElement("span"); |
1862 statement.textContent = "Statement / Question: "+this.specification.statement; | 1806 statement.textContent = "Statement / Question: " + this.specification.statement; |
1863 statementRoot.appendChild(statement); | 1807 statementRoot.appendChild(statement); |
1864 this.children.push(statementRoot); | 1808 this.children.push(statementRoot); |
1865 this.childrenDOM.appendChild(statementRoot); | 1809 this.childrenDOM.appendChild(statementRoot); |
1866 switch(this.specification.type) | 1810 switch (this.specification.type) { |
1867 { | |
1868 case "statement": | 1811 case "statement": |
1869 this.titleDOM.textContent = "Statement"; | 1812 this.titleDOM.textContent = "Statement"; |
1870 break; | 1813 break; |
1871 case "question": | 1814 case "question": |
1872 this.titleDOM.textContent = "Question"; | 1815 this.titleDOM.textContent = "Question"; |
1873 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]); | 1816 var id = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("id")[0]); |
1874 var mandatory = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("mandatory")[0]); | 1817 var mandatory = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("mandatory")[0]); |
1875 var boxsize = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("boxsize")[0]); | 1818 var boxsize = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("boxsize")[0]); |
1876 this.attributeDOM.appendChild(id.holder); | 1819 this.attributeDOM.appendChild(id.holder); |
1877 this.attributes.push(id); | 1820 this.attributes.push(id); |
1878 this.attributeDOM.appendChild(mandatory.holder); | 1821 this.attributeDOM.appendChild(mandatory.holder); |
1879 this.attributes.push(mandatory); | 1822 this.attributes.push(mandatory); |
1880 this.attributeDOM.appendChild(boxsize.holder); | 1823 this.attributeDOM.appendChild(boxsize.holder); |
1881 this.attributes.push(boxsize); | 1824 this.attributes.push(boxsize); |
1882 break; | 1825 break; |
1883 case "number": | 1826 case "number": |
1884 this.titleDOM.textContent = "Number"; | 1827 this.titleDOM.textContent = "Number"; |
1885 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]); | 1828 var id = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("id")[0]); |
1886 var mandatory = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("mandatory")[0]); | 1829 var mandatory = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("mandatory")[0]); |
1887 var min = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("min")[0]); | 1830 var min = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("min")[0]); |
1888 var max = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("max")[0]); | 1831 var max = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("max")[0]); |
1889 this.attributeDOM.appendChild(id.holder); | 1832 this.attributeDOM.appendChild(id.holder); |
1890 this.attributes.push(id); | 1833 this.attributes.push(id); |
1891 this.attributeDOM.appendChild(min.holder); | 1834 this.attributeDOM.appendChild(min.holder); |
1892 this.attributes.push(min); | 1835 this.attributes.push(min); |
1893 this.attributeDOM.appendChild(max.holder); | 1836 this.attributeDOM.appendChild(max.holder); |
1894 this.attributes.push(max); | 1837 this.attributes.push(max); |
1895 break; | 1838 break; |
1896 case "checkbox": | 1839 case "checkbox": |
1897 this.titleDOM.textContent = "Checkbox"; | 1840 this.titleDOM.textContent = "Checkbox"; |
1898 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]); | 1841 var id = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("id")[0]); |
1899 this.attributeDOM.appendChild(id.holder); | 1842 this.attributeDOM.appendChild(id.holder); |
1900 this.attributes.push(id); | 1843 this.attributes.push(id); |
1901 break; | 1844 break; |
1902 case "radio": | 1845 case "radio": |
1903 this.titleDOM.textContent = "Radio"; | 1846 this.titleDOM.textContent = "Radio"; |
1904 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]); | 1847 var id = convert.convertAttributeToDOM(this.specification, specification.schema.getAllElementsByName("id")[0]); |
1905 this.attributeDOM.appendChild(id.holder); | 1848 this.attributeDOM.appendChild(id.holder); |
1906 this.attributes.push(id); | 1849 this.attributes.push(id); |
1907 break; | 1850 break; |
1908 } | 1851 } |
1909 } | 1852 } |
1910 this.build(); | 1853 this.build(); |
1911 | 1854 |
1912 this.editNode = { | 1855 this.editNode = { |
1913 root: document.createElement("button"), | 1856 root: document.createElement("button"), |
1914 parent: this, | 1857 parent: this, |
1915 handleEvent: function() | 1858 handleEvent: function () { |
1916 { | |
1917 popupObject.show(); | 1859 popupObject.show(); |
1918 popupStateNodes.state[5].generate(this.parent.specification,this.parent); | 1860 popupStateNodes.state[5].generate(this.parent.specification, this.parent); |
1919 popupObject.postNode(popupStateNodes.state[5]); | 1861 popupObject.postNode(popupStateNodes.state[5]); |
1920 } | 1862 } |
1921 } | 1863 } |
1922 this.editNode.root.textContent = "Edit Entry"; | 1864 this.editNode.root.textContent = "Edit Entry"; |
1923 this.editNode.root.addEventListener("click",this.editNode,false); | 1865 this.editNode.root.addEventListener("click", this.editNode, false); |
1924 this.buttonDOM.appendChild(this.editNode.root); | 1866 this.buttonDOM.appendChild(this.editNode.root); |
1925 | 1867 |
1926 this.deleteNode = { | 1868 this.deleteNode = { |
1927 root: document.createElement("button"), | 1869 root: document.createElement("button"), |
1928 parent: this, | 1870 parent: this, |
1929 handleEvent: function() | 1871 handleEvent: function () { |
1930 { | |
1931 var optionList = this.parent.parent.specification.options; | 1872 var optionList = this.parent.parent.specification.options; |
1932 var childList = this.parent.parent.children; | 1873 var childList = this.parent.parent.children; |
1933 for (var i=0; i <this.parent.parent.specification.options.length; i++) | 1874 for (var i = 0; i < this.parent.parent.specification.options.length; i++) { |
1934 { | |
1935 var option = this.parent.parent.specification.options[i]; | 1875 var option = this.parent.parent.specification.options[i]; |
1936 if (option == this.parent.specification) | 1876 if (option == this.parent.specification) { |
1937 { | |
1938 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM); | 1877 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM); |
1939 if (i == this.parent.parent.specification.options.length-1) | 1878 if (i == this.parent.parent.specification.options.length - 1) { |
1940 { | 1879 optionList = optionList.slice(0, i); |
1941 optionList = optionList.slice(0,i); | 1880 childList = childList.slice(0, i); |
1942 childList = childList.slice(0,i); | 1881 } else { |
1943 } | 1882 optionList = optionList.slice(0, i).concat(optionList.slice(i + 1)); |
1944 else { | 1883 childList = childList.slice(0, i).concat(childList.slice(i + 1)); |
1945 optionList = optionList.slice(0,i).concat(optionList.slice(i+1)); | |
1946 childList = childList.slice(0,i).concat(childList.slice(i+1)); | |
1947 } | 1884 } |
1948 this.parent.parent.specification.options = optionList; | 1885 this.parent.parent.specification.options = optionList; |
1949 this.parent.parent.children = childList; | 1886 this.parent.parent.children = childList; |
1950 } | 1887 } |
1951 } | 1888 } |
1952 } | 1889 } |
1953 } | 1890 } |
1954 this.deleteNode.root.textContent = "Delete Entry"; | 1891 this.deleteNode.root.textContent = "Delete Entry"; |
1955 this.deleteNode.root.addEventListener("click",this.deleteNode,false); | 1892 this.deleteNode.root.addEventListener("click", this.deleteNode, false); |
1956 this.buttonDOM.appendChild(this.deleteNode.root); | 1893 this.buttonDOM.appendChild(this.deleteNode.root); |
1957 | 1894 |
1958 this.moveToPosition = function(new_index){ | 1895 this.moveToPosition = function (new_index) { |
1959 new_index = Math.min(new_index,this.parent.children.length); | 1896 new_index = Math.min(new_index, this.parent.children.length); |
1960 var curr_index = this.parent.children.findIndex(function(elem){ | 1897 var curr_index = this.parent.children.findIndex(function (elem) { |
1961 if (elem == this) {return true;} else {return false;} | 1898 if (elem == this) { |
1962 },this); | 1899 return true; |
1900 } else { | |
1901 return false; | |
1902 } | |
1903 }, this); | |
1963 // Split at the current location to remove the node and shift all the children up | 1904 // Split at the current location to remove the node and shift all the children up |
1964 var tail = this.parent.children.splice(curr_index+1); | 1905 var tail = this.parent.children.splice(curr_index + 1); |
1965 this.parent.children.pop(); | 1906 this.parent.children.pop(); |
1966 this.parent.children = this.parent.children.concat(tail); | 1907 this.parent.children = this.parent.children.concat(tail); |
1967 | 1908 |
1968 //Split at the new location and insert the node | 1909 //Split at the new location and insert the node |
1969 tail = this.parent.children.splice(new_index); | 1910 tail = this.parent.children.splice(new_index); |
1970 this.parent.children.push(this); | 1911 this.parent.children.push(this); |
1971 this.parent.children = this.parent.children.concat(tail); | 1912 this.parent.children = this.parent.children.concat(tail); |
1972 | 1913 |
1973 // Re-build the specification | 1914 // Re-build the specification |
1974 this.parent.specification.options = []; | 1915 this.parent.specification.options = []; |
1975 this.parent.childrenDOM.innerHTML = ""; | 1916 this.parent.childrenDOM.innerHTML = ""; |
1976 for (var obj of this.parent.children) { | 1917 for (var obj of this.parent.children) { |
1977 this.parent.specification.options.push(obj.specification); | 1918 this.parent.specification.options.push(obj.specification); |
1978 this.parent.childrenDOM.appendChild(obj.rootDOM); | 1919 this.parent.childrenDOM.appendChild(obj.rootDOM); |
1979 } | 1920 } |
1980 this.parent.children.forEach(function(obj,index){ | 1921 this.parent.children.forEach(function (obj, index) { |
1981 obj.moveButtons.disable(index); | 1922 obj.moveButtons.disable(index); |
1982 }); | 1923 }); |
1983 } | 1924 } |
1984 | 1925 |
1985 this.moveButtons = { | 1926 this.moveButtons = { |
1986 root_up: document.createElement("button"), | 1927 root_up: document.createElement("button"), |
1987 root_down: document.createElement("button"), | 1928 root_down: document.createElement("button"), |
1988 parent: this, | 1929 parent: this, |
1989 handleEvent: function(event) { | 1930 handleEvent: function (event) { |
1990 var index = this.parent.parent.children.indexOf(this.parent); | 1931 var index = this.parent.parent.children.indexOf(this.parent); |
1991 if (event.currentTarget.getAttribute("direction") == "up") { | 1932 if (event.currentTarget.getAttribute("direction") == "up") { |
1992 index = Math.max(index-1,0); | 1933 index = Math.max(index - 1, 0); |
1993 } else if (event.currentTarget.getAttribute("direction") == "down") { | 1934 } else if (event.currentTarget.getAttribute("direction") == "down") { |
1994 index = Math.min(index+1,this.parent.parent.children.length-1); | 1935 index = Math.min(index + 1, this.parent.parent.children.length - 1); |
1995 } | 1936 } |
1996 this.parent.moveToPosition(index); | 1937 this.parent.moveToPosition(index); |
1997 this.disable(index); | 1938 this.disable(index); |
1998 }, | 1939 }, |
1999 disable: function(index) { | 1940 disable: function (index) { |
2000 if (index == 0) { | 1941 if (index == 0) { |
2001 this.root_up.disabled = true; | 1942 this.root_up.disabled = true; |
2002 } else { | 1943 } else { |
2003 this.root_up.disabled = false; | 1944 this.root_up.disabled = false; |
2004 } | 1945 } |
2005 if (index == this.parent.parent.children.length-1) { | 1946 if (index == this.parent.parent.children.length - 1) { |
2006 this.root_down.disabled = true; | 1947 this.root_down.disabled = true; |
2007 } else { | 1948 } else { |
2008 this.root_down.disabled = false; | 1949 this.root_down.disabled = false; |
2009 } | 1950 } |
2010 } | 1951 } |
2011 } | 1952 } |
2012 this.moveButtons.root_up.setAttribute("direction","up"); | 1953 this.moveButtons.root_up.setAttribute("direction", "up"); |
2013 this.moveButtons.root_down.setAttribute("direction","down"); | 1954 this.moveButtons.root_down.setAttribute("direction", "down"); |
2014 this.moveButtons.root_up.addEventListener("click",this.moveButtons,false); | 1955 this.moveButtons.root_up.addEventListener("click", this.moveButtons, false); |
2015 this.moveButtons.root_down.addEventListener("click",this.moveButtons,false); | 1956 this.moveButtons.root_down.addEventListener("click", this.moveButtons, false); |
2016 this.moveButtons.root_up.textContent = "Move Up"; | 1957 this.moveButtons.root_up.textContent = "Move Up"; |
2017 this.moveButtons.root_down.textContent = "Move Down"; | 1958 this.moveButtons.root_down.textContent = "Move Down"; |
2018 this.buttonDOM.appendChild(this.moveButtons.root_up); | 1959 this.buttonDOM.appendChild(this.moveButtons.root_up); |
2019 this.buttonDOM.appendChild(this.moveButtons.root_down); | 1960 this.buttonDOM.appendChild(this.moveButtons.root_down); |
2020 } | 1961 } |
2021 this.addNode = { | 1962 this.addNode = { |
2022 root: document.createElement("button"), | 1963 root: document.createElement("button"), |
2023 parent: this, | 1964 parent: this, |
2024 handleEvent: function() | 1965 handleEvent: function () { |
2025 { | |
2026 var newNode = new this.parent.specification.OptionNode(this.parent.specification); | 1966 var newNode = new this.parent.specification.OptionNode(this.parent.specification); |
2027 this.parent.specification.options.push(newNode); | 1967 this.parent.specification.options.push(newNode); |
2028 popupObject.show(); | 1968 popupObject.show(); |
2029 popupStateNodes.state[5].generate(newNode,this.parent); | 1969 popupStateNodes.state[5].generate(newNode, this.parent); |
2030 popupObject.postNode(popupStateNodes.state[5]); | 1970 popupObject.postNode(popupStateNodes.state[5]); |
2031 } | 1971 } |
2032 } | 1972 } |
2033 this.addNode.root.textContent = "Add Survey Entry"; | 1973 this.addNode.root.textContent = "Add Survey Entry"; |
2034 this.addNode.root.addEventListener("click",this.addNode,false); | 1974 this.addNode.root.addEventListener("click", this.addNode, false); |
2035 this.buttonDOM.appendChild(this.addNode.root); | 1975 this.buttonDOM.appendChild(this.addNode.root); |
2036 | 1976 |
2037 for (var option of this.specification.options) | 1977 for (var option of this.specification.options) { |
2038 { | 1978 var newNode = new this.surveyEntryNode(this, option); |
2039 var newNode = new this.surveyEntryNode(this,option); | |
2040 this.children.push(newNode); | 1979 this.children.push(newNode); |
2041 this.childrenDOM.appendChild(newNode.rootDOM); | 1980 this.childrenDOM.appendChild(newNode.rootDOM); |
2042 } | 1981 } |
2043 | 1982 |
2044 this.children.forEach(function(obj,index){ | 1983 this.children.forEach(function (obj, index) { |
2045 obj.moveButtons.disable(index); | 1984 obj.moveButtons.disable(index); |
2046 }); | 1985 }); |
2047 } | 1986 } |
2048 | 1987 |
2049 this.pageNode = function(parent,rootObject) | 1988 this.pageNode = function (parent, rootObject) { |
2050 { | |
2051 this.type = "pageNode"; | 1989 this.type = "pageNode"; |
2052 this.rootDOM = document.createElement("div"); | 1990 this.rootDOM = document.createElement("div"); |
2053 this.titleDOM = document.createElement("span"); | 1991 this.titleDOM = document.createElement("span"); |
2054 this.attributeDOM = document.createElement("div"); | 1992 this.attributeDOM = document.createElement("div"); |
2055 this.attributes = []; | 1993 this.attributes = []; |
2064 var titleDiv = document.createElement('div'); | 2002 var titleDiv = document.createElement('div'); |
2065 titleDiv.className = "node-title"; | 2003 titleDiv.className = "node-title"; |
2066 this.titleDOM.className = "node-title"; | 2004 this.titleDOM.className = "node-title"; |
2067 this.titleDOM.textContent = "Test Page"; | 2005 this.titleDOM.textContent = "Test Page"; |
2068 titleDiv.appendChild(this.titleDOM); | 2006 titleDiv.appendChild(this.titleDOM); |
2069 | 2007 |
2070 this.attributeDOM.className = "node-attributes"; | 2008 this.attributeDOM.className = "node-attributes"; |
2071 this.childrenDOM.className = "node-children"; | 2009 this.childrenDOM.className = "node-children"; |
2072 this.buttonDOM.className = "node-buttons"; | 2010 this.buttonDOM.className = "node-buttons"; |
2073 | 2011 |
2074 this.rootDOM.appendChild(titleDiv); | 2012 this.rootDOM.appendChild(titleDiv); |
2075 this.rootDOM.appendChild(this.attributeDOM); | 2013 this.rootDOM.appendChild(this.attributeDOM); |
2076 this.rootDOM.appendChild(this.childrenDOM); | 2014 this.rootDOM.appendChild(this.childrenDOM); |
2077 this.rootDOM.appendChild(this.buttonDOM); | 2015 this.rootDOM.appendChild(this.buttonDOM); |
2078 | 2016 |
2079 // Do the comment prefix node | 2017 // Do the comment prefix node |
2080 var cpn = this.parent.createGeneralNodeDOM("Comment Prefix",""+this.specification.id+"-commentprefix",this.parent); | 2018 var cpn = this.parent.createGeneralNodeDOM("Comment Prefix", "" + this.specification.id + "-commentprefix", this.parent); |
2081 cpn.rootDOM.removeChild(cpn.attributeDOM); | 2019 cpn.rootDOM.removeChild(cpn.attributeDOM); |
2082 var obj = { | 2020 var obj = { |
2083 root: document.createElement("div"), | 2021 root: document.createElement("div"), |
2084 input: document.createElement("input"), | 2022 input: document.createElement("input"), |
2085 parent: this, | 2023 parent: this, |
2086 handleEvent: function() | 2024 handleEvent: function () { |
2087 { | |
2088 this.parent.specification.commentBoxPrefix = event.currentTarget.value; | 2025 this.parent.specification.commentBoxPrefix = event.currentTarget.value; |
2089 } | 2026 } |
2090 } | 2027 } |
2091 cpn.children.push(obj); | 2028 cpn.children.push(obj); |
2092 cpn.childrenDOM.appendChild(obj.root); | 2029 cpn.childrenDOM.appendChild(obj.root); |
2093 obj.root.appendChild(obj.input); | 2030 obj.root.appendChild(obj.input); |
2094 obj.input.addEventListener("change",obj,false); | 2031 obj.input.addEventListener("change", obj, false); |
2095 obj.input.value = this.specification.commentBoxPrefix; | 2032 obj.input.value = this.specification.commentBoxPrefix; |
2096 this.childrenDOM.appendChild(cpn.rootDOM); | 2033 this.childrenDOM.appendChild(cpn.rootDOM); |
2097 this.children.push(cpn); | 2034 this.children.push(cpn); |
2098 | 2035 |
2099 // Now both before and after surveys | 2036 // Now both before and after surveys |
2100 if (this.specification.preTest == undefined){ | 2037 if (this.specification.preTest == undefined) { |
2101 this.specification.preTest = new specification.surveyNode(specification); | 2038 this.specification.preTest = new specification.surveyNode(specification); |
2102 this.specification.preTest.location = "pre"; | 2039 this.specification.preTest.location = "pre"; |
2103 } | 2040 } |
2104 if (this.specification.postTest == undefined){ | 2041 if (this.specification.postTest == undefined) { |
2105 this.specification.postTest = new specification.surveyNode(specification); | 2042 this.specification.postTest = new specification.surveyNode(specification); |
2106 this.specification.postTest.location = "post"; | 2043 this.specification.postTest.location = "post"; |
2107 } | 2044 } |
2108 var surveyBefore = new this.parent.surveyNode(this,this.specification.preTest,"Pre"); | 2045 var surveyBefore = new this.parent.surveyNode(this, this.specification.preTest, "Pre"); |
2109 var surveyAfter = new this.parent.surveyNode(this,this.specification.postTest,"Post"); | 2046 var surveyAfter = new this.parent.surveyNode(this, this.specification.postTest, "Post"); |
2110 this.children.push(surveyBefore); | 2047 this.children.push(surveyBefore); |
2111 this.children.push(surveyAfter); | 2048 this.children.push(surveyAfter); |
2112 this.childrenDOM.appendChild(surveyBefore.rootDOM); | 2049 this.childrenDOM.appendChild(surveyBefore.rootDOM); |
2113 this.childrenDOM.appendChild(surveyAfter.rootDOM); | 2050 this.childrenDOM.appendChild(surveyAfter.rootDOM); |
2114 | 2051 |
2115 // Build the attributes | 2052 // Build the attributes |
2116 var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); | 2053 var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); |
2117 for (var i=0; i<attributeList.length; i++) | 2054 for (var i = 0; i < attributeList.length; i++) { |
2118 { | |
2119 var attributeName = attributeList[i].getAttribute('name'); | 2055 var attributeName = attributeList[i].getAttribute('name'); |
2120 var attrObject = this.parent.convertAttributeToDOM(rootObject,attributeList[i]); | 2056 var attrObject = this.parent.convertAttributeToDOM(rootObject, attributeList[i]); |
2121 this.attributeDOM.appendChild(attrObject.holder); | 2057 this.attributeDOM.appendChild(attrObject.holder); |
2122 this.attributes.push(attrObject); | 2058 this.attributes.push(attrObject); |
2123 } | 2059 } |
2124 | 2060 |
2125 this.interfaces = []; | 2061 this.interfaces = []; |
2126 | 2062 |
2127 this.getAudioElements = function() { | 2063 this.getAudioElements = function () { |
2128 var array = []; | 2064 var array = []; |
2129 for (var i=0; i<this.children.length; i++) { | 2065 for (var i = 0; i < this.children.length; i++) { |
2130 if (this.children[i].type == "audioElementNode") { | 2066 if (this.children[i].type == "audioElementNode") { |
2131 array[array.length] = this.children[i]; | 2067 array[array.length] = this.children[i]; |
2132 } | 2068 } |
2133 } | 2069 } |
2134 return array; | 2070 return array; |
2135 } | 2071 } |
2136 | 2072 |
2137 this.redrawChildren = function() { | 2073 this.redrawChildren = function () { |
2138 this.childrenDOM.innerHTML = ""; | 2074 this.childrenDOM.innerHTML = ""; |
2139 for(var child of this.children) { | 2075 for (var child of this.children) { |
2140 this.childrenDOM.appendChild(child.rootDOM); | 2076 this.childrenDOM.appendChild(child.rootDOM); |
2141 } | 2077 } |
2142 } | 2078 } |
2143 | 2079 |
2144 this.audioElementNode = function(parent,rootObject) | 2080 this.audioElementNode = function (parent, rootObject) { |
2145 { | |
2146 this.type = "audioElementNode"; | 2081 this.type = "audioElementNode"; |
2147 this.rootDOM = document.createElement("div"); | 2082 this.rootDOM = document.createElement("div"); |
2148 this.titleDOM = document.createElement("span"); | 2083 this.titleDOM = document.createElement("span"); |
2149 this.attributeDOM = document.createElement("div"); | 2084 this.attributeDOM = document.createElement("div"); |
2150 this.attributes = []; | 2085 this.attributes = []; |
2168 | 2103 |
2169 this.rootDOM.appendChild(titleDiv); | 2104 this.rootDOM.appendChild(titleDiv); |
2170 this.rootDOM.appendChild(this.attributeDOM); | 2105 this.rootDOM.appendChild(this.attributeDOM); |
2171 this.rootDOM.appendChild(this.childrenDOM); | 2106 this.rootDOM.appendChild(this.childrenDOM); |
2172 this.rootDOM.appendChild(this.buttonDOM); | 2107 this.rootDOM.appendChild(this.buttonDOM); |
2173 | 2108 |
2174 // Build the attributes | 2109 // Build the attributes |
2175 var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); | 2110 var attributeList = this.schema.getAllElementsByTagName("xs:attribute"); |
2176 for (var i=0; i<attributeList.length; i++) | 2111 for (var i = 0; i < attributeList.length; i++) { |
2177 { | |
2178 var attributeName = attributeList[i].getAttribute('name'); | 2112 var attributeName = attributeList[i].getAttribute('name'); |
2179 var attrObject = this.parent.parent.convertAttributeToDOM(rootObject,attributeList[i]); | 2113 var attrObject = this.parent.parent.convertAttributeToDOM(rootObject, attributeList[i]); |
2180 this.attributeDOM.appendChild(attrObject.holder); | 2114 this.attributeDOM.appendChild(attrObject.holder); |
2181 this.attributes.push(attrObject); | 2115 this.attributes.push(attrObject); |
2182 } | 2116 } |
2183 | 2117 |
2184 this.deleteNode = { | 2118 this.deleteNode = { |
2185 root: document.createElement("button"), | 2119 root: document.createElement("button"), |
2186 parent: this, | 2120 parent: this, |
2187 handleEvent: function() | 2121 handleEvent: function () { |
2188 { | 2122 var i = this.parent.parent.specification.audioElements.findIndex(this.findNode, this); |
2189 var i = this.parent.parent.specification.audioElements.findIndex(this.findNode,this); | |
2190 if (i >= 0) { | 2123 if (i >= 0) { |
2191 var aeList = this.parent.parent.specification.audioElements; | 2124 var aeList = this.parent.parent.specification.audioElements; |
2192 if (i < aeList.length-1) { | 2125 if (i < aeList.length - 1) { |
2193 aeList = aeList.slice(0,i).concat(aeList.slice(i+1)); | 2126 aeList = aeList.slice(0, i).concat(aeList.slice(i + 1)); |
2194 } else { | 2127 } else { |
2195 aeList = aeList.slice(0,i); | 2128 aeList = aeList.slice(0, i); |
2196 } | 2129 } |
2197 } | 2130 } |
2198 i = this.parent.parent.children.findIndex(function(element,index,array){ | 2131 i = this.parent.parent.children.findIndex(function (element, index, array) { |
2199 if (element == this.parent) | 2132 if (element == this.parent) |
2200 return true; | 2133 return true; |
2201 else | 2134 else |
2202 return false; | 2135 return false; |
2203 },this); | 2136 }, this); |
2204 if (i >= 0) { | 2137 if (i >= 0) { |
2205 var childList = this.parent.children; | 2138 var childList = this.parent.children; |
2206 if (i < aeList.length-1) { | 2139 if (i < aeList.length - 1) { |
2207 childList = childList.slice(0,i).concat(childList.slice(i+1)); | 2140 childList = childList.slice(0, i).concat(childList.slice(i + 1)); |
2208 } else { | 2141 } else { |
2209 childList = childList.slice(0,i); | 2142 childList = childList.slice(0, i); |
2210 } | 2143 } |
2211 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM); | 2144 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM); |
2212 } | 2145 } |
2213 }, | 2146 }, |
2214 findNode: function(element,index,array){ | 2147 findNode: function (element, index, array) { |
2215 if (element == this.parent.specification) | 2148 if (element == this.parent.specification) |
2216 return true; | 2149 return true; |
2217 else | 2150 else |
2218 return false; | 2151 return false; |
2219 } | 2152 } |
2220 } | 2153 } |
2221 this.deleteNode.root.textContent = "Delete Entry"; | 2154 this.deleteNode.root.textContent = "Delete Entry"; |
2222 this.deleteNode.root.addEventListener("click",this.deleteNode,false); | 2155 this.deleteNode.root.addEventListener("click", this.deleteNode, false); |
2223 this.buttonDOM.appendChild(this.deleteNode.root); | 2156 this.buttonDOM.appendChild(this.deleteNode.root); |
2224 | 2157 |
2225 this.moveButtons = { | 2158 this.moveButtons = { |
2226 root_up: document.createElement("button"), | 2159 root_up: document.createElement("button"), |
2227 root_down: document.createElement("button"), | 2160 root_down: document.createElement("button"), |
2228 parent: this, | 2161 parent: this, |
2229 handleEvent: function(event) { | 2162 handleEvent: function (event) { |
2230 var index = this.parent.parent.getAudioElements().indexOf(this.parent); | 2163 var index = this.parent.parent.getAudioElements().indexOf(this.parent); |
2231 if (event.currentTarget.getAttribute("direction") == "up") { | 2164 if (event.currentTarget.getAttribute("direction") == "up") { |
2232 index = Math.max(index-1,0); | 2165 index = Math.max(index - 1, 0); |
2233 } else if (event.currentTarget.getAttribute("direction") == "down") { | 2166 } else if (event.currentTarget.getAttribute("direction") == "down") { |
2234 index = Math.min(index+1,this.parent.parent.getAudioElements().length-1); | 2167 index = Math.min(index + 1, this.parent.parent.getAudioElements().length - 1); |
2235 } | 2168 } |
2236 this.parent.moveToPosition(index); | 2169 this.parent.moveToPosition(index); |
2237 this.disable(index); | 2170 this.disable(index); |
2238 }, | 2171 }, |
2239 disable: function(index) { | 2172 disable: function (index) { |
2240 if (index == 0) { | 2173 if (index == 0) { |
2241 this.root_up.disabled = true; | 2174 this.root_up.disabled = true; |
2242 } else { | 2175 } else { |
2243 this.root_up.disabled = false; | 2176 this.root_up.disabled = false; |
2244 } | 2177 } |
2245 if (index == this.parent.parent.getAudioElements().length-1) { | 2178 if (index == this.parent.parent.getAudioElements().length - 1) { |
2246 this.root_down.disabled = true; | 2179 this.root_down.disabled = true; |
2247 } else { | 2180 } else { |
2248 this.root_down.disabled = false; | 2181 this.root_down.disabled = false; |
2249 } | 2182 } |
2250 } | 2183 } |
2251 } | 2184 } |
2252 this.moveButtons.root_up.setAttribute("direction","up"); | 2185 this.moveButtons.root_up.setAttribute("direction", "up"); |
2253 this.moveButtons.root_down.setAttribute("direction","down"); | 2186 this.moveButtons.root_down.setAttribute("direction", "down"); |
2254 this.moveButtons.root_up.addEventListener("click",this.moveButtons,false); | 2187 this.moveButtons.root_up.addEventListener("click", this.moveButtons, false); |
2255 this.moveButtons.root_down.addEventListener("click",this.moveButtons,false); | 2188 this.moveButtons.root_down.addEventListener("click", this.moveButtons, false); |
2256 this.moveButtons.root_up.textContent = "Move Up"; | 2189 this.moveButtons.root_up.textContent = "Move Up"; |
2257 this.moveButtons.root_down.textContent = "Move Down"; | 2190 this.moveButtons.root_down.textContent = "Move Down"; |
2258 this.buttonDOM.appendChild(this.moveButtons.root_up); | 2191 this.buttonDOM.appendChild(this.moveButtons.root_up); |
2259 this.buttonDOM.appendChild(this.moveButtons.root_down); | 2192 this.buttonDOM.appendChild(this.moveButtons.root_down); |
2260 | 2193 |
2261 this.moveToPosition = function(new_index) { | 2194 this.moveToPosition = function (new_index) { |
2262 | 2195 |
2263 // Get the zero-th Object | 2196 // Get the zero-th Object |
2264 var zero_object = this.parent.getAudioElements()[0]; | 2197 var zero_object = this.parent.getAudioElements()[0]; |
2265 var parent_children_root_index = this.parent.children.indexOf(zero_object); | 2198 var parent_children_root_index = this.parent.children.indexOf(zero_object); |
2266 // splice out the array for processing | 2199 // splice out the array for processing |
2267 var process_array = this.parent.children.splice(parent_children_root_index); | 2200 var process_array = this.parent.children.splice(parent_children_root_index); |
2268 | 2201 |
2269 | 2202 |
2270 new_index = Math.min(new_index, process_array.length); | 2203 new_index = Math.min(new_index, process_array.length); |
2271 var curr_index = process_array.findIndex(function(elem){ | 2204 var curr_index = process_array.findIndex(function (elem) { |
2272 if (elem == this) {return true;} else {return false;} | 2205 if (elem == this) { |
2273 },this); | 2206 return true; |
2274 | 2207 } else { |
2208 return false; | |
2209 } | |
2210 }, this); | |
2211 | |
2275 // Split at the current location to remove the node and shift all the children up | 2212 // Split at the current location to remove the node and shift all the children up |
2276 var tail = process_array.splice(curr_index+1); | 2213 var tail = process_array.splice(curr_index + 1); |
2277 process_array.pop(); | 2214 process_array.pop(); |
2278 process_array = process_array.concat(tail); | 2215 process_array = process_array.concat(tail); |
2279 | 2216 |
2280 //Split at the new location and insert the node | 2217 //Split at the new location and insert the node |
2281 tail = process_array.splice(new_index); | 2218 tail = process_array.splice(new_index); |
2282 process_array.push(this); | 2219 process_array.push(this); |
2283 process_array = process_array.concat(tail); | 2220 process_array = process_array.concat(tail); |
2284 | 2221 |
2285 // Re-attach to the parent.children | 2222 // Re-attach to the parent.children |
2286 this.parent.children = this.parent.children.concat(process_array); | 2223 this.parent.children = this.parent.children.concat(process_array); |
2287 | 2224 |
2288 // Re-build the specification | 2225 // Re-build the specification |
2289 this.parent.specification.audioElements = []; | 2226 this.parent.specification.audioElements = []; |
2290 for (var obj of process_array) { | 2227 for (var obj of process_array) { |
2291 this.parent.specification.audioElements.push(obj.specification); | 2228 this.parent.specification.audioElements.push(obj.specification); |
2292 } | 2229 } |
2293 this.parent.redrawChildren(); | 2230 this.parent.redrawChildren(); |
2294 | 2231 |
2295 process_array.forEach(function(obj,index){ | 2232 process_array.forEach(function (obj, index) { |
2296 obj.moveButtons.disable(index); | 2233 obj.moveButtons.disable(index); |
2297 }); | 2234 }); |
2298 | 2235 |
2299 } | 2236 } |
2300 } | 2237 } |
2301 | 2238 |
2302 this.commentQuestionNode = function(parent,rootObject) | 2239 this.commentQuestionNode = function (parent, rootObject) { |
2303 { | |
2304 this.type = "commentQuestionNode"; | 2240 this.type = "commentQuestionNode"; |
2305 this.rootDOM = document.createElement("div"); | 2241 this.rootDOM = document.createElement("div"); |
2306 this.titleDOM = document.createElement("span"); | 2242 this.titleDOM = document.createElement("span"); |
2307 this.attributeDOM = document.createElement("div"); | 2243 this.attributeDOM = document.createElement("div"); |
2308 this.attributes = []; | 2244 this.attributes = []; |
2326 | 2262 |
2327 this.rootDOM.appendChild(titleDiv); | 2263 this.rootDOM.appendChild(titleDiv); |
2328 this.rootDOM.appendChild(this.attributeDOM); | 2264 this.rootDOM.appendChild(this.attributeDOM); |
2329 this.rootDOM.appendChild(this.childrenDOM); | 2265 this.rootDOM.appendChild(this.childrenDOM); |
2330 this.rootDOM.appendChild(this.buttonDOM); | 2266 this.rootDOM.appendChild(this.buttonDOM); |
2331 | 2267 |
2332 } | 2268 } |
2333 | 2269 |
2334 // Build the components | 2270 // Build the components |
2335 if (this.specification.interfaces.length == 0) { | 2271 if (this.specification.interfaces.length == 0) { |
2336 this.specification.interfaces.push(new specification.interfaceNode(specification)); | 2272 this.specification.interfaces.push(new specification.interfaceNode(specification)); |
2337 } | 2273 } |
2338 for (var interfaceObj of this.specification.interfaces) | 2274 for (var interfaceObj of this.specification.interfaces) { |
2339 { | 2275 var newInterface = new this.parent.interfaceNode(this.parent, interfaceObj); |
2340 var newInterface = new this.parent.interfaceNode(this.parent,interfaceObj); | 2276 newInterface.build("Interface", "" + this.specification.id + "-interface", this.childrenDOM); |
2341 newInterface.build("Interface",""+this.specification.id+"-interface",this.childrenDOM); | |
2342 this.children.push(newInterface); | 2277 this.children.push(newInterface); |
2343 this.interfaces.push(newInterface); | 2278 this.interfaces.push(newInterface); |
2344 } | 2279 } |
2345 | 2280 |
2346 for (var elements of this.specification.audioElements) | 2281 for (var elements of this.specification.audioElements) { |
2347 { | 2282 var audioElementDOM = new this.audioElementNode(this, elements); |
2348 var audioElementDOM = new this.audioElementNode(this,elements); | |
2349 this.children.push(audioElementDOM); | 2283 this.children.push(audioElementDOM); |
2350 this.childrenDOM.appendChild(audioElementDOM.rootDOM); | 2284 this.childrenDOM.appendChild(audioElementDOM.rootDOM); |
2351 } | 2285 } |
2352 | 2286 |
2353 this.getAudioElements().forEach(function(elem){ | 2287 this.getAudioElements().forEach(function (elem) { |
2354 elem.moveButtons.disable(); | 2288 elem.moveButtons.disable(); |
2355 }); | 2289 }); |
2356 | 2290 |
2357 this.addInterface = { | 2291 this.addInterface = { |
2358 root: document.createElement("button"), | 2292 root: document.createElement("button"), |
2359 parent: this, | 2293 parent: this, |
2360 handleEvent: function() { | 2294 handleEvent: function () { |
2361 var InterfaceObj = new specification.interfaceNode(specification); | 2295 var InterfaceObj = new specification.interfaceNode(specification); |
2362 var newInterface = new this.parent.parent.interfaceNode(this.parent.parent,InterfaceObj); | 2296 var newInterface = new this.parent.parent.interfaceNode(this.parent.parent, InterfaceObj); |
2363 newInterface.build("Interface",""+this.parent.specification.id+"-interface",this.parent.childrenDOM); | 2297 newInterface.build("Interface", "" + this.parent.specification.id + "-interface", this.parent.childrenDOM); |
2364 this.parent.children.push(newInterface); | 2298 this.parent.children.push(newInterface); |
2365 this.parent.specification.interfaces.push(InterfaceObj); | 2299 this.parent.specification.interfaces.push(InterfaceObj); |
2366 this.parent.interfaces.push(newInterface); | 2300 this.parent.interfaces.push(newInterface); |
2367 } | 2301 } |
2368 } | 2302 } |
2369 this.addInterface.root.textContent = "Add Interface"; | 2303 this.addInterface.root.textContent = "Add Interface"; |
2370 this.addInterface.root.addEventListener("click",this.addInterface,false); | 2304 this.addInterface.root.addEventListener("click", this.addInterface, false); |
2371 this.buttonDOM.appendChild(this.addInterface.root); | 2305 this.buttonDOM.appendChild(this.addInterface.root); |
2372 | 2306 |
2373 this.addAudioElement = { | 2307 this.addAudioElement = { |
2374 root: document.createElement("button"), | 2308 root: document.createElement("button"), |
2375 parent: this, | 2309 parent: this, |
2376 handleEvent: function() { | 2310 handleEvent: function () { |
2377 var audioElementObject = new this.parent.specification.audioElementNode(specification); | 2311 var audioElementObject = new this.parent.specification.audioElementNode(specification); |
2378 var audioElementDOM = new this.parent.audioElementNode(this.parent,audioElementObject); | 2312 var audioElementDOM = new this.parent.audioElementNode(this.parent, audioElementObject); |
2379 this.parent.specification.audioElements.push(audioElementObject); | 2313 this.parent.specification.audioElements.push(audioElementObject); |
2380 this.parent.children.push(audioElementDOM); | 2314 this.parent.children.push(audioElementDOM); |
2381 this.parent.childrenDOM.appendChild(audioElementDOM.rootDOM); | 2315 this.parent.childrenDOM.appendChild(audioElementDOM.rootDOM); |
2382 } | 2316 } |
2383 } | 2317 } |
2384 this.addAudioElement.root.textContent = "Add Audio Element"; | 2318 this.addAudioElement.root.textContent = "Add Audio Element"; |
2385 this.addAudioElement.root.addEventListener("click",this.addAudioElement,false); | 2319 this.addAudioElement.root.addEventListener("click", this.addAudioElement, false); |
2386 this.buttonDOM.appendChild(this.addAudioElement.root); | 2320 this.buttonDOM.appendChild(this.addAudioElement.root); |
2387 } | 2321 } |
2388 } | 2322 } |