annotate test_create/test_core.js @ 536:efac13499354 Dev_main

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