annotate test_create/test_core.js @ 1110:f53b1098795f

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