annotate test_create/test_core.js @ 1170:2cd9f09455a5

New test creator tool. Still WIP, but much more dynamic. Based on XSD and external lists so far easier to modify.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 10 Feb 2016 12:02:25 +0000
parents
children f8920367ec32
rev   line source
n@1170 1 var interfaceSpecs;
n@1170 2 var xmlHttp;
n@1170 3 var popupObject;
n@1170 4 var popupStateNodes;
n@1170 5 var specification;
n@1170 6 var convert;
n@1170 7 var attributeText;
n@1170 8
n@1170 9 // Firefox does not have an XMLDocument.prototype.getElementsByName
n@1170 10 // and there is no searchAll style command, this custom function will
n@1170 11 // search all children recusrively for the name. Used for XSD where all
n@1170 12 // element nodes must have a name and therefore can pull the schema node
n@1170 13 XMLDocument.prototype.getAllElementsByName = function(name)
n@1170 14 {
n@1170 15 name = String(name);
n@1170 16 var selected = this.documentElement.getAllElementsByName(name);
n@1170 17 return selected;
n@1170 18 }
n@1170 19
n@1170 20 Element.prototype.getAllElementsByName = function(name)
n@1170 21 {
n@1170 22 name = String(name);
n@1170 23 var selected = [];
n@1170 24 var node = this.firstElementChild;
n@1170 25 while(node != null)
n@1170 26 {
n@1170 27 if (node.getAttribute('name') == name)
n@1170 28 {
n@1170 29 selected.push(node);
n@1170 30 }
n@1170 31 if (node.childElementCount > 0)
n@1170 32 {
n@1170 33 selected = selected.concat(node.getAllElementsByName(name));
n@1170 34 }
n@1170 35 node = node.nextElementSibling;
n@1170 36 }
n@1170 37 return selected;
n@1170 38 }
n@1170 39
n@1170 40 XMLDocument.prototype.getAllElementsByTagName = function(name)
n@1170 41 {
n@1170 42 name = String(name);
n@1170 43 var selected = this.documentElement.getAllElementsByTagName(name);
n@1170 44 return selected;
n@1170 45 }
n@1170 46
n@1170 47 Element.prototype.getAllElementsByTagName = function(name)
n@1170 48 {
n@1170 49 name = String(name);
n@1170 50 var selected = [];
n@1170 51 var node = this.firstElementChild;
n@1170 52 while(node != null)
n@1170 53 {
n@1170 54 if (node.nodeName == name)
n@1170 55 {
n@1170 56 selected.push(node);
n@1170 57 }
n@1170 58 if (node.childElementCount > 0)
n@1170 59 {
n@1170 60 selected = selected.concat(node.getAllElementsByTagName(name));
n@1170 61 }
n@1170 62 node = node.nextElementSibling;
n@1170 63 }
n@1170 64 return selected;
n@1170 65 }
n@1170 66
n@1170 67 // Firefox does not have an XMLDocument.prototype.getElementsByName
n@1170 68 if (typeof XMLDocument.prototype.getElementsByName != "function") {
n@1170 69 XMLDocument.prototype.getElementsByName = function(name)
n@1170 70 {
n@1170 71 name = String(name);
n@1170 72 var node = this.documentElement.firstElementChild;
n@1170 73 var selected = [];
n@1170 74 while(node != null)
n@1170 75 {
n@1170 76 if (node.getAttribute('name') == name)
n@1170 77 {
n@1170 78 selected.push(node);
n@1170 79 }
n@1170 80 node = node.nextElementSibling;
n@1170 81 }
n@1170 82 return selected;
n@1170 83 }
n@1170 84 }
n@1170 85
n@1170 86 window.onload = function()
n@1170 87 {
n@1170 88 specification = new Specification();
n@1170 89 convert = new SpecificationToHTML();
n@1170 90 xmlHttp = new XMLHttpRequest();
n@1170 91 xmlHttp.open("GET","./interface-specs.xml",true);
n@1170 92 xmlHttp.onload = function()
n@1170 93 {
n@1170 94 var parse = new DOMParser();
n@1170 95 interfaceSpecs = parse.parseFromString(xmlHttp.response,'text/xml');
n@1170 96 buildPage();
n@1170 97 popupObject.postNode(popupStateNodes.state[0])
n@1170 98 }
n@1170 99 xmlHttp.send();
n@1170 100
n@1170 101 var xsdGet = new XMLHttpRequest();
n@1170 102 xsdGet.open("GET","../test-schema.xsd",true);
n@1170 103 xsdGet.onload = function()
n@1170 104 {
n@1170 105 var parse = new DOMParser();
n@1170 106 specification.schema = parse.parseFromString(xsdGet.response,'text/xml');;
n@1170 107 }
n@1170 108 xsdGet.send();
n@1170 109
n@1170 110 var jsonAttribute = new XMLHttpRequest();
n@1170 111 jsonAttribute.open("GET","./attributes.json",true);
n@1170 112 jsonAttribute.onload = function()
n@1170 113 {
n@1170 114 attributeText = JSON.parse(jsonAttribute.response)
n@1170 115 }
n@1170 116 jsonAttribute.send();
n@1170 117 }
n@1170 118
n@1170 119 function buildPage()
n@1170 120 {
n@1170 121 popupObject = new function() {
n@1170 122 this.object = document.getElementById("popupHolder");
n@1170 123 this.blanket = document.getElementById("blanket");
n@1170 124
n@1170 125 this.popupTitle = document.createElement("div");
n@1170 126 this.popupTitle.id = "popup-title-holder";
n@1170 127 this.popupTitle.align = "center";
n@1170 128 this.titleDOM = document.createElement("span");
n@1170 129 this.titleDOM.id = "popup-title";
n@1170 130 this.popupTitle.appendChild(this.titleDOM);
n@1170 131 this.object.appendChild(this.popupTitle);
n@1170 132
n@1170 133 this.popupContent = document.createElement("div");
n@1170 134 this.popupContent.id = "popup-content";
n@1170 135 this.object.appendChild(this.popupContent);
n@1170 136
n@1170 137 this.proceedButton = document.createElement("button");
n@1170 138 this.proceedButton.id = "popup-proceed";
n@1170 139 this.proceedButton.textContent = "Next";
n@1170 140 this.proceedButton.onclick = function()
n@1170 141 {
n@1170 142 popupObject.popupContent.innerHTML = null;
n@1170 143 popupObject.shownObject.continue();
n@1170 144 };
n@1170 145 this.object.appendChild(this.proceedButton);
n@1170 146
n@1170 147 this.shownObject;
n@1170 148
n@1170 149 this.resize = function()
n@1170 150 {
n@1170 151 var w = window.innerWidth;
n@1170 152 var h = window.innerHeight;
n@1170 153 this.object.style.left = Math.floor((w-750)/2) + 'px';
n@1170 154 this.object.style.top = Math.floor((h-500)/2) + 'px';
n@1170 155 }
n@1170 156
n@1170 157 this.show = function()
n@1170 158 {
n@1170 159 this.object.style.visibility = "visible";
n@1170 160 this.blanket.style.visibility = "visible";
n@1170 161 }
n@1170 162
n@1170 163 this.hide = function()
n@1170 164 {
n@1170 165 this.object.style.visibility = "hidden";
n@1170 166 this.blanket.style.visibility = "hidden";
n@1170 167 }
n@1170 168
n@1170 169 this.postNode = function(postObject)
n@1170 170 {
n@1170 171 this.show();
n@1170 172 //Passed object must have the following:
n@1170 173 // Title: text to show in the title
n@1170 174 // Content: HTML DOM to show on the page
n@1170 175 // On complete this HTML DOM is destroyed so make sure it is referenced elsewhere for processing
n@1170 176 this.titleDOM.textContent = postObject.title;
n@1170 177 this.popupContent.appendChild(postObject.content);
n@1170 178 this.shownObject = postObject;
n@1170 179 }
n@1170 180
n@1170 181 this.resize();
n@1170 182 this.hide();
n@1170 183 };
n@1170 184
n@1170 185 popupStateNodes = new function()
n@1170 186 {
n@1170 187 // This defines the several popup states wanted
n@1170 188 this.state = [];
n@1170 189 this.state[0] = new function()
n@1170 190 {
n@1170 191 this.title = "Welcome";
n@1170 192 this.content = document.createElement("div");
n@1170 193 this.content.id = "state-0";
n@1170 194 var span = document.createElement("span");
n@1170 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@1170 196 this.content.appendChild(span);
n@1170 197 this.dragArea = document.createElement("div");
n@1170 198 this.dragArea.classList = "drag-area";
n@1170 199 this.content.appendChild(this.dragArea);
n@1170 200
n@1170 201 this.continue = function()
n@1170 202 {
n@1170 203 popupObject.postNode(popupStateNodes.state[1]);
n@1170 204 }
n@1170 205 }
n@1170 206 this.state[1] = new function()
n@1170 207 {
n@1170 208 this.title = "Select your interface";
n@1170 209 this.content = document.createElement("div");
n@1170 210 this.content.id = "state-1";
n@1170 211 var spnH = document.createElement('div');
n@1170 212 var span = document.createElement("span");
n@1170 213 span.textContent = "Please select your interface from the list shown below. This will define the various options which are available. This can later be changed.";
n@1170 214 spnH.appendChild(span);
n@1170 215 this.content.appendChild(spnH);
n@1170 216 this.select = document.createElement("select");
n@1170 217 this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].children;
n@1170 218 for (var i=0; i<this.testsXML.length; i++)
n@1170 219 {
n@1170 220 var option = document.createElement('option');
n@1170 221 option.value = this.testsXML[i].getAttribute('name');
n@1170 222 option.textContent = this.testsXML[i].getAttribute('name');
n@1170 223 this.select.appendChild(option);
n@1170 224 }
n@1170 225 this.content.appendChild(this.select);
n@1170 226 this.continue = function()
n@1170 227 {
n@1170 228 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0];
n@1170 229 specification.interface = testXML.getAttribute("interface");
n@1170 230 popupStateNodes.state[2].generate();
n@1170 231 popupObject.postNode(popupStateNodes.state[2]);
n@1170 232 }
n@1170 233 }
n@1170 234 this.state[2] = new function()
n@1170 235 {
n@1170 236 this.title = "Test Checks & Restrictions";
n@1170 237 this.content = document.createElement("div");
n@1170 238 this.content.id = "state-1";
n@1170 239 var spnH = document.createElement('div');
n@1170 240 var span = document.createElement("span");
n@1170 241 span.textContent = "Select your test checks and restrictions. Greyed out items are fixed by the test/interface and cannot be changed";
n@1170 242 spnH.appendChild(span);
n@1170 243 this.content.appendChild(spnH);
n@1170 244 var holder = document.createElement("div");
n@1170 245 this.options = [];
n@1170 246 this.testXML = null;
n@1170 247 this.interfaceXML = null;
n@1170 248 this.generate = function()
n@1170 249 {
n@1170 250 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 251 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0];
n@1170 252 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 253 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0];
n@1170 254 this.testXML = this.testXML.getAllElementsByTagName("checks");
n@1170 255 for (var i=0; i<this.interfaceXML.children.length; i++)
n@1170 256 {
n@1170 257 var interfaceNode = this.interfaceXML.children[i];
n@1170 258 var checkName = interfaceNode.getAttribute('name');
n@1170 259 var testNode
n@1170 260 if (this.testXML.length > 0)
n@1170 261 {
n@1170 262 testNode = this.testXML[0].getAllElementsByName(checkName);
n@1170 263 if(testNode.length != 0) {testNode = testNode[0];}
n@1170 264 else {testNode = undefined;}
n@1170 265 } else {
n@1170 266 testNode = undefined;
n@1170 267 }
n@1170 268 var optH = document.createElement('div');
n@1170 269 optH.className = "popup-checkbox";
n@1170 270 var checkbox = document.createElement('input');
n@1170 271 checkbox.type = "checkbox";
n@1170 272 var text = document.createElement('span');
n@1170 273 checkbox.setAttribute('name',checkName);
n@1170 274 if (interfaceNode.getAttribute('default') == 'on')
n@1170 275 {
n@1170 276 checkbox.checked = true;
n@1170 277 }
n@1170 278 if (interfaceNode.getAttribute('support') == "none")
n@1170 279 {
n@1170 280 checkbox.disabled = true;
n@1170 281 checkbox.checked = false;
n@1170 282 optH.className = "popup-checkbox disabled";
n@1170 283 } else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 284 {
n@1170 285 checkbox.disabled = true;
n@1170 286 checkbox.checked = true;
n@1170 287 optH.className = "popup-checkbox disabled";
n@1170 288 }
n@1170 289 if(testNode != undefined)
n@1170 290 {
n@1170 291 if (interfaceNode.getAttribute('default') == 'on')
n@1170 292 {
n@1170 293 checkbox.checked = true;
n@1170 294 }
n@1170 295 if (testNode.getAttribute('support') == "none")
n@1170 296 {
n@1170 297 checkbox.disabled = true;
n@1170 298 checkbox.checked = false;
n@1170 299 optH.className = "popup-checkbox disabled";
n@1170 300 }else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 301 {
n@1170 302 checkbox.disabled = true;
n@1170 303 checkbox.checked = true;
n@1170 304 optH.className = "popup-checkbox disabled";
n@1170 305 }
n@1170 306 }
n@1170 307 text.textContent = popupStateNodes.state[2].checkText.getAllElementsByName(checkName)[0].textContent;
n@1170 308 optH.appendChild(checkbox);
n@1170 309 optH.appendChild(text);
n@1170 310 this.options.push(optH);
n@1170 311 this.content.appendChild(optH);
n@1170 312 }
n@1170 313 }
n@1170 314 this.continue = function()
n@1170 315 {
n@1170 316 if (specification.interfaces == null)
n@1170 317 {
n@1170 318 specification.interfaces = new specification.interfaceNode();
n@1170 319 }
n@1170 320 for (var object of this.options)
n@1170 321 {
n@1170 322 var checkbox = object.children[0];
n@1170 323 if (checkbox.checked)
n@1170 324 {
n@1170 325 var option = {
n@1170 326 type: "check",
n@1170 327 name: checkbox.getAttribute('name')
n@1170 328 };
n@1170 329 specification.interfaces.options.push(option);
n@1170 330 }
n@1170 331 }
n@1170 332 popupStateNodes.state[3].generate();
n@1170 333 popupObject.postNode(popupStateNodes.state[3]);
n@1170 334 }
n@1170 335 }
n@1170 336 this.state[3] = new function()
n@1170 337 {
n@1170 338 this.title = "Test Metrics";
n@1170 339 this.content = document.createElement("div");
n@1170 340 this.content.id = "state-1";
n@1170 341 var spnH = document.createElement('div');
n@1170 342 var span = document.createElement("span");
n@1170 343 span.textContent = "Select which data points to include in the exported results XML. Some of this is required for certain post script analysis. See the documentation for further details";
n@1170 344 spnH.appendChild(span);
n@1170 345 this.content.appendChild(spnH);
n@1170 346 this.options = [];
n@1170 347 this.checkText;
n@1170 348 this.testXML;
n@1170 349 this.interfaceXML;
n@1170 350 this.generate = function()
n@1170 351 {
n@1170 352 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 353 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0];
n@1170 354 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 355 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0];
n@1170 356 this.testXML = this.testXML.getAllElementsByTagName("metrics");
n@1170 357 for (var i=0; i<this.interfaceXML.children.length; i++)
n@1170 358 {
n@1170 359 var interfaceNode = this.interfaceXML.children[i];
n@1170 360 var checkName = interfaceNode.getAttribute('name');
n@1170 361 var testNode
n@1170 362 if (this.testXML.length > 0)
n@1170 363 {
n@1170 364 testNode = this.testXML[0].getAllElementsByName(checkName);
n@1170 365 if(testNode.length != 0) {testNode = testNode[0];}
n@1170 366 else {testNode = undefined;}
n@1170 367 } else {
n@1170 368 testNode = undefined;
n@1170 369 }
n@1170 370 var optH = document.createElement('div');
n@1170 371 optH.className = "popup-checkbox";
n@1170 372 var checkbox = document.createElement('input');
n@1170 373 checkbox.type = "checkbox";
n@1170 374 var text = document.createElement('span');
n@1170 375 checkbox.setAttribute('name',checkName);
n@1170 376 if (interfaceNode.getAttribute('default') == 'on')
n@1170 377 {
n@1170 378 checkbox.checked = true;
n@1170 379 }
n@1170 380 if (interfaceNode.getAttribute('support') == "none")
n@1170 381 {
n@1170 382 checkbox.disabled = true;
n@1170 383 checkbox.checked = false;
n@1170 384 optH.className = "popup-checkbox disabled";
n@1170 385 } else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 386 {
n@1170 387 checkbox.disabled = true;
n@1170 388 checkbox.checked = true;
n@1170 389 optH.className = "popup-checkbox disabled";
n@1170 390 }
n@1170 391 if(testNode != undefined)
n@1170 392 {
n@1170 393 if (interfaceNode.getAttribute('default') == 'on')
n@1170 394 {
n@1170 395 checkbox.checked = true;
n@1170 396 }
n@1170 397 if (testNode.getAttribute('support') == "none")
n@1170 398 {
n@1170 399 checkbox.disabled = true;
n@1170 400 checkbox.checked = false;
n@1170 401 optH.className = "popup-checkbox disabled";
n@1170 402 }else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 403 {
n@1170 404 checkbox.disabled = true;
n@1170 405 checkbox.checked = true;
n@1170 406 optH.className = "popup-checkbox disabled";
n@1170 407 }
n@1170 408 }
n@1170 409 text.textContent = popupStateNodes.state[3].checkText.getAllElementsByName(checkName)[0].textContent;
n@1170 410 optH.appendChild(checkbox);
n@1170 411 optH.appendChild(text);
n@1170 412 this.options.push(optH);
n@1170 413 this.content.appendChild(optH);
n@1170 414 }
n@1170 415 }
n@1170 416 this.continue = function()
n@1170 417 {
n@1170 418 if (specification.metrics == null) {
n@1170 419 specification.metrics = new specification.metricNode();
n@1170 420 }
n@1170 421 for (var object of this.options)
n@1170 422 {
n@1170 423 var checkbox = object.children[0];
n@1170 424 if (checkbox.checked)
n@1170 425 {
n@1170 426 specification.metrics.enabled.push(checkbox.getAttribute('name'));
n@1170 427 }
n@1170 428 }
n@1170 429 popupStateNodes.state[4].generate();
n@1170 430 popupObject.postNode(popupStateNodes.state[4]);
n@1170 431 }
n@1170 432 }
n@1170 433 this.state[4] = new function()
n@1170 434 {
n@1170 435 this.title = "Test Visuals";
n@1170 436 this.content = document.createElement("div");
n@1170 437 this.content.id = "state-1";
n@1170 438 var spnH = document.createElement('div');
n@1170 439 var span = document.createElement("span");
n@1170 440 span.textContent = "You can display extra visual content with your interface for the test user to interact with. Select from the available options below. Greyed out options are unavailable for your selected interface";
n@1170 441 spnH.appendChild(span);
n@1170 442 this.content.appendChild(spnH);
n@1170 443 this.options = [];
n@1170 444 this.checkText;
n@1170 445 this.testXML;
n@1170 446 this.interfaceXML;
n@1170 447 this.generate = function()
n@1170 448 {
n@1170 449 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 450 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0];
n@1170 451 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 452 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0];
n@1170 453 this.testXML = this.testXML.getAllElementsByTagName("metrics");
n@1170 454 for (var i=0; i<this.interfaceXML.children.length; i++)
n@1170 455 {
n@1170 456 var interfaceNode = this.interfaceXML.children[i];
n@1170 457 var checkName = interfaceNode.getAttribute('name');
n@1170 458 var testNode
n@1170 459 if (this.testXML.length > 0)
n@1170 460 {
n@1170 461 testNode = this.testXML[0].getAllElementsByName(checkName);
n@1170 462 if(testNode.length != 0) {testNode = testNode[0];}
n@1170 463 else {testNode = undefined;}
n@1170 464 } else {
n@1170 465 testNode = undefined;
n@1170 466 }
n@1170 467 var optH = document.createElement('div');
n@1170 468 optH.className = "popup-checkbox";
n@1170 469 var checkbox = document.createElement('input');
n@1170 470 checkbox.type = "checkbox";
n@1170 471 var text = document.createElement('span');
n@1170 472 checkbox.setAttribute('name',checkName);
n@1170 473 if (interfaceNode.getAttribute('default') == 'on')
n@1170 474 {
n@1170 475 checkbox.checked = true;
n@1170 476 }
n@1170 477 if (interfaceNode.getAttribute('support') == "none")
n@1170 478 {
n@1170 479 checkbox.disabled = true;
n@1170 480 checkbox.checked = false;
n@1170 481 optH.className = "popup-checkbox disabled";
n@1170 482 } else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 483 {
n@1170 484 checkbox.disabled = true;
n@1170 485 checkbox.checked = true;
n@1170 486 optH.className = "popup-checkbox disabled";
n@1170 487 }
n@1170 488 if(testNode != undefined)
n@1170 489 {
n@1170 490 if (interfaceNode.getAttribute('default') == 'on')
n@1170 491 {
n@1170 492 checkbox.checked = true;
n@1170 493 }
n@1170 494 if (testNode.getAttribute('support') == "none")
n@1170 495 {
n@1170 496 checkbox.disabled = true;
n@1170 497 checkbox.checked = false;
n@1170 498 optH.className = "popup-checkbox disabled";
n@1170 499 }else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 500 {
n@1170 501 checkbox.disabled = true;
n@1170 502 checkbox.checked = true;
n@1170 503 optH.className = "popup-checkbox disabled";
n@1170 504 }
n@1170 505 }
n@1170 506 text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent;
n@1170 507 optH.appendChild(checkbox);
n@1170 508 optH.appendChild(text);
n@1170 509 this.options.push(optH);
n@1170 510 this.content.appendChild(optH);
n@1170 511 }
n@1170 512 }
n@1170 513 this.continue = function()
n@1170 514 {
n@1170 515 if (specification.interfaces == null)
n@1170 516 {
n@1170 517 specification.interfaces = new specification.interfaceNode();
n@1170 518 }
n@1170 519 for (var object of this.options)
n@1170 520 {
n@1170 521 var checkbox = object.children[0];
n@1170 522 if (checkbox.checked)
n@1170 523 {
n@1170 524 var option = {
n@1170 525 type: "show",
n@1170 526 name: checkbox.getAttribute('name')
n@1170 527 };
n@1170 528 specification.interfaces.options.push(option);
n@1170 529 }
n@1170 530 }
n@1170 531 popupObject.hide();
n@1170 532 convert.convert(document.getElementById('content'));
n@1170 533 }
n@1170 534 }
n@1170 535 this.state[5] = new function() {
n@1170 536 this.title = "Add/Edit Survey Element";
n@1170 537 this.content = document.createElement("div");
n@1170 538 this.content.id = "state-1";
n@1170 539 var spnH = document.createElement('div');
n@1170 540 var span = document.createElement("span");
n@1170 541 span.textContent = "You can configure your survey element here. Press 'Continue' to complete your changes.";
n@1170 542 spnH.appendChild(span);
n@1170 543 this.content.appendChild(spnH);
n@1170 544 this.dynamic = document.createElement("div");
n@1170 545 this.option = null;
n@1170 546 this.parent = null;
n@1170 547 var select = document.createElement("select");
n@1170 548 select.setAttribute("name","type");
n@1170 549 select.addEventListener("change",this,false);
n@1170 550 this.content.appendChild(select);
n@1170 551 this.content.appendChild(this.dynamic);
n@1170 552 this.generate = function(option, parent)
n@1170 553 {
n@1170 554 this.option = option;
n@1170 555 this.parent = parent;
n@1170 556 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration");
n@1170 557 for (var i=0; i<optionList.length; i++)
n@1170 558 {
n@1170 559 var selectOption = document.createElement("option");
n@1170 560 selectOption.value = optionList[i].getAttribute("value");
n@1170 561 selectOption.textContent = selectOption.value;
n@1170 562 select.appendChild(selectOption);
n@1170 563 }
n@1170 564 if (this.option.type != undefined){
n@1170 565 select.value = this.option.type
n@1170 566 } else {
n@1170 567 select.value = "statement";
n@1170 568 this.option.type = "statement";
n@1170 569 }
n@1170 570
n@1170 571 this.dynamic.innerHTML = null;
n@1170 572 var statement = document.createElement("div");
n@1170 573 var statementText = document.createElement("span");
n@1170 574 var statementEntry = document.createElement("textarea");
n@1170 575 statement.appendChild(statementText);
n@1170 576 statement.appendChild(statementEntry);
n@1170 577 statementText.textContent = "Statement/Question";
n@1170 578 statementEntry.addEventListener("change",this,false);
n@1170 579 statementEntry.setAttribute("name","statement");
n@1170 580 statementEntry.value = this.option.statement;
n@1170 581 this.dynamic.appendChild(statement);
n@1170 582 switch(this.option.type)
n@1170 583 {
n@1170 584 case "statement":
n@1170 585 break;
n@1170 586 case "question":
n@1170 587 var boxsizeSelect = document.createElement("select");
n@1170 588 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration");
n@1170 589 for (var i=0; i<optionList.length; i++)
n@1170 590 {
n@1170 591 var selectOption = document.createElement("option");
n@1170 592 selectOption.value = optionList[i].getAttribute("value");
n@1170 593 selectOption.textContent = selectOption.value;
n@1170 594 boxsizeSelect.appendChild(selectOption);
n@1170 595 }
n@1170 596 if(this.option.boxsize != undefined) {
n@1170 597 boxsizeSelect.value = this.option.boxsize;
n@1170 598 } else {
n@1170 599 boxsizeSelect.value = "normal";
n@1170 600 this.option.boxsize = "normal";
n@1170 601 }
n@1170 602 boxsizeSelect.setAttribute("name","boxsize");
n@1170 603 boxsizeSelect.addEventListener("change",this,false);
n@1170 604 var boxsize = document.createElement("div");
n@1170 605 var boxsizeText = document.createElement("span");
n@1170 606 boxsizeText.textContent = "Entry Size: ";
n@1170 607 boxsize.appendChild(boxsizeText);
n@1170 608 boxsize.appendChild(boxsizeSelect);
n@1170 609 this.dynamic.appendChild(boxsize);
n@1170 610
n@1170 611 var mandatory = document.createElement("div");
n@1170 612 var mandatoryInput = document.createElement("input");
n@1170 613 var mandatoryText = document.createElement("span");
n@1170 614 mandatoryText.textContent = "Mandatory: ";
n@1170 615 mandatory.appendChild(mandatoryText);
n@1170 616 mandatory.appendChild(mandatoryInput);
n@1170 617 mandatoryInput.type = "checkbox";
n@1170 618 if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;}
n@1170 619 mandatoryInput.setAttribute("name","mandatory");
n@1170 620 mandatoryInput.addEventListener("change",this,false);
n@1170 621 mandatory.appendChild(mandatoryText);
n@1170 622 mandatory.appendChild(mandatoryInput);
n@1170 623 this.dynamic.appendChild(mandatory);
n@1170 624 break;
n@1170 625 }
n@1170 626 }
n@1170 627 this.handleEvent = function()
n@1170 628 {
n@1170 629 var name = event.currentTarget.getAttribute("name");
n@1170 630 switch(name) {
n@1170 631 case "type":
n@1170 632 // If type has changed, we may need to rebuild the entire state node
n@1170 633 if (event.currentTarget.value != this.option.name)
n@1170 634 {
n@1170 635 this.option.type = event.currentTarget.value;
n@1170 636 this.generate(this.option,this.parent);
n@1170 637 }
n@1170 638 break;
n@1170 639 case "mandatory":
n@1170 640 this.option.mandatory = event.currentTarget.checked;
n@1170 641 break;
n@1170 642 case "boxsize":
n@1170 643 this.option.boxsize = event.currentTarget.value;
n@1170 644 break;
n@1170 645 case "statement":
n@1170 646 this.option.statement = event.currentTarget.value;
n@1170 647 break;
n@1170 648 }
n@1170 649 }
n@1170 650 this.continue = function()
n@1170 651 {
n@1170 652 var newNode = new this.parent.surveyEntryNode(this.parent,this.option);
n@1170 653 this.parent.children.push(newNode);
n@1170 654 this.parent.childrenDOM.appendChild(newNode.rootDOM);
n@1170 655 popupObject.hide();
n@1170 656 }
n@1170 657 }
n@1170 658 }
n@1170 659 }
n@1170 660
n@1170 661 function SpecificationToHTML()
n@1170 662 {
n@1170 663 // This takes the specification node and converts it to an on-page HTML object
n@1170 664 // Each Specification Node is given its own JS object which listens to the XSD for instant verification
n@1170 665 // Once generated, it directly binds into the specification object to update with changes
n@1170 666 // Fixed DOM entries
n@1170 667 this.injectDOM;
n@1170 668 this.setupDOM;
n@1170 669 this.pages = [];
n@1170 670
n@1170 671 // Self-contained generators
n@1170 672 this.createGeneralNodeDOM = function(name,id,parent)
n@1170 673 {
n@1170 674 var root = document.createElement('div');
n@1170 675 root.id = id;
n@1170 676 root.className = "node";
n@1170 677
n@1170 678 var titleDiv = document.createElement('div');
n@1170 679 titleDiv.className = "node-title";
n@1170 680 var title = document.createElement('span');
n@1170 681 title.className = "node-title";
n@1170 682 title.textContent = name;
n@1170 683 titleDiv.appendChild(title);
n@1170 684
n@1170 685 var attributeDiv = document.createElement('div');
n@1170 686 attributeDiv.className = "node-attributes";
n@1170 687
n@1170 688 var childrenDiv = document.createElement('div');
n@1170 689 childrenDiv.className = "node-children";
n@1170 690
n@1170 691 var buttonsDiv = document.createElement('div');
n@1170 692 buttonsDiv.className = "node-buttons";
n@1170 693
n@1170 694 root.appendChild(titleDiv);
n@1170 695 root.appendChild(attributeDiv);
n@1170 696 root.appendChild(childrenDiv);
n@1170 697 root.appendChild(buttonsDiv);
n@1170 698
n@1170 699 var obj = {
n@1170 700 rootDOM: root,
n@1170 701 titleDOM: title,
n@1170 702 attributeDOM: attributeDiv,
n@1170 703 attributes: [],
n@1170 704 childrenDOM: childrenDiv,
n@1170 705 children: [],
n@1170 706 buttonDOM: buttonsDiv,
n@1170 707 parent: parent
n@1170 708 }
n@1170 709 return obj;
n@1170 710 }
n@1170 711
n@1170 712 this.convertAttributeToDOM = function(node,schema)
n@1170 713 {
n@1170 714 // This takes an attribute schema node and returns an object with the input node and any bindings
n@1170 715 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined)
n@1170 716 {
n@1170 717 schema = specification.schema.getAllElementsByName(schema.getAttribute('ref'))[0];
n@1170 718 }
n@1170 719 var obj = new function()
n@1170 720 {
n@1170 721 this.input;
n@1170 722 this.name;
n@1170 723 this.owner;
n@1170 724 this.holder;
n@1170 725
n@1170 726 this.name = schema.getAttribute('name');
n@1170 727 this.default = schema.getAttribute('default');
n@1170 728 this.dataType = schema.getAttribute('type');
n@1170 729 if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);}
n@1170 730 else {this.dataType = "string";}
n@1170 731 var minVar = undefined;
n@1170 732 var maxVar = undefined;
n@1170 733 switch(this.dataType)
n@1170 734 {
n@1170 735 case "negativeInteger":
n@1170 736 maxVar = -1;
n@1170 737 break;
n@1170 738 case "positiveInteger":
n@1170 739 minVar = 1;
n@1170 740 break;
n@1170 741 case "nonNegativeInteger":
n@1170 742 minVar = 0;
n@1170 743 break;
n@1170 744 case "nonPositiveInteger":
n@1170 745 maxVar = 0;
n@1170 746 break;
n@1170 747 case "byte":
n@1170 748 minVar = 0;
n@1170 749 maxVar = 256;
n@1170 750 break;
n@1170 751 case "short":
n@1170 752 minVar = 0;
n@1170 753 maxVar = 65536;
n@1170 754 break;
n@1170 755 default:
n@1170 756 break;
n@1170 757 }
n@1170 758
n@1170 759 this.input = document.createElement('input');
n@1170 760 switch(this.dataType)
n@1170 761 {
n@1170 762 case "boolean":
n@1170 763 this.input.type = "checkbox";
n@1170 764 break;
n@1170 765 case "negativeInteger":
n@1170 766 case "positiveInteger":
n@1170 767 case "nonNegativeInteger":
n@1170 768 case "nonPositiveInteger":
n@1170 769 case "integer":
n@1170 770 case "short":
n@1170 771 case "byte":
n@1170 772 this.input.step = 1;
n@1170 773 case "decimal":
n@1170 774 this.input.type = "number";
n@1170 775 this.input.min = minVar;
n@1170 776 this.input.max = maxVar;
n@1170 777 break;
n@1170 778 default:
n@1170 779 break;
n@1170 780 }
n@1170 781 var value;
n@1170 782 eval("value = specification."+this.name)
n@1170 783 if (value != undefined)
n@1170 784 {
n@1170 785 this.input.value = value;
n@1170 786 } else if (this.default != undefined)
n@1170 787 {
n@1170 788 this.input.value = this.default;
n@1170 789 }
n@1170 790 this.handleEvent = function(event)
n@1170 791 {
n@1170 792 var value;
n@1170 793 switch(this.input.type)
n@1170 794 {
n@1170 795 case "checkbox":
n@1170 796 value = event.currentTarget.checked;
n@1170 797 break;
n@1170 798 case "number":
n@1170 799 value = Number(event.currentTarget.value);
n@1170 800 break;
n@1170 801 default:
n@1170 802 value = event.currentTarget.value;
n@1170 803 break;
n@1170 804 }
n@1170 805 eval("this.owner."+this.name+" = value");
n@1170 806 }
n@1170 807 this.holder = document.createElement('div');
n@1170 808 this.holder.className = "attribute";
n@1170 809 this.holder.setAttribute('name',this.name);
n@1170 810 var text = document.createElement('span');
n@1170 811 eval("text.textContent = attributeText."+this.name+"+': '");
n@1170 812 this.holder.appendChild(text);
n@1170 813 this.holder.appendChild(this.input);
n@1170 814 this.owner = node;
n@1170 815 this.input.addEventListener("change",this,false);
n@1170 816 }
n@1170 817 if (obj.attribute != null)
n@1170 818 {
n@1170 819 obj.input.value = obj.attribute;
n@1170 820 }
n@1170 821 return obj;
n@1170 822 }
n@1170 823
n@1170 824 this.convert = function(root)
n@1170 825 {
n@1170 826 //Performs the actual conversion using the given root DOM as the root
n@1170 827 this.injectDOM = root;
n@1170 828
n@1170 829 // First perform the setupNode;
n@1170 830 var setupSchema = specification.schema.getAllElementsByName('setup')[0];
n@1170 831 this.setupDOM = new this.createGeneralNodeDOM('setup','setup',null);
n@1170 832 this.injectDOM.appendChild(this.setupDOM.rootDOM);
n@1170 833 var setupAttributes = setupSchema.getAllElementsByTagName('xs:attribute');
n@1170 834 for (var i=0; i<setupAttributes.length; i++)
n@1170 835 {
n@1170 836 var attributeName = setupAttributes[i].getAttribute('name');
n@1170 837 var attrObject = this.convertAttributeToDOM(specification,setupAttributes[i]);
n@1170 838 this.setupDOM.attributeDOM.appendChild(attrObject.holder);
n@1170 839 this.setupDOM.attributes.push(attrObject);
n@1170 840 }
n@1170 841
n@1170 842 // Now we must build the interface Node
n@1170 843 this.interfaceDOM = new this.interfaceNode(this,specification.interfaces);
n@1170 844 this.interfaceDOM.build("Interface","setup-interface",this.setupDOM.rootDOM);
n@1170 845
n@1170 846 // Now build the Metrics selection node
n@1170 847 var metric = this.createGeneralNodeDOM("metrics","setup-metric",this.setupDOM);
n@1170 848 metric.rootDOM.removeChild(metric.attributeDOM);
n@1170 849 this.setupDOM.children.push(metric);
n@1170 850 this.setupDOM.childrenDOM.appendChild(metric.rootDOM);
n@1170 851 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 852 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0];
n@1170 853 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 854 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0];
n@1170 855 testXML = testXML.getAllElementsByTagName("metrics");
n@1170 856 for (var i=0; i<interfaceXML.children.length; i++)
n@1170 857 {
n@1170 858 var obj = {
n@1170 859 input: document.createElement('input'),
n@1170 860 root: document.createElement('div'),
n@1170 861 text: document.createElement('span'),
n@1170 862 specification: specification.metrics.enabled,
n@1170 863 name: interfaceXML.children[i].getAttribute("name"),
n@1170 864 handleEvent: function()
n@1170 865 {
n@1170 866 for (var i=0; i<this.specification.length; i++)
n@1170 867 {
n@1170 868 if (this.specification[i] == this.name)
n@1170 869 {
n@1170 870 var options = this.specification;
n@1170 871 if (this.input.checked == false) {
n@1170 872 if (i == options.length)
n@1170 873 {options = options.slice(0,i);}
n@1170 874 else {
n@1170 875 options = options.slice(0,i).concat(options.slice(i+1));
n@1170 876 }
n@1170 877 } else {
n@1170 878 return;
n@1170 879 }
n@1170 880 this.specification = options;
n@1170 881 break;
n@1170 882 }
n@1170 883 }
n@1170 884 if (this.input.checked) {
n@1170 885 this.specification.push(this.name);
n@1170 886 }
n@1170 887 }
n@1170 888 };
n@1170 889 obj.root.className = "attribute";
n@1170 890 obj.input.type = "checkbox";
n@1170 891 obj.root.appendChild(obj.text);
n@1170 892 obj.root.appendChild(obj.input);
n@1170 893 obj.text.textContent = checkText.children[i].textContent;
n@1170 894 metric.children.push(obj);
n@1170 895 metric.childrenDOM.appendChild(obj.root);
n@1170 896 for (var i=0; i<specification.metrics.enabled.length; i++)
n@1170 897 {
n@1170 898 if (specification.metrics.enabled[i] == obj.name)
n@1170 899 {
n@1170 900 obj.input.checked = true;
n@1170 901 break;
n@1170 902 }
n@1170 903 }
n@1170 904 }
n@1170 905
n@1170 906 // Now both before and after surveys
n@1170 907 if (specification.preTest == undefined){
n@1170 908 specification.preTest = new specification.surveyNode();
n@1170 909 specification.preTest.location = "pre";
n@1170 910 }
n@1170 911 if (specification.postTest == undefined){
n@1170 912 specification.postTest = new specification.surveyNode();
n@1170 913 specification.postTest.location = "post";
n@1170 914 }
n@1170 915 var surveyBefore = new this.surveyNode(this,specification.preTest,"Pre");
n@1170 916 var surveyAfter = new this.surveyNode(this,specification.postTest,"Post");
n@1170 917 this.setupDOM.children.push(surveyBefore);
n@1170 918 this.setupDOM.children.push(surveyAfter);
n@1170 919 this.setupDOM.childrenDOM.appendChild(surveyBefore.rootDOM);
n@1170 920 this.setupDOM.childrenDOM.appendChild(surveyAfter.rootDOM);
n@1170 921
n@1170 922 // Add in the page creator button
n@1170 923 this.addPage = {
n@1170 924 root: document.createElement("button"),
n@1170 925 parent: this,
n@1170 926 handleEvent: function()
n@1170 927 {
n@1170 928 var pageObj = new specification.page();
n@1170 929 specification.pages.push(pageObj);
n@1170 930 var newPage = new this.parent.pageNode(this.parent,pageObj);
n@1170 931 this.parent.injectDOM.appendChild(newPage.rootDOM);
n@1170 932 this.parent.pages.push(newPage);
n@1170 933 }
n@1170 934 }
n@1170 935 this.addPage.root.textContent = "Add Page";
n@1170 936 this.addPage.root.addEventListener("click",this.addPage,false);
n@1170 937 this.injectDOM.appendChild(this.addPage.root);
n@1170 938 }
n@1170 939
n@1170 940 this.interfaceNode = function(parent,rootObject)
n@1170 941 {
n@1170 942 this.rootDOM;
n@1170 943 this.titleDOM;
n@1170 944 this.attributeDOM;
n@1170 945 this.attributes = [];
n@1170 946 this.childrenDOM;
n@1170 947 this.children = [];
n@1170 948 this.buttonDOM;
n@1170 949 this.parent = parent;
n@1170 950 this.HTMLPoint;
n@1170 951 this.specification = rootObject;
n@1170 952 this.schema = specification.schema.getAllElementsByName("interface")[1];
n@1170 953
n@1170 954 this.createIOasAttr = function(name,specification,parent,type) {
n@1170 955 this.root = document.createElement('div');
n@1170 956 this.input = document.createElement("input");
n@1170 957 this.name = name;
n@1170 958 this.type = type;
n@1170 959 this.parent = parent;
n@1170 960 this.specification = specification;
n@1170 961 this.handleEvent = function(event) {
n@1170 962 for (var i=0; i<this.specification.options.length; i++)
n@1170 963 {
n@1170 964 if (this.specification.options[i].name == this.name)
n@1170 965 {
n@1170 966 var options = this.specification.options;
n@1170 967 if (this.input.checked == false) {
n@1170 968 if (i == options.length)
n@1170 969 {options = options.slice(0,i);}
n@1170 970 else {
n@1170 971 options = options.slice(0,i).concat(options.slice(i+1));
n@1170 972 }
n@1170 973 } else {
n@1170 974 return;
n@1170 975 }
n@1170 976 this.specification.options = options;
n@1170 977 break;
n@1170 978 }
n@1170 979 }
n@1170 980 if (this.input.checked) {
n@1170 981 var obj = {
n@1170 982 name: this.name,
n@1170 983 type: this.type
n@1170 984 };
n@1170 985 this.specification.options.push(obj);
n@1170 986 }
n@1170 987 if (this.parent.HTMLPoint.id == "setup")
n@1170 988 {
n@1170 989 // We've changed a global setting, must update all child 'interfaces' and disable them
n@1170 990 for (pages of convert.pages)
n@1170 991 {
n@1170 992 for (interface of pages.interfaces)
n@1170 993 {
n@1170 994 if (this.type == "check")
n@1170 995 {
n@1170 996 for (node of interface.children[0].attributes)
n@1170 997 {
n@1170 998 if (node.name == this.name) {
n@1170 999 if (this.input.checked) {
n@1170 1000 node.input.disabled = true;
n@1170 1001 node.input.checked = false;
n@1170 1002 } else {
n@1170 1003 node.input.disabled = false;
n@1170 1004 }
n@1170 1005 break;
n@1170 1006 }
n@1170 1007 }
n@1170 1008 } else if (this.type == "show")
n@1170 1009 {
n@1170 1010 for (node of interface.children[1].attributes)
n@1170 1011 {
n@1170 1012 if (node.name == this.name) {
n@1170 1013 if (this.input.checked) {
n@1170 1014 node.input.disabled = true;
n@1170 1015 } else {
n@1170 1016 node.input.disabled = false;
n@1170 1017 }
n@1170 1018 break;
n@1170 1019 }
n@1170 1020 }
n@1170 1021 }
n@1170 1022 }
n@1170 1023 }
n@1170 1024 }
n@1170 1025 };
n@1170 1026 this.findIndex = function(element,index,array){
n@1170 1027 if (element.name == this.name)
n@1170 1028 return true;
n@1170 1029 else
n@1170 1030 return false;
n@1170 1031 };
n@1170 1032 this.findNode = function(element,index,array){
n@1170 1033 if (element.name == this.name)
n@1170 1034 return true;
n@1170 1035 else
n@1170 1036 return false;
n@1170 1037 };
n@1170 1038 this.input.type = "checkbox";
n@1170 1039 this.input.setAttribute("name",name);
n@1170 1040 this.input.addEventListener("change",this,false);
n@1170 1041 this.root.appendChild(this.input);
n@1170 1042 this.root.className = "attribute";
n@1170 1043 return this;
n@1170 1044 }
n@1170 1045
n@1170 1046 this.build = function(name,id,parent)
n@1170 1047 {
n@1170 1048 var obj = this.parent.createGeneralNodeDOM(name,id,parent);
n@1170 1049
n@1170 1050 this.rootDOM = obj.rootDOM;
n@1170 1051 this.titleDOM = obj.titleDOM;
n@1170 1052 this.attributeDOM = obj.attributeDOM;
n@1170 1053 this.childrenDOM = obj.childrenDOM;
n@1170 1054 this.buttonDOM = obj.buttonsDOM;
n@1170 1055 this.HTMLPoint = parent;
n@1170 1056 this.rootDOM.removeChild(this.attributeDOM);
n@1170 1057 // Put in the check / show options as individual children
n@1170 1058 var checks = this.parent.createGeneralNodeDOM("Checks","setup-interface-checks",this);
n@1170 1059
n@1170 1060 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 1061 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0];
n@1170 1062 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 1063 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0];
n@1170 1064 testXML = testXML.getAllElementsByTagName("checks");
n@1170 1065 for (var i=0; i<interfaceXML.children.length; i++)
n@1170 1066 {
n@1170 1067 var obj = new this.createIOasAttr(interfaceXML.children[i].getAttribute("name"),this.specification,this,"check");
n@1170 1068 for (var option of this.specification.options)
n@1170 1069 {
n@1170 1070 if (option.name == obj.name)
n@1170 1071 {
n@1170 1072 obj.input.checked = true;
n@1170 1073 break;
n@1170 1074 }
n@1170 1075 }
n@1170 1076 if (parent.id != "setup") {
n@1170 1077 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj);
n@1170 1078 if (node.input.checked) {
n@1170 1079 obj.input.checked = false;
n@1170 1080 obj.input.disable = true;
n@1170 1081 }
n@1170 1082 }
n@1170 1083 var text = document.createElement('span');
n@1170 1084 text.textContent = checkText.children[i].textContent;
n@1170 1085 obj.root.appendChild(text);
n@1170 1086 checks.attributeDOM.appendChild(obj.root);
n@1170 1087 checks.attributes.push(obj);
n@1170 1088 }
n@1170 1089 this.children.push(checks);
n@1170 1090 this.childrenDOM.appendChild(checks.rootDOM);
n@1170 1091
n@1170 1092 var show = this.parent.createGeneralNodeDOM("Show","setup-interface-show",this);
n@1170 1093 interfaceName = popupStateNodes.state[1].select.value;
n@1170 1094 checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0];
n@1170 1095 testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 1096 interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0];
n@1170 1097 testXML = testXML.getAllElementsByTagName("show");
n@1170 1098 for (var i=0; i<interfaceXML.children.length; i++)
n@1170 1099 {
n@1170 1100 var obj = new this.createIOasAttr(interfaceXML.children[i].getAttribute("name"),this.specification,this,"show");
n@1170 1101 for (var option of this.specification.options)
n@1170 1102 {
n@1170 1103 if (option.name == obj.name)
n@1170 1104 {
n@1170 1105 obj.input.checked = true;
n@1170 1106 break;
n@1170 1107 }
n@1170 1108 }
n@1170 1109 if (parent.id != "setup") {
n@1170 1110 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj);
n@1170 1111 if (node.input.checked) {
n@1170 1112 obj.input.checked = false;
n@1170 1113 obj.input.disable = true;
n@1170 1114 }
n@1170 1115 }
n@1170 1116 var text = document.createElement('span');
n@1170 1117 text.textContent = checkText.children[i].textContent;
n@1170 1118 obj.root.appendChild(text);
n@1170 1119 show.attributeDOM.appendChild(obj.root);
n@1170 1120 show.attributes.push(obj);
n@1170 1121 }
n@1170 1122 this.children.push(show);
n@1170 1123 this.childrenDOM.appendChild(show.rootDOM);
n@1170 1124
n@1170 1125 if (parent.id == "setup")
n@1170 1126 {
n@1170 1127 } else {
n@1170 1128 var nameAttr = this.parent.convertAttributeToDOM(this,specification.schema.getAllElementsByName("name")[0]);
n@1170 1129 this.attributeDOM.appendChild(nameAttr.holder);
n@1170 1130 this.attributes.push(nameAttr);
n@1170 1131 }
n@1170 1132 if (parent != undefined)
n@1170 1133 {
n@1170 1134 parent.appendChild(this.rootDOM);
n@1170 1135 }
n@1170 1136 }
n@1170 1137 }
n@1170 1138
n@1170 1139 this.surveyNode = function(parent,rootObject,location)
n@1170 1140 {
n@1170 1141 this.rootDOM = document.createElement("div");
n@1170 1142 this.titleDOM = document.createElement("span");
n@1170 1143 this.attributeDOM = document.createElement("div");
n@1170 1144 this.attributes = [];
n@1170 1145 this.childrenDOM = document.createElement("div");
n@1170 1146 this.children = [];
n@1170 1147 this.buttonDOM = document.createElement("div");
n@1170 1148 this.parent = parent;
n@1170 1149 this.specification = rootObject;
n@1170 1150 this.schema = specification.schema.getAllElementsByName("survey")[1];
n@1170 1151 this.rootDOM.className = "node";
n@1170 1152
n@1170 1153 var titleDiv = document.createElement('div');
n@1170 1154 titleDiv.className = "node-title";
n@1170 1155 this.titleDOM.className = "node-title";
n@1170 1156 this.titleDOM.textContent = "Survey";
n@1170 1157 titleDiv.appendChild(this.titleDOM);
n@1170 1158
n@1170 1159 this.attributeDOM.className = "node-attributes";
n@1170 1160 var locationAttr = document.createElement("span");
n@1170 1161 this.attributeDOM.appendChild(locationAttr);
n@1170 1162 if (location == "Pre" || location == "pre") {
n@1170 1163 locationAttr.textContent = "Location: Before";
n@1170 1164 } else {
n@1170 1165 locationAttr.textContent = "Location: After";
n@1170 1166 }
n@1170 1167 this.childrenDOM.className = "node-children";
n@1170 1168 this.buttonDOM.className = "node-buttons";
n@1170 1169
n@1170 1170 this.rootDOM.appendChild(titleDiv);
n@1170 1171 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1172 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1173 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1174
n@1170 1175 this.surveyEntryNode = function(parent,rootObject)
n@1170 1176 {
n@1170 1177 this.rootDOM = document.createElement("div");
n@1170 1178 this.titleDOM = document.createElement("span");
n@1170 1179 this.attributeDOM = document.createElement("div");
n@1170 1180 this.attributes = [];
n@1170 1181 this.childrenDOM = document.createElement("div");
n@1170 1182 this.children = [];
n@1170 1183 this.buttonDOM = document.createElement("div");
n@1170 1184 this.parent = parent;
n@1170 1185 this.specification = rootObject;
n@1170 1186 this.schema = specification.schema.getAllElementsByName("surveyentry")[1];
n@1170 1187
n@1170 1188 this.rootDOM.id = id;
n@1170 1189 this.rootDOM.className = "node";
n@1170 1190 this.rootDOM.style.minWidth = "50%";
n@1170 1191
n@1170 1192 var titleDiv = document.createElement('div');
n@1170 1193 titleDiv.className = "node-title";
n@1170 1194 this.titleDOM.className = "node-title";
n@1170 1195 titleDiv.appendChild(this.titleDOM);
n@1170 1196
n@1170 1197 this.attributeDOM.className = "node-attributes";
n@1170 1198 this.childrenDOM.className = "node-children";
n@1170 1199 this.buttonDOM.className = "node-buttons";
n@1170 1200
n@1170 1201 this.rootDOM.appendChild(titleDiv);
n@1170 1202 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1203 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1204 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1205
n@1170 1206 var statement = {};
n@1170 1207 statement.rootDOM = document.createElement("div");
n@1170 1208 statement.titleDOM = document.createElement("span");
n@1170 1209 statement.titleDOM.textContent = "Statement/Question";
n@1170 1210 statement.input = document.createElement("textarea");
n@1170 1211 statement.input.value = this.specification.statement;
n@1170 1212 statement.specification = this.specification;
n@1170 1213 statement.handleEvent = function() {
n@1170 1214 this.specification.statement = this.input.value;
n@1170 1215 }
n@1170 1216 statement.input.addEventListener("change",statement,false);
n@1170 1217 statement.rootDOM.appendChild(statement.titleDOM);
n@1170 1218 statement.rootDOM.appendChild(statement.input);
n@1170 1219 this.children.push(statement);
n@1170 1220 this.childrenDOM.appendChild(statement.rootDOM);
n@1170 1221 switch(this.specification.type)
n@1170 1222 {
n@1170 1223 case "statement":
n@1170 1224 this.titleDOM.textContent = "Statement";
n@1170 1225 this.rootDOM.removeChild(this.attributeDOM);
n@1170 1226 break;
n@1170 1227 case "question":
n@1170 1228 var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
n@1170 1229 var mandatory = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("id")[0]);
n@1170 1230 var boxsize = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("boxsize")[0]);
n@1170 1231 break;
n@1170 1232 }
n@1170 1233
n@1170 1234 this.editNode = {
n@1170 1235 root: document.createElement("button"),
n@1170 1236 parent: this,
n@1170 1237 handleEvent: function()
n@1170 1238 {
n@1170 1239 popupObject.show();
n@1170 1240 popupStateNodes.state[5].generate(this,this.parent);
n@1170 1241 popupObject.postNode(popupStateNodes.state[5]);
n@1170 1242 }
n@1170 1243 }
n@1170 1244 this.editNode.root.textContent = "Edit Entry";
n@1170 1245 this.editNode.root.addEventListener("click",this.editNode,false);
n@1170 1246 this.buttonDOM.appendChild(this.editNode.root);
n@1170 1247
n@1170 1248 this.deleteNode = {
n@1170 1249 root: document.createElement("button"),
n@1170 1250 parent: this,
n@1170 1251 handleEvent: function()
n@1170 1252 {
n@1170 1253 var optionList = this.parent.parent.specification.options;
n@1170 1254 var childList = this.parent.parent.children;
n@1170 1255 for (var i=0; i <this.parent.parent.specification.options.length; i++)
n@1170 1256 {
n@1170 1257 var option = this.parent.parent.specification.options[i];
n@1170 1258 if (option == this.parent.specification)
n@1170 1259 {
n@1170 1260 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM);
n@1170 1261 if (i == this.parent.parent.specification.options.length-1)
n@1170 1262 {
n@1170 1263 optionList = optionList.slice(0,i);
n@1170 1264 childList = childList.slice(0,i);
n@1170 1265 }
n@1170 1266 else {
n@1170 1267 optionList = optionList.slice(0,i).concat(optionList.slice(i+1));
n@1170 1268 childList = childList.slice(0,i).concat(childList.slice(i+1));
n@1170 1269 }
n@1170 1270 this.parent.parent.specification.options = optionList;
n@1170 1271 this.parent.parent.children = childList;
n@1170 1272 }
n@1170 1273 }
n@1170 1274 }
n@1170 1275 }
n@1170 1276 this.deleteNode.root.textContent = "Delete Entry";
n@1170 1277 this.deleteNode.root.addEventListener("click",this.deleteNode,false);
n@1170 1278 this.buttonDOM.appendChild(this.deleteNode.root);
n@1170 1279 }
n@1170 1280 this.addNode = {
n@1170 1281 root: document.createElement("button"),
n@1170 1282 parent: this,
n@1170 1283 handleEvent: function()
n@1170 1284 {
n@1170 1285 var newNode = new this.parent.specification.OptionNode();
n@1170 1286 this.parent.specification.options.push(newNode);
n@1170 1287 popupObject.show();
n@1170 1288 popupStateNodes.state[5].generate(newNode,this.parent);
n@1170 1289 popupObject.postNode(popupStateNodes.state[5]);
n@1170 1290 }
n@1170 1291 }
n@1170 1292 this.addNode.root.textContent = "Add Survey Entry";
n@1170 1293 this.addNode.root.addEventListener("click",this.addNode,false);
n@1170 1294 this.buttonDOM.appendChild(this.addNode.root);
n@1170 1295
n@1170 1296 for (var option of this.specification.options)
n@1170 1297 {
n@1170 1298 var newNode = new this.surveyEntryNode(this,option);
n@1170 1299 this.children.push(newNode);
n@1170 1300 this.childrenDOM.appendChild(newNode.rootDOM);
n@1170 1301 }
n@1170 1302 }
n@1170 1303
n@1170 1304 this.pageNode = function(parent,rootObject)
n@1170 1305 {
n@1170 1306 this.rootDOM = document.createElement("div");
n@1170 1307 this.titleDOM = document.createElement("span");
n@1170 1308 this.attributeDOM = document.createElement("div");
n@1170 1309 this.attributes = [];
n@1170 1310 this.childrenDOM = document.createElement("div");
n@1170 1311 this.children = [];
n@1170 1312 this.buttonDOM = document.createElement("div");
n@1170 1313 this.parent = parent;
n@1170 1314 this.specification = rootObject;
n@1170 1315 this.schema = specification.schema.getAllElementsByName("page")[0];
n@1170 1316 this.rootDOM.className = "node";
n@1170 1317
n@1170 1318 var titleDiv = document.createElement('div');
n@1170 1319 titleDiv.className = "node-title";
n@1170 1320 this.titleDOM.className = "node-title";
n@1170 1321 this.titleDOM.textContent = "Test Page";
n@1170 1322 titleDiv.appendChild(this.titleDOM);
n@1170 1323
n@1170 1324 this.attributeDOM.className = "node-attributes";
n@1170 1325 this.childrenDOM.className = "node-children";
n@1170 1326 this.buttonDOM.className = "node-buttons";
n@1170 1327
n@1170 1328 this.rootDOM.appendChild(titleDiv);
n@1170 1329 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1330 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1331 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1332
n@1170 1333 // Do the comment prefix node
n@1170 1334 var cpn = this.parent.createGeneralNodeDOM("Comment Prefix",""+this.specification.id+"-commentprefix",this.parent);
n@1170 1335 cpn.rootDOM.removeChild(cpn.attributeDOM);
n@1170 1336 var obj = {
n@1170 1337 root: document.createElement("div"),
n@1170 1338 input: document.createElement("input"),
n@1170 1339 parent: this,
n@1170 1340 handleEvent: function()
n@1170 1341 {
n@1170 1342 this.parent.specification.commentBoxPrefix = event.currentTarget.value;
n@1170 1343 }
n@1170 1344 }
n@1170 1345 cpn.children.push(obj);
n@1170 1346 cpn.childrenDOM.appendChild(obj.root);
n@1170 1347 obj.root.appendChild(obj.input);
n@1170 1348 obj.input.addEventListener("change",obj,false);
n@1170 1349 obj.input.value = this.specification.commentBoxPrefix;
n@1170 1350 this.childrenDOM.appendChild(cpn.rootDOM);
n@1170 1351 this.children.push(cpn);
n@1170 1352
n@1170 1353 // Now both before and after surveys
n@1170 1354 if (this.specification.preTest == undefined){
n@1170 1355 this.specification.preTest = new specification.surveyNode();
n@1170 1356 this.specification.preTest.location = "pre";
n@1170 1357 }
n@1170 1358 if (this.specification.postTest == undefined){
n@1170 1359 this.specification.postTest = new specification.surveyNode();
n@1170 1360 this.specification.postTest.location = "post";
n@1170 1361 }
n@1170 1362 var surveyBefore = new this.parent.surveyNode(this,this.specification.preTest,"Pre");
n@1170 1363 var surveyAfter = new this.parent.surveyNode(this,this.specification.postTest,"Post");
n@1170 1364 this.children.push(surveyBefore);
n@1170 1365 this.children.push(surveyAfter);
n@1170 1366 this.childrenDOM.appendChild(surveyBefore.rootDOM);
n@1170 1367 this.childrenDOM.appendChild(surveyAfter.rootDOM);
n@1170 1368
n@1170 1369 // Build the attributes
n@1170 1370 var attributeList = this.schema.getAllElementsByTagName("xs:attribute");
n@1170 1371 for (var i=0; i<attributeList.length; i++)
n@1170 1372 {
n@1170 1373 var attributeName = attributeList[i].getAttribute('name');
n@1170 1374 var attrObject = this.parent.convertAttributeToDOM(rootObject,attributeList[i]);
n@1170 1375 this.attributeDOM.appendChild(attrObject.holder);
n@1170 1376 this.attributes.push(attrObject);
n@1170 1377 }
n@1170 1378
n@1170 1379 this.interfaces = [];
n@1170 1380
n@1170 1381 this.audioElementNode = function(parent,rootObject)
n@1170 1382 {
n@1170 1383 this.rootDOM = document.createElement("div");
n@1170 1384 this.titleDOM = document.createElement("span");
n@1170 1385 this.attributeDOM = document.createElement("div");
n@1170 1386 this.attributes = [];
n@1170 1387 this.childrenDOM = document.createElement("div");
n@1170 1388 this.children = [];
n@1170 1389 this.buttonDOM = document.createElement("div");
n@1170 1390 this.parent = parent;
n@1170 1391 this.specification = rootObject;
n@1170 1392 this.schema = specification.schema.getAllElementsByName("audioelement")[0];
n@1170 1393 this.rootDOM.className = "node";
n@1170 1394
n@1170 1395 var titleDiv = document.createElement('div');
n@1170 1396 titleDiv.className = "node-title";
n@1170 1397 this.titleDOM.className = "node-title";
n@1170 1398 this.titleDOM.textContent = "Audio Element";
n@1170 1399 titleDiv.appendChild(this.titleDOM);
n@1170 1400
n@1170 1401 this.attributeDOM.className = "node-attributes";
n@1170 1402 this.childrenDOM.className = "node-children";
n@1170 1403 this.buttonDOM.className = "node-buttons";
n@1170 1404
n@1170 1405 this.rootDOM.appendChild(titleDiv);
n@1170 1406 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1407 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1408 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1409
n@1170 1410 // Build the attributes
n@1170 1411 var attributeList = this.schema.getAllElementsByTagName("xs:attribute");
n@1170 1412 for (var i=0; i<attributeList.length; i++)
n@1170 1413 {
n@1170 1414 var attributeName = attributeList[i].getAttribute('name');
n@1170 1415 var attrObject = this.parent.parent.convertAttributeToDOM(rootObject,attributeList[i]);
n@1170 1416 this.attributeDOM.appendChild(attrObject.holder);
n@1170 1417 this.attributes.push(attrObject);
n@1170 1418 }
n@1170 1419
n@1170 1420 this.deleteNode = {
n@1170 1421 root: document.createElement("button"),
n@1170 1422 parent: this,
n@1170 1423 handleEvent: function()
n@1170 1424 {
n@1170 1425 var i = this.parent.parent.specification.audioElements.findIndex(this.findNode,this);
n@1170 1426 if (i >= 0) {
n@1170 1427 var aeList = this.parent.parent.specification.audioElements;
n@1170 1428 if (i < aeList.length-1) {
n@1170 1429 aeList = aeList.slice(0,i).concat(aeList.slice(i+1));
n@1170 1430 } else {
n@1170 1431 aeList = aeList.slice(0,i);
n@1170 1432 }
n@1170 1433 }
n@1170 1434 i = this.parent.parent.children.findIndex(function(element,index,array){
n@1170 1435 if (element == this.parent)
n@1170 1436 return true;
n@1170 1437 else
n@1170 1438 return false;
n@1170 1439 },this);
n@1170 1440 if (i >= 0) {
n@1170 1441 var childList = this.parent.children;
n@1170 1442 if (i < aeList.length-1) {
n@1170 1443 childList = childList.slice(0,i).concat(childList.slice(i+1));
n@1170 1444 } else {
n@1170 1445 childList = childList.slice(0,i);
n@1170 1446 }
n@1170 1447 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM);
n@1170 1448 }
n@1170 1449 },
n@1170 1450 findNode: function(element,index,array){
n@1170 1451 if (element == this.parent.specification)
n@1170 1452 return true;
n@1170 1453 else
n@1170 1454 return false;
n@1170 1455 }
n@1170 1456 }
n@1170 1457 this.deleteNode.root.textContent = "Delete Entry";
n@1170 1458 this.deleteNode.root.addEventListener("click",this.deleteNode,false);
n@1170 1459 this.buttonDOM.appendChild(this.deleteNode.root);
n@1170 1460 }
n@1170 1461
n@1170 1462 this.commentQuestionNode = function(parent,rootObject)
n@1170 1463 {
n@1170 1464 this.rootDOM = document.createElement("div");
n@1170 1465 this.titleDOM = document.createElement("span");
n@1170 1466 this.attributeDOM = document.createElement("div");
n@1170 1467 this.attributes = [];
n@1170 1468 this.childrenDOM = document.createElement("div");
n@1170 1469 this.children = [];
n@1170 1470 this.buttonDOM = document.createElement("div");
n@1170 1471 this.parent = parent;
n@1170 1472 this.specification = rootObject;
n@1170 1473 this.schema = specification.schema.getAllElementsByName("page")[0];
n@1170 1474 this.rootDOM.className = "node";
n@1170 1475
n@1170 1476 var titleDiv = document.createElement('div');
n@1170 1477 titleDiv.className = "node-title";
n@1170 1478 this.titleDOM.className = "node-title";
n@1170 1479 this.titleDOM.textContent = "Test Page";
n@1170 1480 titleDiv.appendChild(this.titleDOM);
n@1170 1481
n@1170 1482 this.attributeDOM.className = "node-attributes";
n@1170 1483 this.childrenDOM.className = "node-children";
n@1170 1484 this.buttonDOM.className = "node-buttons";
n@1170 1485
n@1170 1486 this.rootDOM.appendChild(titleDiv);
n@1170 1487 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1488 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1489 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1490
n@1170 1491 }
n@1170 1492
n@1170 1493 this.addInterface = {
n@1170 1494 root: document.createElement("button"),
n@1170 1495 parent: this,
n@1170 1496 handleEvent: function() {
n@1170 1497 var InterfaceObj = new specification.interfaceNode();
n@1170 1498 var newInterface = new this.parent.parent.interfaceNode(this.parent.parent,InterfaceObj);
n@1170 1499 newInterface.build("Interface",""+this.parent.specification.id+"-interface",this.parent.childrenDOM);
n@1170 1500 this.parent.children.push(newInterface);
n@1170 1501 this.parent.specification.interfaces.push(InterfaceObj);
n@1170 1502 this.parent.interfaces.push(newInterface);
n@1170 1503 }
n@1170 1504 }
n@1170 1505 this.addInterface.root.textContent = "Add Interface";
n@1170 1506 this.addInterface.root.addEventListener("click",this.addInterface,false);
n@1170 1507 this.buttonDOM.appendChild(this.addInterface.root);
n@1170 1508
n@1170 1509 this.addAudioElement = {
n@1170 1510 root: document.createElement("button"),
n@1170 1511 parent: this,
n@1170 1512 handleEvent: function() {
n@1170 1513 var audioElementObject = new this.parent.specification.audioElementNode();
n@1170 1514 var audioElementDOM = new this.parent.audioElementNode(this.parent,audioElementObject);
n@1170 1515 this.parent.specification.audioElements.push(audioElementObject);
n@1170 1516 this.parent.children.push(audioElementDOM);
n@1170 1517 this.parent.childrenDOM.appendChild(audioElementDOM.rootDOM);
n@1170 1518 }
n@1170 1519 }
n@1170 1520 this.addAudioElement.root.textContent = "Add Audio Element";
n@1170 1521 this.addAudioElement.root.addEventListener("click",this.addAudioElement,false);
n@1170 1522 this.buttonDOM.appendChild(this.addAudioElement.root);
n@1170 1523 }
n@1170 1524 }