n@1170
|
1 var interfaceSpecs;
|
n@1170
|
2 var xmlHttp;
|
n@1170
|
3 var popupObject;
|
n@1170
|
4 var popupStateNodes;
|
n@1170
|
5 var specification;
|
n@1170
|
6 var convert;
|
n@1170
|
7 var attributeText;
|
n@1170
|
8
|
n@1170
|
9 // Firefox does not have an XMLDocument.prototype.getElementsByName
|
n@1170
|
10 // and there is no searchAll style command, this custom function will
|
n@1170
|
11 // search all children recusrively for the name. Used for XSD where all
|
n@1170
|
12 // element nodes must have a name and therefore can pull the schema node
|
n@1170
|
13 XMLDocument.prototype.getAllElementsByName = function(name)
|
n@1170
|
14 {
|
n@1170
|
15 name = String(name);
|
n@1170
|
16 var selected = this.documentElement.getAllElementsByName(name);
|
n@1170
|
17 return selected;
|
n@1170
|
18 }
|
n@1170
|
19
|
n@1170
|
20 Element.prototype.getAllElementsByName = function(name)
|
n@1170
|
21 {
|
n@1170
|
22 name = String(name);
|
n@1170
|
23 var selected = [];
|
n@1170
|
24 var node = this.firstElementChild;
|
n@1170
|
25 while(node != null)
|
n@1170
|
26 {
|
n@1170
|
27 if (node.getAttribute('name') == name)
|
n@1170
|
28 {
|
n@1170
|
29 selected.push(node);
|
n@1170
|
30 }
|
n@1170
|
31 if (node.childElementCount > 0)
|
n@1170
|
32 {
|
n@1170
|
33 selected = selected.concat(node.getAllElementsByName(name));
|
n@1170
|
34 }
|
n@1170
|
35 node = node.nextElementSibling;
|
n@1170
|
36 }
|
n@1170
|
37 return selected;
|
n@1170
|
38 }
|
n@1170
|
39
|
n@1170
|
40 XMLDocument.prototype.getAllElementsByTagName = function(name)
|
n@1170
|
41 {
|
n@1170
|
42 name = String(name);
|
n@1170
|
43 var selected = this.documentElement.getAllElementsByTagName(name);
|
n@1170
|
44 return selected;
|
n@1170
|
45 }
|
n@1170
|
46
|
n@1170
|
47 Element.prototype.getAllElementsByTagName = function(name)
|
n@1170
|
48 {
|
n@1170
|
49 name = String(name);
|
n@1170
|
50 var selected = [];
|
n@1170
|
51 var node = this.firstElementChild;
|
n@1170
|
52 while(node != null)
|
n@1170
|
53 {
|
n@1170
|
54 if (node.nodeName == name)
|
n@1170
|
55 {
|
n@1170
|
56 selected.push(node);
|
n@1170
|
57 }
|
n@1170
|
58 if (node.childElementCount > 0)
|
n@1170
|
59 {
|
n@1170
|
60 selected = selected.concat(node.getAllElementsByTagName(name));
|
n@1170
|
61 }
|
n@1170
|
62 node = node.nextElementSibling;
|
n@1170
|
63 }
|
n@1170
|
64 return selected;
|
n@1170
|
65 }
|
n@1170
|
66
|
n@1170
|
67 // Firefox does not have an XMLDocument.prototype.getElementsByName
|
n@1170
|
68 if (typeof XMLDocument.prototype.getElementsByName != "function") {
|
n@1170
|
69 XMLDocument.prototype.getElementsByName = function(name)
|
n@1170
|
70 {
|
n@1170
|
71 name = String(name);
|
n@1170
|
72 var node = this.documentElement.firstElementChild;
|
n@1170
|
73 var selected = [];
|
n@1170
|
74 while(node != null)
|
n@1170
|
75 {
|
n@1170
|
76 if (node.getAttribute('name') == name)
|
n@1170
|
77 {
|
n@1170
|
78 selected.push(node);
|
n@1170
|
79 }
|
n@1170
|
80 node = node.nextElementSibling;
|
n@1170
|
81 }
|
n@1170
|
82 return selected;
|
n@1170
|
83 }
|
n@1170
|
84 }
|
n@1170
|
85
|
n@1170
|
86 window.onload = function()
|
n@1170
|
87 {
|
n@1170
|
88 specification = new Specification();
|
n@1170
|
89 convert = new SpecificationToHTML();
|
n@1170
|
90 xmlHttp = new XMLHttpRequest();
|
n@1170
|
91 xmlHttp.open("GET","./interface-specs.xml",true);
|
n@1170
|
92 xmlHttp.onload = function()
|
n@1170
|
93 {
|
n@1170
|
94 var parse = new DOMParser();
|
n@1170
|
95 interfaceSpecs = parse.parseFromString(xmlHttp.response,'text/xml');
|
n@1170
|
96 buildPage();
|
n@1170
|
97 popupObject.postNode(popupStateNodes.state[0])
|
n@1170
|
98 }
|
n@1170
|
99 xmlHttp.send();
|
n@1170
|
100
|
n@1170
|
101 var xsdGet = new XMLHttpRequest();
|
n@1170
|
102 xsdGet.open("GET","../test-schema.xsd",true);
|
n@1170
|
103 xsdGet.onload = function()
|
n@1170
|
104 {
|
n@1170
|
105 var parse = new DOMParser();
|
n@1170
|
106 specification.schema = parse.parseFromString(xsdGet.response,'text/xml');;
|
n@1170
|
107 }
|
n@1170
|
108 xsdGet.send();
|
n@1170
|
109
|
n@1170
|
110 var jsonAttribute = new XMLHttpRequest();
|
n@1170
|
111 jsonAttribute.open("GET","./attributes.json",true);
|
n@1170
|
112 jsonAttribute.onload = function()
|
n@1170
|
113 {
|
n@1170
|
114 attributeText = JSON.parse(jsonAttribute.response)
|
n@1170
|
115 }
|
n@1170
|
116 jsonAttribute.send();
|
n@1170
|
117 }
|
n@1170
|
118
|
n@1170
|
119 function buildPage()
|
n@1170
|
120 {
|
n@1170
|
121 popupObject = new function() {
|
n@1170
|
122 this.object = document.getElementById("popupHolder");
|
n@1170
|
123 this.blanket = document.getElementById("blanket");
|
n@1170
|
124
|
n@1170
|
125 this.popupTitle = document.createElement("div");
|
n@1170
|
126 this.popupTitle.id = "popup-title-holder";
|
n@1170
|
127 this.popupTitle.align = "center";
|
n@1170
|
128 this.titleDOM = document.createElement("span");
|
n@1170
|
129 this.titleDOM.id = "popup-title";
|
n@1170
|
130 this.popupTitle.appendChild(this.titleDOM);
|
n@1170
|
131 this.object.appendChild(this.popupTitle);
|
n@1170
|
132
|
n@1170
|
133 this.popupContent = document.createElement("div");
|
n@1170
|
134 this.popupContent.id = "popup-content";
|
n@1170
|
135 this.object.appendChild(this.popupContent);
|
n@1170
|
136
|
n@1170
|
137 this.proceedButton = document.createElement("button");
|
n@1170
|
138 this.proceedButton.id = "popup-proceed";
|
n@1170
|
139 this.proceedButton.textContent = "Next";
|
n@1170
|
140 this.proceedButton.onclick = function()
|
n@1170
|
141 {
|
n@1170
|
142 popupObject.popupContent.innerHTML = null;
|
n@1170
|
143 popupObject.shownObject.continue();
|
n@1170
|
144 };
|
n@1170
|
145 this.object.appendChild(this.proceedButton);
|
n@1170
|
146
|
n@1170
|
147 this.shownObject;
|
n@1170
|
148
|
n@1170
|
149 this.resize = function()
|
n@1170
|
150 {
|
n@1170
|
151 var w = window.innerWidth;
|
n@1170
|
152 var h = window.innerHeight;
|
n@1170
|
153 this.object.style.left = Math.floor((w-750)/2) + 'px';
|
n@1170
|
154 this.object.style.top = Math.floor((h-500)/2) + 'px';
|
n@1170
|
155 }
|
n@1170
|
156
|
n@1170
|
157 this.show = function()
|
n@1170
|
158 {
|
n@1170
|
159 this.object.style.visibility = "visible";
|
n@1170
|
160 this.blanket.style.visibility = "visible";
|
n@1170
|
161 }
|
n@1170
|
162
|
n@1170
|
163 this.hide = function()
|
n@1170
|
164 {
|
n@1170
|
165 this.object.style.visibility = "hidden";
|
n@1170
|
166 this.blanket.style.visibility = "hidden";
|
n@1170
|
167 }
|
n@1170
|
168
|
n@1170
|
169 this.postNode = function(postObject)
|
n@1170
|
170 {
|
n@1170
|
171 this.show();
|
n@1170
|
172 //Passed object must have the following:
|
n@1170
|
173 // Title: text to show in the title
|
n@1170
|
174 // Content: HTML DOM to show on the page
|
n@1170
|
175 // On complete this HTML DOM is destroyed so make sure it is referenced elsewhere for processing
|
n@1170
|
176 this.titleDOM.textContent = postObject.title;
|
n@1170
|
177 this.popupContent.appendChild(postObject.content);
|
n@1170
|
178 this.shownObject = postObject;
|
n@1170
|
179 }
|
n@1170
|
180
|
n@1170
|
181 this.resize();
|
n@1170
|
182 this.hide();
|
n@1170
|
183 };
|
n@1170
|
184
|
n@1170
|
185 popupStateNodes = new function()
|
n@1170
|
186 {
|
n@1170
|
187 // This defines the several popup states wanted
|
n@1170
|
188 this.state = [];
|
n@1170
|
189 this.state[0] = new function()
|
n@1170
|
190 {
|
n@1170
|
191 this.title = "Welcome";
|
n@1170
|
192 this.content = document.createElement("div");
|
n@1170
|
193 this.content.id = "state-0";
|
n@1170
|
194 var span = document.createElement("span");
|
n@1170
|
195 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."
|
n@1170
|
196 this.content.appendChild(span);
|
n@1170
|
197 this.dragArea = document.createElement("div");
|
n@1173
|
198 this.dragArea.className = "drag-area";
|
n@1173
|
199 this.dragArea.id = "project-drop";
|
n@1170
|
200 this.content.appendChild(this.dragArea);
|
n@1173
|
201
|
n@1174
|
202 this.dragArea.addEventListener('dragover',function(e){
|
n@1173
|
203 e.stopPropagation();
|
n@1173
|
204 e.preventDefault();
|
n@1173
|
205 e.dataTransfer.dropEffect = 'copy';
|
n@1173
|
206 e.currentTarget.className = "drag-area drag-over";
|
n@1173
|
207 });
|
n@1173
|
208
|
n@1173
|
209 this.dragArea.addEventListener('dragexit',function(e){
|
n@1173
|
210 e.stopPropagation();
|
n@1173
|
211 e.preventDefault();
|
n@1173
|
212 e.dataTransfer.dropEffect = 'copy';
|
n@1173
|
213 e.currentTarget.className = "drag-area";
|
n@1173
|
214 });
|
n@1173
|
215
|
n@1173
|
216 this.dragArea.addEventListener('drop',function(e){
|
n@1173
|
217 e.stopPropagation();
|
n@1173
|
218 e.preventDefault();
|
n@1173
|
219 e.currentTarget.className = "drag-area drag-dropped";
|
n@1173
|
220 var files = e.dataTransfer.files[0];
|
n@1174
|
221 var reader = new FileReader();
|
n@1174
|
222 reader.onload = function(decoded) {
|
n@1174
|
223 var parse = new DOMParser();
|
n@1174
|
224 specification.decode(parse.parseFromString(decoded.target.result,'text/xml'));
|
n@1174
|
225 popupObject.hide();
|
n@1175
|
226 popupObject.popupContent.innerHTML = null;
|
n@1174
|
227 convert.convert(document.getElementById('content'));
|
n@1174
|
228 }
|
n@1174
|
229 reader.readAsText(files);
|
n@1173
|
230 });
|
n@1173
|
231
|
n@1170
|
232
|
n@1170
|
233 this.continue = function()
|
n@1170
|
234 {
|
n@1170
|
235 popupObject.postNode(popupStateNodes.state[1]);
|
n@1170
|
236 }
|
n@1170
|
237 }
|
n@1170
|
238 this.state[1] = new function()
|
n@1170
|
239 {
|
n@1170
|
240 this.title = "Select your interface";
|
n@1170
|
241 this.content = document.createElement("div");
|
n@1170
|
242 this.content.id = "state-1";
|
n@1170
|
243 var spnH = document.createElement('div');
|
n@1170
|
244 var span = document.createElement("span");
|
n@1170
|
245 span.textContent = "Please select your interface from the list shown below. This will define the various options which are available. This can later be changed.";
|
n@1170
|
246 spnH.appendChild(span);
|
n@1170
|
247 this.content.appendChild(spnH);
|
n@1170
|
248 this.select = document.createElement("select");
|
n@1170
|
249 this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].children;
|
n@1170
|
250 for (var i=0; i<this.testsXML.length; i++)
|
n@1170
|
251 {
|
n@1170
|
252 var option = document.createElement('option');
|
n@1170
|
253 option.value = this.testsXML[i].getAttribute('name');
|
n@1170
|
254 option.textContent = this.testsXML[i].getAttribute('name');
|
n@1170
|
255 this.select.appendChild(option);
|
n@1170
|
256 }
|
n@1170
|
257 this.content.appendChild(this.select);
|
n@1170
|
258 this.continue = function()
|
n@1170
|
259 {
|
n@1170
|
260 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0];
|
n@1170
|
261 specification.interface = testXML.getAttribute("interface");
|
n@1170
|
262 popupStateNodes.state[2].generate();
|
n@1170
|
263 popupObject.postNode(popupStateNodes.state[2]);
|
n@1170
|
264 }
|
n@1170
|
265 }
|
n@1170
|
266 this.state[2] = new function()
|
n@1170
|
267 {
|
n@1170
|
268 this.title = "Test Checks & Restrictions";
|
n@1170
|
269 this.content = document.createElement("div");
|
n@1170
|
270 this.content.id = "state-1";
|
n@1170
|
271 var spnH = document.createElement('div');
|
n@1170
|
272 var span = document.createElement("span");
|
n@1170
|
273 span.textContent = "Select your test checks and restrictions. Greyed out items are fixed by the test/interface and cannot be changed";
|
n@1170
|
274 spnH.appendChild(span);
|
n@1170
|
275 this.content.appendChild(spnH);
|
n@1170
|
276 var holder = document.createElement("div");
|
n@1170
|
277 this.options = [];
|
n@1170
|
278 this.testXML = null;
|
n@1170
|
279 this.interfaceXML = null;
|
n@1170
|
280 this.generate = function()
|
n@1170
|
281 {
|
n@1170
|
282 var interfaceName = popupStateNodes.state[1].select.value;
|
n@1170
|
283 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0];
|
n@1170
|
284 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
|
n@1170
|
285 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0];
|
n@1170
|
286 this.testXML = this.testXML.getAllElementsByTagName("checks");
|
n@1170
|
287 for (var i=0; i<this.interfaceXML.children.length; i++)
|
n@1170
|
288 {
|
n@1170
|
289 var interfaceNode = this.interfaceXML.children[i];
|
n@1170
|
290 var checkName = interfaceNode.getAttribute('name');
|
n@1170
|
291 var testNode
|
n@1170
|
292 if (this.testXML.length > 0)
|
n@1170
|
293 {
|
n@1170
|
294 testNode = this.testXML[0].getAllElementsByName(checkName);
|
n@1170
|
295 if(testNode.length != 0) {testNode = testNode[0];}
|
n@1170
|
296 else {testNode = undefined;}
|
n@1170
|
297 } else {
|
n@1170
|
298 testNode = undefined;
|
n@1170
|
299 }
|
n@1170
|
300 var optH = document.createElement('div');
|
n@1170
|
301 optH.className = "popup-checkbox";
|
n@1170
|
302 var checkbox = document.createElement('input');
|
n@1170
|
303 checkbox.type = "checkbox";
|
n@1170
|
304 var text = document.createElement('span');
|
n@1170
|
305 checkbox.setAttribute('name',checkName);
|
n@1170
|
306 if (interfaceNode.getAttribute('default') == 'on')
|
n@1170
|
307 {
|
n@1170
|
308 checkbox.checked = true;
|
n@1170
|
309 }
|
n@1170
|
310 if (interfaceNode.getAttribute('support') == "none")
|
n@1170
|
311 {
|
n@1170
|
312 checkbox.disabled = true;
|
n@1170
|
313 checkbox.checked = false;
|
n@1170
|
314 optH.className = "popup-checkbox disabled";
|
n@1170
|
315 } else if (interfaceNode.getAttribute('support') == "mandatory")
|
n@1170
|
316 {
|
n@1170
|
317 checkbox.disabled = true;
|
n@1170
|
318 checkbox.checked = true;
|
n@1170
|
319 optH.className = "popup-checkbox disabled";
|
n@1170
|
320 }
|
n@1170
|
321 if(testNode != undefined)
|
n@1170
|
322 {
|
n@1170
|
323 if (interfaceNode.getAttribute('default') == 'on')
|
n@1170
|
324 {
|
n@1170
|
325 checkbox.checked = true;
|
n@1170
|
326 }
|
n@1170
|
327 if (testNode.getAttribute('support') == "none")
|
n@1170
|
328 {
|
n@1170
|
329 checkbox.disabled = true;
|
n@1170
|
330 checkbox.checked = false;
|
n@1170
|
331 optH.className = "popup-checkbox disabled";
|
n@1170
|
332 }else if (interfaceNode.getAttribute('support') == "mandatory")
|
n@1170
|
333 {
|
n@1170
|
334 checkbox.disabled = true;
|
n@1170
|
335 checkbox.checked = true;
|
n@1170
|
336 optH.className = "popup-checkbox disabled";
|
n@1170
|
337 }
|
n@1170
|
338 }
|
n@1170
|
339 text.textContent = popupStateNodes.state[2].checkText.getAllElementsByName(checkName)[0].textContent;
|
n@1170
|
340 optH.appendChild(checkbox);
|
n@1170
|
341 optH.appendChild(text);
|
n@1170
|
342 this.options.push(optH);
|
n@1170
|
343 this.content.appendChild(optH);
|
n@1170
|
344 }
|
n@1170
|
345 }
|
n@1170
|
346 this.continue = function()
|
n@1170
|
347 {
|
n@1170
|
348 if (specification.interfaces == null)
|
n@1170
|
349 {
|
n@1170
|
350 specification.interfaces = new specification.interfaceNode();
|
n@1170
|
351 }
|
n@1170
|
352 for (var object of this.options)
|
n@1170
|
353 {
|
n@1170
|
354 var checkbox = object.children[0];
|
n@1170
|
355 if (checkbox.checked)
|
n@1170
|
356 {
|
n@1170
|
357 var option = {
|
n@1170
|
358 type: "check",
|
n@1170
|
359 name: checkbox.getAttribute('name')
|
n@1170
|
360 };
|
n@1170
|
361 specification.interfaces.options.push(option);
|
n@1170
|
362 }
|
n@1170
|
363 }
|
n@1170
|
364 popupStateNodes.state[3].generate();
|
n@1170
|
365 popupObject.postNode(popupStateNodes.state[3]);
|
n@1170
|
366 }
|
n@1170
|
367 }
|
n@1170
|
368 this.state[3] = new function()
|
n@1170
|
369 {
|
n@1170
|
370 this.title = "Test Metrics";
|
n@1170
|
371 this.content = document.createElement("div");
|
n@1170
|
372 this.content.id = "state-1";
|
n@1170
|
373 var spnH = document.createElement('div');
|
n@1170
|
374 var span = document.createElement("span");
|
n@1170
|
375 span.textContent = "Select which data points to include in the exported results XML. Some of this is required for certain post script analysis. See the documentation for further details";
|
n@1170
|
376 spnH.appendChild(span);
|
n@1170
|
377 this.content.appendChild(spnH);
|
n@1170
|
378 this.options = [];
|
n@1170
|
379 this.checkText;
|
n@1170
|
380 this.testXML;
|
n@1170
|
381 this.interfaceXML;
|
n@1170
|
382 this.generate = function()
|
n@1170
|
383 {
|
n@1170
|
384 var interfaceName = popupStateNodes.state[1].select.value;
|
n@1170
|
385 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0];
|
n@1170
|
386 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
|
n@1170
|
387 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0];
|
n@1170
|
388 this.testXML = this.testXML.getAllElementsByTagName("metrics");
|
n@1170
|
389 for (var i=0; i<this.interfaceXML.children.length; i++)
|
n@1170
|
390 {
|
n@1170
|
391 var interfaceNode = this.interfaceXML.children[i];
|
n@1170
|
392 var checkName = interfaceNode.getAttribute('name');
|
n@1170
|
393 var testNode
|
n@1170
|
394 if (this.testXML.length > 0)
|
n@1170
|
395 {
|
n@1170
|
396 testNode = this.testXML[0].getAllElementsByName(checkName);
|
n@1170
|
397 if(testNode.length != 0) {testNode = testNode[0];}
|
n@1170
|
398 else {testNode = undefined;}
|
n@1170
|
399 } else {
|
n@1170
|
400 testNode = undefined;
|
n@1170
|
401 }
|
n@1170
|
402 var optH = document.createElement('div');
|
n@1170
|
403 optH.className = "popup-checkbox";
|
n@1170
|
404 var checkbox = document.createElement('input');
|
n@1170
|
405 checkbox.type = "checkbox";
|
n@1170
|
406 var text = document.createElement('span');
|
n@1170
|
407 checkbox.setAttribute('name',checkName);
|
n@1170
|
408 if (interfaceNode.getAttribute('default') == 'on')
|
n@1170
|
409 {
|
n@1170
|
410 checkbox.checked = true;
|
n@1170
|
411 }
|
n@1170
|
412 if (interfaceNode.getAttribute('support') == "none")
|
n@1170
|
413 {
|
n@1170
|
414 checkbox.disabled = true;
|
n@1170
|
415 checkbox.checked = false;
|
n@1170
|
416 optH.className = "popup-checkbox disabled";
|
n@1170
|
417 } else if (interfaceNode.getAttribute('support') == "mandatory")
|
n@1170
|
418 {
|
n@1170
|
419 checkbox.disabled = true;
|
n@1170
|
420 checkbox.checked = true;
|
n@1170
|
421 optH.className = "popup-checkbox disabled";
|
n@1170
|
422 }
|
n@1170
|
423 if(testNode != undefined)
|
n@1170
|
424 {
|
n@1170
|
425 if (interfaceNode.getAttribute('default') == 'on')
|
n@1170
|
426 {
|
n@1170
|
427 checkbox.checked = true;
|
n@1170
|
428 }
|
n@1170
|
429 if (testNode.getAttribute('support') == "none")
|
n@1170
|
430 {
|
n@1170
|
431 checkbox.disabled = true;
|
n@1170
|
432 checkbox.checked = false;
|
n@1170
|
433 optH.className = "popup-checkbox disabled";
|
n@1170
|
434 }else if (interfaceNode.getAttribute('support') == "mandatory")
|
n@1170
|
435 {
|
n@1170
|
436 checkbox.disabled = true;
|
n@1170
|
437 checkbox.checked = true;
|
n@1170
|
438 optH.className = "popup-checkbox disabled";
|
n@1170
|
439 }
|
n@1170
|
440 }
|
n@1170
|
441 text.textContent = popupStateNodes.state[3].checkText.getAllElementsByName(checkName)[0].textContent;
|
n@1170
|
442 optH.appendChild(checkbox);
|
n@1170
|
443 optH.appendChild(text);
|
n@1170
|
444 this.options.push(optH);
|
n@1170
|
445 this.content.appendChild(optH);
|
n@1170
|
446 }
|
n@1170
|
447 }
|
n@1170
|
448 this.continue = function()
|
n@1170
|
449 {
|
n@1170
|
450 if (specification.metrics == null) {
|
n@1170
|
451 specification.metrics = new specification.metricNode();
|
n@1170
|
452 }
|
n@1170
|
453 for (var object of this.options)
|
n@1170
|
454 {
|
n@1170
|
455 var checkbox = object.children[0];
|
n@1170
|
456 if (checkbox.checked)
|
n@1170
|
457 {
|
n@1170
|
458 specification.metrics.enabled.push(checkbox.getAttribute('name'));
|
n@1170
|
459 }
|
n@1170
|
460 }
|
n@1170
|
461 popupStateNodes.state[4].generate();
|
n@1170
|
462 popupObject.postNode(popupStateNodes.state[4]);
|
n@1170
|
463 }
|
n@1170
|
464 }
|
n@1170
|
465 this.state[4] = new function()
|
n@1170
|
466 {
|
n@1170
|
467 this.title = "Test Visuals";
|
n@1170
|
468 this.content = document.createElement("div");
|
n@1170
|
469 this.content.id = "state-1";
|
n@1170
|
470 var spnH = document.createElement('div');
|
n@1170
|
471 var span = document.createElement("span");
|
n@1170
|
472 span.textContent = "You can display extra visual content with your interface for the test user to interact with. Select from the available options below. Greyed out options are unavailable for your selected interface";
|
n@1170
|
473 spnH.appendChild(span);
|
n@1170
|
474 this.content.appendChild(spnH);
|
n@1170
|
475 this.options = [];
|
n@1170
|
476 this.checkText;
|
n@1170
|
477 this.testXML;
|
n@1170
|
478 this.interfaceXML;
|
n@1170
|
479 this.generate = function()
|
n@1170
|
480 {
|
n@1170
|
481 var interfaceName = popupStateNodes.state[1].select.value;
|
n@1170
|
482 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0];
|
n@1170
|
483 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
|
n@1170
|
484 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0];
|
n@1170
|
485 this.testXML = this.testXML.getAllElementsByTagName("metrics");
|
n@1170
|
486 for (var i=0; i<this.interfaceXML.children.length; i++)
|
n@1170
|
487 {
|
n@1170
|
488 var interfaceNode = this.interfaceXML.children[i];
|
n@1170
|
489 var checkName = interfaceNode.getAttribute('name');
|
n@1170
|
490 var testNode
|
n@1170
|
491 if (this.testXML.length > 0)
|
n@1170
|
492 {
|
n@1170
|
493 testNode = this.testXML[0].getAllElementsByName(checkName);
|
n@1170
|
494 if(testNode.length != 0) {testNode = testNode[0];}
|
n@1170
|
495 else {testNode = undefined;}
|
n@1170
|
496 } else {
|
n@1170
|
497 testNode = undefined;
|
n@1170
|
498 }
|
n@1170
|
499 var optH = document.createElement('div');
|
n@1170
|
500 optH.className = "popup-checkbox";
|
n@1170
|
501 var checkbox = document.createElement('input');
|
n@1170
|
502 checkbox.type = "checkbox";
|
n@1170
|
503 var text = document.createElement('span');
|
n@1170
|
504 checkbox.setAttribute('name',checkName);
|
n@1170
|
505 if (interfaceNode.getAttribute('default') == 'on')
|
n@1170
|
506 {
|
n@1170
|
507 checkbox.checked = true;
|
n@1170
|
508 }
|
n@1170
|
509 if (interfaceNode.getAttribute('support') == "none")
|
n@1170
|
510 {
|
n@1170
|
511 checkbox.disabled = true;
|
n@1170
|
512 checkbox.checked = false;
|
n@1170
|
513 optH.className = "popup-checkbox disabled";
|
n@1170
|
514 } else if (interfaceNode.getAttribute('support') == "mandatory")
|
n@1170
|
515 {
|
n@1170
|
516 checkbox.disabled = true;
|
n@1170
|
517 checkbox.checked = true;
|
n@1170
|
518 optH.className = "popup-checkbox disabled";
|
n@1170
|
519 }
|
n@1170
|
520 if(testNode != undefined)
|
n@1170
|
521 {
|
n@1170
|
522 if (interfaceNode.getAttribute('default') == 'on')
|
n@1170
|
523 {
|
n@1170
|
524 checkbox.checked = true;
|
n@1170
|
525 }
|
n@1170
|
526 if (testNode.getAttribute('support') == "none")
|
n@1170
|
527 {
|
n@1170
|
528 checkbox.disabled = true;
|
n@1170
|
529 checkbox.checked = false;
|
n@1170
|
530 optH.className = "popup-checkbox disabled";
|
n@1170
|
531 }else if (interfaceNode.getAttribute('support') == "mandatory")
|
n@1170
|
532 {
|
n@1170
|
533 checkbox.disabled = true;
|
n@1170
|
534 checkbox.checked = true;
|
n@1170
|
535 optH.className = "popup-checkbox disabled";
|
n@1170
|
536 }
|
n@1170
|
537 }
|
n@1170
|
538 text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent;
|
n@1170
|
539 optH.appendChild(checkbox);
|
n@1170
|
540 optH.appendChild(text);
|
n@1170
|
541 this.options.push(optH);
|
n@1170
|
542 this.content.appendChild(optH);
|
n@1170
|
543 }
|
n@1170
|
544 }
|
n@1170
|
545 this.continue = function()
|
n@1170
|
546 {
|
n@1170
|
547 if (specification.interfaces == null)
|
n@1170
|
548 {
|
n@1170
|
549 specification.interfaces = new specification.interfaceNode();
|
n@1170
|
550 }
|
n@1170
|
551 for (var object of this.options)
|
n@1170
|
552 {
|
n@1170
|
553 var checkbox = object.children[0];
|
n@1170
|
554 if (checkbox.checked)
|
n@1170
|
555 {
|
n@1170
|
556 var option = {
|
n@1170
|
557 type: "show",
|
n@1170
|
558 name: checkbox.getAttribute('name')
|
n@1170
|
559 };
|
n@1170
|
560 specification.interfaces.options.push(option);
|
n@1170
|
561 }
|
n@1170
|
562 }
|
n@1170
|
563 popupObject.hide();
|
n@1170
|
564 convert.convert(document.getElementById('content'));
|
n@1170
|
565 }
|
n@1170
|
566 }
|
n@1170
|
567 this.state[5] = new function() {
|
n@1170
|
568 this.title = "Add/Edit Survey Element";
|
n@1170
|
569 this.content = document.createElement("div");
|
n@1170
|
570 this.content.id = "state-1";
|
n@1170
|
571 var spnH = document.createElement('div');
|
n@1170
|
572 var span = document.createElement("span");
|
n@1170
|
573 span.textContent = "You can configure your survey element here. Press 'Continue' to complete your changes.";
|
n@1170
|
574 spnH.appendChild(span);
|
n@1170
|
575 this.content.appendChild(spnH);
|
n@1170
|
576 this.dynamic = document.createElement("div");
|
n@1170
|
577 this.option = null;
|
n@1170
|
578 this.parent = null;
|
n@1175
|
579 this.optionLists = [];
|
n@1170
|
580 var select = document.createElement("select");
|
n@1170
|
581 select.setAttribute("name","type");
|
n@1170
|
582 select.addEventListener("change",this,false);
|
n@1170
|
583 this.content.appendChild(select);
|
n@1170
|
584 this.content.appendChild(this.dynamic);
|
n@1170
|
585 this.generate = function(option, parent)
|
n@1170
|
586 {
|
n@1170
|
587 this.option = option;
|
n@1170
|
588 this.parent = parent;
|
n@1170
|
589 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration");
|
n@1170
|
590 for (var i=0; i<optionList.length; i++)
|
n@1170
|
591 {
|
n@1170
|
592 var selectOption = document.createElement("option");
|
n@1170
|
593 selectOption.value = optionList[i].getAttribute("value");
|
n@1170
|
594 selectOption.textContent = selectOption.value;
|
n@1170
|
595 select.appendChild(selectOption);
|
n@1170
|
596 }
|
n@1170
|
597 if (this.option.type != undefined){
|
n@1170
|
598 select.value = this.option.type
|
n@1170
|
599 } else {
|
n@1170
|
600 select.value = "statement";
|
n@1170
|
601 this.option.type = "statement";
|
n@1170
|
602 }
|
n@1170
|
603
|
n@1170
|
604 this.dynamic.innerHTML = null;
|
n@1170
|
605 var statement = document.createElement("div");
|
n@1170
|
606 var statementText = document.createElement("span");
|
n@1170
|
607 var statementEntry = document.createElement("textarea");
|
n@1170
|
608 statement.appendChild(statementText);
|
n@1170
|
609 statement.appendChild(statementEntry);
|
n@1170
|
610 statementText.textContent = "Statement/Question";
|
n@1170
|
611 statementEntry.addEventListener("change",this,false);
|
n@1170
|
612 statementEntry.setAttribute("name","statement");
|
n@1170
|
613 statementEntry.value = this.option.statement;
|
n@1170
|
614 this.dynamic.appendChild(statement);
|
n@1175
|
615
|
n@1175
|
616 var id = document.createElement("div");
|
n@1175
|
617 var idText = document.createElement("span");
|
n@1175
|
618 var idEntry = document.createElement("input");
|
n@1175
|
619 id.appendChild(idText);
|
n@1175
|
620 id.appendChild(idEntry);
|
n@1175
|
621 idText.textContent = "ID: ";
|
n@1175
|
622 idEntry.addEventListener("change",this,false);
|
n@1175
|
623 idEntry.setAttribute("name","id");
|
n@1175
|
624 idEntry.value = this.option.id;
|
n@1175
|
625
|
n@1170
|
626 switch(this.option.type)
|
n@1170
|
627 {
|
n@1170
|
628 case "statement":
|
n@1170
|
629 break;
|
n@1170
|
630 case "question":
|
n@1175
|
631 this.dynamic.appendChild(id);
|
n@1170
|
632 var boxsizeSelect = document.createElement("select");
|
n@1170
|
633 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration");
|
n@1170
|
634 for (var i=0; i<optionList.length; i++)
|
n@1170
|
635 {
|
n@1170
|
636 var selectOption = document.createElement("option");
|
n@1170
|
637 selectOption.value = optionList[i].getAttribute("value");
|
n@1170
|
638 selectOption.textContent = selectOption.value;
|
n@1170
|
639 boxsizeSelect.appendChild(selectOption);
|
n@1170
|
640 }
|
n@1170
|
641 if(this.option.boxsize != undefined) {
|
n@1170
|
642 boxsizeSelect.value = this.option.boxsize;
|
n@1170
|
643 } else {
|
n@1170
|
644 boxsizeSelect.value = "normal";
|
n@1170
|
645 this.option.boxsize = "normal";
|
n@1170
|
646 }
|
n@1170
|
647 boxsizeSelect.setAttribute("name","boxsize");
|
n@1170
|
648 boxsizeSelect.addEventListener("change",this,false);
|
n@1170
|
649 var boxsize = document.createElement("div");
|
n@1170
|
650 var boxsizeText = document.createElement("span");
|
n@1170
|
651 boxsizeText.textContent = "Entry Size: ";
|
n@1170
|
652 boxsize.appendChild(boxsizeText);
|
n@1170
|
653 boxsize.appendChild(boxsizeSelect);
|
n@1170
|
654 this.dynamic.appendChild(boxsize);
|
n@1170
|
655
|
n@1170
|
656 var mandatory = document.createElement("div");
|
n@1170
|
657 var mandatoryInput = document.createElement("input");
|
n@1170
|
658 var mandatoryText = document.createElement("span");
|
n@1170
|
659 mandatoryText.textContent = "Mandatory: ";
|
n@1170
|
660 mandatory.appendChild(mandatoryText);
|
n@1170
|
661 mandatory.appendChild(mandatoryInput);
|
n@1170
|
662 mandatoryInput.type = "checkbox";
|
n@1170
|
663 if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;}
|
n@1170
|
664 mandatoryInput.setAttribute("name","mandatory");
|
n@1170
|
665 mandatoryInput.addEventListener("change",this,false);
|
n@1175
|
666 this.dynamic.appendChild(mandatory);
|
n@1175
|
667 break;
|
n@1175
|
668 case "number":
|
n@1175
|
669 this.dynamic.appendChild(id);
|
n@1175
|
670
|
n@1175
|
671 var mandatory = document.createElement("div");
|
n@1175
|
672 var mandatoryInput = document.createElement("input");
|
n@1175
|
673 var mandatoryText = document.createElement("span");
|
n@1175
|
674 mandatoryText.textContent = "Mandatory: ";
|
n@1170
|
675 mandatory.appendChild(mandatoryText);
|
n@1170
|
676 mandatory.appendChild(mandatoryInput);
|
n@1175
|
677 mandatoryInput.type = "checkbox";
|
n@1175
|
678 if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;}
|
n@1175
|
679 mandatoryInput.setAttribute("name","mandatory");
|
n@1175
|
680 mandatoryInput.addEventListener("change",this,false);
|
n@1170
|
681 this.dynamic.appendChild(mandatory);
|
n@1175
|
682
|
n@1175
|
683 var minimum = document.createElement("div");
|
n@1175
|
684 var minimumEntry = document.createElement("input");
|
n@1175
|
685 var minimumText = document.createElement("span");
|
n@1175
|
686 minimumText.textContent = "Minimum: ";
|
n@1175
|
687 minimum.appendChild(minimumText);
|
n@1175
|
688 minimum.appendChild(minimumEntry);
|
n@1175
|
689 minimumEntry.type = "number";
|
n@1175
|
690 minimumEntry.setAttribute("name","min");
|
n@1175
|
691 minimumEntry.addEventListener("change",this,false);
|
n@1175
|
692 minimumEntry.value = this.option.min;
|
n@1175
|
693 this.dynamic.appendChild(minimum);
|
n@1175
|
694
|
n@1175
|
695 var maximum = document.createElement("div");
|
n@1175
|
696 var maximumEntry = document.createElement("input");
|
n@1175
|
697 var maximumText = document.createElement("span");
|
n@1175
|
698 maximumText.textContent = "Maximum: ";
|
n@1175
|
699 maximum.appendChild(maximumText);
|
n@1175
|
700 maximum.appendChild(maximumEntry);
|
n@1175
|
701 maximumEntry.type = "number";
|
n@1175
|
702 maximumEntry.setAttribute("name","max");
|
n@1175
|
703 maximumEntry.addEventListener("change",this,false);
|
n@1175
|
704 maximumEntry.value = this.option.max;
|
n@1175
|
705 this.dynamic.appendChild(maximum);
|
n@1170
|
706 break;
|
n@1175
|
707 case "checkbox":
|
n@1175
|
708 case "radio":
|
n@1175
|
709 this.dynamic.appendChild(id);
|
n@1175
|
710 var optionHolder = document.createElement("div");
|
n@1175
|
711 optionHolder.className = 'node';
|
n@1175
|
712 optionHolder.id = 'popup-option-holder';
|
n@1175
|
713 var optionObject = function(parent,option) {
|
n@1175
|
714 this.rootDOM = document.createElement("div");
|
n@1175
|
715 this.rootDOM.className = "popup-option-entry";
|
n@1175
|
716 this.inputName = document.createElement("input");
|
n@1175
|
717 this.inputName.setAttribute("name","name");
|
n@1175
|
718 this.inputLabel = document.createElement("input");
|
n@1175
|
719 this.inputLabel.setAttribute("name","text");
|
n@1175
|
720 this.specification = option;
|
n@1175
|
721 this.parent = parent;
|
n@1175
|
722 this.handleEvent = function()
|
n@1175
|
723 {
|
n@1175
|
724 var target = event.currentTarget.getAttribute("name");
|
n@1175
|
725 eval("this.specification."+target+" = event.currentTarget.value");
|
n@1175
|
726 };
|
n@1175
|
727
|
n@1175
|
728 var nameText = document.createElement("span");
|
n@1175
|
729 nameText.textContent = "Name: ";
|
n@1175
|
730 var labelText = document.createElement("span");
|
n@1175
|
731 labelText.textContent = "Label: ";
|
n@1175
|
732 this.rootDOM.appendChild(nameText);
|
n@1175
|
733 this.rootDOM.appendChild(this.inputName);
|
n@1175
|
734 this.rootDOM.appendChild(labelText);
|
n@1175
|
735 this.rootDOM.appendChild(this.inputLabel);
|
n@1175
|
736 this.inputName.addEventListener("change",this,false);
|
n@1175
|
737 this.inputLabel.addEventListener("change",this,false);
|
n@1175
|
738 this.inputName.value = this.specification.name;
|
n@1175
|
739 this.inputLabel.value = this.specification.text;
|
n@1175
|
740
|
n@1175
|
741 this.deleteEntry = {
|
n@1175
|
742 root: document.createElement("button"),
|
n@1175
|
743 parent: this,
|
n@1175
|
744 handleEvent: function() {
|
n@1175
|
745 document.getElementById("popup-option-holder").removeChild(this.parent.rootDOM);
|
n@1175
|
746 var index = this.parent.parent.option.options.findIndex(function(element,index,array){
|
n@1175
|
747 if (element == this.parent.specification)
|
n@1175
|
748 return true;
|
n@1175
|
749 else
|
n@1175
|
750 return false;
|
n@1175
|
751 },this);
|
n@1175
|
752 var optionList = this.parent.parent.option.options;
|
n@1175
|
753 if (index == optionList.length-1) {
|
n@1175
|
754 optionList = optionList.slice(0,index);
|
n@1175
|
755 } else {
|
n@1175
|
756 optionList = optionList.slice(0,index).concat(optionList.slice(index+1));
|
n@1175
|
757 }
|
n@1175
|
758 this.parent.parent.option.options = optionList;
|
n@1175
|
759 }
|
n@1175
|
760 };
|
n@1175
|
761 this.deleteEntry.root.textContent = "Delete Option";
|
n@1175
|
762 this.deleteEntry.root.addEventListener("click",this.deleteEntry,false);
|
n@1175
|
763 this.rootDOM.appendChild(this.deleteEntry.root);
|
n@1175
|
764 }
|
n@1175
|
765 for (var i=0; i<this.option.options.length; i++)
|
n@1175
|
766 {
|
n@1175
|
767 var obj = new optionObject(this,this.option.options[i]);
|
n@1175
|
768 this.optionLists.push(obj);
|
n@1175
|
769 optionHolder.appendChild(obj.rootDOM);
|
n@1175
|
770 }
|
n@1175
|
771 this.dynamic.appendChild(optionHolder);
|
n@1170
|
772 }
|
n@1170
|
773 }
|
n@1170
|
774 this.handleEvent = function()
|
n@1170
|
775 {
|
n@1170
|
776 var name = event.currentTarget.getAttribute("name");
|
n@1170
|
777 switch(name) {
|
n@1170
|
778 case "type":
|
n@1170
|
779 // If type has changed, we may need to rebuild the entire state node
|
n@1170
|
780 if (event.currentTarget.value != this.option.name)
|
n@1170
|
781 {
|
n@1170
|
782 this.option.type = event.currentTarget.value;
|
n@1170
|
783 this.generate(this.option,this.parent);
|
n@1170
|
784 }
|
n@1170
|
785 break;
|
n@1170
|
786 case "mandatory":
|
n@1170
|
787 this.option.mandatory = event.currentTarget.checked;
|
n@1170
|
788 break;
|
n@1170
|
789 case "boxsize":
|
n@1170
|
790 this.option.boxsize = event.currentTarget.value;
|
n@1170
|
791 break;
|
n@1170
|
792 case "statement":
|
n@1170
|
793 this.option.statement = event.currentTarget.value;
|
n@1170
|
794 break;
|
n@1170
|
795 }
|
n@1170
|
796 }
|
n@1170
|
797 this.continue = function()
|
n@1170
|
798 {
|
n@1175
|
799 if (this.parent.type == "surveyNode")
|
n@1175
|
800 {
|
n@1175
|
801 var newNode = new this.parent.surveyEntryNode(this.parent,this.option);
|
n@1175
|
802 this.parent.children.push(newNode);
|
n@1175
|
803 this.parent.childrenDOM.appendChild(newNode.rootDOM);
|
n@1175
|
804 } else if (this.parent.type == "surveyEntryNode") {
|
n@1175
|
805 this.parent.build();
|
n@1175
|
806 }
|
n@1170
|
807 popupObject.hide();
|
n@1170
|
808 }
|
n@1170
|
809 }
|
n@1170
|
810 }
|
n@1170
|
811 }
|
n@1170
|
812
|
n@1170
|
813 function SpecificationToHTML()
|
n@1170
|
814 {
|
n@1170
|
815 // This takes the specification node and converts it to an on-page HTML object
|
n@1170
|
816 // Each Specification Node is given its own JS object which listens to the XSD for instant verification
|
n@1170
|
817 // Once generated, it directly binds into the specification object to update with changes
|
n@1170
|
818 // Fixed DOM entries
|
n@1170
|
819 this.injectDOM;
|
n@1170
|
820 this.setupDOM;
|
n@1170
|
821 this.pages = [];
|
n@1170
|
822
|
n@1170
|
823 // Self-contained generators
|
n@1170
|
824 this.createGeneralNodeDOM = function(name,id,parent)
|
n@1170
|
825 {
|
n@1175
|
826 this.type = name;
|
n@1170
|
827 var root = document.createElement('div');
|
n@1170
|
828 root.id = id;
|
n@1170
|
829 root.className = "node";
|
n@1170
|
830
|
n@1170
|
831 var titleDiv = document.createElement('div');
|
n@1170
|
832 titleDiv.className = "node-title";
|
n@1170
|
833 var title = document.createElement('span');
|
n@1170
|
834 title.className = "node-title";
|
n@1170
|
835 title.textContent = name;
|
n@1170
|
836 titleDiv.appendChild(title);
|
n@1170
|
837
|
n@1170
|
838 var attributeDiv = document.createElement('div');
|
n@1170
|
839 attributeDiv.className = "node-attributes";
|
n@1170
|
840
|
n@1170
|
841 var childrenDiv = document.createElement('div');
|
n@1170
|
842 childrenDiv.className = "node-children";
|
n@1170
|
843
|
n@1170
|
844 var buttonsDiv = document.createElement('div');
|
n@1170
|
845 buttonsDiv.className = "node-buttons";
|
n@1170
|
846
|
n@1170
|
847 root.appendChild(titleDiv);
|
n@1170
|
848 root.appendChild(attributeDiv);
|
n@1170
|
849 root.appendChild(childrenDiv);
|
n@1170
|
850 root.appendChild(buttonsDiv);
|
n@1170
|
851
|
n@1170
|
852 var obj = {
|
n@1170
|
853 rootDOM: root,
|
n@1170
|
854 titleDOM: title,
|
n@1170
|
855 attributeDOM: attributeDiv,
|
n@1170
|
856 attributes: [],
|
n@1170
|
857 childrenDOM: childrenDiv,
|
n@1170
|
858 children: [],
|
n@1170
|
859 buttonDOM: buttonsDiv,
|
n@1170
|
860 parent: parent
|
n@1170
|
861 }
|
n@1170
|
862 return obj;
|
n@1170
|
863 }
|
n@1170
|
864
|
n@1170
|
865 this.convertAttributeToDOM = function(node,schema)
|
n@1170
|
866 {
|
n@1170
|
867 // This takes an attribute schema node and returns an object with the input node and any bindings
|
n@1170
|
868 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined)
|
n@1170
|
869 {
|
n@1170
|
870 schema = specification.schema.getAllElementsByName(schema.getAttribute('ref'))[0];
|
n@1170
|
871 }
|
n@1170
|
872 var obj = new function()
|
n@1170
|
873 {
|
n@1170
|
874 this.input;
|
n@1170
|
875 this.name;
|
n@1170
|
876 this.owner;
|
n@1170
|
877 this.holder;
|
n@1170
|
878
|
n@1170
|
879 this.name = schema.getAttribute('name');
|
n@1170
|
880 this.default = schema.getAttribute('default');
|
n@1170
|
881 this.dataType = schema.getAttribute('type');
|
n@1170
|
882 if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);}
|
n@1170
|
883 else {this.dataType = "string";}
|
n@1170
|
884 var minVar = undefined;
|
n@1170
|
885 var maxVar = undefined;
|
n@1170
|
886 switch(this.dataType)
|
n@1170
|
887 {
|
n@1170
|
888 case "negativeInteger":
|
n@1170
|
889 maxVar = -1;
|
n@1170
|
890 break;
|
n@1170
|
891 case "positiveInteger":
|
n@1170
|
892 minVar = 1;
|
n@1170
|
893 break;
|
n@1170
|
894 case "nonNegativeInteger":
|
n@1170
|
895 minVar = 0;
|
n@1170
|
896 break;
|
n@1170
|
897 case "nonPositiveInteger":
|
n@1170
|
898 maxVar = 0;
|
n@1170
|
899 break;
|
n@1170
|
900 case "byte":
|
n@1170
|
901 minVar = 0;
|
n@1170
|
902 maxVar = 256;
|
n@1170
|
903 break;
|
n@1170
|
904 case "short":
|
n@1170
|
905 minVar = 0;
|
n@1170
|
906 maxVar = 65536;
|
n@1170
|
907 break;
|
n@1170
|
908 default:
|
n@1170
|
909 break;
|
n@1170
|
910 }
|
n@1170
|
911
|
n@1170
|
912 this.input = document.createElement('input');
|
n@1170
|
913 switch(this.dataType)
|
n@1170
|
914 {
|
n@1170
|
915 case "boolean":
|
n@1170
|
916 this.input.type = "checkbox";
|
n@1170
|
917 break;
|
n@1170
|
918 case "negativeInteger":
|
n@1170
|
919 case "positiveInteger":
|
n@1170
|
920 case "nonNegativeInteger":
|
n@1170
|
921 case "nonPositiveInteger":
|
n@1170
|
922 case "integer":
|
n@1170
|
923 case "short":
|
n@1170
|
924 case "byte":
|
n@1170
|
925 this.input.step = 1;
|
n@1170
|
926 case "decimal":
|
n@1170
|
927 this.input.type = "number";
|
n@1170
|
928 this.input.min = minVar;
|
n@1170
|
929 this.input.max = maxVar;
|
n@1170
|
930 break;
|
n@1170
|
931 default:
|
n@1170
|
932 break;
|
n@1170
|
933 }
|
n@1170
|
934 var value;
|
n@1173
|
935 eval("value = node."+this.name)
|
n@1170
|
936 if (value != undefined)
|
n@1170
|
937 {
|
n@1170
|
938 this.input.value = value;
|
n@1170
|
939 } else if (this.default != undefined)
|
n@1170
|
940 {
|
n@1170
|
941 this.input.value = this.default;
|
n@1170
|
942 }
|
n@1170
|
943 this.handleEvent = function(event)
|
n@1170
|
944 {
|
n@1170
|
945 var value;
|
n@1170
|
946 switch(this.input.type)
|
n@1170
|
947 {
|
n@1170
|
948 case "checkbox":
|
n@1170
|
949 value = event.currentTarget.checked;
|
n@1170
|
950 break;
|
n@1170
|
951 case "number":
|
n@1170
|
952 value = Number(event.currentTarget.value);
|
n@1170
|
953 break;
|
n@1170
|
954 default:
|
n@1170
|
955 value = event.currentTarget.value;
|
n@1170
|
956 break;
|
n@1170
|
957 }
|
n@1170
|
958 eval("this.owner."+this.name+" = value");
|
n@1170
|
959 }
|
n@1170
|
960 this.holder = document.createElement('div');
|
n@1170
|
961 this.holder.className = "attribute";
|
n@1170
|
962 this.holder.setAttribute('name',this.name);
|
n@1170
|
963 var text = document.createElement('span');
|
n@1170
|
964 eval("text.textContent = attributeText."+this.name+"+': '");
|
n@1170
|
965 this.holder.appendChild(text);
|
n@1170
|
966 this.holder.appendChild(this.input);
|
n@1170
|
967 this.owner = node;
|
n@1170
|
968 this.input.addEventListener("change",this,false);
|
n@1170
|
969 }
|
n@1170
|
970 if (obj.attribute != null)
|
n@1170
|
971 {
|
n@1170
|
972 obj.input.value = obj.attribute;
|
n@1170
|
973 }
|
n@1170
|
974 return obj;
|
n@1170
|
975 }
|
n@1170
|
976
|
n@1170
|
977 this.convert = function(root)
|
n@1170
|
978 {
|
n@1170
|
979 //Performs the actual conversion using the given root DOM as the root
|
n@1170
|
980 this.injectDOM = root;
|
n@1170
|
981
|
n@1173
|
982 // Build the export button
|
n@1173
|
983 var exportButton = document.createElement("button");
|
n@1173
|
984 exportButton.textContent = "Export to XML";
|
n@1173
|
985 exportButton.onclick = function()
|
n@1173
|
986 {
|
n@1173
|
987 var doc = specification.encode();
|
n@1173
|
988 var obj = {};
|
n@1173
|
989 obj.title = "Export";
|
n@1173
|
990 obj.content = document.createElement("div");
|
n@1173
|
991 obj.content.id = "finish";
|
n@1173
|
992 var span = document.createElement("span");
|
n@1173
|
993 span.textContent = "Your XML document is linked below. On most browsers, simply right click on the link and select 'Save As'. Or clicking on the link may download the file directly."
|
n@1173
|
994 obj.content.appendChild(span);
|
n@1173
|
995 var link = document.createElement("div");
|
n@1173
|
996 link.appendChild(doc.children[0]);
|
n@1173
|
997 var file = [link.innerHTML];
|
n@1173
|
998 var bb = new Blob(file,{type : 'application/xml'});
|
n@1173
|
999 var dnlk = window.URL.createObjectURL(bb);
|
n@1173
|
1000 var a = document.createElement("a");
|
n@1173
|
1001 a.hidden = '';
|
n@1173
|
1002 a.href = dnlk;
|
n@1173
|
1003 a.download = "project-specification.xml";
|
n@1173
|
1004 a.textContent = "Save File";
|
n@1173
|
1005 obj.content.appendChild(a);
|
n@1173
|
1006 popupObject.show();
|
n@1173
|
1007 popupObject.postNode(obj);
|
n@1173
|
1008 }
|
n@1173
|
1009 this.injectDOM.appendChild(exportButton);
|
n@1173
|
1010
|
n@1170
|
1011 // First perform the setupNode;
|
n@1170
|
1012 var setupSchema = specification.schema.getAllElementsByName('setup')[0];
|
n@1170
|
1013 this.setupDOM = new this.createGeneralNodeDOM('setup','setup',null);
|
n@1170
|
1014 this.injectDOM.appendChild(this.setupDOM.rootDOM);
|
n@1170
|
1015 var setupAttributes = setupSchema.getAllElementsByTagName('xs:attribute');
|
n@1170
|
1016 for (var i=0; i<setupAttributes.length; i++)
|
n@1170
|
1017 {
|
n@1170
|
1018 var attributeName = setupAttributes[i].getAttribute('name');
|
n@1170
|
1019 var attrObject = this.convertAttributeToDOM(specification,setupAttributes[i]);
|
n@1170
|
1020 this.setupDOM.attributeDOM.appendChild(attrObject.holder);
|
n@1170
|
1021 this.setupDOM.attributes.push(attrObject);
|
n@1170
|
1022 }
|
n@1170
|
1023
|
n@1170
|
1024 // Now we must build the interface Node
|
n@1170
|
1025 this.interfaceDOM = new this.interfaceNode(this,specification.interfaces);
|
n@1170
|
1026 this.interfaceDOM.build("Interface","setup-interface",this.setupDOM.rootDOM);
|
n@1170
|
1027
|
n@1170
|
1028 // Now build the Metrics selection node
|
n@1170
|
1029 var metric = this.createGeneralNodeDOM("metrics","setup-metric",this.setupDOM);
|
n@1170
|
1030 metric.rootDOM.removeChild(metric.attributeDOM);
|
n@1170
|
1031 this.setupDOM.children.push(metric);
|
n@1170
|
1032 this.setupDOM.childrenDOM.appendChild(metric.rootDOM);
|
n@1170
|
1033 var interfaceName = popupStateNodes.state[1].select.value;
|
n@1170
|
1034 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0];
|
n@1170
|
1035 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
|
n@1170
|
1036 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0];
|
n@1170
|
1037 testXML = testXML.getAllElementsByTagName("metrics");
|
n@1170
|
1038 for (var i=0; i<interfaceXML.children.length; i++)
|
n@1170
|
1039 {
|
n@1170
|
1040 var obj = {
|
n@1170
|
1041 input: document.createElement('input'),
|
n@1170
|
1042 root: document.createElement('div'),
|
n@1170
|
1043 text: document.createElement('span'),
|
n@1170
|
1044 specification: specification.metrics.enabled,
|
n@1170
|
1045 name: interfaceXML.children[i].getAttribute("name"),
|
n@1170
|
1046 handleEvent: function()
|
n@1170
|
1047 {
|
n@1170
|
1048 for (var i=0; i<this.specification.length; i++)
|
n@1170
|
1049 {
|
n@1170
|
1050 if (this.specification[i] == this.name)
|
n@1170
|
1051 {
|
n@1170
|
1052 var options = this.specification;
|
n@1170
|
1053 if (this.input.checked == false) {
|
n@1170
|
1054 if (i == options.length)
|
n@1170
|
1055 {options = options.slice(0,i);}
|
n@1170
|
1056 else {
|
n@1170
|
1057 options = options.slice(0,i).concat(options.slice(i+1));
|
n@1170
|
1058 }
|
n@1170
|
1059 } else {
|
n@1170
|
1060 return;
|
n@1170
|
1061 }
|
n@1170
|
1062 this.specification = options;
|
n@1170
|
1063 break;
|
n@1170
|
1064 }
|
n@1170
|
1065 }
|
n@1170
|
1066 if (this.input.checked) {
|
n@1170
|
1067 this.specification.push(this.name);
|
n@1170
|
1068 }
|
n@1170
|
1069 }
|
n@1170
|
1070 };
|
n@1170
|
1071 obj.root.className = "attribute";
|
n@1170
|
1072 obj.input.type = "checkbox";
|
n@1170
|
1073 obj.root.appendChild(obj.text);
|
n@1170
|
1074 obj.root.appendChild(obj.input);
|
n@1170
|
1075 obj.text.textContent = checkText.children[i].textContent;
|
n@1170
|
1076 metric.children.push(obj);
|
n@1170
|
1077 metric.childrenDOM.appendChild(obj.root);
|
n@1170
|
1078 for (var i=0; i<specification.metrics.enabled.length; i++)
|
n@1170
|
1079 {
|
n@1170
|
1080 if (specification.metrics.enabled[i] == obj.name)
|
n@1170
|
1081 {
|
n@1170
|
1082 obj.input.checked = true;
|
n@1170
|
1083 break;
|
n@1170
|
1084 }
|
n@1170
|
1085 }
|
n@1170
|
1086 }
|
n@1170
|
1087
|
n@1170
|
1088 // Now both before and after surveys
|
n@1170
|
1089 if (specification.preTest == undefined){
|
n@1170
|
1090 specification.preTest = new specification.surveyNode();
|
n@1170
|
1091 specification.preTest.location = "pre";
|
n@1170
|
1092 }
|
n@1170
|
1093 if (specification.postTest == undefined){
|
n@1170
|
1094 specification.postTest = new specification.surveyNode();
|
n@1170
|
1095 specification.postTest.location = "post";
|
n@1170
|
1096 }
|
n@1170
|
1097 var surveyBefore = new this.surveyNode(this,specification.preTest,"Pre");
|
n@1170
|
1098 var surveyAfter = new this.surveyNode(this,specification.postTest,"Post");
|
n@1170
|
1099 this.setupDOM.children.push(surveyBefore);
|
n@1170
|
1100 this.setupDOM.children.push(surveyAfter);
|
n@1170
|
1101 this.setupDOM.childrenDOM.appendChild(surveyBefore.rootDOM);
|
n@1170
|
1102 this.setupDOM.childrenDOM.appendChild(surveyAfter.rootDOM);
|
n@1170
|
1103
|
n@1170
|
1104 // Add in the page creator button
|
n@1170
|
1105 this.addPage = {
|
n@1170
|
1106 root: document.createElement("button"),
|
n@1170
|
1107 parent: this,
|
n@1170
|
1108 handleEvent: function()
|
n@1170
|
1109 {
|
n@1170
|
1110 var pageObj = new specification.page();
|
n@1170
|
1111 specification.pages.push(pageObj);
|
n@1170
|
1112 var newPage = new this.parent.pageNode(this.parent,pageObj);
|
n@1170
|
1113 this.parent.injectDOM.appendChild(newPage.rootDOM);
|
n@1170
|
1114 this.parent.pages.push(newPage);
|
n@1170
|
1115 }
|
n@1170
|
1116 }
|
n@1170
|
1117 this.addPage.root.textContent = "Add Page";
|
n@1170
|
1118 this.addPage.root.addEventListener("click",this.addPage,false);
|
n@1170
|
1119 this.injectDOM.appendChild(this.addPage.root);
|
n@1174
|
1120
|
n@1174
|
1121 // Build each page
|
n@1174
|
1122 for (var page of specification.pages)
|
n@1174
|
1123 {
|
n@1174
|
1124 var newPage = new this.pageNode(this,page);
|
n@1174
|
1125 this.injectDOM.appendChild(newPage.rootDOM);
|
n@1174
|
1126 this.pages.push(newPage);
|
n@1174
|
1127 }
|
n@1170
|
1128 }
|
n@1170
|
1129
|
n@1170
|
1130 this.interfaceNode = function(parent,rootObject)
|
n@1170
|
1131 {
|
n@1175
|
1132 this.type = "interfaceNode";
|
n@1170
|
1133 this.rootDOM;
|
n@1170
|
1134 this.titleDOM;
|
n@1170
|
1135 this.attributeDOM;
|
n@1170
|
1136 this.attributes = [];
|
n@1170
|
1137 this.childrenDOM;
|
n@1170
|
1138 this.children = [];
|
n@1170
|
1139 this.buttonDOM;
|
n@1170
|
1140 this.parent = parent;
|
n@1170
|
1141 this.HTMLPoint;
|
n@1170
|
1142 this.specification = rootObject;
|
n@1170
|
1143 this.schema = specification.schema.getAllElementsByName("interface")[1];
|
n@1170
|
1144
|
n@1170
|
1145 this.createIOasAttr = function(name,specification,parent,type) {
|
n@1170
|
1146 this.root = document.createElement('div');
|
n@1170
|
1147 this.input = document.createElement("input");
|
n@1170
|
1148 this.name = name;
|
n@1170
|
1149 this.type = type;
|
n@1170
|
1150 this.parent = parent;
|
n@1170
|
1151 this.specification = specification;
|
n@1170
|
1152 this.handleEvent = function(event) {
|
n@1170
|
1153 for (var i=0; i<this.specification.options.length; i++)
|
n@1170
|
1154 {
|
n@1170
|
1155 if (this.specification.options[i].name == this.name)
|
n@1170
|
1156 {
|
n@1170
|
1157 var options = this.specification.options;
|
n@1170
|
1158 if (this.input.checked == false) {
|
n@1170
|
1159 if (i == options.length)
|
n@1170
|
1160 {options = options.slice(0,i);}
|
n@1170
|
1161 else {
|
n@1170
|
1162 options = options.slice(0,i).concat(options.slice(i+1));
|
n@1170
|
1163 }
|
n@1170
|
1164 } else {
|
n@1170
|
1165 return;
|
n@1170
|
1166 }
|
n@1170
|
1167 this.specification.options = options;
|
n@1170
|
1168 break;
|
n@1170
|
1169 }
|
n@1170
|
1170 }
|
n@1170
|
1171 if (this.input.checked) {
|
n@1170
|
1172 var obj = {
|
n@1170
|
1173 name: this.name,
|
n@1170
|
1174 type: this.type
|
n@1170
|
1175 };
|
n@1170
|
1176 this.specification.options.push(obj);
|
n@1170
|
1177 }
|
n@1170
|
1178 if (this.parent.HTMLPoint.id == "setup")
|
n@1170
|
1179 {
|
n@1170
|
1180 // We've changed a global setting, must update all child 'interfaces' and disable them
|
n@1170
|
1181 for (pages of convert.pages)
|
n@1170
|
1182 {
|
n@1170
|
1183 for (interface of pages.interfaces)
|
n@1170
|
1184 {
|
n@1170
|
1185 if (this.type == "check")
|
n@1170
|
1186 {
|
n@1170
|
1187 for (node of interface.children[0].attributes)
|
n@1170
|
1188 {
|
n@1170
|
1189 if (node.name == this.name) {
|
n@1170
|
1190 if (this.input.checked) {
|
n@1170
|
1191 node.input.disabled = true;
|
n@1170
|
1192 node.input.checked = false;
|
n@1170
|
1193 } else {
|
n@1170
|
1194 node.input.disabled = false;
|
n@1170
|
1195 }
|
n@1170
|
1196 break;
|
n@1170
|
1197 }
|
n@1170
|
1198 }
|
n@1170
|
1199 } else if (this.type == "show")
|
n@1170
|
1200 {
|
n@1170
|
1201 for (node of interface.children[1].attributes)
|
n@1170
|
1202 {
|
n@1170
|
1203 if (node.name == this.name) {
|
n@1170
|
1204 if (this.input.checked) {
|
n@1170
|
1205 node.input.disabled = true;
|
n@1170
|
1206 } else {
|
n@1170
|
1207 node.input.disabled = false;
|
n@1170
|
1208 }
|
n@1170
|
1209 break;
|
n@1170
|
1210 }
|
n@1170
|
1211 }
|
n@1170
|
1212 }
|
n@1170
|
1213 }
|
n@1170
|
1214 }
|
n@1170
|
1215 }
|
n@1170
|
1216 };
|
n@1170
|
1217 this.findIndex = function(element,index,array){
|
n@1170
|
1218 if (element.name == this.name)
|
n@1170
|
1219 return true;
|
n@1170
|
1220 else
|
n@1170
|
1221 return false;
|
n@1170
|
1222 };
|
n@1170
|
1223 this.findNode = function(element,index,array){
|
n@1170
|
1224 if (element.name == this.name)
|
n@1170
|
1225 return true;
|
n@1170
|
1226 else
|
n@1170
|
1227 return false;
|
n@1170
|
1228 };
|
n@1170
|
1229 this.input.type = "checkbox";
|
n@1170
|
1230 this.input.setAttribute("name",name);
|
n@1170
|
1231 this.input.addEventListener("change",this,false);
|
n@1170
|
1232 this.root.appendChild(this.input);
|
n@1170
|
1233 this.root.className = "attribute";
|
n@1170
|
1234 return this;
|
n@1170
|
1235 }
|
n@1170
|
1236
|
n@1170
|
1237 this.build = function(name,id,parent)
|
n@1170
|
1238 {
|
n@1170
|
1239 var obj = this.parent.createGeneralNodeDOM(name,id,parent);
|
n@1170
|
1240
|
n@1170
|
1241 this.rootDOM = obj.rootDOM;
|
n@1170
|
1242 this.titleDOM = obj.titleDOM;
|
n@1170
|
1243 this.attributeDOM = obj.attributeDOM;
|
n@1170
|
1244 this.childrenDOM = obj.childrenDOM;
|
n@1170
|
1245 this.buttonDOM = obj.buttonsDOM;
|
n@1170
|
1246 this.HTMLPoint = parent;
|
n@1170
|
1247 this.rootDOM.removeChild(this.attributeDOM);
|
n@1170
|
1248 // Put in the check / show options as individual children
|
n@1170
|
1249 var checks = this.parent.createGeneralNodeDOM("Checks","setup-interface-checks",this);
|
n@1170
|
1250
|
n@1170
|
1251 var interfaceName = popupStateNodes.state[1].select.value;
|
n@1170
|
1252 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0];
|
n@1170
|
1253 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
|
n@1170
|
1254 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0];
|
n@1170
|
1255 testXML = testXML.getAllElementsByTagName("checks");
|
n@1170
|
1256 for (var i=0; i<interfaceXML.children.length; i++)
|
n@1170
|
1257 {
|
n@1170
|
1258 var obj = new this.createIOasAttr(interfaceXML.children[i].getAttribute("name"),this.specification,this,"check");
|
n@1170
|
1259 for (var option of this.specification.options)
|
n@1170
|
1260 {
|
n@1170
|
1261 if (option.name == obj.name)
|
n@1170
|
1262 {
|
n@1170
|
1263 obj.input.checked = true;
|
n@1170
|
1264 break;
|
n@1170
|
1265 }
|
n@1170
|
1266 }
|
n@1170
|
1267 if (parent.id != "setup") {
|
n@1170
|
1268 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj);
|
n@1170
|
1269 if (node.input.checked) {
|
n@1170
|
1270 obj.input.checked = false;
|
n@1170
|
1271 obj.input.disable = true;
|
n@1170
|
1272 }
|
n@1170
|
1273 }
|
n@1170
|
1274 var text = document.createElement('span');
|
n@1170
|
1275 text.textContent = checkText.children[i].textContent;
|
n@1170
|
1276 obj.root.appendChild(text);
|
n@1170
|
1277 checks.attributeDOM.appendChild(obj.root);
|
n@1170
|
1278 checks.attributes.push(obj);
|
n@1170
|
1279 }
|
n@1170
|
1280 this.children.push(checks);
|
n@1170
|
1281 this.childrenDOM.appendChild(checks.rootDOM);
|
n@1170
|
1282
|
n@1170
|
1283 var show = this.parent.createGeneralNodeDOM("Show","setup-interface-show",this);
|
n@1170
|
1284 interfaceName = popupStateNodes.state[1].select.value;
|
n@1170
|
1285 checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0];
|
n@1170
|
1286 testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
|
n@1170
|
1287 interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0];
|
n@1170
|
1288 testXML = testXML.getAllElementsByTagName("show");
|
n@1170
|
1289 for (var i=0; i<interfaceXML.children.length; i++)
|
n@1170
|
1290 {
|
n@1170
|
1291 var obj = new this.createIOasAttr(interfaceXML.children[i].getAttribute("name"),this.specification,this,"show");
|
n@1170
|
1292 for (var option of this.specification.options)
|
n@1170
|
1293 {
|
n@1170
|
1294 if (option.name == obj.name)
|
n@1170
|
1295 {
|
n@1170
|
1296 obj.input.checked = true;
|
n@1170
|
1297 break;
|
n@1170
|
1298 }
|
n@1170
|
1299 }
|
n@1170
|
1300 if (parent.id != "setup") {
|
n@1170
|
1301 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj);
|
n@1170
|
1302 if (node.input.checked) {
|
n@1170
|
1303 obj.input.checked = false;
|
n@1170
|
1304 obj.input.disable = true;
|
n@1170
|
1305 }
|
n@1170
|
1306 }
|
n@1170
|
1307 var text = document.createElement('span');
|
n@1170
|
1308 text.textContent = checkText.children[i].textContent;
|
n@1170
|
1309 obj.root.appendChild(text);
|
n@1170
|
1310 show.attributeDOM.appendChild(obj.root);
|
n@1170
|
1311 show.attributes.push(obj);
|
n@1170
|
1312 }
|
n@1170
|
1313 this.children.push(show);
|
n@1170
|
1314 this.childrenDOM.appendChild(show.rootDOM);
|
n@1170
|
1315
|
n@1170
|
1316 if (parent.id == "setup")
|
n@1170
|
1317 {
|
n@1170
|
1318 } else {
|
n@1170
|
1319 var nameAttr = this.parent.convertAttributeToDOM(this,specification.schema.getAllElementsByName("name")[0]);
|
n@1170
|
1320 this.attributeDOM.appendChild(nameAttr.holder);
|
n@1170
|
1321 this.attributes.push(nameAttr);
|
n@1170
|
1322 }
|
n@1170
|
1323 if (parent != undefined)
|
n@1170
|
1324 {
|
n@1170
|
1325 parent.appendChild(this.rootDOM);
|
n@1170
|
1326 }
|
n@1170
|
1327 }
|
n@1170
|
1328 }
|
n@1170
|
1329
|
n@1170
|
1330 this.surveyNode = function(parent,rootObject,location)
|
n@1170
|
1331 {
|
n@1175
|
1332 this.type = "surveyNode";
|
n@1170
|
1333 this.rootDOM = document.createElement("div");
|
n@1170
|
1334 this.titleDOM = document.createElement("span");
|
n@1170
|
1335 this.attributeDOM = document.createElement("div");
|
n@1170
|
1336 this.attributes = [];
|
n@1170
|
1337 this.childrenDOM = document.createElement("div");
|
n@1170
|
1338 this.children = [];
|
n@1170
|
1339 this.buttonDOM = document.createElement("div");
|
n@1170
|
1340 this.parent = parent;
|
n@1170
|
1341 this.specification = rootObject;
|
n@1170
|
1342 this.schema = specification.schema.getAllElementsByName("survey")[1];
|
n@1170
|
1343 this.rootDOM.className = "node";
|
n@1170
|
1344
|
n@1170
|
1345 var titleDiv = document.createElement('div');
|
n@1170
|
1346 titleDiv.className = "node-title";
|
n@1170
|
1347 this.titleDOM.className = "node-title";
|
n@1170
|
1348 this.titleDOM.textContent = "Survey";
|
n@1170
|
1349 titleDiv.appendChild(this.titleDOM);
|
n@1170
|
1350
|
n@1170
|
1351 this.attributeDOM.className = "node-attributes";
|
n@1170
|
1352 var locationAttr = document.createElement("span");
|
n@1170
|
1353 this.attributeDOM.appendChild(locationAttr);
|
n@1170
|
1354 if (location == "Pre" || location == "pre") {
|
n@1170
|
1355 locationAttr.textContent = "Location: Before";
|
n@1170
|
1356 } else {
|
n@1170
|
1357 locationAttr.textContent = "Location: After";
|
n@1170
|
1358 }
|
n@1170
|
1359 this.childrenDOM.className = "node-children";
|
n@1170
|
1360 this.buttonDOM.className = "node-buttons";
|
n@1170
|
1361
|
n@1170
|
1362 this.rootDOM.appendChild(titleDiv);
|
n@1170
|
1363 this.rootDOM.appendChild(this.attributeDOM);
|
n@1170
|
1364 this.rootDOM.appendChild(this.childrenDOM);
|
n@1170
|
1365 this.rootDOM.appendChild(this.buttonDOM);
|
n@1170
|
1366
|
n@1170
|
1367 this.surveyEntryNode = function(parent,rootObject)
|
n@1170
|
1368 {
|
n@1175
|
1369 this.type = "surveyEntryNode";
|
n@1170
|
1370 this.rootDOM = document.createElement("div");
|
n@1170
|
1371 this.titleDOM = document.createElement("span");
|
n@1170
|
1372 this.attributeDOM = document.createElement("div");
|
n@1170
|
1373 this.attributes = [];
|
n@1170
|
1374 this.childrenDOM = document.createElement("div");
|
n@1170
|
1375 this.children = [];
|
n@1170
|
1376 this.buttonDOM = document.createElement("div");
|
n@1170
|
1377 this.parent = parent;
|
n@1170
|
1378 this.specification = rootObject;
|
n@1170
|
1379 this.schema = specification.schema.getAllElementsByName("surveyentry")[1];
|
n@1170
|
1380
|
n@1170
|
1381 this.rootDOM.className = "node";
|
n@1170
|
1382 this.rootDOM.style.minWidth = "50%";
|
n@1170
|
1383
|
n@1170
|
1384 var titleDiv = document.createElement('div');
|
n@1170
|
1385 titleDiv.className = "node-title";
|
n@1170
|
1386 this.titleDOM.className = "node-title";
|
n@1170
|
1387 titleDiv.appendChild(this.titleDOM);
|
n@1170
|
1388
|
n@1170
|
1389 this.attributeDOM.className = "node-attributes";
|
n@1170
|
1390 this.childrenDOM.className = "node-children";
|
n@1170
|
1391 this.buttonDOM.className = "node-buttons";
|
n@1170
|
1392
|
n@1170
|
1393 this.rootDOM.appendChild(titleDiv);
|
n@1170
|
1394 this.rootDOM.appendChild(this.attributeDOM);
|
n@1170
|
1395 this.rootDOM.appendChild(this.childrenDOM);
|
n@1170
|
1396 this.rootDOM.appendChild(this.buttonDOM);
|
n@1170
|
1397
|
n@1175
|
1398 this.build = function()
|
n@1175
|
1399 {
|
n@1175
|
1400 this.attributeDOM.innerHTML = null;
|
n@1175
|
1401 this.childrenDOM.innerHTML = null;
|
n@1175
|
1402 var statementRoot = document.createElement("div");
|
n@1175
|
1403 var statement = document.createElement("span");
|
n@1175
|
1404 statement.textContent = "Statement / Question: "+this.specification.statement;
|
n@1175
|
1405 statementRoot.appendChild(statement);
|
n@1175
|
1406 this.children.push(statementRoot);
|
n@1175
|
1407 this.childrenDOM.appendChild(statementRoot);
|
n@1175
|
1408 switch(this.specification.type)
|
n@1175
|
1409 {
|
n@1175
|
1410 case "statement":
|
n@1175
|
1411 this.titleDOM.textContent = "Statement";
|
n@1175
|
1412 break;
|
n@1175
|
1413 case "question":
|
n@1175
|
1414 this.titleDOM.textContent = "Question";
|
n@1175
|
1415 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]);
|
n@1175
|
1416 var mandatory = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("mandatory")[0]);
|
n@1175
|
1417 var boxsize = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("boxsize")[0]);
|
n@1175
|
1418 this.attributeDOM.appendChild(id.holder);
|
n@1175
|
1419 this.attributes.push(id);
|
n@1175
|
1420 this.attributeDOM.appendChild(mandatory.holder);
|
n@1175
|
1421 this.attributes.push(mandatory);
|
n@1175
|
1422 this.attributeDOM.appendChild(boxsize.holder);
|
n@1175
|
1423 this.attributes.push(boxsize);
|
n@1175
|
1424 break;
|
n@1175
|
1425 case "number":
|
n@1175
|
1426 this.titleDOM.textContent = "Number";
|
n@1175
|
1427 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]);
|
n@1175
|
1428 var mandatory = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("mandatory")[0]);
|
n@1175
|
1429 var min = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("min")[0]);
|
n@1175
|
1430 var max = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("max")[0]);
|
n@1175
|
1431 this.attributeDOM.appendChild(id.holder);
|
n@1175
|
1432 this.attributes.push(id);
|
n@1175
|
1433 this.attributeDOM.appendChild(min.holder);
|
n@1175
|
1434 this.attributes.push(min);
|
n@1175
|
1435 this.attributeDOM.appendChild(max.holder);
|
n@1175
|
1436 this.attributes.push(max);
|
n@1175
|
1437 break;
|
n@1175
|
1438 case "checkbox":
|
n@1175
|
1439 this.titleDOM.textContent = "Checkbox";
|
n@1175
|
1440 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]);
|
n@1175
|
1441 this.attributeDOM.appendChild(id.holder);
|
n@1175
|
1442 this.attributes.push(id);
|
n@1175
|
1443 break;
|
n@1175
|
1444 case "radio":
|
n@1175
|
1445 this.titleDOM.textContent = "Radio";
|
n@1175
|
1446 var id = convert.convertAttributeToDOM(this.specification,specification.schema.getAllElementsByName("id")[0]);
|
n@1175
|
1447 this.attributeDOM.appendChild(id.holder);
|
n@1175
|
1448 this.attributes.push(id);
|
n@1175
|
1449 break;
|
n@1175
|
1450 }
|
n@1170
|
1451 }
|
n@1175
|
1452 this.build();
|
n@1170
|
1453
|
n@1170
|
1454 this.editNode = {
|
n@1170
|
1455 root: document.createElement("button"),
|
n@1170
|
1456 parent: this,
|
n@1170
|
1457 handleEvent: function()
|
n@1170
|
1458 {
|
n@1170
|
1459 popupObject.show();
|
n@1175
|
1460 popupStateNodes.state[5].generate(this.parent.specification,this.parent);
|
n@1170
|
1461 popupObject.postNode(popupStateNodes.state[5]);
|
n@1170
|
1462 }
|
n@1170
|
1463 }
|
n@1170
|
1464 this.editNode.root.textContent = "Edit Entry";
|
n@1170
|
1465 this.editNode.root.addEventListener("click",this.editNode,false);
|
n@1170
|
1466 this.buttonDOM.appendChild(this.editNode.root);
|
n@1170
|
1467
|
n@1170
|
1468 this.deleteNode = {
|
n@1170
|
1469 root: document.createElement("button"),
|
n@1170
|
1470 parent: this,
|
n@1170
|
1471 handleEvent: function()
|
n@1170
|
1472 {
|
n@1170
|
1473 var optionList = this.parent.parent.specification.options;
|
n@1170
|
1474 var childList = this.parent.parent.children;
|
n@1170
|
1475 for (var i=0; i <this.parent.parent.specification.options.length; i++)
|
n@1170
|
1476 {
|
n@1170
|
1477 var option = this.parent.parent.specification.options[i];
|
n@1170
|
1478 if (option == this.parent.specification)
|
n@1170
|
1479 {
|
n@1170
|
1480 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM);
|
n@1170
|
1481 if (i == this.parent.parent.specification.options.length-1)
|
n@1170
|
1482 {
|
n@1170
|
1483 optionList = optionList.slice(0,i);
|
n@1170
|
1484 childList = childList.slice(0,i);
|
n@1170
|
1485 }
|
n@1170
|
1486 else {
|
n@1170
|
1487 optionList = optionList.slice(0,i).concat(optionList.slice(i+1));
|
n@1170
|
1488 childList = childList.slice(0,i).concat(childList.slice(i+1));
|
n@1170
|
1489 }
|
n@1170
|
1490 this.parent.parent.specification.options = optionList;
|
n@1170
|
1491 this.parent.parent.children = childList;
|
n@1170
|
1492 }
|
n@1170
|
1493 }
|
n@1170
|
1494 }
|
n@1170
|
1495 }
|
n@1170
|
1496 this.deleteNode.root.textContent = "Delete Entry";
|
n@1170
|
1497 this.deleteNode.root.addEventListener("click",this.deleteNode,false);
|
n@1170
|
1498 this.buttonDOM.appendChild(this.deleteNode.root);
|
n@1170
|
1499 }
|
n@1170
|
1500 this.addNode = {
|
n@1170
|
1501 root: document.createElement("button"),
|
n@1170
|
1502 parent: this,
|
n@1170
|
1503 handleEvent: function()
|
n@1170
|
1504 {
|
n@1170
|
1505 var newNode = new this.parent.specification.OptionNode();
|
n@1170
|
1506 this.parent.specification.options.push(newNode);
|
n@1170
|
1507 popupObject.show();
|
n@1170
|
1508 popupStateNodes.state[5].generate(newNode,this.parent);
|
n@1170
|
1509 popupObject.postNode(popupStateNodes.state[5]);
|
n@1170
|
1510 }
|
n@1170
|
1511 }
|
n@1170
|
1512 this.addNode.root.textContent = "Add Survey Entry";
|
n@1170
|
1513 this.addNode.root.addEventListener("click",this.addNode,false);
|
n@1170
|
1514 this.buttonDOM.appendChild(this.addNode.root);
|
n@1170
|
1515
|
n@1170
|
1516 for (var option of this.specification.options)
|
n@1170
|
1517 {
|
n@1170
|
1518 var newNode = new this.surveyEntryNode(this,option);
|
n@1170
|
1519 this.children.push(newNode);
|
n@1170
|
1520 this.childrenDOM.appendChild(newNode.rootDOM);
|
n@1170
|
1521 }
|
n@1170
|
1522 }
|
n@1170
|
1523
|
n@1170
|
1524 this.pageNode = function(parent,rootObject)
|
n@1170
|
1525 {
|
n@1175
|
1526 this.type = "pageNode";
|
n@1170
|
1527 this.rootDOM = document.createElement("div");
|
n@1170
|
1528 this.titleDOM = document.createElement("span");
|
n@1170
|
1529 this.attributeDOM = document.createElement("div");
|
n@1170
|
1530 this.attributes = [];
|
n@1170
|
1531 this.childrenDOM = document.createElement("div");
|
n@1170
|
1532 this.children = [];
|
n@1170
|
1533 this.buttonDOM = document.createElement("div");
|
n@1170
|
1534 this.parent = parent;
|
n@1170
|
1535 this.specification = rootObject;
|
n@1170
|
1536 this.schema = specification.schema.getAllElementsByName("page")[0];
|
n@1170
|
1537 this.rootDOM.className = "node";
|
n@1170
|
1538
|
n@1170
|
1539 var titleDiv = document.createElement('div');
|
n@1170
|
1540 titleDiv.className = "node-title";
|
n@1170
|
1541 this.titleDOM.className = "node-title";
|
n@1170
|
1542 this.titleDOM.textContent = "Test Page";
|
n@1170
|
1543 titleDiv.appendChild(this.titleDOM);
|
n@1170
|
1544
|
n@1170
|
1545 this.attributeDOM.className = "node-attributes";
|
n@1170
|
1546 this.childrenDOM.className = "node-children";
|
n@1170
|
1547 this.buttonDOM.className = "node-buttons";
|
n@1170
|
1548
|
n@1170
|
1549 this.rootDOM.appendChild(titleDiv);
|
n@1170
|
1550 this.rootDOM.appendChild(this.attributeDOM);
|
n@1170
|
1551 this.rootDOM.appendChild(this.childrenDOM);
|
n@1170
|
1552 this.rootDOM.appendChild(this.buttonDOM);
|
n@1170
|
1553
|
n@1170
|
1554 // Do the comment prefix node
|
n@1170
|
1555 var cpn = this.parent.createGeneralNodeDOM("Comment Prefix",""+this.specification.id+"-commentprefix",this.parent);
|
n@1170
|
1556 cpn.rootDOM.removeChild(cpn.attributeDOM);
|
n@1170
|
1557 var obj = {
|
n@1170
|
1558 root: document.createElement("div"),
|
n@1170
|
1559 input: document.createElement("input"),
|
n@1170
|
1560 parent: this,
|
n@1170
|
1561 handleEvent: function()
|
n@1170
|
1562 {
|
n@1170
|
1563 this.parent.specification.commentBoxPrefix = event.currentTarget.value;
|
n@1170
|
1564 }
|
n@1170
|
1565 }
|
n@1170
|
1566 cpn.children.push(obj);
|
n@1170
|
1567 cpn.childrenDOM.appendChild(obj.root);
|
n@1170
|
1568 obj.root.appendChild(obj.input);
|
n@1170
|
1569 obj.input.addEventListener("change",obj,false);
|
n@1170
|
1570 obj.input.value = this.specification.commentBoxPrefix;
|
n@1170
|
1571 this.childrenDOM.appendChild(cpn.rootDOM);
|
n@1170
|
1572 this.children.push(cpn);
|
n@1170
|
1573
|
n@1170
|
1574 // Now both before and after surveys
|
n@1170
|
1575 if (this.specification.preTest == undefined){
|
n@1170
|
1576 this.specification.preTest = new specification.surveyNode();
|
n@1170
|
1577 this.specification.preTest.location = "pre";
|
n@1170
|
1578 }
|
n@1170
|
1579 if (this.specification.postTest == undefined){
|
n@1170
|
1580 this.specification.postTest = new specification.surveyNode();
|
n@1170
|
1581 this.specification.postTest.location = "post";
|
n@1170
|
1582 }
|
n@1170
|
1583 var surveyBefore = new this.parent.surveyNode(this,this.specification.preTest,"Pre");
|
n@1170
|
1584 var surveyAfter = new this.parent.surveyNode(this,this.specification.postTest,"Post");
|
n@1170
|
1585 this.children.push(surveyBefore);
|
n@1170
|
1586 this.children.push(surveyAfter);
|
n@1170
|
1587 this.childrenDOM.appendChild(surveyBefore.rootDOM);
|
n@1170
|
1588 this.childrenDOM.appendChild(surveyAfter.rootDOM);
|
n@1170
|
1589
|
n@1170
|
1590 // Build the attributes
|
n@1170
|
1591 var attributeList = this.schema.getAllElementsByTagName("xs:attribute");
|
n@1170
|
1592 for (var i=0; i<attributeList.length; i++)
|
n@1170
|
1593 {
|
n@1170
|
1594 var attributeName = attributeList[i].getAttribute('name');
|
n@1170
|
1595 var attrObject = this.parent.convertAttributeToDOM(rootObject,attributeList[i]);
|
n@1170
|
1596 this.attributeDOM.appendChild(attrObject.holder);
|
n@1170
|
1597 this.attributes.push(attrObject);
|
n@1170
|
1598 }
|
n@1170
|
1599
|
n@1170
|
1600 this.interfaces = [];
|
n@1170
|
1601
|
n@1170
|
1602 this.audioElementNode = function(parent,rootObject)
|
n@1170
|
1603 {
|
n@1175
|
1604 this.type = "audioElementNode";
|
n@1170
|
1605 this.rootDOM = document.createElement("div");
|
n@1170
|
1606 this.titleDOM = document.createElement("span");
|
n@1170
|
1607 this.attributeDOM = document.createElement("div");
|
n@1170
|
1608 this.attributes = [];
|
n@1170
|
1609 this.childrenDOM = document.createElement("div");
|
n@1170
|
1610 this.children = [];
|
n@1170
|
1611 this.buttonDOM = document.createElement("div");
|
n@1170
|
1612 this.parent = parent;
|
n@1170
|
1613 this.specification = rootObject;
|
n@1170
|
1614 this.schema = specification.schema.getAllElementsByName("audioelement")[0];
|
n@1170
|
1615 this.rootDOM.className = "node";
|
n@1170
|
1616
|
n@1170
|
1617 var titleDiv = document.createElement('div');
|
n@1170
|
1618 titleDiv.className = "node-title";
|
n@1170
|
1619 this.titleDOM.className = "node-title";
|
n@1170
|
1620 this.titleDOM.textContent = "Audio Element";
|
n@1170
|
1621 titleDiv.appendChild(this.titleDOM);
|
n@1170
|
1622
|
n@1170
|
1623 this.attributeDOM.className = "node-attributes";
|
n@1170
|
1624 this.childrenDOM.className = "node-children";
|
n@1170
|
1625 this.buttonDOM.className = "node-buttons";
|
n@1170
|
1626
|
n@1170
|
1627 this.rootDOM.appendChild(titleDiv);
|
n@1170
|
1628 this.rootDOM.appendChild(this.attributeDOM);
|
n@1170
|
1629 this.rootDOM.appendChild(this.childrenDOM);
|
n@1170
|
1630 this.rootDOM.appendChild(this.buttonDOM);
|
n@1170
|
1631
|
n@1170
|
1632 // Build the attributes
|
n@1170
|
1633 var attributeList = this.schema.getAllElementsByTagName("xs:attribute");
|
n@1170
|
1634 for (var i=0; i<attributeList.length; i++)
|
n@1170
|
1635 {
|
n@1170
|
1636 var attributeName = attributeList[i].getAttribute('name');
|
n@1170
|
1637 var attrObject = this.parent.parent.convertAttributeToDOM(rootObject,attributeList[i]);
|
n@1170
|
1638 this.attributeDOM.appendChild(attrObject.holder);
|
n@1170
|
1639 this.attributes.push(attrObject);
|
n@1170
|
1640 }
|
n@1170
|
1641
|
n@1170
|
1642 this.deleteNode = {
|
n@1170
|
1643 root: document.createElement("button"),
|
n@1170
|
1644 parent: this,
|
n@1170
|
1645 handleEvent: function()
|
n@1170
|
1646 {
|
n@1170
|
1647 var i = this.parent.parent.specification.audioElements.findIndex(this.findNode,this);
|
n@1170
|
1648 if (i >= 0) {
|
n@1170
|
1649 var aeList = this.parent.parent.specification.audioElements;
|
n@1170
|
1650 if (i < aeList.length-1) {
|
n@1170
|
1651 aeList = aeList.slice(0,i).concat(aeList.slice(i+1));
|
n@1170
|
1652 } else {
|
n@1170
|
1653 aeList = aeList.slice(0,i);
|
n@1170
|
1654 }
|
n@1170
|
1655 }
|
n@1170
|
1656 i = this.parent.parent.children.findIndex(function(element,index,array){
|
n@1170
|
1657 if (element == this.parent)
|
n@1170
|
1658 return true;
|
n@1170
|
1659 else
|
n@1170
|
1660 return false;
|
n@1170
|
1661 },this);
|
n@1170
|
1662 if (i >= 0) {
|
n@1170
|
1663 var childList = this.parent.children;
|
n@1170
|
1664 if (i < aeList.length-1) {
|
n@1170
|
1665 childList = childList.slice(0,i).concat(childList.slice(i+1));
|
n@1170
|
1666 } else {
|
n@1170
|
1667 childList = childList.slice(0,i);
|
n@1170
|
1668 }
|
n@1170
|
1669 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM);
|
n@1170
|
1670 }
|
n@1170
|
1671 },
|
n@1170
|
1672 findNode: function(element,index,array){
|
n@1170
|
1673 if (element == this.parent.specification)
|
n@1170
|
1674 return true;
|
n@1170
|
1675 else
|
n@1170
|
1676 return false;
|
n@1170
|
1677 }
|
n@1170
|
1678 }
|
n@1170
|
1679 this.deleteNode.root.textContent = "Delete Entry";
|
n@1170
|
1680 this.deleteNode.root.addEventListener("click",this.deleteNode,false);
|
n@1170
|
1681 this.buttonDOM.appendChild(this.deleteNode.root);
|
n@1170
|
1682 }
|
n@1170
|
1683
|
n@1170
|
1684 this.commentQuestionNode = function(parent,rootObject)
|
n@1170
|
1685 {
|
n@1175
|
1686 this.type = "commentQuestionNode";
|
n@1170
|
1687 this.rootDOM = document.createElement("div");
|
n@1170
|
1688 this.titleDOM = document.createElement("span");
|
n@1170
|
1689 this.attributeDOM = document.createElement("div");
|
n@1170
|
1690 this.attributes = [];
|
n@1170
|
1691 this.childrenDOM = document.createElement("div");
|
n@1170
|
1692 this.children = [];
|
n@1170
|
1693 this.buttonDOM = document.createElement("div");
|
n@1170
|
1694 this.parent = parent;
|
n@1170
|
1695 this.specification = rootObject;
|
n@1170
|
1696 this.schema = specification.schema.getAllElementsByName("page")[0];
|
n@1170
|
1697 this.rootDOM.className = "node";
|
n@1170
|
1698
|
n@1170
|
1699 var titleDiv = document.createElement('div');
|
n@1170
|
1700 titleDiv.className = "node-title";
|
n@1170
|
1701 this.titleDOM.className = "node-title";
|
n@1170
|
1702 this.titleDOM.textContent = "Test Page";
|
n@1170
|
1703 titleDiv.appendChild(this.titleDOM);
|
n@1170
|
1704
|
n@1170
|
1705 this.attributeDOM.className = "node-attributes";
|
n@1170
|
1706 this.childrenDOM.className = "node-children";
|
n@1170
|
1707 this.buttonDOM.className = "node-buttons";
|
n@1170
|
1708
|
n@1170
|
1709 this.rootDOM.appendChild(titleDiv);
|
n@1170
|
1710 this.rootDOM.appendChild(this.attributeDOM);
|
n@1170
|
1711 this.rootDOM.appendChild(this.childrenDOM);
|
n@1170
|
1712 this.rootDOM.appendChild(this.buttonDOM);
|
n@1170
|
1713
|
n@1170
|
1714 }
|
n@1170
|
1715
|
n@1174
|
1716 // Build the components
|
n@1174
|
1717 for (var elements of this.specification.audioElements)
|
n@1174
|
1718 {
|
n@1174
|
1719 var audioElementDOM = new this.audioElementNode(this,elements);
|
n@1174
|
1720 this.children.push(audioElementDOM);
|
n@1174
|
1721 this.childrenDOM.appendChild(audioElementDOM.rootDOM);
|
n@1174
|
1722 }
|
n@1174
|
1723
|
n@1170
|
1724 this.addInterface = {
|
n@1170
|
1725 root: document.createElement("button"),
|
n@1170
|
1726 parent: this,
|
n@1170
|
1727 handleEvent: function() {
|
n@1170
|
1728 var InterfaceObj = new specification.interfaceNode();
|
n@1170
|
1729 var newInterface = new this.parent.parent.interfaceNode(this.parent.parent,InterfaceObj);
|
n@1170
|
1730 newInterface.build("Interface",""+this.parent.specification.id+"-interface",this.parent.childrenDOM);
|
n@1170
|
1731 this.parent.children.push(newInterface);
|
n@1170
|
1732 this.parent.specification.interfaces.push(InterfaceObj);
|
n@1170
|
1733 this.parent.interfaces.push(newInterface);
|
n@1170
|
1734 }
|
n@1170
|
1735 }
|
n@1170
|
1736 this.addInterface.root.textContent = "Add Interface";
|
n@1170
|
1737 this.addInterface.root.addEventListener("click",this.addInterface,false);
|
n@1170
|
1738 this.buttonDOM.appendChild(this.addInterface.root);
|
n@1170
|
1739
|
n@1170
|
1740 this.addAudioElement = {
|
n@1170
|
1741 root: document.createElement("button"),
|
n@1170
|
1742 parent: this,
|
n@1170
|
1743 handleEvent: function() {
|
n@1170
|
1744 var audioElementObject = new this.parent.specification.audioElementNode();
|
n@1170
|
1745 var audioElementDOM = new this.parent.audioElementNode(this.parent,audioElementObject);
|
n@1170
|
1746 this.parent.specification.audioElements.push(audioElementObject);
|
n@1170
|
1747 this.parent.children.push(audioElementDOM);
|
n@1170
|
1748 this.parent.childrenDOM.appendChild(audioElementDOM.rootDOM);
|
n@1170
|
1749 }
|
n@1170
|
1750 }
|
n@1170
|
1751 this.addAudioElement.root.textContent = "Add Audio Element";
|
n@1170
|
1752 this.addAudioElement.root.addEventListener("click",this.addAudioElement,false);
|
n@1170
|
1753 this.buttonDOM.appendChild(this.addAudioElement.root);
|
n@1170
|
1754 }
|
n@1170
|
1755 } |