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