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