annotate test_create/test_core.js @ 542:e23de2023941 Dev_main

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