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