annotate test_create/test_core.js @ 1174:dd7ba3054bf9

Test create drag and drop active. Auto-builds on page HTML from specification.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 11 Feb 2016 12:06:54 +0000
parents d4348ae0bc02
children 1dbc6d3e6fb5
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@1173 198 this.dragArea.className = "drag-area";
n@1173 199 this.dragArea.id = "project-drop";
n@1170 200 this.content.appendChild(this.dragArea);
n@1173 201
n@1174 202 this.dragArea.addEventListener('dragover',function(e){
n@1173 203 e.stopPropagation();
n@1173 204 e.preventDefault();
n@1173 205 e.dataTransfer.dropEffect = 'copy';
n@1173 206 e.currentTarget.className = "drag-area drag-over";
n@1173 207 });
n@1173 208
n@1173 209 this.dragArea.addEventListener('dragexit',function(e){
n@1173 210 e.stopPropagation();
n@1173 211 e.preventDefault();
n@1173 212 e.dataTransfer.dropEffect = 'copy';
n@1173 213 e.currentTarget.className = "drag-area";
n@1173 214 });
n@1173 215
n@1173 216 this.dragArea.addEventListener('drop',function(e){
n@1173 217 e.stopPropagation();
n@1173 218 e.preventDefault();
n@1173 219 e.currentTarget.className = "drag-area drag-dropped";
n@1173 220 var files = e.dataTransfer.files[0];
n@1174 221 var reader = new FileReader();
n@1174 222 reader.onload = function(decoded) {
n@1174 223 var parse = new DOMParser();
n@1174 224 specification.decode(parse.parseFromString(decoded.target.result,'text/xml'));
n@1174 225 popupObject.hide();
n@1174 226 convert.convert(document.getElementById('content'));
n@1174 227 }
n@1174 228 reader.readAsText(files);
n@1173 229 });
n@1173 230
n@1170 231
n@1170 232 this.continue = function()
n@1170 233 {
n@1170 234 popupObject.postNode(popupStateNodes.state[1]);
n@1170 235 }
n@1170 236 }
n@1170 237 this.state[1] = new function()
n@1170 238 {
n@1170 239 this.title = "Select your interface";
n@1170 240 this.content = document.createElement("div");
n@1170 241 this.content.id = "state-1";
n@1170 242 var spnH = document.createElement('div');
n@1170 243 var span = document.createElement("span");
n@1170 244 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 245 spnH.appendChild(span);
n@1170 246 this.content.appendChild(spnH);
n@1170 247 this.select = document.createElement("select");
n@1170 248 this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].children;
n@1170 249 for (var i=0; i<this.testsXML.length; i++)
n@1170 250 {
n@1170 251 var option = document.createElement('option');
n@1170 252 option.value = this.testsXML[i].getAttribute('name');
n@1170 253 option.textContent = this.testsXML[i].getAttribute('name');
n@1170 254 this.select.appendChild(option);
n@1170 255 }
n@1170 256 this.content.appendChild(this.select);
n@1170 257 this.continue = function()
n@1170 258 {
n@1170 259 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0];
n@1170 260 specification.interface = testXML.getAttribute("interface");
n@1170 261 popupStateNodes.state[2].generate();
n@1170 262 popupObject.postNode(popupStateNodes.state[2]);
n@1170 263 }
n@1170 264 }
n@1170 265 this.state[2] = new function()
n@1170 266 {
n@1170 267 this.title = "Test Checks & Restrictions";
n@1170 268 this.content = document.createElement("div");
n@1170 269 this.content.id = "state-1";
n@1170 270 var spnH = document.createElement('div');
n@1170 271 var span = document.createElement("span");
n@1170 272 span.textContent = "Select your test checks and restrictions. Greyed out items are fixed by the test/interface and cannot be changed";
n@1170 273 spnH.appendChild(span);
n@1170 274 this.content.appendChild(spnH);
n@1170 275 var holder = document.createElement("div");
n@1170 276 this.options = [];
n@1170 277 this.testXML = null;
n@1170 278 this.interfaceXML = null;
n@1170 279 this.generate = function()
n@1170 280 {
n@1170 281 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 282 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0];
n@1170 283 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 284 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0];
n@1170 285 this.testXML = this.testXML.getAllElementsByTagName("checks");
n@1170 286 for (var i=0; i<this.interfaceXML.children.length; i++)
n@1170 287 {
n@1170 288 var interfaceNode = this.interfaceXML.children[i];
n@1170 289 var checkName = interfaceNode.getAttribute('name');
n@1170 290 var testNode
n@1170 291 if (this.testXML.length > 0)
n@1170 292 {
n@1170 293 testNode = this.testXML[0].getAllElementsByName(checkName);
n@1170 294 if(testNode.length != 0) {testNode = testNode[0];}
n@1170 295 else {testNode = undefined;}
n@1170 296 } else {
n@1170 297 testNode = undefined;
n@1170 298 }
n@1170 299 var optH = document.createElement('div');
n@1170 300 optH.className = "popup-checkbox";
n@1170 301 var checkbox = document.createElement('input');
n@1170 302 checkbox.type = "checkbox";
n@1170 303 var text = document.createElement('span');
n@1170 304 checkbox.setAttribute('name',checkName);
n@1170 305 if (interfaceNode.getAttribute('default') == 'on')
n@1170 306 {
n@1170 307 checkbox.checked = true;
n@1170 308 }
n@1170 309 if (interfaceNode.getAttribute('support') == "none")
n@1170 310 {
n@1170 311 checkbox.disabled = true;
n@1170 312 checkbox.checked = false;
n@1170 313 optH.className = "popup-checkbox disabled";
n@1170 314 } else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 315 {
n@1170 316 checkbox.disabled = true;
n@1170 317 checkbox.checked = true;
n@1170 318 optH.className = "popup-checkbox disabled";
n@1170 319 }
n@1170 320 if(testNode != undefined)
n@1170 321 {
n@1170 322 if (interfaceNode.getAttribute('default') == 'on')
n@1170 323 {
n@1170 324 checkbox.checked = true;
n@1170 325 }
n@1170 326 if (testNode.getAttribute('support') == "none")
n@1170 327 {
n@1170 328 checkbox.disabled = true;
n@1170 329 checkbox.checked = false;
n@1170 330 optH.className = "popup-checkbox disabled";
n@1170 331 }else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 332 {
n@1170 333 checkbox.disabled = true;
n@1170 334 checkbox.checked = true;
n@1170 335 optH.className = "popup-checkbox disabled";
n@1170 336 }
n@1170 337 }
n@1170 338 text.textContent = popupStateNodes.state[2].checkText.getAllElementsByName(checkName)[0].textContent;
n@1170 339 optH.appendChild(checkbox);
n@1170 340 optH.appendChild(text);
n@1170 341 this.options.push(optH);
n@1170 342 this.content.appendChild(optH);
n@1170 343 }
n@1170 344 }
n@1170 345 this.continue = function()
n@1170 346 {
n@1170 347 if (specification.interfaces == null)
n@1170 348 {
n@1170 349 specification.interfaces = new specification.interfaceNode();
n@1170 350 }
n@1170 351 for (var object of this.options)
n@1170 352 {
n@1170 353 var checkbox = object.children[0];
n@1170 354 if (checkbox.checked)
n@1170 355 {
n@1170 356 var option = {
n@1170 357 type: "check",
n@1170 358 name: checkbox.getAttribute('name')
n@1170 359 };
n@1170 360 specification.interfaces.options.push(option);
n@1170 361 }
n@1170 362 }
n@1170 363 popupStateNodes.state[3].generate();
n@1170 364 popupObject.postNode(popupStateNodes.state[3]);
n@1170 365 }
n@1170 366 }
n@1170 367 this.state[3] = new function()
n@1170 368 {
n@1170 369 this.title = "Test Metrics";
n@1170 370 this.content = document.createElement("div");
n@1170 371 this.content.id = "state-1";
n@1170 372 var spnH = document.createElement('div');
n@1170 373 var span = document.createElement("span");
n@1170 374 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 375 spnH.appendChild(span);
n@1170 376 this.content.appendChild(spnH);
n@1170 377 this.options = [];
n@1170 378 this.checkText;
n@1170 379 this.testXML;
n@1170 380 this.interfaceXML;
n@1170 381 this.generate = function()
n@1170 382 {
n@1170 383 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 384 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0];
n@1170 385 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 386 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0];
n@1170 387 this.testXML = this.testXML.getAllElementsByTagName("metrics");
n@1170 388 for (var i=0; i<this.interfaceXML.children.length; i++)
n@1170 389 {
n@1170 390 var interfaceNode = this.interfaceXML.children[i];
n@1170 391 var checkName = interfaceNode.getAttribute('name');
n@1170 392 var testNode
n@1170 393 if (this.testXML.length > 0)
n@1170 394 {
n@1170 395 testNode = this.testXML[0].getAllElementsByName(checkName);
n@1170 396 if(testNode.length != 0) {testNode = testNode[0];}
n@1170 397 else {testNode = undefined;}
n@1170 398 } else {
n@1170 399 testNode = undefined;
n@1170 400 }
n@1170 401 var optH = document.createElement('div');
n@1170 402 optH.className = "popup-checkbox";
n@1170 403 var checkbox = document.createElement('input');
n@1170 404 checkbox.type = "checkbox";
n@1170 405 var text = document.createElement('span');
n@1170 406 checkbox.setAttribute('name',checkName);
n@1170 407 if (interfaceNode.getAttribute('default') == 'on')
n@1170 408 {
n@1170 409 checkbox.checked = true;
n@1170 410 }
n@1170 411 if (interfaceNode.getAttribute('support') == "none")
n@1170 412 {
n@1170 413 checkbox.disabled = true;
n@1170 414 checkbox.checked = false;
n@1170 415 optH.className = "popup-checkbox disabled";
n@1170 416 } else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 417 {
n@1170 418 checkbox.disabled = true;
n@1170 419 checkbox.checked = true;
n@1170 420 optH.className = "popup-checkbox disabled";
n@1170 421 }
n@1170 422 if(testNode != undefined)
n@1170 423 {
n@1170 424 if (interfaceNode.getAttribute('default') == 'on')
n@1170 425 {
n@1170 426 checkbox.checked = true;
n@1170 427 }
n@1170 428 if (testNode.getAttribute('support') == "none")
n@1170 429 {
n@1170 430 checkbox.disabled = true;
n@1170 431 checkbox.checked = false;
n@1170 432 optH.className = "popup-checkbox disabled";
n@1170 433 }else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 434 {
n@1170 435 checkbox.disabled = true;
n@1170 436 checkbox.checked = true;
n@1170 437 optH.className = "popup-checkbox disabled";
n@1170 438 }
n@1170 439 }
n@1170 440 text.textContent = popupStateNodes.state[3].checkText.getAllElementsByName(checkName)[0].textContent;
n@1170 441 optH.appendChild(checkbox);
n@1170 442 optH.appendChild(text);
n@1170 443 this.options.push(optH);
n@1170 444 this.content.appendChild(optH);
n@1170 445 }
n@1170 446 }
n@1170 447 this.continue = function()
n@1170 448 {
n@1170 449 if (specification.metrics == null) {
n@1170 450 specification.metrics = new specification.metricNode();
n@1170 451 }
n@1170 452 for (var object of this.options)
n@1170 453 {
n@1170 454 var checkbox = object.children[0];
n@1170 455 if (checkbox.checked)
n@1170 456 {
n@1170 457 specification.metrics.enabled.push(checkbox.getAttribute('name'));
n@1170 458 }
n@1170 459 }
n@1170 460 popupStateNodes.state[4].generate();
n@1170 461 popupObject.postNode(popupStateNodes.state[4]);
n@1170 462 }
n@1170 463 }
n@1170 464 this.state[4] = new function()
n@1170 465 {
n@1170 466 this.title = "Test Visuals";
n@1170 467 this.content = document.createElement("div");
n@1170 468 this.content.id = "state-1";
n@1170 469 var spnH = document.createElement('div');
n@1170 470 var span = document.createElement("span");
n@1170 471 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 472 spnH.appendChild(span);
n@1170 473 this.content.appendChild(spnH);
n@1170 474 this.options = [];
n@1170 475 this.checkText;
n@1170 476 this.testXML;
n@1170 477 this.interfaceXML;
n@1170 478 this.generate = function()
n@1170 479 {
n@1170 480 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 481 this.checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0];
n@1170 482 this.testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 483 this.interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(this.testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0];
n@1170 484 this.testXML = this.testXML.getAllElementsByTagName("metrics");
n@1170 485 for (var i=0; i<this.interfaceXML.children.length; i++)
n@1170 486 {
n@1170 487 var interfaceNode = this.interfaceXML.children[i];
n@1170 488 var checkName = interfaceNode.getAttribute('name');
n@1170 489 var testNode
n@1170 490 if (this.testXML.length > 0)
n@1170 491 {
n@1170 492 testNode = this.testXML[0].getAllElementsByName(checkName);
n@1170 493 if(testNode.length != 0) {testNode = testNode[0];}
n@1170 494 else {testNode = undefined;}
n@1170 495 } else {
n@1170 496 testNode = undefined;
n@1170 497 }
n@1170 498 var optH = document.createElement('div');
n@1170 499 optH.className = "popup-checkbox";
n@1170 500 var checkbox = document.createElement('input');
n@1170 501 checkbox.type = "checkbox";
n@1170 502 var text = document.createElement('span');
n@1170 503 checkbox.setAttribute('name',checkName);
n@1170 504 if (interfaceNode.getAttribute('default') == 'on')
n@1170 505 {
n@1170 506 checkbox.checked = true;
n@1170 507 }
n@1170 508 if (interfaceNode.getAttribute('support') == "none")
n@1170 509 {
n@1170 510 checkbox.disabled = true;
n@1170 511 checkbox.checked = false;
n@1170 512 optH.className = "popup-checkbox disabled";
n@1170 513 } else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 514 {
n@1170 515 checkbox.disabled = true;
n@1170 516 checkbox.checked = true;
n@1170 517 optH.className = "popup-checkbox disabled";
n@1170 518 }
n@1170 519 if(testNode != undefined)
n@1170 520 {
n@1170 521 if (interfaceNode.getAttribute('default') == 'on')
n@1170 522 {
n@1170 523 checkbox.checked = true;
n@1170 524 }
n@1170 525 if (testNode.getAttribute('support') == "none")
n@1170 526 {
n@1170 527 checkbox.disabled = true;
n@1170 528 checkbox.checked = false;
n@1170 529 optH.className = "popup-checkbox disabled";
n@1170 530 }else if (interfaceNode.getAttribute('support') == "mandatory")
n@1170 531 {
n@1170 532 checkbox.disabled = true;
n@1170 533 checkbox.checked = true;
n@1170 534 optH.className = "popup-checkbox disabled";
n@1170 535 }
n@1170 536 }
n@1170 537 text.textContent = this.checkText.getAllElementsByName(checkName)[0].textContent;
n@1170 538 optH.appendChild(checkbox);
n@1170 539 optH.appendChild(text);
n@1170 540 this.options.push(optH);
n@1170 541 this.content.appendChild(optH);
n@1170 542 }
n@1170 543 }
n@1170 544 this.continue = function()
n@1170 545 {
n@1170 546 if (specification.interfaces == null)
n@1170 547 {
n@1170 548 specification.interfaces = new specification.interfaceNode();
n@1170 549 }
n@1170 550 for (var object of this.options)
n@1170 551 {
n@1170 552 var checkbox = object.children[0];
n@1170 553 if (checkbox.checked)
n@1170 554 {
n@1170 555 var option = {
n@1170 556 type: "show",
n@1170 557 name: checkbox.getAttribute('name')
n@1170 558 };
n@1170 559 specification.interfaces.options.push(option);
n@1170 560 }
n@1170 561 }
n@1170 562 popupObject.hide();
n@1170 563 convert.convert(document.getElementById('content'));
n@1170 564 }
n@1170 565 }
n@1170 566 this.state[5] = new function() {
n@1170 567 this.title = "Add/Edit Survey Element";
n@1170 568 this.content = document.createElement("div");
n@1170 569 this.content.id = "state-1";
n@1170 570 var spnH = document.createElement('div');
n@1170 571 var span = document.createElement("span");
n@1170 572 span.textContent = "You can configure your survey element here. Press 'Continue' to complete your changes.";
n@1170 573 spnH.appendChild(span);
n@1170 574 this.content.appendChild(spnH);
n@1170 575 this.dynamic = document.createElement("div");
n@1170 576 this.option = null;
n@1170 577 this.parent = null;
n@1170 578 var select = document.createElement("select");
n@1170 579 select.setAttribute("name","type");
n@1170 580 select.addEventListener("change",this,false);
n@1170 581 this.content.appendChild(select);
n@1170 582 this.content.appendChild(this.dynamic);
n@1170 583 this.generate = function(option, parent)
n@1170 584 {
n@1170 585 this.option = option;
n@1170 586 this.parent = parent;
n@1170 587 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("type")[0].getAllElementsByTagName("xs:enumeration");
n@1170 588 for (var i=0; i<optionList.length; i++)
n@1170 589 {
n@1170 590 var selectOption = document.createElement("option");
n@1170 591 selectOption.value = optionList[i].getAttribute("value");
n@1170 592 selectOption.textContent = selectOption.value;
n@1170 593 select.appendChild(selectOption);
n@1170 594 }
n@1170 595 if (this.option.type != undefined){
n@1170 596 select.value = this.option.type
n@1170 597 } else {
n@1170 598 select.value = "statement";
n@1170 599 this.option.type = "statement";
n@1170 600 }
n@1170 601
n@1170 602 this.dynamic.innerHTML = null;
n@1170 603 var statement = document.createElement("div");
n@1170 604 var statementText = document.createElement("span");
n@1170 605 var statementEntry = document.createElement("textarea");
n@1170 606 statement.appendChild(statementText);
n@1170 607 statement.appendChild(statementEntry);
n@1170 608 statementText.textContent = "Statement/Question";
n@1170 609 statementEntry.addEventListener("change",this,false);
n@1170 610 statementEntry.setAttribute("name","statement");
n@1170 611 statementEntry.value = this.option.statement;
n@1170 612 this.dynamic.appendChild(statement);
n@1170 613 switch(this.option.type)
n@1170 614 {
n@1170 615 case "statement":
n@1170 616 break;
n@1170 617 case "question":
n@1170 618 var boxsizeSelect = document.createElement("select");
n@1170 619 var optionList = specification.schema.getAllElementsByName("survey")[0].getAllElementsByName("boxsize")[0].getAllElementsByTagName("xs:enumeration");
n@1170 620 for (var i=0; i<optionList.length; i++)
n@1170 621 {
n@1170 622 var selectOption = document.createElement("option");
n@1170 623 selectOption.value = optionList[i].getAttribute("value");
n@1170 624 selectOption.textContent = selectOption.value;
n@1170 625 boxsizeSelect.appendChild(selectOption);
n@1170 626 }
n@1170 627 if(this.option.boxsize != undefined) {
n@1170 628 boxsizeSelect.value = this.option.boxsize;
n@1170 629 } else {
n@1170 630 boxsizeSelect.value = "normal";
n@1170 631 this.option.boxsize = "normal";
n@1170 632 }
n@1170 633 boxsizeSelect.setAttribute("name","boxsize");
n@1170 634 boxsizeSelect.addEventListener("change",this,false);
n@1170 635 var boxsize = document.createElement("div");
n@1170 636 var boxsizeText = document.createElement("span");
n@1170 637 boxsizeText.textContent = "Entry Size: ";
n@1170 638 boxsize.appendChild(boxsizeText);
n@1170 639 boxsize.appendChild(boxsizeSelect);
n@1170 640 this.dynamic.appendChild(boxsize);
n@1170 641
n@1170 642 var mandatory = document.createElement("div");
n@1170 643 var mandatoryInput = document.createElement("input");
n@1170 644 var mandatoryText = document.createElement("span");
n@1170 645 mandatoryText.textContent = "Mandatory: ";
n@1170 646 mandatory.appendChild(mandatoryText);
n@1170 647 mandatory.appendChild(mandatoryInput);
n@1170 648 mandatoryInput.type = "checkbox";
n@1170 649 if (this.option.mandatory) {mandatoryInput.checked = true;} else {mandatoryInput.checked = false;}
n@1170 650 mandatoryInput.setAttribute("name","mandatory");
n@1170 651 mandatoryInput.addEventListener("change",this,false);
n@1170 652 mandatory.appendChild(mandatoryText);
n@1170 653 mandatory.appendChild(mandatoryInput);
n@1170 654 this.dynamic.appendChild(mandatory);
n@1170 655 break;
n@1170 656 }
n@1170 657 }
n@1170 658 this.handleEvent = function()
n@1170 659 {
n@1170 660 var name = event.currentTarget.getAttribute("name");
n@1170 661 switch(name) {
n@1170 662 case "type":
n@1170 663 // If type has changed, we may need to rebuild the entire state node
n@1170 664 if (event.currentTarget.value != this.option.name)
n@1170 665 {
n@1170 666 this.option.type = event.currentTarget.value;
n@1170 667 this.generate(this.option,this.parent);
n@1170 668 }
n@1170 669 break;
n@1170 670 case "mandatory":
n@1170 671 this.option.mandatory = event.currentTarget.checked;
n@1170 672 break;
n@1170 673 case "boxsize":
n@1170 674 this.option.boxsize = event.currentTarget.value;
n@1170 675 break;
n@1170 676 case "statement":
n@1170 677 this.option.statement = event.currentTarget.value;
n@1170 678 break;
n@1170 679 }
n@1170 680 }
n@1170 681 this.continue = function()
n@1170 682 {
n@1170 683 var newNode = new this.parent.surveyEntryNode(this.parent,this.option);
n@1170 684 this.parent.children.push(newNode);
n@1170 685 this.parent.childrenDOM.appendChild(newNode.rootDOM);
n@1170 686 popupObject.hide();
n@1170 687 }
n@1170 688 }
n@1170 689 }
n@1170 690 }
n@1170 691
n@1170 692 function SpecificationToHTML()
n@1170 693 {
n@1170 694 // This takes the specification node and converts it to an on-page HTML object
n@1170 695 // Each Specification Node is given its own JS object which listens to the XSD for instant verification
n@1170 696 // Once generated, it directly binds into the specification object to update with changes
n@1170 697 // Fixed DOM entries
n@1170 698 this.injectDOM;
n@1170 699 this.setupDOM;
n@1170 700 this.pages = [];
n@1170 701
n@1170 702 // Self-contained generators
n@1170 703 this.createGeneralNodeDOM = function(name,id,parent)
n@1170 704 {
n@1170 705 var root = document.createElement('div');
n@1170 706 root.id = id;
n@1170 707 root.className = "node";
n@1170 708
n@1170 709 var titleDiv = document.createElement('div');
n@1170 710 titleDiv.className = "node-title";
n@1170 711 var title = document.createElement('span');
n@1170 712 title.className = "node-title";
n@1170 713 title.textContent = name;
n@1170 714 titleDiv.appendChild(title);
n@1170 715
n@1170 716 var attributeDiv = document.createElement('div');
n@1170 717 attributeDiv.className = "node-attributes";
n@1170 718
n@1170 719 var childrenDiv = document.createElement('div');
n@1170 720 childrenDiv.className = "node-children";
n@1170 721
n@1170 722 var buttonsDiv = document.createElement('div');
n@1170 723 buttonsDiv.className = "node-buttons";
n@1170 724
n@1170 725 root.appendChild(titleDiv);
n@1170 726 root.appendChild(attributeDiv);
n@1170 727 root.appendChild(childrenDiv);
n@1170 728 root.appendChild(buttonsDiv);
n@1170 729
n@1170 730 var obj = {
n@1170 731 rootDOM: root,
n@1170 732 titleDOM: title,
n@1170 733 attributeDOM: attributeDiv,
n@1170 734 attributes: [],
n@1170 735 childrenDOM: childrenDiv,
n@1170 736 children: [],
n@1170 737 buttonDOM: buttonsDiv,
n@1170 738 parent: parent
n@1170 739 }
n@1170 740 return obj;
n@1170 741 }
n@1170 742
n@1170 743 this.convertAttributeToDOM = function(node,schema)
n@1170 744 {
n@1170 745 // This takes an attribute schema node and returns an object with the input node and any bindings
n@1170 746 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined)
n@1170 747 {
n@1170 748 schema = specification.schema.getAllElementsByName(schema.getAttribute('ref'))[0];
n@1170 749 }
n@1170 750 var obj = new function()
n@1170 751 {
n@1170 752 this.input;
n@1170 753 this.name;
n@1170 754 this.owner;
n@1170 755 this.holder;
n@1170 756
n@1170 757 this.name = schema.getAttribute('name');
n@1170 758 this.default = schema.getAttribute('default');
n@1170 759 this.dataType = schema.getAttribute('type');
n@1170 760 if (typeof this.dataType == "string") { this.dataType = this.dataType.substr(3);}
n@1170 761 else {this.dataType = "string";}
n@1170 762 var minVar = undefined;
n@1170 763 var maxVar = undefined;
n@1170 764 switch(this.dataType)
n@1170 765 {
n@1170 766 case "negativeInteger":
n@1170 767 maxVar = -1;
n@1170 768 break;
n@1170 769 case "positiveInteger":
n@1170 770 minVar = 1;
n@1170 771 break;
n@1170 772 case "nonNegativeInteger":
n@1170 773 minVar = 0;
n@1170 774 break;
n@1170 775 case "nonPositiveInteger":
n@1170 776 maxVar = 0;
n@1170 777 break;
n@1170 778 case "byte":
n@1170 779 minVar = 0;
n@1170 780 maxVar = 256;
n@1170 781 break;
n@1170 782 case "short":
n@1170 783 minVar = 0;
n@1170 784 maxVar = 65536;
n@1170 785 break;
n@1170 786 default:
n@1170 787 break;
n@1170 788 }
n@1170 789
n@1170 790 this.input = document.createElement('input');
n@1170 791 switch(this.dataType)
n@1170 792 {
n@1170 793 case "boolean":
n@1170 794 this.input.type = "checkbox";
n@1170 795 break;
n@1170 796 case "negativeInteger":
n@1170 797 case "positiveInteger":
n@1170 798 case "nonNegativeInteger":
n@1170 799 case "nonPositiveInteger":
n@1170 800 case "integer":
n@1170 801 case "short":
n@1170 802 case "byte":
n@1170 803 this.input.step = 1;
n@1170 804 case "decimal":
n@1170 805 this.input.type = "number";
n@1170 806 this.input.min = minVar;
n@1170 807 this.input.max = maxVar;
n@1170 808 break;
n@1170 809 default:
n@1170 810 break;
n@1170 811 }
n@1170 812 var value;
n@1173 813 eval("value = node."+this.name)
n@1170 814 if (value != undefined)
n@1170 815 {
n@1170 816 this.input.value = value;
n@1170 817 } else if (this.default != undefined)
n@1170 818 {
n@1170 819 this.input.value = this.default;
n@1170 820 }
n@1170 821 this.handleEvent = function(event)
n@1170 822 {
n@1170 823 var value;
n@1170 824 switch(this.input.type)
n@1170 825 {
n@1170 826 case "checkbox":
n@1170 827 value = event.currentTarget.checked;
n@1170 828 break;
n@1170 829 case "number":
n@1170 830 value = Number(event.currentTarget.value);
n@1170 831 break;
n@1170 832 default:
n@1170 833 value = event.currentTarget.value;
n@1170 834 break;
n@1170 835 }
n@1170 836 eval("this.owner."+this.name+" = value");
n@1170 837 }
n@1170 838 this.holder = document.createElement('div');
n@1170 839 this.holder.className = "attribute";
n@1170 840 this.holder.setAttribute('name',this.name);
n@1170 841 var text = document.createElement('span');
n@1170 842 eval("text.textContent = attributeText."+this.name+"+': '");
n@1170 843 this.holder.appendChild(text);
n@1170 844 this.holder.appendChild(this.input);
n@1170 845 this.owner = node;
n@1170 846 this.input.addEventListener("change",this,false);
n@1170 847 }
n@1170 848 if (obj.attribute != null)
n@1170 849 {
n@1170 850 obj.input.value = obj.attribute;
n@1170 851 }
n@1170 852 return obj;
n@1170 853 }
n@1170 854
n@1170 855 this.convert = function(root)
n@1170 856 {
n@1170 857 //Performs the actual conversion using the given root DOM as the root
n@1170 858 this.injectDOM = root;
n@1170 859
n@1173 860 // Build the export button
n@1173 861 var exportButton = document.createElement("button");
n@1173 862 exportButton.textContent = "Export to XML";
n@1173 863 exportButton.onclick = function()
n@1173 864 {
n@1173 865 var doc = specification.encode();
n@1173 866 var obj = {};
n@1173 867 obj.title = "Export";
n@1173 868 obj.content = document.createElement("div");
n@1173 869 obj.content.id = "finish";
n@1173 870 var span = document.createElement("span");
n@1173 871 span.textContent = "Your XML document is linked below. On most browsers, simply right click on the link and select 'Save As'. Or clicking on the link may download the file directly."
n@1173 872 obj.content.appendChild(span);
n@1173 873 var link = document.createElement("div");
n@1173 874 link.appendChild(doc.children[0]);
n@1173 875 var file = [link.innerHTML];
n@1173 876 var bb = new Blob(file,{type : 'application/xml'});
n@1173 877 var dnlk = window.URL.createObjectURL(bb);
n@1173 878 var a = document.createElement("a");
n@1173 879 a.hidden = '';
n@1173 880 a.href = dnlk;
n@1173 881 a.download = "project-specification.xml";
n@1173 882 a.textContent = "Save File";
n@1173 883 obj.content.appendChild(a);
n@1173 884 popupObject.show();
n@1173 885 popupObject.postNode(obj);
n@1173 886 }
n@1173 887 this.injectDOM.appendChild(exportButton);
n@1173 888
n@1170 889 // First perform the setupNode;
n@1170 890 var setupSchema = specification.schema.getAllElementsByName('setup')[0];
n@1170 891 this.setupDOM = new this.createGeneralNodeDOM('setup','setup',null);
n@1170 892 this.injectDOM.appendChild(this.setupDOM.rootDOM);
n@1170 893 var setupAttributes = setupSchema.getAllElementsByTagName('xs:attribute');
n@1170 894 for (var i=0; i<setupAttributes.length; i++)
n@1170 895 {
n@1170 896 var attributeName = setupAttributes[i].getAttribute('name');
n@1170 897 var attrObject = this.convertAttributeToDOM(specification,setupAttributes[i]);
n@1170 898 this.setupDOM.attributeDOM.appendChild(attrObject.holder);
n@1170 899 this.setupDOM.attributes.push(attrObject);
n@1170 900 }
n@1170 901
n@1170 902 // Now we must build the interface Node
n@1170 903 this.interfaceDOM = new this.interfaceNode(this,specification.interfaces);
n@1170 904 this.interfaceDOM.build("Interface","setup-interface",this.setupDOM.rootDOM);
n@1170 905
n@1170 906 // Now build the Metrics selection node
n@1170 907 var metric = this.createGeneralNodeDOM("metrics","setup-metric",this.setupDOM);
n@1170 908 metric.rootDOM.removeChild(metric.attributeDOM);
n@1170 909 this.setupDOM.children.push(metric);
n@1170 910 this.setupDOM.childrenDOM.appendChild(metric.rootDOM);
n@1170 911 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 912 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("metrics")[0];
n@1170 913 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 914 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("metrics")[0];
n@1170 915 testXML = testXML.getAllElementsByTagName("metrics");
n@1170 916 for (var i=0; i<interfaceXML.children.length; i++)
n@1170 917 {
n@1170 918 var obj = {
n@1170 919 input: document.createElement('input'),
n@1170 920 root: document.createElement('div'),
n@1170 921 text: document.createElement('span'),
n@1170 922 specification: specification.metrics.enabled,
n@1170 923 name: interfaceXML.children[i].getAttribute("name"),
n@1170 924 handleEvent: function()
n@1170 925 {
n@1170 926 for (var i=0; i<this.specification.length; i++)
n@1170 927 {
n@1170 928 if (this.specification[i] == this.name)
n@1170 929 {
n@1170 930 var options = this.specification;
n@1170 931 if (this.input.checked == false) {
n@1170 932 if (i == options.length)
n@1170 933 {options = options.slice(0,i);}
n@1170 934 else {
n@1170 935 options = options.slice(0,i).concat(options.slice(i+1));
n@1170 936 }
n@1170 937 } else {
n@1170 938 return;
n@1170 939 }
n@1170 940 this.specification = options;
n@1170 941 break;
n@1170 942 }
n@1170 943 }
n@1170 944 if (this.input.checked) {
n@1170 945 this.specification.push(this.name);
n@1170 946 }
n@1170 947 }
n@1170 948 };
n@1170 949 obj.root.className = "attribute";
n@1170 950 obj.input.type = "checkbox";
n@1170 951 obj.root.appendChild(obj.text);
n@1170 952 obj.root.appendChild(obj.input);
n@1170 953 obj.text.textContent = checkText.children[i].textContent;
n@1170 954 metric.children.push(obj);
n@1170 955 metric.childrenDOM.appendChild(obj.root);
n@1170 956 for (var i=0; i<specification.metrics.enabled.length; i++)
n@1170 957 {
n@1170 958 if (specification.metrics.enabled[i] == obj.name)
n@1170 959 {
n@1170 960 obj.input.checked = true;
n@1170 961 break;
n@1170 962 }
n@1170 963 }
n@1170 964 }
n@1170 965
n@1170 966 // Now both before and after surveys
n@1170 967 if (specification.preTest == undefined){
n@1170 968 specification.preTest = new specification.surveyNode();
n@1170 969 specification.preTest.location = "pre";
n@1170 970 }
n@1170 971 if (specification.postTest == undefined){
n@1170 972 specification.postTest = new specification.surveyNode();
n@1170 973 specification.postTest.location = "post";
n@1170 974 }
n@1170 975 var surveyBefore = new this.surveyNode(this,specification.preTest,"Pre");
n@1170 976 var surveyAfter = new this.surveyNode(this,specification.postTest,"Post");
n@1170 977 this.setupDOM.children.push(surveyBefore);
n@1170 978 this.setupDOM.children.push(surveyAfter);
n@1170 979 this.setupDOM.childrenDOM.appendChild(surveyBefore.rootDOM);
n@1170 980 this.setupDOM.childrenDOM.appendChild(surveyAfter.rootDOM);
n@1170 981
n@1170 982 // Add in the page creator button
n@1170 983 this.addPage = {
n@1170 984 root: document.createElement("button"),
n@1170 985 parent: this,
n@1170 986 handleEvent: function()
n@1170 987 {
n@1170 988 var pageObj = new specification.page();
n@1170 989 specification.pages.push(pageObj);
n@1170 990 var newPage = new this.parent.pageNode(this.parent,pageObj);
n@1170 991 this.parent.injectDOM.appendChild(newPage.rootDOM);
n@1170 992 this.parent.pages.push(newPage);
n@1170 993 }
n@1170 994 }
n@1170 995 this.addPage.root.textContent = "Add Page";
n@1170 996 this.addPage.root.addEventListener("click",this.addPage,false);
n@1170 997 this.injectDOM.appendChild(this.addPage.root);
n@1174 998
n@1174 999 // Build each page
n@1174 1000 for (var page of specification.pages)
n@1174 1001 {
n@1174 1002 var newPage = new this.pageNode(this,page);
n@1174 1003 this.injectDOM.appendChild(newPage.rootDOM);
n@1174 1004 this.pages.push(newPage);
n@1174 1005 }
n@1170 1006 }
n@1170 1007
n@1170 1008 this.interfaceNode = function(parent,rootObject)
n@1170 1009 {
n@1170 1010 this.rootDOM;
n@1170 1011 this.titleDOM;
n@1170 1012 this.attributeDOM;
n@1170 1013 this.attributes = [];
n@1170 1014 this.childrenDOM;
n@1170 1015 this.children = [];
n@1170 1016 this.buttonDOM;
n@1170 1017 this.parent = parent;
n@1170 1018 this.HTMLPoint;
n@1170 1019 this.specification = rootObject;
n@1170 1020 this.schema = specification.schema.getAllElementsByName("interface")[1];
n@1170 1021
n@1170 1022 this.createIOasAttr = function(name,specification,parent,type) {
n@1170 1023 this.root = document.createElement('div');
n@1170 1024 this.input = document.createElement("input");
n@1170 1025 this.name = name;
n@1170 1026 this.type = type;
n@1170 1027 this.parent = parent;
n@1170 1028 this.specification = specification;
n@1170 1029 this.handleEvent = function(event) {
n@1170 1030 for (var i=0; i<this.specification.options.length; i++)
n@1170 1031 {
n@1170 1032 if (this.specification.options[i].name == this.name)
n@1170 1033 {
n@1170 1034 var options = this.specification.options;
n@1170 1035 if (this.input.checked == false) {
n@1170 1036 if (i == options.length)
n@1170 1037 {options = options.slice(0,i);}
n@1170 1038 else {
n@1170 1039 options = options.slice(0,i).concat(options.slice(i+1));
n@1170 1040 }
n@1170 1041 } else {
n@1170 1042 return;
n@1170 1043 }
n@1170 1044 this.specification.options = options;
n@1170 1045 break;
n@1170 1046 }
n@1170 1047 }
n@1170 1048 if (this.input.checked) {
n@1170 1049 var obj = {
n@1170 1050 name: this.name,
n@1170 1051 type: this.type
n@1170 1052 };
n@1170 1053 this.specification.options.push(obj);
n@1170 1054 }
n@1170 1055 if (this.parent.HTMLPoint.id == "setup")
n@1170 1056 {
n@1170 1057 // We've changed a global setting, must update all child 'interfaces' and disable them
n@1170 1058 for (pages of convert.pages)
n@1170 1059 {
n@1170 1060 for (interface of pages.interfaces)
n@1170 1061 {
n@1170 1062 if (this.type == "check")
n@1170 1063 {
n@1170 1064 for (node of interface.children[0].attributes)
n@1170 1065 {
n@1170 1066 if (node.name == this.name) {
n@1170 1067 if (this.input.checked) {
n@1170 1068 node.input.disabled = true;
n@1170 1069 node.input.checked = false;
n@1170 1070 } else {
n@1170 1071 node.input.disabled = false;
n@1170 1072 }
n@1170 1073 break;
n@1170 1074 }
n@1170 1075 }
n@1170 1076 } else if (this.type == "show")
n@1170 1077 {
n@1170 1078 for (node of interface.children[1].attributes)
n@1170 1079 {
n@1170 1080 if (node.name == this.name) {
n@1170 1081 if (this.input.checked) {
n@1170 1082 node.input.disabled = true;
n@1170 1083 } else {
n@1170 1084 node.input.disabled = false;
n@1170 1085 }
n@1170 1086 break;
n@1170 1087 }
n@1170 1088 }
n@1170 1089 }
n@1170 1090 }
n@1170 1091 }
n@1170 1092 }
n@1170 1093 };
n@1170 1094 this.findIndex = function(element,index,array){
n@1170 1095 if (element.name == this.name)
n@1170 1096 return true;
n@1170 1097 else
n@1170 1098 return false;
n@1170 1099 };
n@1170 1100 this.findNode = function(element,index,array){
n@1170 1101 if (element.name == this.name)
n@1170 1102 return true;
n@1170 1103 else
n@1170 1104 return false;
n@1170 1105 };
n@1170 1106 this.input.type = "checkbox";
n@1170 1107 this.input.setAttribute("name",name);
n@1170 1108 this.input.addEventListener("change",this,false);
n@1170 1109 this.root.appendChild(this.input);
n@1170 1110 this.root.className = "attribute";
n@1170 1111 return this;
n@1170 1112 }
n@1170 1113
n@1170 1114 this.build = function(name,id,parent)
n@1170 1115 {
n@1170 1116 var obj = this.parent.createGeneralNodeDOM(name,id,parent);
n@1170 1117
n@1170 1118 this.rootDOM = obj.rootDOM;
n@1170 1119 this.titleDOM = obj.titleDOM;
n@1170 1120 this.attributeDOM = obj.attributeDOM;
n@1170 1121 this.childrenDOM = obj.childrenDOM;
n@1170 1122 this.buttonDOM = obj.buttonsDOM;
n@1170 1123 this.HTMLPoint = parent;
n@1170 1124 this.rootDOM.removeChild(this.attributeDOM);
n@1170 1125 // Put in the check / show options as individual children
n@1170 1126 var checks = this.parent.createGeneralNodeDOM("Checks","setup-interface-checks",this);
n@1170 1127
n@1170 1128 var interfaceName = popupStateNodes.state[1].select.value;
n@1170 1129 var checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("checks")[0];
n@1170 1130 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 1131 var interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("checks")[0];
n@1170 1132 testXML = testXML.getAllElementsByTagName("checks");
n@1170 1133 for (var i=0; i<interfaceXML.children.length; i++)
n@1170 1134 {
n@1170 1135 var obj = new this.createIOasAttr(interfaceXML.children[i].getAttribute("name"),this.specification,this,"check");
n@1170 1136 for (var option of this.specification.options)
n@1170 1137 {
n@1170 1138 if (option.name == obj.name)
n@1170 1139 {
n@1170 1140 obj.input.checked = true;
n@1170 1141 break;
n@1170 1142 }
n@1170 1143 }
n@1170 1144 if (parent.id != "setup") {
n@1170 1145 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj);
n@1170 1146 if (node.input.checked) {
n@1170 1147 obj.input.checked = false;
n@1170 1148 obj.input.disable = true;
n@1170 1149 }
n@1170 1150 }
n@1170 1151 var text = document.createElement('span');
n@1170 1152 text.textContent = checkText.children[i].textContent;
n@1170 1153 obj.root.appendChild(text);
n@1170 1154 checks.attributeDOM.appendChild(obj.root);
n@1170 1155 checks.attributes.push(obj);
n@1170 1156 }
n@1170 1157 this.children.push(checks);
n@1170 1158 this.childrenDOM.appendChild(checks.rootDOM);
n@1170 1159
n@1170 1160 var show = this.parent.createGeneralNodeDOM("Show","setup-interface-show",this);
n@1170 1161 interfaceName = popupStateNodes.state[1].select.value;
n@1170 1162 checkText = interfaceSpecs.getElementsByTagName("global")[0].getAllElementsByTagName("show")[0];
n@1170 1163 testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(interfaceName)[0];
n@1170 1164 interfaceXML = interfaceSpecs.getAllElementsByTagName("interfaces")[0].getAllElementsByName(testXML.getAttribute("interface"))[0].getAllElementsByTagName("show")[0];
n@1170 1165 testXML = testXML.getAllElementsByTagName("show");
n@1170 1166 for (var i=0; i<interfaceXML.children.length; i++)
n@1170 1167 {
n@1170 1168 var obj = new this.createIOasAttr(interfaceXML.children[i].getAttribute("name"),this.specification,this,"show");
n@1170 1169 for (var option of this.specification.options)
n@1170 1170 {
n@1170 1171 if (option.name == obj.name)
n@1170 1172 {
n@1170 1173 obj.input.checked = true;
n@1170 1174 break;
n@1170 1175 }
n@1170 1176 }
n@1170 1177 if (parent.id != "setup") {
n@1170 1178 var node = convert.interfaceDOM.children[0].attributes.find(obj.findNode,obj);
n@1170 1179 if (node.input.checked) {
n@1170 1180 obj.input.checked = false;
n@1170 1181 obj.input.disable = true;
n@1170 1182 }
n@1170 1183 }
n@1170 1184 var text = document.createElement('span');
n@1170 1185 text.textContent = checkText.children[i].textContent;
n@1170 1186 obj.root.appendChild(text);
n@1170 1187 show.attributeDOM.appendChild(obj.root);
n@1170 1188 show.attributes.push(obj);
n@1170 1189 }
n@1170 1190 this.children.push(show);
n@1170 1191 this.childrenDOM.appendChild(show.rootDOM);
n@1170 1192
n@1170 1193 if (parent.id == "setup")
n@1170 1194 {
n@1170 1195 } else {
n@1170 1196 var nameAttr = this.parent.convertAttributeToDOM(this,specification.schema.getAllElementsByName("name")[0]);
n@1170 1197 this.attributeDOM.appendChild(nameAttr.holder);
n@1170 1198 this.attributes.push(nameAttr);
n@1170 1199 }
n@1170 1200 if (parent != undefined)
n@1170 1201 {
n@1170 1202 parent.appendChild(this.rootDOM);
n@1170 1203 }
n@1170 1204 }
n@1170 1205 }
n@1170 1206
n@1170 1207 this.surveyNode = function(parent,rootObject,location)
n@1170 1208 {
n@1170 1209 this.rootDOM = document.createElement("div");
n@1170 1210 this.titleDOM = document.createElement("span");
n@1170 1211 this.attributeDOM = document.createElement("div");
n@1170 1212 this.attributes = [];
n@1170 1213 this.childrenDOM = document.createElement("div");
n@1170 1214 this.children = [];
n@1170 1215 this.buttonDOM = document.createElement("div");
n@1170 1216 this.parent = parent;
n@1170 1217 this.specification = rootObject;
n@1170 1218 this.schema = specification.schema.getAllElementsByName("survey")[1];
n@1170 1219 this.rootDOM.className = "node";
n@1170 1220
n@1170 1221 var titleDiv = document.createElement('div');
n@1170 1222 titleDiv.className = "node-title";
n@1170 1223 this.titleDOM.className = "node-title";
n@1170 1224 this.titleDOM.textContent = "Survey";
n@1170 1225 titleDiv.appendChild(this.titleDOM);
n@1170 1226
n@1170 1227 this.attributeDOM.className = "node-attributes";
n@1170 1228 var locationAttr = document.createElement("span");
n@1170 1229 this.attributeDOM.appendChild(locationAttr);
n@1170 1230 if (location == "Pre" || location == "pre") {
n@1170 1231 locationAttr.textContent = "Location: Before";
n@1170 1232 } else {
n@1170 1233 locationAttr.textContent = "Location: After";
n@1170 1234 }
n@1170 1235 this.childrenDOM.className = "node-children";
n@1170 1236 this.buttonDOM.className = "node-buttons";
n@1170 1237
n@1170 1238 this.rootDOM.appendChild(titleDiv);
n@1170 1239 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1240 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1241 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1242
n@1170 1243 this.surveyEntryNode = function(parent,rootObject)
n@1170 1244 {
n@1170 1245 this.rootDOM = document.createElement("div");
n@1170 1246 this.titleDOM = document.createElement("span");
n@1170 1247 this.attributeDOM = document.createElement("div");
n@1170 1248 this.attributes = [];
n@1170 1249 this.childrenDOM = document.createElement("div");
n@1170 1250 this.children = [];
n@1170 1251 this.buttonDOM = document.createElement("div");
n@1170 1252 this.parent = parent;
n@1170 1253 this.specification = rootObject;
n@1170 1254 this.schema = specification.schema.getAllElementsByName("surveyentry")[1];
n@1170 1255
n@1170 1256 this.rootDOM.id = id;
n@1170 1257 this.rootDOM.className = "node";
n@1170 1258 this.rootDOM.style.minWidth = "50%";
n@1170 1259
n@1170 1260 var titleDiv = document.createElement('div');
n@1170 1261 titleDiv.className = "node-title";
n@1170 1262 this.titleDOM.className = "node-title";
n@1170 1263 titleDiv.appendChild(this.titleDOM);
n@1170 1264
n@1170 1265 this.attributeDOM.className = "node-attributes";
n@1170 1266 this.childrenDOM.className = "node-children";
n@1170 1267 this.buttonDOM.className = "node-buttons";
n@1170 1268
n@1170 1269 this.rootDOM.appendChild(titleDiv);
n@1170 1270 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1271 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1272 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1273
n@1170 1274 var statement = {};
n@1170 1275 statement.rootDOM = document.createElement("div");
n@1170 1276 statement.titleDOM = document.createElement("span");
n@1170 1277 statement.titleDOM.textContent = "Statement/Question";
n@1170 1278 statement.input = document.createElement("textarea");
n@1170 1279 statement.input.value = this.specification.statement;
n@1170 1280 statement.specification = this.specification;
n@1170 1281 statement.handleEvent = function() {
n@1170 1282 this.specification.statement = this.input.value;
n@1170 1283 }
n@1170 1284 statement.input.addEventListener("change",statement,false);
n@1170 1285 statement.rootDOM.appendChild(statement.titleDOM);
n@1170 1286 statement.rootDOM.appendChild(statement.input);
n@1170 1287 this.children.push(statement);
n@1170 1288 this.childrenDOM.appendChild(statement.rootDOM);
n@1170 1289 switch(this.specification.type)
n@1170 1290 {
n@1170 1291 case "statement":
n@1170 1292 this.titleDOM.textContent = "Statement";
n@1170 1293 this.rootDOM.removeChild(this.attributeDOM);
n@1170 1294 break;
n@1170 1295 case "question":
n@1174 1296 this.titleDOM.textContent = "Question";
n@1170 1297 var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
n@1174 1298 var mandatory = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("mandatory")[0]);
n@1170 1299 var boxsize = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("boxsize")[0]);
n@1174 1300 this.attributeDOM.appendChild(id.holder);
n@1174 1301 this.attributes.push(id);
n@1174 1302 this.attributeDOM.appendChild(mandatory.holder);
n@1174 1303 this.attributes.push(mandatory);
n@1174 1304 this.attributeDOM.appendChild(boxsize.holder);
n@1174 1305 this.attributes.push(boxsize);
n@1170 1306 break;
n@1174 1307 case "checkbox":
n@1174 1308 this.titleDOM.textContent = "Checkbox";
n@1174 1309 var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
n@1174 1310 this.attributeDOM.appendChild(id.holder);
n@1174 1311 this.attributes.push(id);
n@1174 1312 case "radio":
n@1174 1313 this.titleDOM.textContent = "Radio";
n@1174 1314 var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
n@1174 1315 this.attributeDOM.appendChild(id.holder);
n@1174 1316 this.attributes.push(id);
n@1170 1317 }
n@1170 1318
n@1170 1319 this.editNode = {
n@1170 1320 root: document.createElement("button"),
n@1170 1321 parent: this,
n@1170 1322 handleEvent: function()
n@1170 1323 {
n@1170 1324 popupObject.show();
n@1170 1325 popupStateNodes.state[5].generate(this,this.parent);
n@1170 1326 popupObject.postNode(popupStateNodes.state[5]);
n@1170 1327 }
n@1170 1328 }
n@1170 1329 this.editNode.root.textContent = "Edit Entry";
n@1170 1330 this.editNode.root.addEventListener("click",this.editNode,false);
n@1170 1331 this.buttonDOM.appendChild(this.editNode.root);
n@1170 1332
n@1170 1333 this.deleteNode = {
n@1170 1334 root: document.createElement("button"),
n@1170 1335 parent: this,
n@1170 1336 handleEvent: function()
n@1170 1337 {
n@1170 1338 var optionList = this.parent.parent.specification.options;
n@1170 1339 var childList = this.parent.parent.children;
n@1170 1340 for (var i=0; i <this.parent.parent.specification.options.length; i++)
n@1170 1341 {
n@1170 1342 var option = this.parent.parent.specification.options[i];
n@1170 1343 if (option == this.parent.specification)
n@1170 1344 {
n@1170 1345 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM);
n@1170 1346 if (i == this.parent.parent.specification.options.length-1)
n@1170 1347 {
n@1170 1348 optionList = optionList.slice(0,i);
n@1170 1349 childList = childList.slice(0,i);
n@1170 1350 }
n@1170 1351 else {
n@1170 1352 optionList = optionList.slice(0,i).concat(optionList.slice(i+1));
n@1170 1353 childList = childList.slice(0,i).concat(childList.slice(i+1));
n@1170 1354 }
n@1170 1355 this.parent.parent.specification.options = optionList;
n@1170 1356 this.parent.parent.children = childList;
n@1170 1357 }
n@1170 1358 }
n@1170 1359 }
n@1170 1360 }
n@1170 1361 this.deleteNode.root.textContent = "Delete Entry";
n@1170 1362 this.deleteNode.root.addEventListener("click",this.deleteNode,false);
n@1170 1363 this.buttonDOM.appendChild(this.deleteNode.root);
n@1170 1364 }
n@1170 1365 this.addNode = {
n@1170 1366 root: document.createElement("button"),
n@1170 1367 parent: this,
n@1170 1368 handleEvent: function()
n@1170 1369 {
n@1170 1370 var newNode = new this.parent.specification.OptionNode();
n@1170 1371 this.parent.specification.options.push(newNode);
n@1170 1372 popupObject.show();
n@1170 1373 popupStateNodes.state[5].generate(newNode,this.parent);
n@1170 1374 popupObject.postNode(popupStateNodes.state[5]);
n@1170 1375 }
n@1170 1376 }
n@1170 1377 this.addNode.root.textContent = "Add Survey Entry";
n@1170 1378 this.addNode.root.addEventListener("click",this.addNode,false);
n@1170 1379 this.buttonDOM.appendChild(this.addNode.root);
n@1170 1380
n@1170 1381 for (var option of this.specification.options)
n@1170 1382 {
n@1170 1383 var newNode = new this.surveyEntryNode(this,option);
n@1170 1384 this.children.push(newNode);
n@1170 1385 this.childrenDOM.appendChild(newNode.rootDOM);
n@1170 1386 }
n@1170 1387 }
n@1170 1388
n@1170 1389 this.pageNode = function(parent,rootObject)
n@1170 1390 {
n@1170 1391 this.rootDOM = document.createElement("div");
n@1170 1392 this.titleDOM = document.createElement("span");
n@1170 1393 this.attributeDOM = document.createElement("div");
n@1170 1394 this.attributes = [];
n@1170 1395 this.childrenDOM = document.createElement("div");
n@1170 1396 this.children = [];
n@1170 1397 this.buttonDOM = document.createElement("div");
n@1170 1398 this.parent = parent;
n@1170 1399 this.specification = rootObject;
n@1170 1400 this.schema = specification.schema.getAllElementsByName("page")[0];
n@1170 1401 this.rootDOM.className = "node";
n@1170 1402
n@1170 1403 var titleDiv = document.createElement('div');
n@1170 1404 titleDiv.className = "node-title";
n@1170 1405 this.titleDOM.className = "node-title";
n@1170 1406 this.titleDOM.textContent = "Test Page";
n@1170 1407 titleDiv.appendChild(this.titleDOM);
n@1170 1408
n@1170 1409 this.attributeDOM.className = "node-attributes";
n@1170 1410 this.childrenDOM.className = "node-children";
n@1170 1411 this.buttonDOM.className = "node-buttons";
n@1170 1412
n@1170 1413 this.rootDOM.appendChild(titleDiv);
n@1170 1414 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1415 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1416 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1417
n@1170 1418 // Do the comment prefix node
n@1170 1419 var cpn = this.parent.createGeneralNodeDOM("Comment Prefix",""+this.specification.id+"-commentprefix",this.parent);
n@1170 1420 cpn.rootDOM.removeChild(cpn.attributeDOM);
n@1170 1421 var obj = {
n@1170 1422 root: document.createElement("div"),
n@1170 1423 input: document.createElement("input"),
n@1170 1424 parent: this,
n@1170 1425 handleEvent: function()
n@1170 1426 {
n@1170 1427 this.parent.specification.commentBoxPrefix = event.currentTarget.value;
n@1170 1428 }
n@1170 1429 }
n@1170 1430 cpn.children.push(obj);
n@1170 1431 cpn.childrenDOM.appendChild(obj.root);
n@1170 1432 obj.root.appendChild(obj.input);
n@1170 1433 obj.input.addEventListener("change",obj,false);
n@1170 1434 obj.input.value = this.specification.commentBoxPrefix;
n@1170 1435 this.childrenDOM.appendChild(cpn.rootDOM);
n@1170 1436 this.children.push(cpn);
n@1170 1437
n@1170 1438 // Now both before and after surveys
n@1170 1439 if (this.specification.preTest == undefined){
n@1170 1440 this.specification.preTest = new specification.surveyNode();
n@1170 1441 this.specification.preTest.location = "pre";
n@1170 1442 }
n@1170 1443 if (this.specification.postTest == undefined){
n@1170 1444 this.specification.postTest = new specification.surveyNode();
n@1170 1445 this.specification.postTest.location = "post";
n@1170 1446 }
n@1170 1447 var surveyBefore = new this.parent.surveyNode(this,this.specification.preTest,"Pre");
n@1170 1448 var surveyAfter = new this.parent.surveyNode(this,this.specification.postTest,"Post");
n@1170 1449 this.children.push(surveyBefore);
n@1170 1450 this.children.push(surveyAfter);
n@1170 1451 this.childrenDOM.appendChild(surveyBefore.rootDOM);
n@1170 1452 this.childrenDOM.appendChild(surveyAfter.rootDOM);
n@1170 1453
n@1170 1454 // Build the attributes
n@1170 1455 var attributeList = this.schema.getAllElementsByTagName("xs:attribute");
n@1170 1456 for (var i=0; i<attributeList.length; i++)
n@1170 1457 {
n@1170 1458 var attributeName = attributeList[i].getAttribute('name');
n@1170 1459 var attrObject = this.parent.convertAttributeToDOM(rootObject,attributeList[i]);
n@1170 1460 this.attributeDOM.appendChild(attrObject.holder);
n@1170 1461 this.attributes.push(attrObject);
n@1170 1462 }
n@1170 1463
n@1170 1464 this.interfaces = [];
n@1170 1465
n@1170 1466 this.audioElementNode = function(parent,rootObject)
n@1170 1467 {
n@1170 1468 this.rootDOM = document.createElement("div");
n@1170 1469 this.titleDOM = document.createElement("span");
n@1170 1470 this.attributeDOM = document.createElement("div");
n@1170 1471 this.attributes = [];
n@1170 1472 this.childrenDOM = document.createElement("div");
n@1170 1473 this.children = [];
n@1170 1474 this.buttonDOM = document.createElement("div");
n@1170 1475 this.parent = parent;
n@1170 1476 this.specification = rootObject;
n@1170 1477 this.schema = specification.schema.getAllElementsByName("audioelement")[0];
n@1170 1478 this.rootDOM.className = "node";
n@1170 1479
n@1170 1480 var titleDiv = document.createElement('div');
n@1170 1481 titleDiv.className = "node-title";
n@1170 1482 this.titleDOM.className = "node-title";
n@1170 1483 this.titleDOM.textContent = "Audio Element";
n@1170 1484 titleDiv.appendChild(this.titleDOM);
n@1170 1485
n@1170 1486 this.attributeDOM.className = "node-attributes";
n@1170 1487 this.childrenDOM.className = "node-children";
n@1170 1488 this.buttonDOM.className = "node-buttons";
n@1170 1489
n@1170 1490 this.rootDOM.appendChild(titleDiv);
n@1170 1491 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1492 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1493 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1494
n@1170 1495 // Build the attributes
n@1170 1496 var attributeList = this.schema.getAllElementsByTagName("xs:attribute");
n@1170 1497 for (var i=0; i<attributeList.length; i++)
n@1170 1498 {
n@1170 1499 var attributeName = attributeList[i].getAttribute('name');
n@1170 1500 var attrObject = this.parent.parent.convertAttributeToDOM(rootObject,attributeList[i]);
n@1170 1501 this.attributeDOM.appendChild(attrObject.holder);
n@1170 1502 this.attributes.push(attrObject);
n@1170 1503 }
n@1170 1504
n@1170 1505 this.deleteNode = {
n@1170 1506 root: document.createElement("button"),
n@1170 1507 parent: this,
n@1170 1508 handleEvent: function()
n@1170 1509 {
n@1170 1510 var i = this.parent.parent.specification.audioElements.findIndex(this.findNode,this);
n@1170 1511 if (i >= 0) {
n@1170 1512 var aeList = this.parent.parent.specification.audioElements;
n@1170 1513 if (i < aeList.length-1) {
n@1170 1514 aeList = aeList.slice(0,i).concat(aeList.slice(i+1));
n@1170 1515 } else {
n@1170 1516 aeList = aeList.slice(0,i);
n@1170 1517 }
n@1170 1518 }
n@1170 1519 i = this.parent.parent.children.findIndex(function(element,index,array){
n@1170 1520 if (element == this.parent)
n@1170 1521 return true;
n@1170 1522 else
n@1170 1523 return false;
n@1170 1524 },this);
n@1170 1525 if (i >= 0) {
n@1170 1526 var childList = this.parent.children;
n@1170 1527 if (i < aeList.length-1) {
n@1170 1528 childList = childList.slice(0,i).concat(childList.slice(i+1));
n@1170 1529 } else {
n@1170 1530 childList = childList.slice(0,i);
n@1170 1531 }
n@1170 1532 this.parent.parent.childrenDOM.removeChild(this.parent.rootDOM);
n@1170 1533 }
n@1170 1534 },
n@1170 1535 findNode: function(element,index,array){
n@1170 1536 if (element == this.parent.specification)
n@1170 1537 return true;
n@1170 1538 else
n@1170 1539 return false;
n@1170 1540 }
n@1170 1541 }
n@1170 1542 this.deleteNode.root.textContent = "Delete Entry";
n@1170 1543 this.deleteNode.root.addEventListener("click",this.deleteNode,false);
n@1170 1544 this.buttonDOM.appendChild(this.deleteNode.root);
n@1170 1545 }
n@1170 1546
n@1170 1547 this.commentQuestionNode = function(parent,rootObject)
n@1170 1548 {
n@1170 1549 this.rootDOM = document.createElement("div");
n@1170 1550 this.titleDOM = document.createElement("span");
n@1170 1551 this.attributeDOM = document.createElement("div");
n@1170 1552 this.attributes = [];
n@1170 1553 this.childrenDOM = document.createElement("div");
n@1170 1554 this.children = [];
n@1170 1555 this.buttonDOM = document.createElement("div");
n@1170 1556 this.parent = parent;
n@1170 1557 this.specification = rootObject;
n@1170 1558 this.schema = specification.schema.getAllElementsByName("page")[0];
n@1170 1559 this.rootDOM.className = "node";
n@1170 1560
n@1170 1561 var titleDiv = document.createElement('div');
n@1170 1562 titleDiv.className = "node-title";
n@1170 1563 this.titleDOM.className = "node-title";
n@1170 1564 this.titleDOM.textContent = "Test Page";
n@1170 1565 titleDiv.appendChild(this.titleDOM);
n@1170 1566
n@1170 1567 this.attributeDOM.className = "node-attributes";
n@1170 1568 this.childrenDOM.className = "node-children";
n@1170 1569 this.buttonDOM.className = "node-buttons";
n@1170 1570
n@1170 1571 this.rootDOM.appendChild(titleDiv);
n@1170 1572 this.rootDOM.appendChild(this.attributeDOM);
n@1170 1573 this.rootDOM.appendChild(this.childrenDOM);
n@1170 1574 this.rootDOM.appendChild(this.buttonDOM);
n@1170 1575
n@1170 1576 }
n@1170 1577
n@1174 1578 // Build the components
n@1174 1579 for (var elements of this.specification.audioElements)
n@1174 1580 {
n@1174 1581 var audioElementDOM = new this.audioElementNode(this,elements);
n@1174 1582 this.children.push(audioElementDOM);
n@1174 1583 this.childrenDOM.appendChild(audioElementDOM.rootDOM);
n@1174 1584 }
n@1174 1585
n@1170 1586 this.addInterface = {
n@1170 1587 root: document.createElement("button"),
n@1170 1588 parent: this,
n@1170 1589 handleEvent: function() {
n@1170 1590 var InterfaceObj = new specification.interfaceNode();
n@1170 1591 var newInterface = new this.parent.parent.interfaceNode(this.parent.parent,InterfaceObj);
n@1170 1592 newInterface.build("Interface",""+this.parent.specification.id+"-interface",this.parent.childrenDOM);
n@1170 1593 this.parent.children.push(newInterface);
n@1170 1594 this.parent.specification.interfaces.push(InterfaceObj);
n@1170 1595 this.parent.interfaces.push(newInterface);
n@1170 1596 }
n@1170 1597 }
n@1170 1598 this.addInterface.root.textContent = "Add Interface";
n@1170 1599 this.addInterface.root.addEventListener("click",this.addInterface,false);
n@1170 1600 this.buttonDOM.appendChild(this.addInterface.root);
n@1170 1601
n@1170 1602 this.addAudioElement = {
n@1170 1603 root: document.createElement("button"),
n@1170 1604 parent: this,
n@1170 1605 handleEvent: function() {
n@1170 1606 var audioElementObject = new this.parent.specification.audioElementNode();
n@1170 1607 var audioElementDOM = new this.parent.audioElementNode(this.parent,audioElementObject);
n@1170 1608 this.parent.specification.audioElements.push(audioElementObject);
n@1170 1609 this.parent.children.push(audioElementDOM);
n@1170 1610 this.parent.childrenDOM.appendChild(audioElementDOM.rootDOM);
n@1170 1611 }
n@1170 1612 }
n@1170 1613 this.addAudioElement.root.textContent = "Add Audio Element";
n@1170 1614 this.addAudioElement.root.addEventListener("click",this.addAudioElement,false);
n@1170 1615 this.buttonDOM.appendChild(this.addAudioElement.root);
n@1170 1616 }
n@1170 1617 }