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