annotate test_create/test_core.js @ 1185:05012deab817

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