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