annotate test_create/test_core.js @ 1200:525608556601

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