annotate test_create/test_core.js @ 1266:6533f0c11d9a

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