annotate test_create/test_core.js @ 637:df6c09f5835d Dev_main

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