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