annotate test_create/test_create.html @ 1318:64541cd9265d

Added schema for Test Specification Document for validation (wip)
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 23 Dec 2015 12:41:08 +0000
parents
children 43801b3d6131 2cd9f09455a5
rev   line source
nickjillings@1318 1 <!DOCTYPE html>
nickjillings@1318 2 <html lang="en">
nickjillings@1318 3 <head>
nickjillings@1318 4 <meta charset="utf-8">
nickjillings@1318 5
nickjillings@1318 6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
nickjillings@1318 7 Remove this if you use the .htaccess -->
nickjillings@1318 8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
nickjillings@1318 9
nickjillings@1318 10 <title>WAET: Test Creator</title>
nickjillings@1318 11
nickjillings@1318 12 <meta name="viewport" content="width=device-width; initial-scale=1.0">
nickjillings@1318 13 <script type="text/javascript">
nickjillings@1318 14
nickjillings@1318 15 var APEInterfaceOptions = [["playhead","page-count"],["Show the playhead/scrubber bar", "Show test page count"]];
nickjillings@1318 16 var APEInterfaceChecks = [["fragmentPlayed","fragmentFullPlayback","fragmentMoved","fragmentComments"],["All Fragments Played","All Fragments Played in entirety","All sliders moved","All fragments have comments"]];
nickjillings@1318 17 var APEInterfaceMetrics = [["testTimer","elementTimer","elementTracker","elementTrackerFull","elementFlagListenedTo","elementFlagMoved","elementFlagComments"],["Test Duration","Total time each fragment was listened to","Return initialised position of marker","Fragment movement tracker with timestamps","Flag if fragment listened to","Flag if fragment moved","Flag if fragment has comments"]];
nickjillings@1318 18 var MUSHRAInterfaceOptions = [[],[]];
nickjillings@1318 19 var MUSHRAInterfaceChecks = [["fragmentPlayed","fragmentMoved","fragmentComments"],["All Fragments Played","All sliders moved","All fragments have comments"]];
nickjillings@1318 20 var MUSHRAInterfaceMetrics = [["testTimer","elementTimer","elementTracker","elementTrackerFull","elementFlagListenedTo","elementFlagMoved","elementFlagComments"],["Test Duration","Total time each fragment was listened to","Return initialised position of marker","Fragment movement tracker with timestamps","Flag if fragment listened to","Flag if fragment moved","Flag if fragment has comments"]];
nickjillings@1318 21 var popupInstance;
nickjillings@1318 22 var specificationNode;
nickjillings@1318 23 var audioContext;
nickjillings@1318 24 var audioObjects = [];
nickjillings@1318 25 window.onload = function()
nickjillings@1318 26 {
nickjillings@1318 27 var AudioContext = window.AudioContext || window.webkitAudioContext;
nickjillings@1318 28 audioContext = new AudioContext;
nickjillings@1318 29 popupInstance = new popup();
nickjillings@1318 30 popupInstance.advanceState();
nickjillings@1318 31 specificationNode = new Specification();
nickjillings@1318 32 specificationNode.projectReturn = "null";
nickjillings@1318 33 };
nickjillings@1318 34
nickjillings@1318 35 function popup()
nickjillings@1318 36 {
nickjillings@1318 37 var x = window.innerWidth;
nickjillings@1318 38 var y = window.innerHeight;
nickjillings@1318 39 this.popupHolder = document.createElement('div');
nickjillings@1318 40 this.popupHolder.style.visibility = 'hidden';
nickjillings@1318 41 this.popupContent = document.createElement('div');
nickjillings@1318 42 this.popupTitle = document.createElement('div');
nickjillings@1318 43 this.popupBody = document.createElement('div');
nickjillings@1318 44 this.popupFooter = document.createElement('div');
nickjillings@1318 45 this.popupTitleText = document.createElement('span');
nickjillings@1318 46 this.popupTitle.appendChild(this.popupTitleText);
nickjillings@1318 47
nickjillings@1318 48 this.popupHolder.className = "popup";
nickjillings@1318 49 this.popupHolder.style.left = (x-500)/2 +'px';
nickjillings@1318 50 this.popupHolder.style.top = (y-400)/2 + 'px';
nickjillings@1318 51 this.popupContent.style.padding = "20px";
nickjillings@1318 52 this.popupHolder.appendChild(this.popupContent);
nickjillings@1318 53
nickjillings@1318 54 this.popupTitle.style.width = "100%";
nickjillings@1318 55 this.popupTitle.style.height = "50px";
nickjillings@1318 56 this.popupTitle.style.fontSize = "xx-large";
nickjillings@1318 57 this.popupContent.appendChild(this.popupTitle);
nickjillings@1318 58
nickjillings@1318 59 this.popupBody.style.width = "100%";
nickjillings@1318 60 this.popupBody.style.height = "280px";
nickjillings@1318 61 this.popupContent.appendChild(this.popupBody);
nickjillings@1318 62
nickjillings@1318 63 this.popupFooter.style.width = "100%";
nickjillings@1318 64 this.popupFooter.style.height = "30px";
nickjillings@1318 65 this.popupContent.appendChild(this.popupFooter);
nickjillings@1318 66 var body = document.getElementsByTagName('body')[0];
nickjillings@1318 67 body.appendChild(this.popupHolder);
nickjillings@1318 68
nickjillings@1318 69 this.pageBlank = document.createElement('div');
nickjillings@1318 70 body.appendChild(this.pageBlank);
nickjillings@1318 71 this.pageBlank.style.width = "100%";
nickjillings@1318 72 this.pageBlank.style.height = "100%";
nickjillings@1318 73 this.pageBlank.style.position = "absolute";
nickjillings@1318 74 this.pageBlank.style.left = "0px";
nickjillings@1318 75 this.pageBlank.style.top = "0px";
nickjillings@1318 76 this.pageBlank.style.backgroundColor = "rgba(0,0,0,0.5)";
nickjillings@1318 77 this.pageBlank.style.visibility = 'hidden';
nickjillings@1318 78
nickjillings@1318 79 this.state = 0;
nickjillings@1318 80 this.dataTransfer = null;
nickjillings@1318 81
nickjillings@1318 82 this.showPopup = function()
nickjillings@1318 83 {
nickjillings@1318 84 this.popupHolder.style.visibility = 'visible';
nickjillings@1318 85 this.popupHolder.style.zIndex = "3";
nickjillings@1318 86 this.pageBlank.style.visibility = 'visible';
nickjillings@1318 87 this.pageBlank.style.zIndex = "2";
nickjillings@1318 88 };
nickjillings@1318 89
nickjillings@1318 90 this.hidePopup = function()
nickjillings@1318 91 {
nickjillings@1318 92 this.popupHolder.style.visibility = 'hidden';
nickjillings@1318 93 this.popupHolder.style.zIndex = "-1";
nickjillings@1318 94 this.pageBlank.style.visibility = 'hidden';
nickjillings@1318 95 this.pageBlank.style.zIndex = "-2";
nickjillings@1318 96 };
nickjillings@1318 97
nickjillings@1318 98 this.init = function()
nickjillings@1318 99 {
nickjillings@1318 100 this.popupTitleText.textContent = "Welcome";
nickjillings@1318 101 var text = document.createElement('span');
nickjillings@1318 102 text.textContent = "Thank you for downloading the Web Audio Evaluation Toolbox. This page will help guide you through creating the documents required to run a test. If you have an existing XML file you wish to edit, please drag and drop it into the box below";
nickjillings@1318 103 var dnd = document.createElement('div');
nickjillings@1318 104 dnd.style.width = "100%";
nickjillings@1318 105 dnd.style.height = "50px";
nickjillings@1318 106 dnd.className = "dragndrop";
nickjillings@1318 107 dnd.ondragover = function(e) {
nickjillings@1318 108 e.stopPropagation();
nickjillings@1318 109 e.preventDefault();
nickjillings@1318 110 };
nickjillings@1318 111 dnd.ondragenter = function(e) {
nickjillings@1318 112 e.stopPropagation();
nickjillings@1318 113 e.preventDefault();
nickjillings@1318 114 this.style.backgroundColor = '#AAFFAA';
nickjillings@1318 115 };
nickjillings@1318 116 dnd.ondragleave = function(e) {
nickjillings@1318 117 e.stopPropagation();
nickjillings@1318 118 e.preventDefault();
nickjillings@1318 119 this.style.backgroundColor = "#FFFFFF";
nickjillings@1318 120 };
nickjillings@1318 121 dnd.ondrop = function(e) {
nickjillings@1318 122 e.stopPropagation();
nickjillings@1318 123 e.preventDefault();
nickjillings@1318 124
nickjillings@1318 125 var file = e.dataTransfer.files[0];
nickjillings@1318 126
nickjillings@1318 127 // Uses HTML5 FileAPI - https://w3c.github.io/FileAPI/#filereader-interface
nickjillings@1318 128 var reader = new FileReader();
nickjillings@1318 129 reader.onload = function() {
nickjillings@1318 130 var parse = new DOMParser();
nickjillings@1318 131 var xml = parse.parseFromString(reader.result,'text/xml');
nickjillings@1318 132 specificationNode.decode(xml);
nickjillings@1318 133 popupInstance.hidePopup();
nickjillings@1318 134 SpecificationToHTML();
nickjillings@1318 135 };
nickjillings@1318 136 reader.readAsText(file);
nickjillings@1318 137
nickjillings@1318 138 };
nickjillings@1318 139 this.popupBody.appendChild(text);
nickjillings@1318 140 this.popupBody.appendChild(dnd);
nickjillings@1318 141 this.showPopup();
nickjillings@1318 142
nickjillings@1318 143 var button = document.createElement('button');
nickjillings@1318 144 button.className = "popupButton";
nickjillings@1318 145 button.textContent = "New File";
nickjillings@1318 146 button.onclick = function(event) {
nickjillings@1318 147 popupInstance.advanceState();
nickjillings@1318 148 };
nickjillings@1318 149 this.popupFooter.appendChild(button);
nickjillings@1318 150 };
nickjillings@1318 151
nickjillings@1318 152 this.advanceState = function()
nickjillings@1318 153 {
nickjillings@1318 154 this.popupBody.innerHTML = null;
nickjillings@1318 155 this.popupFooter.innerHTML = null;
nickjillings@1318 156 this.popupTitleText.textContent = null;
nickjillings@1318 157 switch(this.state)
nickjillings@1318 158 {
nickjillings@1318 159 case 0:
nickjillings@1318 160 this.init();
nickjillings@1318 161 break;
nickjillings@1318 162 case 1:
nickjillings@1318 163 this.popupTitleText.textContent = "Test Type";
nickjillings@1318 164 var text = document.createElement("span");
nickjillings@1318 165 text.textContent = "What type of test would you like to use. Currently APE (Audio Perceptual Evaluation) and MUSHRA style interfaces are available";
nickjillings@1318 166 this.popupBody.appendChild(text);
nickjillings@1318 167 var select = document.createElement("select");
nickjillings@1318 168 select.id="interface-select";
nickjillings@1318 169 var opt1 = document.createElement("option");
nickjillings@1318 170 opt1.value = "APE";
nickjillings@1318 171 opt1.textContent = "APE";
nickjillings@1318 172 select.appendChild(opt1);
nickjillings@1318 173 var opt2 = document.createElement("option");
nickjillings@1318 174 opt2.value = "MUSHRA";
nickjillings@1318 175 opt2.textContent = "MUSHRA";
nickjillings@1318 176 select.appendChild(opt2);
nickjillings@1318 177 this.popupBody.appendChild(select);
nickjillings@1318 178
nickjillings@1318 179 var button = document.createElement('button');
nickjillings@1318 180 button.className = "popupButton";
nickjillings@1318 181 button.textContent = "Submit";
nickjillings@1318 182 button.onclick = function(event) {
nickjillings@1318 183 var select = document.getElementById("interface-select");
nickjillings@1318 184 specificationNode.interfaceType = select.value;
nickjillings@1318 185 specificationNode.collectMetrics = true;
nickjillings@1318 186 popupInstance.advanceState();
nickjillings@1318 187 };
nickjillings@1318 188 this.popupFooter.appendChild(button);
nickjillings@1318 189 break;
nickjillings@1318 190 case 2:
nickjillings@1318 191 this.popupTitleText.textContent = "Test Options";
nickjillings@1318 192 var holder = document.createElement('div');
nickjillings@1318 193 holder.style.margin = "5px";
nickjillings@1318 194 var checkbox = document.createElement('input');
nickjillings@1318 195 checkbox.type = 'checkbox';
nickjillings@1318 196 checkbox.id = "Randomise-Page";
nickjillings@1318 197 var text = document.createElement('span');
nickjillings@1318 198 text.textContent = "Randomise Page Order";
nickjillings@1318 199 holder.appendChild(checkbox);
nickjillings@1318 200 holder.appendChild(text);
nickjillings@1318 201 this.popupBody.appendChild(holder);
nickjillings@1318 202 switch(specificationNode.interfaceType)
nickjillings@1318 203 {
nickjillings@1318 204 case "APE":
nickjillings@1318 205 for (var i=0; i<APEInterfaceOptions[0].length; i++)
nickjillings@1318 206 {
nickjillings@1318 207 holder = document.createElement('div');
nickjillings@1318 208 holder.style.margin = "5px";
nickjillings@1318 209 checkbox = document.createElement('input');
nickjillings@1318 210 checkbox.type = 'checkbox';
nickjillings@1318 211 checkbox.setAttribute("name","option");
nickjillings@1318 212 checkbox.id = APEInterfaceOptions[0][i];
nickjillings@1318 213 text = document.createElement('span');
nickjillings@1318 214 text.textContent = APEInterfaceOptions[1][i];
nickjillings@1318 215 holder.appendChild(checkbox);
nickjillings@1318 216 holder.appendChild(text);
nickjillings@1318 217 this.popupBody.appendChild(holder);
nickjillings@1318 218 }
nickjillings@1318 219 for (var i=0; i<APEInterfaceChecks[0].length; i++)
nickjillings@1318 220 {
nickjillings@1318 221 holder = document.createElement('div');
nickjillings@1318 222 holder.style.margin = "5px";
nickjillings@1318 223 checkbox = document.createElement('input');
nickjillings@1318 224 checkbox.type = 'checkbox';
nickjillings@1318 225 checkbox.setAttribute("name","check");
nickjillings@1318 226 checkbox.id = APEInterfaceChecks[0][i];
nickjillings@1318 227 text = document.createElement('span');
nickjillings@1318 228 text.textContent = APEInterfaceChecks[1][i];
nickjillings@1318 229 holder.appendChild(checkbox);
nickjillings@1318 230 holder.appendChild(text);
nickjillings@1318 231 this.popupBody.appendChild(holder);
nickjillings@1318 232 }
nickjillings@1318 233 break;
nickjillings@1318 234 case "MUSHRA":
nickjillings@1318 235 for (var i=0; i<MUSHRAInterfaceOptions[0].length; i++)
nickjillings@1318 236 {
nickjillings@1318 237 holder = document.createElement('div');
nickjillings@1318 238 holder.style.margin = "5px";
nickjillings@1318 239 checkbox = document.createElement('input');
nickjillings@1318 240 checkbox.type = 'checkbox';
nickjillings@1318 241 checkbox.setAttribute("name","option");
nickjillings@1318 242 checkbox.id = MUSHRAInterfaceOptions[0][i];
nickjillings@1318 243 text = document.createElement('span');
nickjillings@1318 244 text.textContent = MUSHRAInterfaceOptions[1][i];
nickjillings@1318 245 holder.appendChild(checkbox);
nickjillings@1318 246 holder.appendChild(text);
nickjillings@1318 247 this.popupBody.appendChild(holder);
nickjillings@1318 248 }
nickjillings@1318 249 for (var i=0; i<MUSHRAInterfaceChecks[0].length; i++)
nickjillings@1318 250 {
nickjillings@1318 251 holder = document.createElement('div');
nickjillings@1318 252 holder.style.margin = "5px";
nickjillings@1318 253 checkbox = document.createElement('input');
nickjillings@1318 254 checkbox.type = 'checkbox';
nickjillings@1318 255 checkbox.setAttribute("name","check");
nickjillings@1318 256 checkbox.id = MUSHRAInterfaceChecks[0][i];
nickjillings@1318 257 text = document.createElement('span');
nickjillings@1318 258 text.textContent = MUSHRAInterfaceChecks[1][i];
nickjillings@1318 259 holder.appendChild(checkbox);
nickjillings@1318 260 holder.appendChild(text);
nickjillings@1318 261 this.popupBody.appendChild(holder);
nickjillings@1318 262 }
nickjillings@1318 263 }
nickjillings@1318 264 var button = document.createElement('button');
nickjillings@1318 265 button.className = "popupButton";
nickjillings@1318 266 button.textContent = "Submit";
nickjillings@1318 267 button.onclick = function(event) {
nickjillings@1318 268 var optHold = popupInstance.popupBody;
nickjillings@1318 269 var opt = optHold.firstChild;
nickjillings@1318 270 var input = opt.getElementsByTagName('input')[0];
nickjillings@1318 271 specificationNode.randomiseOrder = input.checked;
nickjillings@1318 272 while(opt.nextSibling != null)
nickjillings@1318 273 {
nickjillings@1318 274 opt = opt.nextSibling;
nickjillings@1318 275 input = opt.getElementsByTagName('input')[0];
nickjillings@1318 276 if (input.checked)
nickjillings@1318 277 {
nickjillings@1318 278 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(input));
nickjillings@1318 279 }
nickjillings@1318 280
nickjillings@1318 281 }
nickjillings@1318 282 popupInstance.advanceState();
nickjillings@1318 283 };
nickjillings@1318 284 this.popupFooter.appendChild(button);
nickjillings@1318 285 break;
nickjillings@1318 286 case 3:
nickjillings@1318 287 audioObjects = [];
nickjillings@1318 288 this.popupTitleText.textContent = "Test Page";
nickjillings@1318 289 var span = document.createElement('span');
nickjillings@1318 290 span.textContent = "Drag and drop your audio files into the box below to add them to a test page";
nickjillings@1318 291 this.popupBody.appendChild(span);
nickjillings@1318 292 var dnd = document.createElement('div');
nickjillings@1318 293 dnd.id = "audio-holder-drop";
nickjillings@1318 294 dnd.style.width = "100%";
nickjillings@1318 295 dnd.style.minHeight = "50px";
nickjillings@1318 296 dnd.style.maxHeight = "220px";
nickjillings@1318 297 dnd.style.overflow = 'auto';
nickjillings@1318 298 dnd.className = "dragndrop";
nickjillings@1318 299 dnd.ondragover = function(e) {
nickjillings@1318 300 if(e.preventDefault) {e.preventDefault();}
nickjillings@1318 301 return false;
nickjillings@1318 302 };
nickjillings@1318 303 dnd.ondragenter = function(e) {
nickjillings@1318 304 if(e.preventDefault) {e.preventDefault();}
nickjillings@1318 305 return false;
nickjillings@1318 306 };
nickjillings@1318 307 dnd.ondrop = function(e) {
nickjillings@1318 308 if(e.preventDefault) {e.preventDefault();}
nickjillings@1318 309 var dt = e.dataTransfer;
nickjillings@1318 310 var body = document.getElementById("audio-holder-drop");
nickjillings@1318 311 var files = dt.files;
nickjillings@1318 312 for (var i = 0, f; f = files[i]; i++)
nickjillings@1318 313 {
nickjillings@1318 314 var ao = new audioObject();
nickjillings@1318 315 ao.constructTrack(f);
nickjillings@1318 316 audioObjects.push(ao);
nickjillings@1318 317 var dndHeader = document.createElement('div');
nickjillings@1318 318 dndHeader.style.width = "100%";
nickjillings@1318 319 dndHeader.style.height = "20px";
nickjillings@1318 320 dndHeader.style.borderBottom = "#DDD";
nickjillings@1318 321 dndHeader.style.borderBottomWidth = "1px";
nickjillings@1318 322 dndHeader.style.borderBottomStyle = "solid";
nickjillings@1318 323 dndHeader.setAttribute('aoID',audioObjects.length-1);
nickjillings@1318 324 var dndHInclude = document.createElement('div');
nickjillings@1318 325 dndHInclude.style.width = "30px";
nickjillings@1318 326 dndHInclude.className = "dndheaderelement";
nickjillings@1318 327 var includeCheck = document.createElement('input');
nickjillings@1318 328 includeCheck.type = "checkbox";
nickjillings@1318 329 includeCheck.name = "include-check";
nickjillings@1318 330 includeCheck.checked = true;
nickjillings@1318 331 includeCheck.onchange = function()
nickjillings@1318 332 {
nickjillings@1318 333 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
nickjillings@1318 334 audioObjects[i].include = event.currentTarget.checked;
nickjillings@1318 335 };
nickjillings@1318 336 dndHInclude.appendChild(includeCheck);
nickjillings@1318 337 dndHeader.appendChild(dndHInclude);
nickjillings@1318 338 var dndHTitle = document.createElement('div');
nickjillings@1318 339 dndHTitle.style.width = "180px";
nickjillings@1318 340 dndHTitle.className = "dndheaderelement";
nickjillings@1318 341 var text = document.createElement('span');
nickjillings@1318 342 text.textContent = f.name;
nickjillings@1318 343 dndHTitle.appendChild(text);
nickjillings@1318 344 dndHeader.appendChild(dndHTitle);
nickjillings@1318 345 var dndHID = document.createElement('div');
nickjillings@1318 346 dndHID.style.width = "100px";
nickjillings@1318 347 dndHID.className = "dndheaderelement";
nickjillings@1318 348 var IDInput = document.createElement('input');
nickjillings@1318 349 IDInput.name = "audio-fragment-ID";
nickjillings@1318 350 IDInput.value = f.name.split('.')[0];
nickjillings@1318 351 IDInput.onchange = function()
nickjillings@1318 352 {
nickjillings@1318 353 var allIDInput = document.getElementsByName("audio-fragment-ID");
nickjillings@1318 354 var isCopy = new Array(allIDInput.length);
nickjillings@1318 355 isCopy.fill(0,0,this.length);
nickjillings@1318 356 if (allIDInput.length > 1)
nickjillings@1318 357 {
nickjillings@1318 358 for (var j=0; j<allIDInput.length; j++)
nickjillings@1318 359 {
nickjillings@1318 360 var textCompare1 = allIDInput[j].value;
nickjillings@1318 361 for (var k=j+1; k<allIDInput.length; k++)
nickjillings@1318 362 {
nickjillings@1318 363 var textCompare2 = allIDInput[k].value;
nickjillings@1318 364 if (textCompare1 == textCompare2)
nickjillings@1318 365 {
nickjillings@1318 366 isCopy[j] = 1;
nickjillings@1318 367 isCopy[k] = 1;
nickjillings@1318 368 }
nickjillings@1318 369 }
nickjillings@1318 370 }
nickjillings@1318 371 }
nickjillings@1318 372 var button = document.getElementById('submit');
nickjillings@1318 373 button.disabled = false;
nickjillings@1318 374 for (var j=0; j<allIDInput.length; j++)
nickjillings@1318 375 {
nickjillings@1318 376 if (isCopy[j] == 1)
nickjillings@1318 377 {
nickjillings@1318 378 allIDInput[j].style.backgroundColor = '#F22';
nickjillings@1318 379 button.disabled = true;
nickjillings@1318 380 }
nickjillings@1318 381 else
nickjillings@1318 382 {
nickjillings@1318 383 allIDInput[j].style.backgroundColor = '#FFF';
nickjillings@1318 384 audioObjects[j].id = allIDInput[j].value;
nickjillings@1318 385 }
nickjillings@1318 386 }
nickjillings@1318 387 };
nickjillings@1318 388 IDInput.style.width = "96px";
nickjillings@1318 389 dndHID.appendChild(IDInput);
nickjillings@1318 390 dndHeader.appendChild(dndHID);
nickjillings@1318 391 var dndHPlay = document.createElement('div');
nickjillings@1318 392 dndHPlay.style.width = "100px";
nickjillings@1318 393 dndHPlay.className = "dndheaderelement";
nickjillings@1318 394 var audio = document.createElement('button');
nickjillings@1318 395 audio.textContent = 'Play';
nickjillings@1318 396 audio.className = "popupButton";
nickjillings@1318 397 audio.style.height = "inherit";
nickjillings@1318 398 audio.onclick = function()
nickjillings@1318 399 {
nickjillings@1318 400 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
nickjillings@1318 401 audioObjects[i].play();
nickjillings@1318 402 };
nickjillings@1318 403 dndHPlay.appendChild(audio);
nickjillings@1318 404 dndHeader.appendChild(dndHPlay);
nickjillings@1318 405 dnd.appendChild(dndHeader);
nickjillings@1318 406 IDInput.onchange();
nickjillings@1318 407 }
nickjillings@1318 408 };
nickjillings@1318 409 var dndHeader = document.createElement('div');
nickjillings@1318 410 dndHeader.style.width = "100%";
nickjillings@1318 411 dndHeader.style.height = "15px";
nickjillings@1318 412 dndHeader.style.borderBottom = "#DDD";
nickjillings@1318 413 dndHeader.style.borderBottomWidth = "1px";
nickjillings@1318 414 dndHeader.style.borderBottomStyle = "solid";
nickjillings@1318 415 var dndHInclude = document.createElement('div');
nickjillings@1318 416 dndHInclude.style.width = "30px";
nickjillings@1318 417 dndHInclude.className = "dndheaderelement";
nickjillings@1318 418 var text = document.createElement('span');
nickjillings@1318 419 text.textContent = "Inc.";
nickjillings@1318 420 dndHInclude.appendChild(text);
nickjillings@1318 421 dndHeader.appendChild(dndHInclude);
nickjillings@1318 422 var dndHTitle = document.createElement('div');
nickjillings@1318 423 dndHTitle.style.width = "180px";
nickjillings@1318 424 dndHTitle.className = "dndheaderelement";
nickjillings@1318 425 text = document.createElement('span');
nickjillings@1318 426 text.textContent = "File Name";
nickjillings@1318 427 dndHTitle.appendChild(text);
nickjillings@1318 428 dndHeader.appendChild(dndHTitle);
nickjillings@1318 429 var dndHID = document.createElement('div');
nickjillings@1318 430 dndHID.style.width = "100px";
nickjillings@1318 431 dndHID.className = "dndheaderelement";
nickjillings@1318 432 text = document.createElement('span');
nickjillings@1318 433 text.textContent = "ID";
nickjillings@1318 434 dndHID.appendChild(text);
nickjillings@1318 435 dndHeader.appendChild(dndHID);
nickjillings@1318 436 var dndHPlay = document.createElement('div');
nickjillings@1318 437 dndHPlay.style.width = "100px";
nickjillings@1318 438 dndHPlay.className = "dndheaderelement";
nickjillings@1318 439 text = document.createElement('span');
nickjillings@1318 440 text.textContent = "Sample";
nickjillings@1318 441 dndHPlay.appendChild(text);
nickjillings@1318 442 dndHeader.appendChild(dndHPlay);
nickjillings@1318 443 dnd.appendChild(dndHeader);
nickjillings@1318 444 this.popupBody.appendChild(dnd);
nickjillings@1318 445 var button = document.createElement('button');
nickjillings@1318 446 button.id = 'submit';
nickjillings@1318 447 button.className = "popupButton";
nickjillings@1318 448 button.textContent = "Submit";
nickjillings@1318 449 button.onclick = function(event)
nickjillings@1318 450 {
nickjillings@1318 451 // Construct the audio-holder nodes;
nickjillings@1318 452 for (var i=0; i<audioObjects.length; i++)
nickjillings@1318 453 {
nickjillings@1318 454 if (!audioObjects[i].include)
nickjillings@1318 455 {
nickjillings@1318 456 audioObjects.pop(audioObjects[i]);
nickjillings@1318 457 }
nickjillings@1318 458 }
nickjillings@1318 459 if (audioObjects.length != 0)
nickjillings@1318 460 {
nickjillings@1318 461 popupInstance.advanceState();
nickjillings@1318 462 }
nickjillings@1318 463 };
nickjillings@1318 464 this.popupFooter.appendChild(button);
nickjillings@1318 465 break;
nickjillings@1318 466 case 4:
nickjillings@1318 467 this.popupTitleText.textContent = "Test Page - Options";
nickjillings@1318 468 var span = document.createElement('span');
nickjillings@1318 469 span.textContent = "Set your test page options here";
nickjillings@1318 470 this.popupBody.appendChild(span);
nickjillings@1318 471 var pair = document.createElement('div');
nickjillings@1318 472 pair.style.margin = '5px';
nickjillings@1318 473 var text = document.createElement('span');
nickjillings@1318 474 text.textContent = "Page ID:";
nickjillings@1318 475 var input = document.createElement('input');
nickjillings@1318 476 input.value = specificationNode.audioHolders.length;
nickjillings@1318 477 input.id = "id";
nickjillings@1318 478 pair.appendChild(text);
nickjillings@1318 479 pair.appendChild(input);
nickjillings@1318 480 this.popupBody.appendChild(pair);
nickjillings@1318 481 pair = document.createElement('div');
nickjillings@1318 482 pair.style.margin = '5px';
nickjillings@1318 483 text = document.createElement('span');
nickjillings@1318 484 text.textContent = "Randomise Fragment Order";
nickjillings@1318 485 input = document.createElement('input');
nickjillings@1318 486 input.type = "checkbox";
nickjillings@1318 487 input.id = "randomiseOrder";
nickjillings@1318 488 pair.appendChild(input);
nickjillings@1318 489 pair.appendChild(text);
nickjillings@1318 490 this.popupBody.appendChild(pair);
nickjillings@1318 491 pair = document.createElement('div');
nickjillings@1318 492 pair.style.margin = '5px';
nickjillings@1318 493 text = document.createElement('span');
nickjillings@1318 494 text.textContent = "Loop Fragment Playback";
nickjillings@1318 495 input = document.createElement('input');
nickjillings@1318 496 input.type = "checkbox";
nickjillings@1318 497 input.id = "loop";
nickjillings@1318 498 pair.appendChild(input);
nickjillings@1318 499 pair.appendChild(text);
nickjillings@1318 500 this.popupBody.appendChild(pair);
nickjillings@1318 501 pair = document.createElement('div');
nickjillings@1318 502 pair.style.margin = '5px';
nickjillings@1318 503 text = document.createElement('span');
nickjillings@1318 504 text.textContent = "Show fragment comment boxes";
nickjillings@1318 505 input = document.createElement('input');
nickjillings@1318 506 input.type = "checkbox";
nickjillings@1318 507 input.id = "elementComments";
nickjillings@1318 508 pair.appendChild(input);
nickjillings@1318 509 pair.appendChild(text);
nickjillings@1318 510 this.popupBody.appendChild(pair);
nickjillings@1318 511 var button = document.createElement('button');
nickjillings@1318 512 button.id = 'submit';
nickjillings@1318 513 button.className = "popupButton";
nickjillings@1318 514 button.textContent = "Next";
nickjillings@1318 515 button.onclick = function(event)
nickjillings@1318 516 {
nickjillings@1318 517 var ah = new specificationNode.audioHolderNode(specificationNode);
nickjillings@1318 518 ah.id = document.getElementById('id').value;
nickjillings@1318 519 ah.presentedId = specificationNode.audioHolders.length;
nickjillings@1318 520 ah.hostURL = ah.id+'/';
nickjillings@1318 521 ah.randomiseOrder = document.getElementById('randomiseOrder').checked;
nickjillings@1318 522 ah.loop = document.getElementById('loop').checked;
nickjillings@1318 523 ah.elementComments = document.getElementById('elementComments').checked;
nickjillings@1318 524 for (var i=0; i<audioObjects.length; i++)
nickjillings@1318 525 {
nickjillings@1318 526 ah.audioElements.push(new ah.audioElementNode(ah,audioObjects[i]));
nickjillings@1318 527 }
nickjillings@1318 528 specificationNode.audioHolders.push(ah);
nickjillings@1318 529 popupInstance.advanceState();
nickjillings@1318 530 };
nickjillings@1318 531 this.popupFooter.appendChild(button);
nickjillings@1318 532 break;
nickjillings@1318 533 case 5:
nickjillings@1318 534 this.dataTransfer = null;
nickjillings@1318 535 this.popupTitleText.textContent = "Test Page - Pre/Post Survey";
nickjillings@1318 536 var span = document.createElement('span');
nickjillings@1318 537 span.textContent = "Add your pre test page options here";
nickjillings@1318 538 this.popupBody.appendChild(span);
nickjillings@1318 539 var preHolder = document.createElement('div');
nickjillings@1318 540 preHolder.id = "preHolder";
nickjillings@1318 541 preHolder.style.width = "460px";
nickjillings@1318 542 preHolder.style.minHeight = "100px";
nickjillings@1318 543 preHolder.style.maxHeight = "220px";
nickjillings@1318 544 preHolder.style.overflow = 'auto';
nickjillings@1318 545 preHolder.style.border = "black";
nickjillings@1318 546 preHolder.style.borderStyle = "solid";
nickjillings@1318 547 preHolder.style.borderWidth = "1px";
nickjillings@1318 548 this.popupBody.appendChild(preHolder);
nickjillings@1318 549 var audioHolder = specificationNode.audioHolders[specificationNode.audioHolders.length-1];
nickjillings@1318 550 var preHeaderHolder = document.createElement('div');
nickjillings@1318 551 preHeaderHolder.style.width = "456px";
nickjillings@1318 552 preHeaderHolder.style.height= "20px";
nickjillings@1318 553 preHeaderHolder.style.margin= "2px";
nickjillings@1318 554 preHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1318 555 preHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1318 556 preHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1318 557 var mvH = document.createElement('div');
nickjillings@1318 558 mvH.className = "dndheaderelement";
nickjillings@1318 559 mvH.style.width = "50px";
nickjillings@1318 560 var text = document.createElement('span');
nickjillings@1318 561 text.textContent = "Order";
nickjillings@1318 562 mvH.appendChild(text);
nickjillings@1318 563 preHeaderHolder.appendChild(mvH);
nickjillings@1318 564 var idH = document.createElement('div');
nickjillings@1318 565 idH.className = "dndheaderelement";
nickjillings@1318 566 idH.style.width = "150px";
nickjillings@1318 567 text = document.createElement('span');
nickjillings@1318 568 text.textContent = "ID";
nickjillings@1318 569 idH.appendChild(text);
nickjillings@1318 570 preHeaderHolder.appendChild(idH);
nickjillings@1318 571 var tH = document.createElement('div');
nickjillings@1318 572 tH.className = "dndheaderelement";
nickjillings@1318 573 tH.style.width = "150px";
nickjillings@1318 574 text = document.createElement('span');
nickjillings@1318 575 text.textContent = "Type";
nickjillings@1318 576 tH.appendChild(text);
nickjillings@1318 577 preHeaderHolder.appendChild(tH);
nickjillings@1318 578 var editH = document.createElement('div');
nickjillings@1318 579 editH.className = "dndheaderelement";
nickjillings@1318 580 editH.style.width = "50px";
nickjillings@1318 581 text = document.createElement('span');
nickjillings@1318 582 text.textContent = "Edit";
nickjillings@1318 583 editH.appendChild(text);
nickjillings@1318 584 preHeaderHolder.appendChild(editH);
nickjillings@1318 585 var deleteH = document.createElement('div');
nickjillings@1318 586 deleteH.className = "dndheaderelement";
nickjillings@1318 587 deleteH.style.width = "50px";
nickjillings@1318 588 text = document.createElement('span');
nickjillings@1318 589 text.textContent = "Delete";
nickjillings@1318 590 deleteH.appendChild(text);
nickjillings@1318 591 preHeaderHolder.appendChild(deleteH);
nickjillings@1318 592 preHolder.appendChild(preHeaderHolder);
nickjillings@1318 593
nickjillings@1318 594
nickjillings@1318 595 for (var i=0; i<audioHolder.preTest.options.length; i++)
nickjillings@1318 596 {
nickjillings@1318 597 var optionNode = audioHolder.preTest.options[i];
nickjillings@1318 598 var entry = document.createElement('div');
nickjillings@1318 599 entry.style.width = "456px";
nickjillings@1318 600 entry.style.height= "20px";
nickjillings@1318 601 entry.style.margin= "2px";
nickjillings@1318 602 entry.style.borderBottom = "#DDD";
nickjillings@1318 603 entry.style.borderBottomWidth = "1px";
nickjillings@1318 604 entry.style.borderBottomStyle = "solid";
nickjillings@1318 605 entry.setAttribute("node-id",i);
nickjillings@1318 606 var node = audioHolder.preTest.options[i];
nickjillings@1318 607 var mvH = document.createElement('div');
nickjillings@1318 608 mvH.className = "dndheaderelement";
nickjillings@1318 609 mvH.style.width = "50px";
nickjillings@1318 610 var mvup = document.createElement("button");
nickjillings@1318 611 mvup.textContent = "Up";
nickjillings@1318 612 mvup.style.width = "25px";
nickjillings@1318 613 mvup.style.padding = "1px 0px";
nickjillings@1318 614 mvup.onclick = function()
nickjillings@1318 615 {
nickjillings@1318 616 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 617 if (i != 0)
nickjillings@1318 618 {
nickjillings@1318 619 var next = audioHolder.preTest.options[i-1];
nickjillings@1318 620 var cur = audioHolder.preTest.options[i];
nickjillings@1318 621 audioHolder.preTest.options[i-1] = cur;
nickjillings@1318 622 audioHolder.preTest.options[i] = next;
nickjillings@1318 623 popupInstance.state = 5;
nickjillings@1318 624 popupInstance.advanceState();
nickjillings@1318 625 }
nickjillings@1318 626 };
nickjillings@1318 627 mvH.appendChild(mvup);
nickjillings@1318 628 var mvdn = document.createElement("button");
nickjillings@1318 629 mvdn.textContent = "Dn";
nickjillings@1318 630 mvdn.style.width = "25px";
nickjillings@1318 631 mvdn.style.padding = "1px 0px";
nickjillings@1318 632 mvdn.onclick = function()
nickjillings@1318 633 {
nickjillings@1318 634 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 635 if (i != audioHolder.preTest.options.length-1)
nickjillings@1318 636 {
nickjillings@1318 637 var next = audioHolder.preTest.options[i+1];
nickjillings@1318 638 var cur = audioHolder.preTest.options[i];
nickjillings@1318 639 audioHolder.preTest.options[i+1] = cur;
nickjillings@1318 640 audioHolder.preTest.options[i] = next;
nickjillings@1318 641 popupInstance.state = 5;
nickjillings@1318 642 popupInstance.advanceState();
nickjillings@1318 643 }
nickjillings@1318 644 };
nickjillings@1318 645 mvH.appendChild(mvdn);
nickjillings@1318 646 entry.appendChild(mvH);
nickjillings@1318 647 var idH = document.createElement('div');
nickjillings@1318 648 idH.className = "dndheaderelement";
nickjillings@1318 649 idH.style.width = "150px";
nickjillings@1318 650 if (optionNode.type != "statement")
nickjillings@1318 651 {
nickjillings@1318 652 var span = document.createElement('span');
nickjillings@1318 653 span.textContent = optionNode.id;
nickjillings@1318 654 idH.appendChild(span);
nickjillings@1318 655 }
nickjillings@1318 656 entry.appendChild(idH);
nickjillings@1318 657 var typeH = document.createElement('div');
nickjillings@1318 658 typeH.className = "dndheaderelement";
nickjillings@1318 659 typeH.style.width = "150px";
nickjillings@1318 660 var span = document.createElement('span');
nickjillings@1318 661 span.textContent = optionNode.type;
nickjillings@1318 662 typeH.appendChild(span);
nickjillings@1318 663 entry.appendChild(typeH);
nickjillings@1318 664 var editH = document.createElement('div');
nickjillings@1318 665 editH.className = "dndheaderelement";
nickjillings@1318 666 editH.style.width = "50px";
nickjillings@1318 667 var editButton = document.createElement("button");
nickjillings@1318 668 editButton.textContent = "Edit";
nickjillings@1318 669 editButton.style.width = "48px";
nickjillings@1318 670 editButton.style.padding = "1px 0px";
nickjillings@1318 671 editButton.onclick = function()
nickjillings@1318 672 {
nickjillings@1318 673 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 674 popupInstance.dataTransfer = new function() {
nickjillings@1318 675 this.title = "Edit Test Node";
nickjillings@1318 676 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
nickjillings@1318 677 this.node = this.parent.options[i];
nickjillings@1318 678 this.previousState = 5;
nickjillings@1318 679 };
nickjillings@1318 680 popupInstance.advanceState();
nickjillings@1318 681 };
nickjillings@1318 682 editH.appendChild(editButton);
nickjillings@1318 683 entry.appendChild(editH);
nickjillings@1318 684 var deleteH = document.createElement('div');
nickjillings@1318 685 deleteH.className = "dndheaderelement";
nickjillings@1318 686 deleteH.style.width = "50px";
nickjillings@1318 687 var deleteButton = document.createElement("button");
nickjillings@1318 688 deleteButton.textContent = "Del";
nickjillings@1318 689 deleteButton.style.width = "48px";
nickjillings@1318 690 deleteButton.style.padding = "1px 0px";
nickjillings@1318 691 deleteButton.onclick = function()
nickjillings@1318 692 {
nickjillings@1318 693 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 694 var j = i+1;
nickjillings@1318 695 while(j < audioHolder.preTest.options.length)
nickjillings@1318 696 {
nickjillings@1318 697 audioHolder.preTest.options[i] = audioHolder.preTest.options[j];
nickjillings@1318 698 j++;
nickjillings@1318 699 i++;
nickjillings@1318 700 }
nickjillings@1318 701 audioHolder.preTest.options.pop();
nickjillings@1318 702 popupInstance.state = 5;
nickjillings@1318 703 popupInstance.advanceState();
nickjillings@1318 704 };
nickjillings@1318 705 deleteH.appendChild(deleteButton);
nickjillings@1318 706 entry.appendChild(deleteH);
nickjillings@1318 707 preHolder.appendChild(entry);
nickjillings@1318 708 }
nickjillings@1318 709 var entry = document.createElement('div');
nickjillings@1318 710 entry.style.width = "456px";
nickjillings@1318 711 entry.style.height= "20px";
nickjillings@1318 712 entry.style.margin= "2px";
nickjillings@1318 713 entry.style.borderBottom = "#DDD";
nickjillings@1318 714 entry.style.borderBottomWidth = "1px";
nickjillings@1318 715 entry.style.borderBottomStyle = "solid";
nickjillings@1318 716 entry.align = "center";
nickjillings@1318 717 var addPre = document.createElement('button');
nickjillings@1318 718 addPre.className = "popupButton";
nickjillings@1318 719 addPre.textContent = "Add New Entry";
nickjillings@1318 720 addPre.style.height = "20px";
nickjillings@1318 721 addPre.onclick = function()
nickjillings@1318 722 {
nickjillings@1318 723 popupInstance.dataTransfer = new function() {
nickjillings@1318 724 this.title = "New Pre Test Node";
nickjillings@1318 725 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
nickjillings@1318 726 this.node = null;
nickjillings@1318 727 this.previousState = 5;
nickjillings@1318 728 };
nickjillings@1318 729 popupInstance.advanceState();
nickjillings@1318 730 };
nickjillings@1318 731 entry.appendChild(addPre);
nickjillings@1318 732 preHolder.appendChild(entry);
nickjillings@1318 733
nickjillings@1318 734 var span = document.createElement('span');
nickjillings@1318 735 span.textContent = "Add your post test page options here";
nickjillings@1318 736 this.popupBody.appendChild(span);
nickjillings@1318 737 var postHolder = document.createElement('div');
nickjillings@1318 738 postHolder.id = "preHolder";
nickjillings@1318 739 postHolder.style.width = "100%";
nickjillings@1318 740 postHolder.style.minHeight = "100px";
nickjillings@1318 741 postHolder.style.maxHeight = "220px";
nickjillings@1318 742 postHolder.style.overflow = 'auto';
nickjillings@1318 743 postHolder.style.border = "black";
nickjillings@1318 744 postHolder.style.borderStyle = "solid";
nickjillings@1318 745 postHolder.style.borderWidth = "1px";
nickjillings@1318 746 this.popupBody.appendChild(postHolder);
nickjillings@1318 747 var postHeaderHolder = document.createElement('div');
nickjillings@1318 748 postHeaderHolder.style.width = "456px";
nickjillings@1318 749 postHeaderHolder.style.height= "20px";
nickjillings@1318 750 postHeaderHolder.style.margin= "2px";
nickjillings@1318 751 postHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1318 752 postHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1318 753 postHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1318 754 var mvH = document.createElement('div');
nickjillings@1318 755 mvH.className = "dndheaderelement";
nickjillings@1318 756 mvH.style.width = "50px";
nickjillings@1318 757 var text = document.createElement('span');
nickjillings@1318 758 text.textContent = "Order";
nickjillings@1318 759 mvH.appendChild(text);
nickjillings@1318 760 postHeaderHolder.appendChild(mvH);
nickjillings@1318 761 var idH = document.createElement('div');
nickjillings@1318 762 idH.className = "dndheaderelement";
nickjillings@1318 763 idH.style.width = "150px";
nickjillings@1318 764 text = document.createElement('span');
nickjillings@1318 765 text.textContent = "ID";
nickjillings@1318 766 idH.appendChild(text);
nickjillings@1318 767 postHeaderHolder.appendChild(idH);
nickjillings@1318 768 var tH = document.createElement('div');
nickjillings@1318 769 tH.className = "dndheaderelement";
nickjillings@1318 770 tH.style.width = "150px";
nickjillings@1318 771 text = document.createElement('span');
nickjillings@1318 772 text.textContent = "Type";
nickjillings@1318 773 tH.appendChild(text);
nickjillings@1318 774 postHeaderHolder.appendChild(tH);
nickjillings@1318 775 var editH = document.createElement('div');
nickjillings@1318 776 editH.className = "dndheaderelement";
nickjillings@1318 777 editH.style.width = "50px";
nickjillings@1318 778 text = document.createElement('span');
nickjillings@1318 779 text.textContent = "Edit";
nickjillings@1318 780 editH.appendChild(text);
nickjillings@1318 781 postHeaderHolder.appendChild(editH);
nickjillings@1318 782 var deleteH = document.createElement('div');
nickjillings@1318 783 deleteH.className = "dndheaderelement";
nickjillings@1318 784 deleteH.style.width = "50px";
nickjillings@1318 785 text = document.createElement('span');
nickjillings@1318 786 text.textContent = "Delete";
nickjillings@1318 787 deleteH.appendChild(text);
nickjillings@1318 788 postHeaderHolder.appendChild(deleteH);
nickjillings@1318 789 postHolder.appendChild(postHeaderHolder);
nickjillings@1318 790
nickjillings@1318 791 for (var i=0; i<audioHolder.postTest.options.length; i++)
nickjillings@1318 792 {
nickjillings@1318 793 var optionNode = audioHolder.postTest.options[i];
nickjillings@1318 794 var entry = document.createElement('div');
nickjillings@1318 795 entry.style.width = "456px";
nickjillings@1318 796 entry.style.height= "20px";
nickjillings@1318 797 entry.style.margin= "2px";
nickjillings@1318 798 entry.style.borderBottom = "#DDD";
nickjillings@1318 799 entry.style.borderBottomWidth = "1px";
nickjillings@1318 800 entry.style.borderBottomStyle = "solid";
nickjillings@1318 801 entry.setAttribute("node-id",i);
nickjillings@1318 802 var node = audioHolder.postTest.options[i];
nickjillings@1318 803 var mvH = document.createElement('div');
nickjillings@1318 804 mvH.className = "dndheaderelement";
nickjillings@1318 805 mvH.style.width = "50px";
nickjillings@1318 806 var mvup = document.createElement("button");
nickjillings@1318 807 mvup.textContent = "Up";
nickjillings@1318 808 mvup.style.width = "25px";
nickjillings@1318 809 mvup.style.padding = "1px 0px";
nickjillings@1318 810 mvup.onclick = function()
nickjillings@1318 811 {
nickjillings@1318 812 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 813 if (i != 0)
nickjillings@1318 814 {
nickjillings@1318 815 var next = audioHolder.postTest.options[i-1];
nickjillings@1318 816 var cur = audioHolder.postTest.options[i];
nickjillings@1318 817 audioHolder.postTest.options[i-1] = cur;
nickjillings@1318 818 audioHolder.postTest.options[i] = next;
nickjillings@1318 819 popupInstance.state = 5;
nickjillings@1318 820 popupInstance.advanceState();
nickjillings@1318 821 }
nickjillings@1318 822 };
nickjillings@1318 823 mvH.appendChild(mvup);
nickjillings@1318 824 var mvdn = document.createElement("button");
nickjillings@1318 825 mvdn.textContent = "Dn";
nickjillings@1318 826 mvdn.style.width = "25px";
nickjillings@1318 827 mvdn.style.padding = "1px 0px";
nickjillings@1318 828 mvdn.onclick = function()
nickjillings@1318 829 {
nickjillings@1318 830 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 831 if (i != audioHolder.postTest.options.length-1)
nickjillings@1318 832 {
nickjillings@1318 833 var next = audioHolder.postTest.options[i+1];
nickjillings@1318 834 var cur = audioHolder.postTest.options[i];
nickjillings@1318 835 audioHolder.postTest.options[i+1] = cur;
nickjillings@1318 836 audioHolder.postTest.options[i] = next;
nickjillings@1318 837 popupInstance.state = 5;
nickjillings@1318 838 popupInstance.advanceState();
nickjillings@1318 839 }
nickjillings@1318 840 };
nickjillings@1318 841 mvH.appendChild(mvdn);
nickjillings@1318 842 entry.appendChild(mvH);
nickjillings@1318 843 var idH = document.createElement('div');
nickjillings@1318 844 idH.className = "dndheaderelement";
nickjillings@1318 845 idH.style.width = "150px";
nickjillings@1318 846 if (optionNode.type != "statement")
nickjillings@1318 847 {
nickjillings@1318 848 var span = document.createElement('span');
nickjillings@1318 849 span.textContent = optionNode.id;
nickjillings@1318 850 idH.appendChild(span);
nickjillings@1318 851 }
nickjillings@1318 852 entry.appendChild(idH);
nickjillings@1318 853 var typeH = document.createElement('div');
nickjillings@1318 854 typeH.className = "dndheaderelement";
nickjillings@1318 855 typeH.style.width = "150px";
nickjillings@1318 856 var span = document.createElement('span');
nickjillings@1318 857 span.textContent = optionNode.type;
nickjillings@1318 858 typeH.appendChild(span);
nickjillings@1318 859 entry.appendChild(typeH);
nickjillings@1318 860 var editH = document.createElement('div');
nickjillings@1318 861 editH.className = "dndheaderelement";
nickjillings@1318 862 editH.style.width = "50px";
nickjillings@1318 863 var editButton = document.createElement("button");
nickjillings@1318 864 editButton.textContent = "Edit";
nickjillings@1318 865 editButton.style.width = "48px";
nickjillings@1318 866 editButton.style.padding = "1px 0px";
nickjillings@1318 867 editButton.onclick = function()
nickjillings@1318 868 {
nickjillings@1318 869 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 870 popupInstance.dataTransfer = new function() {
nickjillings@1318 871 this.title = "Edit Test Node";
nickjillings@1318 872 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
nickjillings@1318 873 this.node = this.parent.options[i];
nickjillings@1318 874 this.previousState = 5;
nickjillings@1318 875 };
nickjillings@1318 876 popupInstance.advanceState();
nickjillings@1318 877 };
nickjillings@1318 878 editH.appendChild(editButton);
nickjillings@1318 879 entry.appendChild(editH);
nickjillings@1318 880 var deleteH = document.createElement('div');
nickjillings@1318 881 deleteH.className = "dndheaderelement";
nickjillings@1318 882 deleteH.style.width = "50px";
nickjillings@1318 883 var deleteButton = document.createElement("button");
nickjillings@1318 884 deleteButton.textContent = "Del";
nickjillings@1318 885 deleteButton.style.width = "48px";
nickjillings@1318 886 deleteButton.style.padding = "1px 0px";
nickjillings@1318 887 deleteButton.onclick = function()
nickjillings@1318 888 {
nickjillings@1318 889 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 890 var j = i+1;
nickjillings@1318 891 while(j < audioHolder.postTest.options.length)
nickjillings@1318 892 {
nickjillings@1318 893 audioHolder.postTest.options[i] = audioHolder.postTest.options[j];
nickjillings@1318 894 j++;
nickjillings@1318 895 i++;
nickjillings@1318 896 }
nickjillings@1318 897 audioHolder.postTest.options.pop();
nickjillings@1318 898 popupInstance.state = 5;
nickjillings@1318 899 popupInstance.advanceState();
nickjillings@1318 900 };
nickjillings@1318 901 deleteH.appendChild(deleteButton);
nickjillings@1318 902 entry.appendChild(deleteH);
nickjillings@1318 903 postHolder.appendChild(entry);
nickjillings@1318 904 }
nickjillings@1318 905
nickjillings@1318 906 var entry = document.createElement('div');
nickjillings@1318 907 entry.style.width = "456px";
nickjillings@1318 908 entry.style.height= "20px";
nickjillings@1318 909 entry.style.margin= "2px";
nickjillings@1318 910 entry.style.borderBottom = "#DDD";
nickjillings@1318 911 entry.style.borderBottomWidth = "1px";
nickjillings@1318 912 entry.style.borderBottomStyle = "solid";
nickjillings@1318 913 entry.align = "center";
nickjillings@1318 914 var addPost = document.createElement('button');
nickjillings@1318 915 addPost.className = "popupButton";
nickjillings@1318 916 addPost.textContent = "Add New Entry";
nickjillings@1318 917 addPost.style.height = "20px";
nickjillings@1318 918 addPost.onclick = function()
nickjillings@1318 919 {
nickjillings@1318 920 popupInstance.dataTransfer = new function() {
nickjillings@1318 921 this.title = "New Pre Test Node";
nickjillings@1318 922 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
nickjillings@1318 923 this.node = null;
nickjillings@1318 924 this.previousState = 5;
nickjillings@1318 925 };
nickjillings@1318 926 popupInstance.advanceState();
nickjillings@1318 927 };
nickjillings@1318 928 entry.appendChild(addPost);
nickjillings@1318 929 postHolder.appendChild(entry);
nickjillings@1318 930
nickjillings@1318 931 var button = document.createElement('button');
nickjillings@1318 932 button.id = 'submit';
nickjillings@1318 933 button.className = "popupButton";
nickjillings@1318 934 button.textContent = "Finish";
nickjillings@1318 935 button.onclick = function(event)
nickjillings@1318 936 {
nickjillings@1318 937 popupInstance.state = 7;
nickjillings@1318 938 popupInstance.advanceState();
nickjillings@1318 939 };
nickjillings@1318 940 this.popupFooter.appendChild(button);
nickjillings@1318 941 button = document.createElement('button');
nickjillings@1318 942 button.id = 'submit';
nickjillings@1318 943 button.className = "popupButton";
nickjillings@1318 944 button.textContent = "Add Another Page";
nickjillings@1318 945 button.onclick = function(event)
nickjillings@1318 946 {
nickjillings@1318 947 popupInstance.state = 3;
nickjillings@1318 948 popupInstance.advanceState();
nickjillings@1318 949 };
nickjillings@1318 950 this.popupFooter.appendChild(button);
nickjillings@1318 951 break;
nickjillings@1318 952 case 6:
nickjillings@1318 953 this.popupTitleText.textContent = this.dataTransfer.title;
nickjillings@1318 954 var span = document.createElement('span');
nickjillings@1318 955 span.textContent = "Select survey settings here";
nickjillings@1318 956 this.popupBody.appendChild(span);
nickjillings@1318 957 var div = document.createElement('div');
nickjillings@1318 958 span = document.createElement("span");
nickjillings@1318 959 span.textContent = "Survey Type";
nickjillings@1318 960 var select = document.createElement("select");
nickjillings@1318 961 select.id="survey-select";
nickjillings@1318 962 var option = document.createElement('option');
nickjillings@1318 963 option.textContent = "Statement";
nickjillings@1318 964 option.value = "statement";
nickjillings@1318 965 select.appendChild(option);
nickjillings@1318 966 option = document.createElement('option');
nickjillings@1318 967 option.textContent = "Question";
nickjillings@1318 968 option.value = "question";
nickjillings@1318 969 select.appendChild(option);
nickjillings@1318 970 option = document.createElement('option');
nickjillings@1318 971 option.textContent = "Number";
nickjillings@1318 972 option.value = "number";
nickjillings@1318 973 select.appendChild(option);
nickjillings@1318 974 option = document.createElement('option');
nickjillings@1318 975 option.textContent = "Radio";
nickjillings@1318 976 option.value = "radio";
nickjillings@1318 977 select.appendChild(option);
nickjillings@1318 978 option = document.createElement('option');
nickjillings@1318 979 option.textContent = "Checkbox";
nickjillings@1318 980 option.value = "checkbox";
nickjillings@1318 981 select.appendChild(option);
nickjillings@1318 982 this.popupBody.appendChild(select);
nickjillings@1318 983 var options = document.createElement('div');
nickjillings@1318 984 options.id = "survey-options";
nickjillings@1318 985 this.popupBody.appendChild(options);
nickjillings@1318 986 var button = document.createElement('button');
nickjillings@1318 987 button.id = 'submit';
nickjillings@1318 988 button.className = "popupButton";
nickjillings@1318 989 button.textContent = "Add";
nickjillings@1318 990 button.onclick = function(event)
nickjillings@1318 991 {
nickjillings@1318 992 var parent = popupInstance.dataTransfer.parent;
nickjillings@1318 993 if (popupInstance.dataTransfer.node == null)
nickjillings@1318 994 {
nickjillings@1318 995 var node = new parent.OptionNode();
nickjillings@1318 996 } else
nickjillings@1318 997 {
nickjillings@1318 998 var node = popupInstance.dataTransfer.node;
nickjillings@1318 999 }
nickjillings@1318 1000 node.type = document.getElementById("survey-select").value;
nickjillings@1318 1001 switch(node.type)
nickjillings@1318 1002 {
nickjillings@1318 1003 case "statement":
nickjillings@1318 1004 node.statement = document.getElementById("statement").value;
nickjillings@1318 1005 break;
nickjillings@1318 1006 case "question":
nickjillings@1318 1007 node.question = document.getElementById("question").value;
nickjillings@1318 1008 node.id = document.getElementById("ID").value;
nickjillings@1318 1009 node.mandatory = document.getElementById("mandatory").checked;
nickjillings@1318 1010 node.boxsize = document.getElementById("boxsize").value;
nickjillings@1318 1011 break;
nickjillings@1318 1012 }
nickjillings@1318 1013 if (popupInstance.dataTransfer.node == null)
nickjillings@1318 1014 {parent.options.push(node);}
nickjillings@1318 1015 popupInstance.state = popupInstance.dataTransfer.previousState;
nickjillings@1318 1016 popupInstance.advanceState();
nickjillings@1318 1017 };
nickjillings@1318 1018 this.popupFooter.appendChild(button);
nickjillings@1318 1019 select.onchange = function()
nickjillings@1318 1020 {
nickjillings@1318 1021 var options = document.getElementById("survey-options");
nickjillings@1318 1022 options.innerHTML = null;
nickjillings@1318 1023 switch(this.value)
nickjillings@1318 1024 {
nickjillings@1318 1025 case "statement":
nickjillings@1318 1026 var span = document.createElement('span');
nickjillings@1318 1027 span.textContent = "Enter Statement";
nickjillings@1318 1028 var tA = document.createElement('textarea');
nickjillings@1318 1029 tA.id = "statement";
nickjillings@1318 1030 tA.style.width = "460px";
nickjillings@1318 1031 tA.style.height = "96px";
nickjillings@1318 1032 if (popupInstance.dataTransfer.node != null)
nickjillings@1318 1033 {tA.value = this.dataTransfer.node.statement;}
nickjillings@1318 1034 options.appendChild(span);
nickjillings@1318 1035 options.appendChild(tA);
nickjillings@1318 1036 break;
nickjillings@1318 1037 case "question":
nickjillings@1318 1038 var span = document.createElement('span');
nickjillings@1318 1039 span.textContent = "Enter Question";
nickjillings@1318 1040 var tA = document.createElement('textarea');
nickjillings@1318 1041 tA.style.width = "460px";
nickjillings@1318 1042 tA.style.height = "54px";
nickjillings@1318 1043 tA.id = "question";
nickjillings@1318 1044 options.appendChild(span);
nickjillings@1318 1045 options.appendChild(tA);
nickjillings@1318 1046 var div = document.createElement('div');
nickjillings@1318 1047 var input = document.createElement('input');
nickjillings@1318 1048 input.id = "ID";
nickjillings@1318 1049 span = document.createElement('span');
nickjillings@1318 1050 span.textContent = "ID:";
nickjillings@1318 1051 div.appendChild(span);
nickjillings@1318 1052 div.appendChild(input);
nickjillings@1318 1053 options.appendChild(div);
nickjillings@1318 1054 div = document.createElement('div');
nickjillings@1318 1055 input = document.createElement('input');
nickjillings@1318 1056 input.type = "checkbox";
nickjillings@1318 1057 input.id = "mandatory";
nickjillings@1318 1058 span = document.createElement('span');
nickjillings@1318 1059 span.textContent = "Mandatory";
nickjillings@1318 1060 div.appendChild(span);
nickjillings@1318 1061 div.appendChild(input);
nickjillings@1318 1062 options.appendChild(div);
nickjillings@1318 1063 div = document.createElement('div');
nickjillings@1318 1064 var boxsize = document.createElement("select");
nickjillings@1318 1065 boxsize.id = "boxsize";
nickjillings@1318 1066 var selOpt = document.createElement("option");
nickjillings@1318 1067 selOpt.value = "normal";
nickjillings@1318 1068 selOpt.textContent = "Normal";
nickjillings@1318 1069 boxsize.appendChild(selOpt);
nickjillings@1318 1070 selOpt = document.createElement("option");
nickjillings@1318 1071 selOpt.value = "small";
nickjillings@1318 1072 selOpt.textContent = "Small";
nickjillings@1318 1073 boxsize.appendChild(selOpt);
nickjillings@1318 1074 selOpt = document.createElement("option");
nickjillings@1318 1075 selOpt.value = "large";
nickjillings@1318 1076 selOpt.textContent = "Large";
nickjillings@1318 1077 boxsize.appendChild(selOpt);
nickjillings@1318 1078 selOpt = document.createElement("option");
nickjillings@1318 1079 selOpt.value = "huge";
nickjillings@1318 1080 selOpt.textContent = "Huge";
nickjillings@1318 1081 boxsize.appendChild(selOpt);
nickjillings@1318 1082 span = document.createElement('span');
nickjillings@1318 1083 span.textContent = "Response Text Area";
nickjillings@1318 1084 div.appendChild(span);
nickjillings@1318 1085 div.appendChild(boxsize);
nickjillings@1318 1086 options.appendChild(div);
nickjillings@1318 1087 if (popupInstance.dataTransfer.node != null)
nickjillings@1318 1088 {
nickjillings@1318 1089 tA.value = popupInstance.dataTransfer.node.question;
nickjillings@1318 1090 document.getElementById("ID").value = popupInstance.dataTransfer.node.id;
nickjillings@1318 1091 document.getElementById("mandatory").value = popupInstance.dataTransfer.node.mandatory;
nickjillings@1318 1092 document.getElementById("boxsize").value = popupInstance.dataTransfer.node.boxsize;
nickjillings@1318 1093 }
nickjillings@1318 1094 break;
nickjillings@1318 1095 case "number":
nickjillings@1318 1096 var span = document.createElement('span');
nickjillings@1318 1097 span.textContent = "Enter Question";
nickjillings@1318 1098 var tA = document.createElement('textarea');
nickjillings@1318 1099 tA.style.width = "460px";
nickjillings@1318 1100 tA.style.height = "54px";
nickjillings@1318 1101 tA.id = "question";
nickjillings@1318 1102 options.appendChild(span);
nickjillings@1318 1103 options.appendChild(tA);
nickjillings@1318 1104 var div = document.createElement('div');
nickjillings@1318 1105 var input = document.createElement('input');
nickjillings@1318 1106 input.id = "ID";
nickjillings@1318 1107 span = document.createElement('span');
nickjillings@1318 1108 span.textContent = "ID:";
nickjillings@1318 1109 div.appendChild(span);
nickjillings@1318 1110 div.appendChild(input);
nickjillings@1318 1111 options.appendChild(div);
nickjillings@1318 1112 div = document.createElement('div');
nickjillings@1318 1113 input = document.createElement('input');
nickjillings@1318 1114 input.type = "checkbox";
nickjillings@1318 1115 input.id = "mandatory";
nickjillings@1318 1116 span = document.createElement('span');
nickjillings@1318 1117 span.textContent = "Mandatory";
nickjillings@1318 1118 div.appendChild(span);
nickjillings@1318 1119 div.appendChild(input);
nickjillings@1318 1120 options.appendChild(div);
nickjillings@1318 1121 div = document.createElement('div');
nickjillings@1318 1122 break;
nickjillings@1318 1123 }
nickjillings@1318 1124 };
nickjillings@1318 1125 if (this.dataTransfer.node != null)
nickjillings@1318 1126 {
nickjillings@1318 1127 select.value = this.dataTransfer.node.type;
nickjillings@1318 1128 }
nickjillings@1318 1129 select.onchange();
nickjillings@1318 1130 break;
nickjillings@1318 1131 case 7:
nickjillings@1318 1132 this.dataTransfer = null;
nickjillings@1318 1133 this.popupTitleText.textContent = "Test Session - Pre/Post Survey";
nickjillings@1318 1134 var span = document.createElement('span');
nickjillings@1318 1135 span.textContent = "Add your pre test session and post test session survey options here";
nickjillings@1318 1136 this.popupBody.appendChild(span);
nickjillings@1318 1137 var preHolder = document.createElement('div');
nickjillings@1318 1138 preHolder.id = "preHolder";
nickjillings@1318 1139 preHolder.style.width = "460px";
nickjillings@1318 1140 preHolder.style.minHeight = "100px";
nickjillings@1318 1141 preHolder.style.maxHeight = "220px";
nickjillings@1318 1142 preHolder.style.overflow = 'auto';
nickjillings@1318 1143 preHolder.style.border = "black";
nickjillings@1318 1144 preHolder.style.borderStyle = "solid";
nickjillings@1318 1145 preHolder.style.borderWidth = "1px";
nickjillings@1318 1146 this.popupBody.appendChild(preHolder);
nickjillings@1318 1147 var preHeaderHolder = document.createElement('div');
nickjillings@1318 1148 preHeaderHolder.style.width = "456px";
nickjillings@1318 1149 preHeaderHolder.style.height= "20px";
nickjillings@1318 1150 preHeaderHolder.style.margin= "2px";
nickjillings@1318 1151 preHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1318 1152 preHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1318 1153 preHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1318 1154 var mvH = document.createElement('div');
nickjillings@1318 1155 mvH.className = "dndheaderelement";
nickjillings@1318 1156 mvH.style.width = "50px";
nickjillings@1318 1157 var text = document.createElement('span');
nickjillings@1318 1158 text.textContent = "Order";
nickjillings@1318 1159 mvH.appendChild(text);
nickjillings@1318 1160 preHeaderHolder.appendChild(mvH);
nickjillings@1318 1161 var idH = document.createElement('div');
nickjillings@1318 1162 idH.className = "dndheaderelement";
nickjillings@1318 1163 idH.style.width = "150px";
nickjillings@1318 1164 text = document.createElement('span');
nickjillings@1318 1165 text.textContent = "ID";
nickjillings@1318 1166 idH.appendChild(text);
nickjillings@1318 1167 preHeaderHolder.appendChild(idH);
nickjillings@1318 1168 var tH = document.createElement('div');
nickjillings@1318 1169 tH.className = "dndheaderelement";
nickjillings@1318 1170 tH.style.width = "150px";
nickjillings@1318 1171 text = document.createElement('span');
nickjillings@1318 1172 text.textContent = "Type";
nickjillings@1318 1173 tH.appendChild(text);
nickjillings@1318 1174 preHeaderHolder.appendChild(tH);
nickjillings@1318 1175 var editH = document.createElement('div');
nickjillings@1318 1176 editH.className = "dndheaderelement";
nickjillings@1318 1177 editH.style.width = "50px";
nickjillings@1318 1178 text = document.createElement('span');
nickjillings@1318 1179 text.textContent = "Edit";
nickjillings@1318 1180 editH.appendChild(text);
nickjillings@1318 1181 preHeaderHolder.appendChild(editH);
nickjillings@1318 1182 var deleteH = document.createElement('div');
nickjillings@1318 1183 deleteH.className = "dndheaderelement";
nickjillings@1318 1184 deleteH.style.width = "50px";
nickjillings@1318 1185 text = document.createElement('span');
nickjillings@1318 1186 text.textContent = "Delete";
nickjillings@1318 1187 deleteH.appendChild(text);
nickjillings@1318 1188 preHeaderHolder.appendChild(deleteH);
nickjillings@1318 1189 preHolder.appendChild(preHeaderHolder);
nickjillings@1318 1190
nickjillings@1318 1191
nickjillings@1318 1192 for (var i=0; i<specificationNode.preTest.options.length; i++)
nickjillings@1318 1193 {
nickjillings@1318 1194 var optionNode = specificationNode.preTest.options[i];
nickjillings@1318 1195 var entry = document.createElement('div');
nickjillings@1318 1196 entry.style.width = "456px";
nickjillings@1318 1197 entry.style.height= "20px";
nickjillings@1318 1198 entry.style.margin= "2px";
nickjillings@1318 1199 entry.style.borderBottom = "#DDD";
nickjillings@1318 1200 entry.style.borderBottomWidth = "1px";
nickjillings@1318 1201 entry.style.borderBottomStyle = "solid";
nickjillings@1318 1202 entry.setAttribute("node-id",i);
nickjillings@1318 1203 var node = specificationNode.preTest.options[i];
nickjillings@1318 1204 var mvH = document.createElement('div');
nickjillings@1318 1205 mvH.className = "dndheaderelement";
nickjillings@1318 1206 mvH.style.width = "50px";
nickjillings@1318 1207 var mvup = document.createElement("button");
nickjillings@1318 1208 mvup.textContent = "Up";
nickjillings@1318 1209 mvup.style.width = "25px";
nickjillings@1318 1210 mvup.style.padding = "1px 0px";
nickjillings@1318 1211 mvup.onclick = function()
nickjillings@1318 1212 {
nickjillings@1318 1213 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1214 if (i != 0)
nickjillings@1318 1215 {
nickjillings@1318 1216 var next = specificationNode.preTest.options[i-1];
nickjillings@1318 1217 var cur = specificationNode.preTest.options[i];
nickjillings@1318 1218 specificationNode.preTest.options[i-1] = cur;
nickjillings@1318 1219 specificationNode.preTest.options[i] = next;
nickjillings@1318 1220 popupInstance.state = 7;
nickjillings@1318 1221 popupInstance.advanceState();
nickjillings@1318 1222 }
nickjillings@1318 1223 };
nickjillings@1318 1224 mvH.appendChild(mvup);
nickjillings@1318 1225 var mvdn = document.createElement("button");
nickjillings@1318 1226 mvdn.textContent = "Dn";
nickjillings@1318 1227 mvdn.style.width = "25px";
nickjillings@1318 1228 mvdn.style.padding = "1px 0px";
nickjillings@1318 1229 mvdn.onclick = function()
nickjillings@1318 1230 {
nickjillings@1318 1231 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1232 if (i != specificationNode.preTest.options.length-1)
nickjillings@1318 1233 {
nickjillings@1318 1234 var next = specificationNode.preTest.options[i+1];
nickjillings@1318 1235 var cur = specificationNode.preTest.options[i];
nickjillings@1318 1236 specificationNode.preTest.options[i+1] = cur;
nickjillings@1318 1237 specificationNode.preTest.options[i] = next;
nickjillings@1318 1238 popupInstance.state = 7;
nickjillings@1318 1239 popupInstance.advanceState();
nickjillings@1318 1240 }
nickjillings@1318 1241 };
nickjillings@1318 1242 mvH.appendChild(mvdn);
nickjillings@1318 1243 entry.appendChild(mvH);
nickjillings@1318 1244 var idH = document.createElement('div');
nickjillings@1318 1245 idH.className = "dndheaderelement";
nickjillings@1318 1246 idH.style.width = "150px";
nickjillings@1318 1247 if (optionNode.type != "statement")
nickjillings@1318 1248 {
nickjillings@1318 1249 var span = document.createElement('span');
nickjillings@1318 1250 span.textContent = optionNode.id;
nickjillings@1318 1251 idH.appendChild(span);
nickjillings@1318 1252 }
nickjillings@1318 1253 entry.appendChild(idH);
nickjillings@1318 1254 var typeH = document.createElement('div');
nickjillings@1318 1255 typeH.className = "dndheaderelement";
nickjillings@1318 1256 typeH.style.width = "150px";
nickjillings@1318 1257 var span = document.createElement('span');
nickjillings@1318 1258 span.textContent = optionNode.type;
nickjillings@1318 1259 typeH.appendChild(span);
nickjillings@1318 1260 entry.appendChild(typeH);
nickjillings@1318 1261 var editH = document.createElement('div');
nickjillings@1318 1262 editH.className = "dndheaderelement";
nickjillings@1318 1263 editH.style.width = "50px";
nickjillings@1318 1264 var editButton = document.createElement("button");
nickjillings@1318 1265 editButton.textContent = "Edit";
nickjillings@1318 1266 editButton.style.width = "48px";
nickjillings@1318 1267 editButton.style.padding = "1px 0px";
nickjillings@1318 1268 editButton.onclick = function()
nickjillings@1318 1269 {
nickjillings@1318 1270 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1271 popupInstance.dataTransfer = new function() {
nickjillings@1318 1272 this.title = "Edit Test Node";
nickjillings@1318 1273 this.parent = specificationNode.preTest;
nickjillings@1318 1274 this.node = this.parent.options[i];
nickjillings@1318 1275 this.previousState = 7;
nickjillings@1318 1276 };
nickjillings@1318 1277 popupInstace.state = 6;
nickjillings@1318 1278 popupInstance.advanceState();
nickjillings@1318 1279 };
nickjillings@1318 1280 editH.appendChild(editButton);
nickjillings@1318 1281 entry.appendChild(editH);
nickjillings@1318 1282 var deleteH = document.createElement('div');
nickjillings@1318 1283 deleteH.className = "dndheaderelement";
nickjillings@1318 1284 deleteH.style.width = "50px";
nickjillings@1318 1285 var deleteButton = document.createElement("button");
nickjillings@1318 1286 deleteButton.textContent = "Del";
nickjillings@1318 1287 deleteButton.style.width = "48px";
nickjillings@1318 1288 deleteButton.style.padding = "1px 0px";
nickjillings@1318 1289 deleteButton.onclick = function()
nickjillings@1318 1290 {
nickjillings@1318 1291 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1292 var j = i+1;
nickjillings@1318 1293 while(j < specificationNode.preTest.options.length)
nickjillings@1318 1294 {
nickjillings@1318 1295 specificationNode.preTest.options[i] = specificationNode.preTest.options[j];
nickjillings@1318 1296 j++;
nickjillings@1318 1297 i++;
nickjillings@1318 1298 }
nickjillings@1318 1299 specificationNode.preTest.options.pop();
nickjillings@1318 1300 popupInstance.state = 7;
nickjillings@1318 1301 popupInstance.advanceState();
nickjillings@1318 1302 };
nickjillings@1318 1303 deleteH.appendChild(deleteButton);
nickjillings@1318 1304 entry.appendChild(deleteH);
nickjillings@1318 1305 preHolder.appendChild(entry);
nickjillings@1318 1306 }
nickjillings@1318 1307 var entry = document.createElement('div');
nickjillings@1318 1308 entry.style.width = "456px";
nickjillings@1318 1309 entry.style.height= "20px";
nickjillings@1318 1310 entry.style.margin= "2px";
nickjillings@1318 1311 entry.style.borderBottom = "#DDD";
nickjillings@1318 1312 entry.style.borderBottomWidth = "1px";
nickjillings@1318 1313 entry.style.borderBottomStyle = "solid";
nickjillings@1318 1314 entry.align = "center";
nickjillings@1318 1315 var addPre = document.createElement('button');
nickjillings@1318 1316 addPre.className = "popupButton";
nickjillings@1318 1317 addPre.textContent = "Add New Entry";
nickjillings@1318 1318 addPre.style.height = "20px";
nickjillings@1318 1319 addPre.onclick = function()
nickjillings@1318 1320 {
nickjillings@1318 1321 popupInstance.dataTransfer = new function() {
nickjillings@1318 1322 this.title = "New Pre Test Node";
nickjillings@1318 1323 this.parent = specificationNode.preTest;
nickjillings@1318 1324 this.node = null;
nickjillings@1318 1325 this.previousState = 7;
nickjillings@1318 1326 };
nickjillings@1318 1327 popupInstance.state = 6;
nickjillings@1318 1328 popupInstance.advanceState();
nickjillings@1318 1329 };
nickjillings@1318 1330 entry.appendChild(addPre);
nickjillings@1318 1331 preHolder.appendChild(entry);
nickjillings@1318 1332
nickjillings@1318 1333 var span = document.createElement('span');
nickjillings@1318 1334 span.textContent = "Add your post test page options here";
nickjillings@1318 1335 this.popupBody.appendChild(span);
nickjillings@1318 1336 var postHolder = document.createElement('div');
nickjillings@1318 1337 postHolder.id = "preHolder";
nickjillings@1318 1338 postHolder.style.width = "100%";
nickjillings@1318 1339 postHolder.style.minHeight = "100px";
nickjillings@1318 1340 postHolder.style.maxHeight = "220px";
nickjillings@1318 1341 postHolder.style.overflow = 'auto';
nickjillings@1318 1342 postHolder.style.border = "black";
nickjillings@1318 1343 postHolder.style.borderStyle = "solid";
nickjillings@1318 1344 postHolder.style.borderWidth = "1px";
nickjillings@1318 1345 this.popupBody.appendChild(postHolder);
nickjillings@1318 1346 var postHeaderHolder = document.createElement('div');
nickjillings@1318 1347 postHeaderHolder.style.width = "456px";
nickjillings@1318 1348 postHeaderHolder.style.height= "20px";
nickjillings@1318 1349 postHeaderHolder.style.margin= "2px";
nickjillings@1318 1350 postHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1318 1351 postHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1318 1352 postHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1318 1353 var mvH = document.createElement('div');
nickjillings@1318 1354 mvH.className = "dndheaderelement";
nickjillings@1318 1355 mvH.style.width = "50px";
nickjillings@1318 1356 var text = document.createElement('span');
nickjillings@1318 1357 text.textContent = "Order";
nickjillings@1318 1358 mvH.appendChild(text);
nickjillings@1318 1359 postHeaderHolder.appendChild(mvH);
nickjillings@1318 1360 var idH = document.createElement('div');
nickjillings@1318 1361 idH.className = "dndheaderelement";
nickjillings@1318 1362 idH.style.width = "150px";
nickjillings@1318 1363 text = document.createElement('span');
nickjillings@1318 1364 text.textContent = "ID";
nickjillings@1318 1365 idH.appendChild(text);
nickjillings@1318 1366 postHeaderHolder.appendChild(idH);
nickjillings@1318 1367 var tH = document.createElement('div');
nickjillings@1318 1368 tH.className = "dndheaderelement";
nickjillings@1318 1369 tH.style.width = "150px";
nickjillings@1318 1370 text = document.createElement('span');
nickjillings@1318 1371 text.textContent = "Type";
nickjillings@1318 1372 tH.appendChild(text);
nickjillings@1318 1373 postHeaderHolder.appendChild(tH);
nickjillings@1318 1374 var editH = document.createElement('div');
nickjillings@1318 1375 editH.className = "dndheaderelement";
nickjillings@1318 1376 editH.style.width = "50px";
nickjillings@1318 1377 text = document.createElement('span');
nickjillings@1318 1378 text.textContent = "Edit";
nickjillings@1318 1379 editH.appendChild(text);
nickjillings@1318 1380 postHeaderHolder.appendChild(editH);
nickjillings@1318 1381 var deleteH = document.createElement('div');
nickjillings@1318 1382 deleteH.className = "dndheaderelement";
nickjillings@1318 1383 deleteH.style.width = "50px";
nickjillings@1318 1384 text = document.createElement('span');
nickjillings@1318 1385 text.textContent = "Delete";
nickjillings@1318 1386 deleteH.appendChild(text);
nickjillings@1318 1387 postHeaderHolder.appendChild(deleteH);
nickjillings@1318 1388 postHolder.appendChild(postHeaderHolder);
nickjillings@1318 1389
nickjillings@1318 1390 for (var i=0; i<specificationNode.postTest.options.length; i++)
nickjillings@1318 1391 {
nickjillings@1318 1392 var optionNode = specificationNode.postTest.options[i];
nickjillings@1318 1393 var entry = document.createElement('div');
nickjillings@1318 1394 entry.style.width = "456px";
nickjillings@1318 1395 entry.style.height= "20px";
nickjillings@1318 1396 entry.style.margin= "2px";
nickjillings@1318 1397 entry.style.borderBottom = "#DDD";
nickjillings@1318 1398 entry.style.borderBottomWidth = "1px";
nickjillings@1318 1399 entry.style.borderBottomStyle = "solid";
nickjillings@1318 1400 entry.setAttribute("node-id",i);
nickjillings@1318 1401 var node = specificationNode.postTest.options[i];
nickjillings@1318 1402 var mvH = document.createElement('div');
nickjillings@1318 1403 mvH.className = "dndheaderelement";
nickjillings@1318 1404 mvH.style.width = "50px";
nickjillings@1318 1405 var mvup = document.createElement("button");
nickjillings@1318 1406 mvup.textContent = "Up";
nickjillings@1318 1407 mvup.style.width = "25px";
nickjillings@1318 1408 mvup.style.padding = "1px 0px";
nickjillings@1318 1409 mvup.onclick = function()
nickjillings@1318 1410 {
nickjillings@1318 1411 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1412 if (i != 0)
nickjillings@1318 1413 {
nickjillings@1318 1414 var next = specificationNode.postTest.options[i-1];
nickjillings@1318 1415 var cur = specificationNode.postTest.options[i];
nickjillings@1318 1416 specificationNode.postTest.options[i-1] = cur;
nickjillings@1318 1417 specificationNode.postTest.options[i] = next;
nickjillings@1318 1418 popupInstance.state = 7;
nickjillings@1318 1419 popupInstance.advanceState();
nickjillings@1318 1420 }
nickjillings@1318 1421 };
nickjillings@1318 1422 mvH.appendChild(mvup);
nickjillings@1318 1423 var mvdn = document.createElement("button");
nickjillings@1318 1424 mvdn.textContent = "Dn";
nickjillings@1318 1425 mvdn.style.width = "25px";
nickjillings@1318 1426 mvdn.style.padding = "1px 0px";
nickjillings@1318 1427 mvdn.onclick = function()
nickjillings@1318 1428 {
nickjillings@1318 1429 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1430 if (i != specificationNode.postTest.options.length-1)
nickjillings@1318 1431 {
nickjillings@1318 1432 var next = specificationNode.postTest.options[i+1];
nickjillings@1318 1433 var cur = specificationNode.postTest.options[i];
nickjillings@1318 1434 specificationNode.postTest.options[i+1] = cur;
nickjillings@1318 1435 specificationNode.postTest.options[i] = next;
nickjillings@1318 1436 popupInstance.state = 7;
nickjillings@1318 1437 popupInstance.advanceState();
nickjillings@1318 1438 }
nickjillings@1318 1439 };
nickjillings@1318 1440 mvH.appendChild(mvdn);
nickjillings@1318 1441 entry.appendChild(mvH);
nickjillings@1318 1442 var idH = document.createElement('div');
nickjillings@1318 1443 idH.className = "dndheaderelement";
nickjillings@1318 1444 idH.style.width = "150px";
nickjillings@1318 1445 if (optionNode.type != "statement")
nickjillings@1318 1446 {
nickjillings@1318 1447 var span = document.createElement('span');
nickjillings@1318 1448 span.textContent = optionNode.id;
nickjillings@1318 1449 idH.appendChild(span);
nickjillings@1318 1450 }
nickjillings@1318 1451 entry.appendChild(idH);
nickjillings@1318 1452 var typeH = document.createElement('div');
nickjillings@1318 1453 typeH.className = "dndheaderelement";
nickjillings@1318 1454 typeH.style.width = "150px";
nickjillings@1318 1455 var span = document.createElement('span');
nickjillings@1318 1456 span.textContent = optionNode.type;
nickjillings@1318 1457 typeH.appendChild(span);
nickjillings@1318 1458 entry.appendChild(typeH);
nickjillings@1318 1459 var editH = document.createElement('div');
nickjillings@1318 1460 editH.className = "dndheaderelement";
nickjillings@1318 1461 editH.style.width = "50px";
nickjillings@1318 1462 var editButton = document.createElement("button");
nickjillings@1318 1463 editButton.textContent = "Edit";
nickjillings@1318 1464 editButton.style.width = "48px";
nickjillings@1318 1465 editButton.style.padding = "1px 0px";
nickjillings@1318 1466 editButton.onclick = function()
nickjillings@1318 1467 {
nickjillings@1318 1468 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1469 popupInstance.dataTransfer = new function() {
nickjillings@1318 1470 this.title = "Edit Test Node";
nickjillings@1318 1471 this.parent = specificationNode.postTest;
nickjillings@1318 1472 this.node = this.parent.options[i];
nickjillings@1318 1473 this.previousState = 7;
nickjillings@1318 1474 };
nickjillings@1318 1475 popupInstance.state = 6;
nickjillings@1318 1476 popupInstance.advanceState();
nickjillings@1318 1477 };
nickjillings@1318 1478 editH.appendChild(editButton);
nickjillings@1318 1479 entry.appendChild(editH);
nickjillings@1318 1480 var deleteH = document.createElement('div');
nickjillings@1318 1481 deleteH.className = "dndheaderelement";
nickjillings@1318 1482 deleteH.style.width = "50px";
nickjillings@1318 1483 var deleteButton = document.createElement("button");
nickjillings@1318 1484 deleteButton.textContent = "Del";
nickjillings@1318 1485 deleteButton.style.width = "48px";
nickjillings@1318 1486 deleteButton.style.padding = "1px 0px";
nickjillings@1318 1487 deleteButton.onclick = function()
nickjillings@1318 1488 {
nickjillings@1318 1489 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1318 1490 var j = i+1;
nickjillings@1318 1491 while(j < specificationNode.postTest.options.length)
nickjillings@1318 1492 {
nickjillings@1318 1493 specificationNode.postTest.options[i] = specificationNode.postTest.options[j];
nickjillings@1318 1494 j++;
nickjillings@1318 1495 i++;
nickjillings@1318 1496 }
nickjillings@1318 1497 audioHolder.postTest.options.pop();
nickjillings@1318 1498 popupInstance.state = 7;
nickjillings@1318 1499 popupInstance.advanceState();
nickjillings@1318 1500 };
nickjillings@1318 1501 deleteH.appendChild(deleteButton);
nickjillings@1318 1502 entry.appendChild(deleteH);
nickjillings@1318 1503 postHolder.appendChild(entry);
nickjillings@1318 1504 }
nickjillings@1318 1505
nickjillings@1318 1506 var entry = document.createElement('div');
nickjillings@1318 1507 entry.style.width = "456px";
nickjillings@1318 1508 entry.style.height= "20px";
nickjillings@1318 1509 entry.style.margin= "2px";
nickjillings@1318 1510 entry.style.borderBottom = "#DDD";
nickjillings@1318 1511 entry.style.borderBottomWidth = "1px";
nickjillings@1318 1512 entry.style.borderBottomStyle = "solid";
nickjillings@1318 1513 entry.align = "center";
nickjillings@1318 1514 var addPost = document.createElement('button');
nickjillings@1318 1515 addPost.className = "popupButton";
nickjillings@1318 1516 addPost.textContent = "Add New Entry";
nickjillings@1318 1517 addPost.style.height = "20px";
nickjillings@1318 1518 addPost.onclick = function()
nickjillings@1318 1519 {
nickjillings@1318 1520 popupInstance.dataTransfer = new function() {
nickjillings@1318 1521 this.title = "New Pre Test Node";
nickjillings@1318 1522 this.parent = specificationNode.postTest;
nickjillings@1318 1523 this.node = null;
nickjillings@1318 1524 this.previousState = 7;
nickjillings@1318 1525 };
nickjillings@1318 1526 popupInstance.state = 6;
nickjillings@1318 1527 popupInstance.advanceState();
nickjillings@1318 1528 };
nickjillings@1318 1529 entry.appendChild(addPost);
nickjillings@1318 1530 postHolder.appendChild(entry);
nickjillings@1318 1531
nickjillings@1318 1532 var button = document.createElement('button');
nickjillings@1318 1533 button.id = 'submit';
nickjillings@1318 1534 button.className = "popupButton";
nickjillings@1318 1535 button.textContent = "Finish";
nickjillings@1318 1536 button.onclick = function(event)
nickjillings@1318 1537 {
nickjillings@1318 1538 popupInstance.state = 8;
nickjillings@1318 1539 popupInstance.advanceState();
nickjillings@1318 1540 };
nickjillings@1318 1541 this.popupFooter.appendChild(button);
nickjillings@1318 1542 break;
nickjillings@1318 1543 case 8:
nickjillings@1318 1544 this.hidePopup();
nickjillings@1318 1545 this.state = 0;
nickjillings@1318 1546 SpecificationToHTML ();
nickjillings@1318 1547 }
nickjillings@1318 1548 this.state++;
nickjillings@1318 1549 };
nickjillings@1318 1550 };
nickjillings@1318 1551
nickjillings@1318 1552 function audioObject()
nickjillings@1318 1553 {
nickjillings@1318 1554 // Used to hold audio information in buffers for quick playback
nickjillings@1318 1555 this.bufferObject;
nickjillings@1318 1556 this.bufferNode = undefined;
nickjillings@1318 1557 this.state = 0;
nickjillings@1318 1558 this.gain = audioContext.createGain();
nickjillings@1318 1559 this.gain.connect(audioContext.destination);
nickjillings@1318 1560 this.include = true;
nickjillings@1318 1561 this.id = undefined;
nickjillings@1318 1562 this.file = undefined;
nickjillings@1318 1563
nickjillings@1318 1564 this.play = function()
nickjillings@1318 1565 {
nickjillings@1318 1566 if (this.bufferNode != undefined)
nickjillings@1318 1567 {
nickjillings@1318 1568 this.bufferNode.stop(0);
nickjillings@1318 1569 this.bufferNode = undefined;
nickjillings@1318 1570 }
nickjillings@1318 1571 if(this.state == 1)
nickjillings@1318 1572 {
nickjillings@1318 1573 this.bufferNode = audioContext.createBufferSource();
nickjillings@1318 1574 this.bufferNode.connect(this.gain);
nickjillings@1318 1575 this.bufferNode.buffer = this.bufferObject;
nickjillings@1318 1576 this.bufferNode.onended = function(event) {
nickjillings@1318 1577 // Safari does not like using 'this' to reference the calling object!
nickjillings@1318 1578 event.currentTarget = undefined;
nickjillings@1318 1579 };
nickjillings@1318 1580 this.bufferNode.start(audioContext.currentTime);
nickjillings@1318 1581 this.bufferNode.stop(audioContext.currentTime+3);
nickjillings@1318 1582 }
nickjillings@1318 1583 };
nickjillings@1318 1584
nickjillings@1318 1585 this.constructTrack = function(file) {
nickjillings@1318 1586 var reader = new FileReader();
nickjillings@1318 1587 this.file = file;
nickjillings@1318 1588 var audioObj = this;
nickjillings@1318 1589 // Create callback to decode the data asynchronously
nickjillings@1318 1590 reader.onloadend = function() {
nickjillings@1318 1591 audioContext.decodeAudioData(reader.result, function(decodedData) {
nickjillings@1318 1592 audioObj.bufferObject = decodedData;
nickjillings@1318 1593 audioObj.state = 1;
nickjillings@1318 1594 }, function(){});
nickjillings@1318 1595 };
nickjillings@1318 1596 reader.readAsArrayBuffer(file);
nickjillings@1318 1597 };
nickjillings@1318 1598 };
nickjillings@1318 1599
nickjillings@1318 1600 function Specification() {
nickjillings@1318 1601 // Handles the decoding of the project specification XML into a simple JavaScript Object.
nickjillings@1318 1602
nickjillings@1318 1603 this.interfaceType = null;
nickjillings@1318 1604 this.commonInterface = new function()
nickjillings@1318 1605 {
nickjillings@1318 1606 this.options = [];
nickjillings@1318 1607 this.optionNode = function(input)
nickjillings@1318 1608 {
nickjillings@1318 1609 var name = input.getAttribute('name');
nickjillings@1318 1610 this.type = name;
nickjillings@1318 1611 if(this.type == "option")
nickjillings@1318 1612 {
nickjillings@1318 1613 this.name = input.id;
nickjillings@1318 1614 } else if (this.type == "check")
nickjillings@1318 1615 {
nickjillings@1318 1616 this.check = input.id;
nickjillings@1318 1617 }
nickjillings@1318 1618 };
nickjillings@1318 1619 };
nickjillings@1318 1620
nickjillings@1318 1621 this.randomiseOrder = function(input)
nickjillings@1318 1622 {
nickjillings@1318 1623 // This takes an array of information and randomises the order
nickjillings@1318 1624 var N = input.length;
nickjillings@1318 1625
nickjillings@1318 1626 var inputSequence = []; // For safety purposes: keep track of randomisation
nickjillings@1318 1627 for (var counter = 0; counter < N; ++counter)
nickjillings@1318 1628 inputSequence.push(counter) // Fill array
nickjillings@1318 1629 var inputSequenceClone = inputSequence.slice(0);
nickjillings@1318 1630
nickjillings@1318 1631 var holdArr = [];
nickjillings@1318 1632 var outputSequence = [];
nickjillings@1318 1633 for (var n=0; n<N; n++)
nickjillings@1318 1634 {
nickjillings@1318 1635 // First pick a random number
nickjillings@1318 1636 var r = Math.random();
nickjillings@1318 1637 // Multiply and floor by the number of elements left
nickjillings@1318 1638 r = Math.floor(r*input.length);
nickjillings@1318 1639 // Pick out that element and delete from the array
nickjillings@1318 1640 holdArr.push(input.splice(r,1)[0]);
nickjillings@1318 1641 // Do the same with sequence
nickjillings@1318 1642 outputSequence.push(inputSequence.splice(r,1)[0]);
nickjillings@1318 1643 }
nickjillings@1318 1644 console.log(inputSequenceClone.toString()); // print original array to console
nickjillings@1318 1645 console.log(outputSequence.toString()); // print randomised array to console
nickjillings@1318 1646 return holdArr;
nickjillings@1318 1647 };
nickjillings@1318 1648 this.projectReturn = null;
nickjillings@1318 1649 this.randomiseOrder = null;
nickjillings@1318 1650 this.collectMetrics = null;
nickjillings@1318 1651 this.testPages = null;
nickjillings@1318 1652 this.audioHolders = [];
nickjillings@1318 1653 this.metrics = [];
nickjillings@1318 1654
nickjillings@1318 1655 this.decode = function(projectXML) {
nickjillings@1318 1656 // projectXML - DOM Parsed document
nickjillings@1318 1657 this.projectXML = projectXML.childNodes[0];
nickjillings@1318 1658 var setupNode = projectXML.getElementsByTagName('setup')[0];
nickjillings@1318 1659 this.interfaceType = setupNode.getAttribute('interface');
nickjillings@1318 1660 this.projectReturn = setupNode.getAttribute('projectReturn');
nickjillings@1318 1661 this.testPages = setupNode.getAttribute('testPages');
nickjillings@1318 1662 if (setupNode.getAttribute('randomiseOrder') == "true") {
nickjillings@1318 1663 this.randomiseOrder = true;
nickjillings@1318 1664 } else {this.randomiseOrder = false;}
nickjillings@1318 1665 if (setupNode.getAttribute('collectMetrics') == "true") {
nickjillings@1318 1666 this.collectMetrics = true;
nickjillings@1318 1667 } else {this.collectMetrics = false;}
nickjillings@1318 1668 if (isNaN(Number(this.testPages)) || this.testPages == undefined)
nickjillings@1318 1669 {
nickjillings@1318 1670 this.testPages = null;
nickjillings@1318 1671 } else {
nickjillings@1318 1672 this.testPages = Number(this.testPages);
nickjillings@1318 1673 if (this.testPages == 0) {this.testPages = null;}
nickjillings@1318 1674 }
nickjillings@1318 1675 var metricCollection = setupNode.getElementsByTagName('Metric');
nickjillings@1318 1676
nickjillings@1318 1677 var setupPreTestNode = setupNode.getElementsByTagName('PreTest');
nickjillings@1318 1678 if (setupPreTestNode.length != 0)
nickjillings@1318 1679 {
nickjillings@1318 1680 setupPreTestNode = setupPreTestNode[0];
nickjillings@1318 1681 this.preTest.construct(setupPreTestNode);
nickjillings@1318 1682 }
nickjillings@1318 1683
nickjillings@1318 1684 var setupPostTestNode = setupNode.getElementsByTagName('PostTest');
nickjillings@1318 1685 if (setupPostTestNode.length != 0)
nickjillings@1318 1686 {
nickjillings@1318 1687 setupPostTestNode = setupPostTestNode[0];
nickjillings@1318 1688 this.postTest.construct(setupPostTestNode);
nickjillings@1318 1689 }
nickjillings@1318 1690
nickjillings@1318 1691 if (metricCollection.length > 0) {
nickjillings@1318 1692 metricCollection = metricCollection[0].getElementsByTagName('metricEnable');
nickjillings@1318 1693 for (var i=0; i<metricCollection.length; i++) {
nickjillings@1318 1694 this.metrics.push(new this.metricNode(metricCollection[i].textContent));
nickjillings@1318 1695 }
nickjillings@1318 1696 }
nickjillings@1318 1697
nickjillings@1318 1698 var commonInterfaceNode = setupNode.getElementsByTagName('interface');
nickjillings@1318 1699 if (commonInterfaceNode.length > 0) {
nickjillings@1318 1700 commonInterfaceNode = commonInterfaceNode[0];
nickjillings@1318 1701 } else {
nickjillings@1318 1702 commonInterfaceNode = undefined;
nickjillings@1318 1703 }
nickjillings@1318 1704
nickjillings@1318 1705 this.commonInterface = new function() {
nickjillings@1318 1706 this.OptionNode = function(child) {
nickjillings@1318 1707 this.type = child.nodeName;
nickjillings@1318 1708 if (this.type == 'option')
nickjillings@1318 1709 {
nickjillings@1318 1710 this.name = child.getAttribute('name');
nickjillings@1318 1711 }
nickjillings@1318 1712 else if (this.type == 'check') {
nickjillings@1318 1713 this.check = child.getAttribute('name');
nickjillings@1318 1714 if (this.check == 'scalerange') {
nickjillings@1318 1715 this.min = child.getAttribute('min');
nickjillings@1318 1716 this.max = child.getAttribute('max');
nickjillings@1318 1717 if (this.min == null) {this.min = 1;}
nickjillings@1318 1718 else if (Number(this.min) > 1 && this.min != null) {
nickjillings@1318 1719 this.min = Number(this.min)/100;
nickjillings@1318 1720 } else {
nickjillings@1318 1721 this.min = Number(this.min);
nickjillings@1318 1722 }
nickjillings@1318 1723 if (this.max == null) {this.max = 0;}
nickjillings@1318 1724 else if (Number(this.max) > 1 && this.max != null) {
nickjillings@1318 1725 this.max = Number(this.max)/100;
nickjillings@1318 1726 } else {
nickjillings@1318 1727 this.max = Number(this.max);
nickjillings@1318 1728 }
nickjillings@1318 1729 }
nickjillings@1318 1730 } else if (this.type == 'anchor' || this.type == 'reference') {
nickjillings@1318 1731 this.value = Number(child.textContent);
nickjillings@1318 1732 this.enforce = child.getAttribute('enforce');
nickjillings@1318 1733 if (this.enforce == 'true') {this.enforce = true;}
nickjillings@1318 1734 else {this.enforce = false;}
nickjillings@1318 1735 }
nickjillings@1318 1736 };
nickjillings@1318 1737 this.options = [];
nickjillings@1318 1738 if (commonInterfaceNode != undefined) {
nickjillings@1318 1739 var child = commonInterfaceNode.firstElementChild;
nickjillings@1318 1740 while (child != undefined) {
nickjillings@1318 1741 this.options.push(new this.OptionNode(child));
nickjillings@1318 1742 child = child.nextElementSibling;
nickjillings@1318 1743 }
nickjillings@1318 1744 }
nickjillings@1318 1745 };
nickjillings@1318 1746
nickjillings@1318 1747 var audioHolders = projectXML.getElementsByTagName('audioHolder');
nickjillings@1318 1748 for (var i=0; i<audioHolders.length; i++) {
nickjillings@1318 1749 var node = new this.audioHolderNode(this);
nickjillings@1318 1750 node.decode(this,audioHolders[i]);
nickjillings@1318 1751 this.audioHolders.push(node);
nickjillings@1318 1752 }
nickjillings@1318 1753
nickjillings@1318 1754 // New check if we need to randomise the test order
nickjillings@1318 1755 if (this.randomiseOrder && typeof randomiseOrder === "function")
nickjillings@1318 1756 {
nickjillings@1318 1757 this.audioHolders = randomiseOrder(this.audioHolders);
nickjillings@1318 1758 for (var i=0; i<this.audioHolders.length; i++)
nickjillings@1318 1759 {
nickjillings@1318 1760 this.audioHolders[i].presentedId = i;
nickjillings@1318 1761 }
nickjillings@1318 1762 }
nickjillings@1318 1763
nickjillings@1318 1764 if (this.testPages != null || this.testPages != undefined)
nickjillings@1318 1765 {
nickjillings@1318 1766 if (this.testPages > audioHolders.length)
nickjillings@1318 1767 {
nickjillings@1318 1768 console.log('Warning: You have specified '+audioHolders.length+' tests but requested '+this.testPages+' be completed!');
nickjillings@1318 1769 this.testPages = audioHolders.length;
nickjillings@1318 1770 }
nickjillings@1318 1771 var aH = this.audioHolders;
nickjillings@1318 1772 this.audioHolders = [];
nickjillings@1318 1773 for (var i=0; i<this.testPages; i++)
nickjillings@1318 1774 {
nickjillings@1318 1775 this.audioHolders.push(aH[i]);
nickjillings@1318 1776 }
nickjillings@1318 1777 }
nickjillings@1318 1778 };
nickjillings@1318 1779
nickjillings@1318 1780 this.encode = function()
nickjillings@1318 1781 {
nickjillings@1318 1782 var root = document.implementation.createDocument(null,"BrowserEvalProjectDocument");
nickjillings@1318 1783 // First get all the <setup> tag compiled
nickjillings@1318 1784 var setupNode = root.createElement("setup");
nickjillings@1318 1785 setupNode.setAttribute('interface',this.interfaceType);
nickjillings@1318 1786 setupNode.setAttribute('projectReturn',this.projectReturn);
nickjillings@1318 1787 setupNode.setAttribute('randomiseOrder',this.randomiseOrder);
nickjillings@1318 1788 setupNode.setAttribute('collectMetrics',this.collectMetrics);
nickjillings@1318 1789 setupNode.setAttribute('testPages',this.testPages);
nickjillings@1318 1790
nickjillings@1318 1791 var setupPreTest = root.createElement("PreTest");
nickjillings@1318 1792 for (var i=0; i<this.preTest.options.length; i++)
nickjillings@1318 1793 {
nickjillings@1318 1794 setupPreTest.appendChild(this.preTest.options[i].exportXML(root));
nickjillings@1318 1795 }
nickjillings@1318 1796
nickjillings@1318 1797 var setupPostTest = root.createElement("PostTest");
nickjillings@1318 1798 for (var i=0; i<this.postTest.options.length; i++)
nickjillings@1318 1799 {
nickjillings@1318 1800 setupPostTest.appendChild(this.postTest.options[i].exportXML(root));
nickjillings@1318 1801 }
nickjillings@1318 1802
nickjillings@1318 1803 setupNode.appendChild(setupPreTest);
nickjillings@1318 1804 setupNode.appendChild(setupPostTest);
nickjillings@1318 1805
nickjillings@1318 1806 // <Metric> tag
nickjillings@1318 1807 var Metric = root.createElement("Metric");
nickjillings@1318 1808 for (var i=0; i<this.metrics.length; i++)
nickjillings@1318 1809 {
nickjillings@1318 1810 var metricEnable = root.createElement("metricEnable");
nickjillings@1318 1811 metricEnable.textContent = this.metrics[i].enabled;
nickjillings@1318 1812 Metric.appendChild(metricEnable);
nickjillings@1318 1813 }
nickjillings@1318 1814 setupNode.appendChild(Metric);
nickjillings@1318 1815
nickjillings@1318 1816 // <interface> tag
nickjillings@1318 1817 var CommonInterface = root.createElement("interface");
nickjillings@1318 1818 for (var i=0; i<this.commonInterface.options.length; i++)
nickjillings@1318 1819 {
nickjillings@1318 1820 var CIObj = this.commonInterface.options[i];
nickjillings@1318 1821 var CINode = root.createElement(CIObj.type);
nickjillings@1318 1822 if (CIObj.type == "check") {CINode.setAttribute("name",CIObj.check);}
nickjillings@1318 1823 else {CINode.setAttribute("name",CIObj.name);}
nickjillings@1318 1824 CommonInterface.appendChild(CINode);
nickjillings@1318 1825 }
nickjillings@1318 1826 setupNode.appendChild(CommonInterface);
nickjillings@1318 1827
nickjillings@1318 1828 root.getElementsByTagName("BrowserEvalProjectDocument")[0].appendChild(setupNode);
nickjillings@1318 1829 // Time for the <audioHolder> tags
nickjillings@1318 1830 for (var ahIndex = 0; ahIndex < this.audioHolders.length; ahIndex++)
nickjillings@1318 1831 {
nickjillings@1318 1832 var node = this.audioHolders[ahIndex].encode(root);
nickjillings@1318 1833 root.getElementsByTagName("BrowserEvalProjectDocument")[0].appendChild(node);
nickjillings@1318 1834 }
nickjillings@1318 1835 return root;
nickjillings@1318 1836 };
nickjillings@1318 1837
nickjillings@1318 1838 this.prepostNode = function(type) {
nickjillings@1318 1839 this.type = type;
nickjillings@1318 1840 this.options = [];
nickjillings@1318 1841
nickjillings@1318 1842 this.OptionNode = function() {
nickjillings@1318 1843
nickjillings@1318 1844 this.childOption = function() {
nickjillings@1318 1845 this.type = 'option';
nickjillings@1318 1846 this.id = null;
nickjillings@1318 1847 this.name = undefined;
nickjillings@1318 1848 this.text = null;
nickjillings@1318 1849 };
nickjillings@1318 1850
nickjillings@1318 1851 this.type = undefined;
nickjillings@1318 1852 this.id = undefined;
nickjillings@1318 1853 this.mandatory = undefined;
nickjillings@1318 1854 this.question = undefined;
nickjillings@1318 1855 this.statement = undefined;
nickjillings@1318 1856 this.boxsize = undefined;
nickjillings@1318 1857 this.options = [];
nickjillings@1318 1858 this.min = undefined;
nickjillings@1318 1859 this.max = undefined;
nickjillings@1318 1860 this.step = undefined;
nickjillings@1318 1861
nickjillings@1318 1862 this.decode = function(child)
nickjillings@1318 1863 {
nickjillings@1318 1864 this.type = child.nodeName;
nickjillings@1318 1865 if (child.nodeName == "question") {
nickjillings@1318 1866 this.id = child.id;
nickjillings@1318 1867 this.mandatory;
nickjillings@1318 1868 if (child.getAttribute('mandatory') == "true") {this.mandatory = true;}
nickjillings@1318 1869 else {this.mandatory = false;}
nickjillings@1318 1870 this.question = child.textContent;
nickjillings@1318 1871 if (child.getAttribute('boxsize') == null) {
nickjillings@1318 1872 this.boxsize = 'normal';
nickjillings@1318 1873 } else {
nickjillings@1318 1874 this.boxsize = child.getAttribute('boxsize');
nickjillings@1318 1875 }
nickjillings@1318 1876 } else if (child.nodeName == "statement") {
nickjillings@1318 1877 this.statement = child.textContent;
nickjillings@1318 1878 } else if (child.nodeName == "checkbox" || child.nodeName == "radio") {
nickjillings@1318 1879 var element = child.firstElementChild;
nickjillings@1318 1880 this.id = child.id;
nickjillings@1318 1881 if (element == null) {
nickjillings@1318 1882 console.log('Malformed' +child.nodeName+ 'entry');
nickjillings@1318 1883 this.statement = 'Malformed' +child.nodeName+ 'entry';
nickjillings@1318 1884 this.type = 'statement';
nickjillings@1318 1885 } else {
nickjillings@1318 1886 this.options = [];
nickjillings@1318 1887 while (element != null) {
nickjillings@1318 1888 if (element.nodeName == 'statement' && this.statement == undefined){
nickjillings@1318 1889 this.statement = element.textContent;
nickjillings@1318 1890 } else if (element.nodeName == 'option') {
nickjillings@1318 1891 var node = new this.childOption();
nickjillings@1318 1892 node.id = element.id;
nickjillings@1318 1893 node.name = element.getAttribute('name');
nickjillings@1318 1894 node.text = element.textContent;
nickjillings@1318 1895 this.options.push(node);
nickjillings@1318 1896 }
nickjillings@1318 1897 element = element.nextElementSibling;
nickjillings@1318 1898 }
nickjillings@1318 1899 }
nickjillings@1318 1900 } else if (child.nodeName == "number") {
nickjillings@1318 1901 this.statement = child.textContent;
nickjillings@1318 1902 this.id = child.id;
nickjillings@1318 1903 this.min = child.getAttribute('min');
nickjillings@1318 1904 this.max = child.getAttribute('max');
nickjillings@1318 1905 this.step = child.getAttribute('step');
nickjillings@1318 1906 }
nickjillings@1318 1907 };
nickjillings@1318 1908
nickjillings@1318 1909 this.exportXML = function(root)
nickjillings@1318 1910 {
nickjillings@1318 1911 var node = root.createElement(this.type);
nickjillings@1318 1912 switch(this.type)
nickjillings@1318 1913 {
nickjillings@1318 1914 case "statement":
nickjillings@1318 1915 node.textContent = this.statement;
nickjillings@1318 1916 break;
nickjillings@1318 1917 case "question":
nickjillings@1318 1918 node.id = this.id;
nickjillings@1318 1919 node.setAttribute("mandatory",this.mandatory);
nickjillings@1318 1920 node.setAttribute("boxsize",this.boxsize);
nickjillings@1318 1921 node.textContent = this.question;
nickjillings@1318 1922 break;
nickjillings@1318 1923 case "number":
nickjillings@1318 1924 node.id = this.id;
nickjillings@1318 1925 node.setAttribute("mandatory",this.mandatory);
nickjillings@1318 1926 node.setAttribute("min", this.min);
nickjillings@1318 1927 node.setAttribute("max", this.max);
nickjillings@1318 1928 node.setAttribute("step", this.step);
nickjillings@1318 1929 node.textContent = this.statement;
nickjillings@1318 1930 break;
nickjillings@1318 1931 case "checkbox":
nickjillings@1318 1932 node.id = this.id;
nickjillings@1318 1933 var statement = root.createElement("statement");
nickjillings@1318 1934 statement.textContent = this.statement;
nickjillings@1318 1935 node.appendChild(statement);
nickjillings@1318 1936 for (var i=0; i<this.options.length; i++)
nickjillings@1318 1937 {
nickjillings@1318 1938 var option = this.options[i];
nickjillings@1318 1939 var optionNode = root.createElement("option");
nickjillings@1318 1940 optionNode.id = option.id;
nickjillings@1318 1941 optionNode.textContent = option.text;
nickjillings@1318 1942 node.appendChild(optionNode);
nickjillings@1318 1943 }
nickjillings@1318 1944 break;
nickjillings@1318 1945 case "radio":
nickjillings@1318 1946 node.id = this.id;
nickjillings@1318 1947 var statement = root.createElement("statement");
nickjillings@1318 1948 statement.textContent = this.statement;
nickjillings@1318 1949 node.appendChild(statement);
nickjillings@1318 1950 for (var i=0; i<this.options.length; i++)
nickjillings@1318 1951 {
nickjillings@1318 1952 var option = this.options[i];
nickjillings@1318 1953 var optionNode = root.createElement("option");
nickjillings@1318 1954 optionNode.setAttribute("name",option.name);
nickjillings@1318 1955 optionNode.textContent = option.text;
nickjillings@1318 1956 node.appendChild(optionNode);
nickjillings@1318 1957 }
nickjillings@1318 1958 break;
nickjillings@1318 1959 }
nickjillings@1318 1960 return node;
nickjillings@1318 1961 };
nickjillings@1318 1962 };
nickjillings@1318 1963 this.construct = function(Collection)
nickjillings@1318 1964 {
nickjillings@1318 1965 if (Collection.childElementCount != 0) {
nickjillings@1318 1966 var child = Collection.firstElementChild;
nickjillings@1318 1967 var node = new this.OptionNode();
nickjillings@1318 1968 node.decode(child);
nickjillings@1318 1969 this.options.push(node);
nickjillings@1318 1970 while (child.nextElementSibling != null) {
nickjillings@1318 1971 child = child.nextElementSibling;
nickjillings@1318 1972 node = new this.OptionNode();
nickjillings@1318 1973 node.decode(child);
nickjillings@1318 1974 this.options.push(node);
nickjillings@1318 1975 }
nickjillings@1318 1976 }
nickjillings@1318 1977 };
nickjillings@1318 1978 };
nickjillings@1318 1979 this.preTest = new this.prepostNode("pretest");
nickjillings@1318 1980 this.postTest = new this.prepostNode("posttest");
nickjillings@1318 1981
nickjillings@1318 1982 this.metricNode = function(name) {
nickjillings@1318 1983 this.enabled = name;
nickjillings@1318 1984 };
nickjillings@1318 1985
nickjillings@1318 1986 this.audioHolderNode = function(parent) {
nickjillings@1318 1987 this.type = 'audioHolder';
nickjillings@1318 1988 this.presentedId = undefined;
nickjillings@1318 1989 this.id = undefined;
nickjillings@1318 1990 this.hostURL = undefined;
nickjillings@1318 1991 this.sampleRate = undefined;
nickjillings@1318 1992 this.randomiseOrder = undefined;
nickjillings@1318 1993 this.loop = undefined;
nickjillings@1318 1994 this.elementComments = undefined;
nickjillings@1318 1995 this.outsideReference = null;
nickjillings@1318 1996 this.preTest = new parent.prepostNode("pretest");
nickjillings@1318 1997 this.postTest = new parent.prepostNode("pretest");
nickjillings@1318 1998 this.interfaces = [];
nickjillings@1318 1999 this.commentBoxPrefix = "Comment on track";
nickjillings@1318 2000 this.audioElements = [];
nickjillings@1318 2001 this.commentQuestions = [];
nickjillings@1318 2002
nickjillings@1318 2003 this.decode = function(parent,xml)
nickjillings@1318 2004 {
nickjillings@1318 2005 this.presentedId = parent.audioHolders.length;
nickjillings@1318 2006 this.id = xml.id;
nickjillings@1318 2007 this.hostURL = xml.getAttribute('hostURL');
nickjillings@1318 2008 this.sampleRate = xml.getAttribute('sampleRate');
nickjillings@1318 2009 if (xml.getAttribute('randomiseOrder') == "true") {this.randomiseOrder = true;}
nickjillings@1318 2010 else {this.randomiseOrder = false;}
nickjillings@1318 2011 this.repeatCount = xml.getAttribute('repeatCount');
nickjillings@1318 2012 if (xml.getAttribute('loop') == 'true') {this.loop = true;}
nickjillings@1318 2013 else {this.loop == false;}
nickjillings@1318 2014 if (xml.getAttribute('elementComments') == "true") {this.elementComments = true;}
nickjillings@1318 2015 else {this.elementComments = false;}
nickjillings@1318 2016
nickjillings@1318 2017 var setupPreTestNode = xml.getElementsByTagName('PreTest');
nickjillings@1318 2018 if (setupPreTestNode.length != 0)
nickjillings@1318 2019 {
nickjillings@1318 2020 setupPreTestNode = setupPreTestNode[0];
nickjillings@1318 2021 this.preTest.construct(setupPreTestNode);
nickjillings@1318 2022 }
nickjillings@1318 2023
nickjillings@1318 2024 var setupPostTestNode = xml.getElementsByTagName('PostTest');
nickjillings@1318 2025 if (setupPostTestNode.length != 0)
nickjillings@1318 2026 {
nickjillings@1318 2027 setupPostTestNode = setupPostTestNode[0];
nickjillings@1318 2028 this.postTest.construct(setupPostTestNode);
nickjillings@1318 2029 }
nickjillings@1318 2030
nickjillings@1318 2031 var interfaceDOM = xml.getElementsByTagName('interface');
nickjillings@1318 2032 for (var i=0; i<interfaceDOM.length; i++) {
nickjillings@1318 2033 var node = new this.interfaceNode();
nickjillings@1318 2034 node.decode(interfaceDOM[i]);
nickjillings@1318 2035 this.interfaces.push(node);
nickjillings@1318 2036 }
nickjillings@1318 2037 this.commentBoxPrefix = xml.getElementsByTagName('commentBoxPrefix');
nickjillings@1318 2038 if (this.commentBoxPrefix.length != 0) {
nickjillings@1318 2039 this.commentBoxPrefix = this.commentBoxPrefix[0].textContent;
nickjillings@1318 2040 } else {
nickjillings@1318 2041 this.commentBoxPrefix = "Comment on track";
nickjillings@1318 2042 }
nickjillings@1318 2043 var audioElementsDOM = xml.getElementsByTagName('audioElements');
nickjillings@1318 2044 for (var i=0; i<audioElementsDOM.length; i++) {
nickjillings@1318 2045 var node = new this.audioElementNode();
nickjillings@1318 2046 node.decode(this,audioElementsDOM[i]);
nickjillings@1318 2047 if (audioElementsDOM[i].getAttribute('type') == 'outsidereference') {
nickjillings@1318 2048 if (this.outsideReference == null) {
nickjillings@1318 2049 this.outsideReference = node;
nickjillings@1318 2050 } else {
nickjillings@1318 2051 console.log('Error only one audioelement can be of type outsidereference per audioholder');
nickjillings@1318 2052 this.audioElements.push(node);
nickjillings@1318 2053 console.log('Element id '+audioElementsDOM[i].id+' made into normal node');
nickjillings@1318 2054 }
nickjillings@1318 2055 } else {
nickjillings@1318 2056 this.audioElements.push(node);
nickjillings@1318 2057 }
nickjillings@1318 2058 }
nickjillings@1318 2059
nickjillings@1318 2060 if (this.randomiseOrder == true && typeof randomiseOrder === "function")
nickjillings@1318 2061 {
nickjillings@1318 2062 this.audioElements = randomiseOrder(this.audioElements);
nickjillings@1318 2063 }
nickjillings@1318 2064
nickjillings@1318 2065 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion');
nickjillings@1318 2066 for (var i=0; i<commentQuestionsDOM.length; i++) {
nickjillings@1318 2067 var node = new this.commentQuestionNode();
nickjillings@1318 2068 node.decode(commentQuestionsDOM[i]);
nickjillings@1318 2069 this.commentQuestions.push(node);
nickjillings@1318 2070 }
nickjillings@1318 2071 };
nickjillings@1318 2072
nickjillings@1318 2073 this.encode = function(root)
nickjillings@1318 2074 {
nickjillings@1318 2075 var AHNode = root.createElement("audioHolder");
nickjillings@1318 2076 AHNode.id = this.id;
nickjillings@1318 2077 AHNode.setAttribute("hostURL",this.hostURL);
nickjillings@1318 2078 AHNode.setAttribute("sampleRate",this.sampleRate);
nickjillings@1318 2079 AHNode.setAttribute("randomiseOrder",this.randomiseOrder);
nickjillings@1318 2080 AHNode.setAttribute("repeatCount",this.repeatCount);
nickjillings@1318 2081 AHNode.setAttribute("loop",this.loop);
nickjillings@1318 2082 AHNode.setAttribute("elementComments",this.elementComments);
nickjillings@1318 2083
nickjillings@1318 2084 for (var i=0; i<this.interfaces.length; i++)
nickjillings@1318 2085 {
nickjillings@1318 2086 AHNode.appendChild(this.interfaces[i].encode(root));
nickjillings@1318 2087 }
nickjillings@1318 2088
nickjillings@1318 2089 for (var i=0; i<this.audioElements.length; i++) {
nickjillings@1318 2090 AHNode.appendChild(this.audioElements[i].encode(root));
nickjillings@1318 2091 }
nickjillings@1318 2092 // Create <CommentQuestion>
nickjillings@1318 2093 for (var i=0; i<this.commentQuestions.length; i++)
nickjillings@1318 2094 {
nickjillings@1318 2095 AHNode.appendChild(this.commentQuestions[i].exportXML(root));
nickjillings@1318 2096 }
nickjillings@1318 2097
nickjillings@1318 2098 // Create <PreTest>
nickjillings@1318 2099 var AHPreTest = root.createElement("PreTest");
nickjillings@1318 2100 for (var i=0; i<this.preTest.options.length; i++)
nickjillings@1318 2101 {
nickjillings@1318 2102 AHPreTest.appendChild(this.preTest.options[i].exportXML(root));
nickjillings@1318 2103 }
nickjillings@1318 2104
nickjillings@1318 2105 var AHPostTest = root.createElement("PostTest");
nickjillings@1318 2106 for (var i=0; i<this.postTest.options.length; i++)
nickjillings@1318 2107 {
nickjillings@1318 2108 AHPostTest.appendChild(this.postTest.options[i].exportXML(root));
nickjillings@1318 2109 }
nickjillings@1318 2110 AHNode.appendChild(AHPreTest);
nickjillings@1318 2111 AHNode.appendChild(AHPostTest);
nickjillings@1318 2112 return AHNode;
nickjillings@1318 2113 };
nickjillings@1318 2114
nickjillings@1318 2115 this.interfaceNode = function() {
nickjillings@1318 2116 this.title = undefined;
nickjillings@1318 2117 this.options = [];
nickjillings@1318 2118 this.scale = [];
nickjillings@1318 2119 this.name = undefined;
nickjillings@1318 2120 this.decode = function(DOM)
nickjillings@1318 2121 {
nickjillings@1318 2122 var title = DOM.getElementsByTagName('title');
nickjillings@1318 2123 if (title.length == 0) {this.title = null;}
nickjillings@1318 2124 else {this.title = title[0].textContent;}
nickjillings@1318 2125 var name = DOM.getAttribute("name");
nickjillings@1318 2126 if (name != undefined) {this.name = name;}
nickjillings@1318 2127 this.options = parent.commonInterface.options;
nickjillings@1318 2128 var scale = DOM.getElementsByTagName('scale');
nickjillings@1318 2129 this.scale = [];
nickjillings@1318 2130 for (var i=0; i<scale.length; i++) {
nickjillings@1318 2131 var arr = [null, null];
nickjillings@1318 2132 arr[0] = scale[i].getAttribute('position');
nickjillings@1318 2133 arr[1] = scale[i].textContent;
nickjillings@1318 2134 this.scale.push(arr);
nickjillings@1318 2135 }
nickjillings@1318 2136 };
nickjillings@1318 2137 this.encode = function(root)
nickjillings@1318 2138 {
nickjillings@1318 2139 var node = root.createElement("interface");
nickjillings@1318 2140 if (this.title != undefined)
nickjillings@1318 2141 {
nickjillings@1318 2142 var title = root.createElement("title");
nickjillings@1318 2143 title.textContent = this.title;
nickjillings@1318 2144 node.appendChild(title);
nickjillings@1318 2145 }
nickjillings@1318 2146 for (var i=0; i<this.options.length; i++)
nickjillings@1318 2147 {
nickjillings@1318 2148 var optionNode = root.createElement(this.options[i].type);
nickjillings@1318 2149 if (this.options[i].type == "option")
nickjillings@1318 2150 {
nickjillings@1318 2151 optionNode.setAttribute("name",this.options[i].name);
nickjillings@1318 2152 } else if (this.options[i].type == "check") {
nickjillings@1318 2153 optionNode.setAttribute("check",this.options[i].check);
nickjillings@1318 2154 } else if (this.options[i].type == "scalerange") {
nickjillings@1318 2155 optionNode.setAttribute("min",this.options[i].min*100);
nickjillings@1318 2156 optionNode.setAttribute("max",this.options[i].max*100);
nickjillings@1318 2157 }
nickjillings@1318 2158 node.appendChild(optionNode);
nickjillings@1318 2159 }
nickjillings@1318 2160 for (var i=0; i<this.scale.length; i++) {
nickjillings@1318 2161 var scale = root.createElement("scale");
nickjillings@1318 2162 scale.setAttribute("position",this.scale[i][0]);
nickjillings@1318 2163 scale.textContent = this.scale[i][1];
nickjillings@1318 2164 node.appendChild(scale);
nickjillings@1318 2165 }
nickjillings@1318 2166 return node;
nickjillings@1318 2167 };
nickjillings@1318 2168 };
nickjillings@1318 2169
nickjillings@1318 2170 this.audioElementNode = function() {
nickjillings@1318 2171 this.url = null;
nickjillings@1318 2172 this.id = null;
nickjillings@1318 2173 this.parent = null;
nickjillings@1318 2174 this.type = "normal";
nickjillings@1318 2175 this.marker = false;
nickjillings@1318 2176 this.enforce = false;
nickjillings@1318 2177 this.gain = 1.0;
nickjillings@1318 2178 this.decode = function(parent,xml)
nickjillings@1318 2179 {
nickjillings@1318 2180 this.url = xml.getAttribute('url');
nickjillings@1318 2181 this.id = xml.id;
nickjillings@1318 2182 this.parent = parent;
nickjillings@1318 2183 this.type = xml.getAttribute('type');
nickjillings@1318 2184 var gain = xml.getAttribute('gain');
nickjillings@1318 2185 if (isNaN(gain) == false && gain != null)
nickjillings@1318 2186 {
nickjillings@1318 2187 this.gain = decibelToLinear(Number(gain));
nickjillings@1318 2188 }
nickjillings@1318 2189 if (this.type == null) {this.type = "normal";}
nickjillings@1318 2190 if (this.type == 'anchor') {this.anchor = true;}
nickjillings@1318 2191 else {this.anchor = false;}
nickjillings@1318 2192 if (this.type == 'reference') {this.reference = true;}
nickjillings@1318 2193 else {this.reference = false;}
nickjillings@1318 2194 if (this.anchor == true || this.reference == true)
nickjillings@1318 2195 {
nickjillings@1318 2196 this.marker = xml.getAttribute('marker');
nickjillings@1318 2197 if (this.marker != undefined)
nickjillings@1318 2198 {
nickjillings@1318 2199 this.marker = Number(this.marker);
nickjillings@1318 2200 if (isNaN(this.marker) == false)
nickjillings@1318 2201 {
nickjillings@1318 2202 if (this.marker > 1)
nickjillings@1318 2203 { this.marker /= 100.0;}
nickjillings@1318 2204 if (this.marker >= 0 && this.marker <= 1)
nickjillings@1318 2205 {
nickjillings@1318 2206 this.enforce = true;
nickjillings@1318 2207 return;
nickjillings@1318 2208 } else {
nickjillings@1318 2209 console.log("ERROR - Marker of audioElement "+this.id+" is not between 0 and 1 (float) or 0 and 100 (integer)!");
nickjillings@1318 2210 console.log("ERROR - Marker not enforced!");
nickjillings@1318 2211 }
nickjillings@1318 2212 } else {
nickjillings@1318 2213 console.log("ERROR - Marker of audioElement "+this.id+" is not a number!");
nickjillings@1318 2214 console.log("ERROR - Marker not enforced!");
nickjillings@1318 2215 }
nickjillings@1318 2216 }
nickjillings@1318 2217 }
nickjillings@1318 2218 };
nickjillings@1318 2219 this.encode = function(root)
nickjillings@1318 2220 {
nickjillings@1318 2221 var AENode = root.createElement("audioElements");
nickjillings@1318 2222 AENode.id = this.id;
nickjillings@1318 2223 AENode.setAttribute("url",this.url);
nickjillings@1318 2224 AENode.setAttribute("type",this.type);
nickjillings@1318 2225 AENode.setAttribute("gain",linearToDecibel(this.gain));
nickjillings@1318 2226 if (this.marker != false)
nickjillings@1318 2227 {
nickjillings@1318 2228 AENode.setAttribute("marker",this.marker*100);
nickjillings@1318 2229 }
nickjillings@1318 2230 return AENode;
nickjillings@1318 2231 };
nickjillings@1318 2232 };
nickjillings@1318 2233
nickjillings@1318 2234 this.commentQuestionNode = function(xml) {
nickjillings@1318 2235 this.id = null;
nickjillings@1318 2236 this.type = undefined;
nickjillings@1318 2237 this.question = undefined;
nickjillings@1318 2238 this.options = [];
nickjillings@1318 2239 this.statement = undefined;
nickjillings@1318 2240
nickjillings@1318 2241 this.childOption = function() {
nickjillings@1318 2242 this.type = 'option';
nickjillings@1318 2243 this.name = null;
nickjillings@1318 2244 this.text = null;
nickjillings@1318 2245 };
nickjillings@1318 2246 this.exportXML = function(root)
nickjillings@1318 2247 {
nickjillings@1318 2248 var CQNode = root.createElement("CommentQuestion");
nickjillings@1318 2249 CQNode.id = this.id;
nickjillings@1318 2250 CQNode.setAttribute("type",this.type);
nickjillings@1318 2251 switch(this.type)
nickjillings@1318 2252 {
nickjillings@1318 2253 case "text":
nickjillings@1318 2254 CQNode.textContent = this.question;
nickjillings@1318 2255 break;
nickjillings@1318 2256 case "radio":
nickjillings@1318 2257 var statement = root.createElement("statement");
nickjillings@1318 2258 statement.textContent = this.statement;
nickjillings@1318 2259 CQNode.appendChild(statement);
nickjillings@1318 2260 for (var i=0; i<this.options.length; i++)
nickjillings@1318 2261 {
nickjillings@1318 2262 var optionNode = root.createElement("option");
nickjillings@1318 2263 optionNode.setAttribute("name",this.options[i].name);
nickjillings@1318 2264 optionNode.textContent = this.options[i].text;
nickjillings@1318 2265 CQNode.appendChild(optionNode);
nickjillings@1318 2266 }
nickjillings@1318 2267 break;
nickjillings@1318 2268 case "checkbox":
nickjillings@1318 2269 var statement = root.createElement("statement");
nickjillings@1318 2270 statement.textContent = this.statement;
nickjillings@1318 2271 CQNode.appendChild(statement);
nickjillings@1318 2272 for (var i=0; i<this.options.length; i++)
nickjillings@1318 2273 {
nickjillings@1318 2274 var optionNode = root.createElement("option");
nickjillings@1318 2275 optionNode.setAttribute("name",this.options[i].name);
nickjillings@1318 2276 optionNode.textContent = this.options[i].text;
nickjillings@1318 2277 CQNode.appendChild(optionNode);
nickjillings@1318 2278 }
nickjillings@1318 2279 break;
nickjillings@1318 2280 }
nickjillings@1318 2281 return CQNode;
nickjillings@1318 2282 };
nickjillings@1318 2283 this.decode = function(xml) {
nickjillings@1318 2284 this.id = xml.id;
nickjillings@1318 2285 if (xml.getAttribute('mandatory') == 'true') {this.mandatory = true;}
nickjillings@1318 2286 else {this.mandatory = false;}
nickjillings@1318 2287 this.type = xml.getAttribute('type');
nickjillings@1318 2288 if (this.type == undefined) {this.type = 'text';}
nickjillings@1318 2289 switch (this.type) {
nickjillings@1318 2290 case 'text':
nickjillings@1318 2291 this.question = xml.textContent;
nickjillings@1318 2292 break;
nickjillings@1318 2293 case 'radio':
nickjillings@1318 2294 var child = xml.firstElementChild;
nickjillings@1318 2295 this.options = [];
nickjillings@1318 2296 while (child != undefined) {
nickjillings@1318 2297 if (child.nodeName == 'statement' && this.statement == undefined) {
nickjillings@1318 2298 this.statement = child.textContent;
nickjillings@1318 2299 } else if (child.nodeName == 'option') {
nickjillings@1318 2300 var node = new this.childOption();
nickjillings@1318 2301 node.name = child.getAttribute('name');
nickjillings@1318 2302 node.text = child.textContent;
nickjillings@1318 2303 this.options.push(node);
nickjillings@1318 2304 }
nickjillings@1318 2305 child = child.nextElementSibling;
nickjillings@1318 2306 }
nickjillings@1318 2307 break;
nickjillings@1318 2308 case 'checkbox':
nickjillings@1318 2309 var child = xml.firstElementChild;
nickjillings@1318 2310 this.options = [];
nickjillings@1318 2311 while (child != undefined) {
nickjillings@1318 2312 if (child.nodeName == 'statement' && this.statement == undefined) {
nickjillings@1318 2313 this.statement = child.textContent;
nickjillings@1318 2314 } else if (child.nodeName == 'option') {
nickjillings@1318 2315 var node = new this.childOption();
nickjillings@1318 2316 node.name = child.getAttribute('name');
nickjillings@1318 2317 node.text = child.textContent;
nickjillings@1318 2318 this.options.push(node);
nickjillings@1318 2319 }
nickjillings@1318 2320 child = child.nextElementSibling;
nickjillings@1318 2321 }
nickjillings@1318 2322 break;
nickjillings@1318 2323 }
nickjillings@1318 2324 };
nickjillings@1318 2325 };
nickjillings@1318 2326 };
nickjillings@1318 2327 }
nickjillings@1318 2328
nickjillings@1318 2329 function linearToDecibel(gain)
nickjillings@1318 2330 {
nickjillings@1318 2331 return 20.0*Math.log10(gain);
nickjillings@1318 2332 }
nickjillings@1318 2333
nickjillings@1318 2334 function decibelToLinear(gain)
nickjillings@1318 2335 {
nickjillings@1318 2336 return Math.pow(10,gain/20.0);
nickjillings@1318 2337 }
nickjillings@1318 2338
nickjillings@1318 2339 function createDeleteNodeButton(node)
nickjillings@1318 2340 {
nickjillings@1318 2341 var button = document.createElement("button");
nickjillings@1318 2342 button.textContent = "Delete";
nickjillings@1318 2343 button.onclick = function(event)
nickjillings@1318 2344 {
nickjillings@1318 2345 var node = event.target.parentElement;
nickjillings@1318 2346 node.parentElement.removeChild(node);
nickjillings@1318 2347 };
nickjillings@1318 2348 return button;
nickjillings@1318 2349 }
nickjillings@1318 2350
nickjillings@1318 2351 function SpecificationToHTML()
nickjillings@1318 2352 {
nickjillings@1318 2353 // Take information from Specification Node and format it into an HTML layout
nickjillings@1318 2354 var destination = document.getElementById("content");
nickjillings@1318 2355 // Setup Header Node
nickjillings@1318 2356 var setupNode = document.createElement("div");
nickjillings@1318 2357 setupNode.className = "topLevel";
nickjillings@1318 2358 setupNode.name = "setup";
nickjillings@1318 2359 var title = document.createElement("h2");
nickjillings@1318 2360 title.textContent = "Setup";
nickjillings@1318 2361 setupNode.appendChild(title);
nickjillings@1318 2362 // Interface Type
nickjillings@1318 2363 var div = document.createElement("div");
nickjillings@1318 2364 div.name = "attributes";
nickjillings@1318 2365 div.style.margin = "5px";
nickjillings@1318 2366 var select = document.createElement("select");
nickjillings@1318 2367 select.id = "interfaceSelect";
nickjillings@1318 2368 select.style.margin = "5px";
nickjillings@1318 2369 var option = document.createElement("option");
nickjillings@1318 2370 option.value = "APE";
nickjillings@1318 2371 option.textContent = "APE";
nickjillings@1318 2372 select.appendChild(option);
nickjillings@1318 2373 option = document.createElement("option");
nickjillings@1318 2374 option.value = "MUSHRA";
nickjillings@1318 2375 option.textContent = "MUSHRA";
nickjillings@1318 2376 select.appendChild(option);
nickjillings@1318 2377 select.value = specificationNode.interfaceType;
nickjillings@1318 2378 select.onchange = function(event)
nickjillings@1318 2379 {
nickjillings@1318 2380 specificationNode.interfaceType = event.currentTarget.value;
nickjillings@1318 2381 };
nickjillings@1318 2382 var span = document.createElement("span");
nickjillings@1318 2383 span.textContent = "Interface Type";
nickjillings@1318 2384 div.appendChild(span);
nickjillings@1318 2385 div.appendChild(select);
nickjillings@1318 2386 // Project Return Attribute
nickjillings@1318 2387 span = document.createElement("span");
nickjillings@1318 2388 span.style.margin = "5px";
nickjillings@1318 2389 span.textContent = "Project Return";
nickjillings@1318 2390 var input = document.createElement("input");
nickjillings@1318 2391 input.value = specificationNode.projectReturn;
nickjillings@1318 2392 input.id = "projectReturn";
nickjillings@1318 2393 input.style.margin = "5px";
nickjillings@1318 2394 input.onchange = function(event) {
nickjillings@1318 2395 specificationNode.projectReturn = event.currentTarget.value;
nickjillings@1318 2396 };
nickjillings@1318 2397 div.appendChild(span);
nickjillings@1318 2398 div.appendChild(input);
nickjillings@1318 2399 // Randomise Order
nickjillings@1318 2400 span = document.createElement("span");
nickjillings@1318 2401 span.textContent = "Randomise Order";
nickjillings@1318 2402 input = document.createElement("input");
nickjillings@1318 2403 input.id = "randomiseOrder";
nickjillings@1318 2404 input.style.margin = "5px";
nickjillings@1318 2405 input.type = "checkbox";
nickjillings@1318 2406 input.checked = specificationNode.randomiseOrder;
nickjillings@1318 2407 input.onchange = function(event) {
nickjillings@1318 2408 specificationNode.randomiseOrder = event.currentTarget.checked;
nickjillings@1318 2409 };
nickjillings@1318 2410 div.appendChild(span);
nickjillings@1318 2411 div.appendChild(input);
nickjillings@1318 2412 setupNode.appendChild(div);
nickjillings@1318 2413
nickjillings@1318 2414 // Now create the common Interface Node
nickjillings@1318 2415 var commonInterface = document.createElement("div");
nickjillings@1318 2416 commonInterface.id = "interface";
nickjillings@1318 2417 commonInterface.className = "SecondLevel";
nickjillings@1318 2418 var title = document.createElement("h3");
nickjillings@1318 2419 title.textContent = "Common Interface";
nickjillings@1318 2420 commonInterface.appendChild(title);
nickjillings@1318 2421 var div = document.createElement("div");
nickjillings@1318 2422 div.name = "attributes";
nickjillings@1318 2423 var interfaceOptions;
nickjillings@1318 2424 var interfaceChecks;
nickjillings@1318 2425 switch(select.value)
nickjillings@1318 2426 {
nickjillings@1318 2427 case "APE":
nickjillings@1318 2428 interfaceOptions = APEInterfaceOptions;
nickjillings@1318 2429 interfaceChecks = APEInterfaceChecks;
nickjillings@1318 2430 break;
nickjillings@1318 2431 case "MUSHRA":
nickjillings@1318 2432 interfaceOptions = MUSHRAInterfaceOptions;
nickjillings@1318 2433 interfaceChecks = MUSHRAInterfaceChecks;
nickjillings@1318 2434 break;
nickjillings@1318 2435 }
nickjillings@1318 2436 for (var i=0; i<interfaceOptions[0].length; i++)
nickjillings@1318 2437 {
nickjillings@1318 2438 var span = document.createElement("span");
nickjillings@1318 2439 span.textContent = interfaceOptions[1][i];
nickjillings@1318 2440 var input = document.createElement("input");
nickjillings@1318 2441 input.type = "checkbox";
nickjillings@1318 2442 input.id = interfaceOptions[0][i];
nickjillings@1318 2443 input.setAttribute("name", "option");
nickjillings@1318 2444 div.appendChild(input);
nickjillings@1318 2445 div.appendChild(span);
nickjillings@1318 2446 commonInterface.appendChild(div);
nickjillings@1318 2447 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1318 2448 {
nickjillings@1318 2449 if (specificationNode.commonInterface.options[j].name == interfaceOptions[0][i])
nickjillings@1318 2450 {
nickjillings@1318 2451 input.checked = true;
nickjillings@1318 2452 break;
nickjillings@1318 2453 }
nickjillings@1318 2454 }
nickjillings@1318 2455 input.onchange = function(event) {
nickjillings@1318 2456 var id = event.currentTarget.id;
nickjillings@1318 2457 if (event.currentTarget.checked) {
nickjillings@1318 2458 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(event.currentTarget));
nickjillings@1318 2459 } else {
nickjillings@1318 2460 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1318 2461 {
nickjillings@1318 2462 if (specificationNode.commonInterface.options[j].name == event.currentTarget.id)
nickjillings@1318 2463 {
nickjillings@1318 2464 specificationNode.commonInterface.options.splice(j,1);
nickjillings@1318 2465 break;
nickjillings@1318 2466 }
nickjillings@1318 2467 }
nickjillings@1318 2468 }
nickjillings@1318 2469 };
nickjillings@1318 2470 }
nickjillings@1318 2471 for (var i=0; i<interfaceChecks[0].length; i++)
nickjillings@1318 2472 {
nickjillings@1318 2473 var span = document.createElement("span");
nickjillings@1318 2474 span.textContent = interfaceChecks[1][i];
nickjillings@1318 2475 var input = document.createElement("input");
nickjillings@1318 2476 input.type = "checkbox";
nickjillings@1318 2477 input.id = interfaceChecks[0][i];
nickjillings@1318 2478 input.setAttribute("name", "check");
nickjillings@1318 2479 div.appendChild(input);
nickjillings@1318 2480 div.appendChild(span);
nickjillings@1318 2481 commonInterface.appendChild(div);
nickjillings@1318 2482 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1318 2483 {
nickjillings@1318 2484 if (specificationNode.commonInterface.options[j].check == interfaceChecks[0][i])
nickjillings@1318 2485 {
nickjillings@1318 2486 input.checked = true;
nickjillings@1318 2487 break;
nickjillings@1318 2488 }
nickjillings@1318 2489 }
nickjillings@1318 2490 input.onchange = function(event) {
nickjillings@1318 2491 var id = event.currentTarget.id;
nickjillings@1318 2492 if (event.currentTarget.checked) {
nickjillings@1318 2493 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(event.currentTarget));
nickjillings@1318 2494 } else {
nickjillings@1318 2495 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1318 2496 {
nickjillings@1318 2497 if (specificationNode.commonInterface.options[j].name == event.currentTarget.id)
nickjillings@1318 2498 {
nickjillings@1318 2499 specificationNode.commonInterface.options.splice(j,1);
nickjillings@1318 2500 break;
nickjillings@1318 2501 }
nickjillings@1318 2502 }
nickjillings@1318 2503 }
nickjillings@1318 2504 };
nickjillings@1318 2505 }
nickjillings@1318 2506 setupNode.appendChild(commonInterface);
nickjillings@1318 2507 // Now the Metric Node
nickjillings@1318 2508 var metrics = document.createElement("div");
nickjillings@1318 2509 metrics.id = "metrics";
nickjillings@1318 2510 metrics.className = "SecondLevel";
nickjillings@1318 2511 var title = document.createElement("h3");
nickjillings@1318 2512 title.textContent = "Metric Collections";
nickjillings@1318 2513 metrics.appendChild(title);
nickjillings@1318 2514 var div = document.createElement("div");
nickjillings@1318 2515 div.name = "attributes";
nickjillings@1318 2516 metrics.appendChild(div);
nickjillings@1318 2517 var supportedMetrics;
nickjillings@1318 2518 switch(select.value)
nickjillings@1318 2519 {
nickjillings@1318 2520 case "APE":
nickjillings@1318 2521 supportedMetrics = APEInterfaceMetrics;
nickjillings@1318 2522 break;
nickjillings@1318 2523 case "MUSHRA":
nickjillings@1318 2524 supportedMetrics = MUSHRAInterfaceMetrics;
nickjillings@1318 2525 break;
nickjillings@1318 2526 }
nickjillings@1318 2527
nickjillings@1318 2528 for (var i=0; i<supportedMetrics[0].length; i++)
nickjillings@1318 2529 {
nickjillings@1318 2530 var span = document.createElement("span");
nickjillings@1318 2531 span.textContent = supportedMetrics[1][i];
nickjillings@1318 2532 var input = document.createElement("input");
nickjillings@1318 2533 input.type = "checkbox";
nickjillings@1318 2534 input.id = supportedMetrics[0][i];
nickjillings@1318 2535 div.appendChild(input);
nickjillings@1318 2536 div.appendChild(span);
nickjillings@1318 2537 for (var j=0; j<specificationNode.metrics.length; j++)
nickjillings@1318 2538 {
nickjillings@1318 2539 if (specificationNode.metrics[j].enabled == supportedMetrics[0][i])
nickjillings@1318 2540 {
nickjillings@1318 2541 input.checked = true;
nickjillings@1318 2542 }
nickjillings@1318 2543 }
nickjillings@1318 2544 input.onchange = function(event)
nickjillings@1318 2545 {
nickjillings@1318 2546 if (event.currentTarget.checked) {
nickjillings@1318 2547 specificationNode.metrics.push(new specificationNode.metricNode(event.currentTarget.id));
nickjillings@1318 2548 } else {
nickjillings@1318 2549 for (var j=0; j<specificationNode.metrics.length; j++)
nickjillings@1318 2550 {
nickjillings@1318 2551 if (specificationNode.metrics[j].enabled == event.currentTarget.id)
nickjillings@1318 2552 {
nickjillings@1318 2553 specificationNode.metrics.splice(j,1);
nickjillings@1318 2554 break;
nickjillings@1318 2555 }
nickjillings@1318 2556 }
nickjillings@1318 2557 }
nickjillings@1318 2558 };
nickjillings@1318 2559 }
nickjillings@1318 2560
nickjillings@1318 2561 setupNode.appendChild(metrics);
nickjillings@1318 2562
nickjillings@1318 2563 // Test Session Pre Test
nickjillings@1318 2564 var preTest = document.createElement("div");
nickjillings@1318 2565 preTest.id = "preTest";
nickjillings@1318 2566 preTest.className = "SecondLevel";
nickjillings@1318 2567 var title = document.createElement("h3");
nickjillings@1318 2568 title.textContent = "Pre test Survey";
nickjillings@1318 2569 preTest.appendChild(title);
nickjillings@1318 2570 var div = document.createElement("div");
nickjillings@1318 2571 div.name = "attributes";
nickjillings@1318 2572 for (var j=0; j<specificationNode.preTest.options.length; j++)
nickjillings@1318 2573 {
nickjillings@1318 2574 var node = PPSurveyToHTML(specificationNode.preTest.options[j]);
nickjillings@1318 2575 node.className = "SecondLevel";
nickjillings@1318 2576 node.id = preTest.id+"-"+j;
nickjillings@1318 2577 var del_button = document.createElement("button");
nickjillings@1318 2578 del_button.textContent = "Delete";
nickjillings@1318 2579 del_button.onclick = function(event) {
nickjillings@1318 2580 var node = event.currentTarget.parentElement;
nickjillings@1318 2581 var id = node.id.split("-")[1];
nickjillings@1318 2582 specificationNode.preTest.options.splice(id,1);
nickjillings@1318 2583 node.parentElement.removeChild(node);
nickjillings@1318 2584 };
nickjillings@1318 2585 node.appendChild(del_button);
nickjillings@1318 2586 preTest.appendChild(node);
nickjillings@1318 2587 }
nickjillings@1318 2588 setupNode.appendChild(preTest);
nickjillings@1318 2589
nickjillings@1318 2590 // Test Session Post Test
nickjillings@1318 2591 var postTest = document.createElement("div");
nickjillings@1318 2592 postTest.id = "postTest";
nickjillings@1318 2593 postTest.className = "SecondLevel";
nickjillings@1318 2594 var title = document.createElement("h3");
nickjillings@1318 2595 title.textContent = "Post test Survey";
nickjillings@1318 2596 postTest.appendChild(title);
nickjillings@1318 2597 var div = document.createElement("div");
nickjillings@1318 2598 div.name = "attributes";
nickjillings@1318 2599
nickjillings@1318 2600 for (var j=0; j<specificationNode.postTest.options.length; j++)
nickjillings@1318 2601 {
nickjillings@1318 2602 var node = PPSurveyToHTML(specificationNode.postTest.options[j]);
nickjillings@1318 2603 node.className = "SecondLevel";
nickjillings@1318 2604 node.id = postTest.id+"-"+j;
nickjillings@1318 2605 var del_button = document.createElement("button");
nickjillings@1318 2606 del_button.textContent = "Delete";
nickjillings@1318 2607 del_button.onclick = function(event) {
nickjillings@1318 2608 var node = event.currentTarget.parentElement;
nickjillings@1318 2609 var id = node.id.split("-")[1];
nickjillings@1318 2610 specificationNode.postTest.options.splice(id,1);
nickjillings@1318 2611 node.parentElement.removeChild(node);
nickjillings@1318 2612 };
nickjillings@1318 2613 node.appendChild(del_button);
nickjillings@1318 2614 postTest.appendChild(node);
nickjillings@1318 2615 }
nickjillings@1318 2616
nickjillings@1318 2617 setupNode.appendChild(postTest);
nickjillings@1318 2618
nickjillings@1318 2619 destination.appendChild(setupNode);
nickjillings@1318 2620
nickjillings@1318 2621 // Now we step through the AudioHolders
nickjillings@1318 2622 for (var i=0; i<specificationNode.audioHolders.length; i++)
nickjillings@1318 2623 {
nickjillings@1318 2624 var aH = specificationNode.audioHolders[i];
nickjillings@1318 2625 var aHTML = document.createElement("div");
nickjillings@1318 2626 aHTML.name = "audioHolder";
nickjillings@1318 2627 aHTML.id = "audioHolder-"+i;
nickjillings@1318 2628 aHTML.className = "topLevel";
nickjillings@1318 2629 aHTML.appendChild(createDeleteNodeButton());
nickjillings@1318 2630 destination.appendChild(aHTML);
nickjillings@1318 2631 var title = document.createElement("h2");
nickjillings@1318 2632 title.textContent = "Audio Holder "+aH.id;
nickjillings@1318 2633 aHTML.appendChild(title);
nickjillings@1318 2634 var attributes = document.createElement("div");
nickjillings@1318 2635 attributes.name = "attributes";
nickjillings@1318 2636 aHTML.appendChild(attributes);
nickjillings@1318 2637 var text = document.createElement("span");
nickjillings@1318 2638 text.textContent = "ID: ";
nickjillings@1318 2639 var input = document.createElement("input");
nickjillings@1318 2640 input.id = aHTML.id+"-id";
nickjillings@1318 2641 input.value = aH.id;
nickjillings@1318 2642 input.onchange = function()
nickjillings@1318 2643 {
nickjillings@1318 2644 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1318 2645 var aholderID = IDSplit[0]+"-"+IDSplit[1];
nickjillings@1318 2646 var aholder = document.getElementById(aholderID);
nickjillings@1318 2647 title = aholder.getElementsByTagName("h2")[0];
nickjillings@1318 2648 title.textContent = "Audio Holder "+event.currentTarget.value;
nickjillings@1318 2649 specificationNode.audioHolders[IDSplit[1]].id = event.currentTarget.value;
nickjillings@1318 2650 };
nickjillings@1318 2651 text.style.margin = "5px";
nickjillings@1318 2652 input.style.margin = "5px";
nickjillings@1318 2653 attributes.appendChild(text);
nickjillings@1318 2654 attributes.appendChild(input);
nickjillings@1318 2655 text = document.createElement("span");
nickjillings@1318 2656 text.textContent = "Host URL: ";
nickjillings@1318 2657 input = document.createElement("input");
nickjillings@1318 2658 input.id = aHTML.id+"-hostURL";
nickjillings@1318 2659 input.value = aH.hostURL;
nickjillings@1318 2660 input.onchange = function()
nickjillings@1318 2661 {
nickjillings@1318 2662 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1318 2663 specificationNode.audioHolders[IDSplit[1]].hostURL = event.currentTarget.value;
nickjillings@1318 2664 };
nickjillings@1318 2665 text.style.margin = "5px";
nickjillings@1318 2666 input.style.margin = "5px";
nickjillings@1318 2667 attributes.appendChild(text);
nickjillings@1318 2668 attributes.appendChild(input);
nickjillings@1318 2669 text = document.createElement("span");
nickjillings@1318 2670 text.textContent = "Loop Fragments: ";
nickjillings@1318 2671 input = document.createElement("input");
nickjillings@1318 2672 input.id = aHTML.id+"-loop";
nickjillings@1318 2673 input.type = "checkbox";
nickjillings@1318 2674 input.checked = aH.loop;
nickjillings@1318 2675 input.onchange = function()
nickjillings@1318 2676 {
nickjillings@1318 2677 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1318 2678 specificationNode.audioHolders[IDSplit[1]].loop = event.currentTarget.checked;
nickjillings@1318 2679 };
nickjillings@1318 2680 text.style.margin = "5px";
nickjillings@1318 2681 input.style.margin = "5px";
nickjillings@1318 2682 attributes.appendChild(text);
nickjillings@1318 2683 attributes.appendChild(input);
nickjillings@1318 2684 text = document.createElement("span");
nickjillings@1318 2685 text.textContent = "Randomise Order: ";
nickjillings@1318 2686 input = document.createElement("input");
nickjillings@1318 2687 input.id = aHTML.id+"-randomiseOrder";
nickjillings@1318 2688 input.type = "checkbox";
nickjillings@1318 2689 input.checked = aH.randomiseOrder;
nickjillings@1318 2690 input.onchange = function()
nickjillings@1318 2691 {
nickjillings@1318 2692 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1318 2693 specificationNode.audioHolders[IDSplit[1]].randomiseOrder = event.currentTarget.checked;
nickjillings@1318 2694 };
nickjillings@1318 2695 text.style.margin = "5px";
nickjillings@1318 2696 input.style.margin = "5px";
nickjillings@1318 2697 attributes.appendChild(text);
nickjillings@1318 2698 attributes.appendChild(input);
nickjillings@1318 2699 text = document.createElement("span");
nickjillings@1318 2700 text.textContent = "Show Fragment Comments";
nickjillings@1318 2701 input = document.createElement("input");
nickjillings@1318 2702 input.id = aHTML.id+"-elementComments";
nickjillings@1318 2703 input.type = "checkbox";
nickjillings@1318 2704 input.checked = aH.elementComments;
nickjillings@1318 2705 input.onchange = function()
nickjillings@1318 2706 {
nickjillings@1318 2707 var IDSplit = event.currentTarget.id.split('-');
nickjillings@1318 2708 specificationNode.audioHolders[IDSplit[1]].elementComments = event.currentTarget.checked;
nickjillings@1318 2709 };
nickjillings@1318 2710 text.style.margin = "5px";
nickjillings@1318 2711 input.style.margin = "5px";
nickjillings@1318 2712 attributes.appendChild(text);
nickjillings@1318 2713 attributes.appendChild(input);
nickjillings@1318 2714
nickjillings@1318 2715 // Test Session Pre Test
nickjillings@1318 2716 var preTest = document.createElement("div");
nickjillings@1318 2717 preTest.id = aHTML.id+"-pretest";
nickjillings@1318 2718 preTest.className = "SecondLevel";
nickjillings@1318 2719 var title = document.createElement("h3");
nickjillings@1318 2720 title.textContent = "Pre test Survey";
nickjillings@1318 2721 preTest.appendChild(title);
nickjillings@1318 2722 var div = document.createElement("div");
nickjillings@1318 2723 div.name = "attributes";
nickjillings@1318 2724
nickjillings@1318 2725 for (var j=0; j<aH.preTest.options.length; j++)
nickjillings@1318 2726 {
nickjillings@1318 2727 var node = PPSurveyToHTML(aH.preTest.options[j]);
nickjillings@1318 2728 node.className = "SecondLevel";
nickjillings@1318 2729 node.id = preTest.id+"-"+j;
nickjillings@1318 2730 var button_delete = document.createElement("button");
nickjillings@1318 2731 button_delete.textContent = "Delete";
nickjillings@1318 2732 button_delete.onclick = function(event)
nickjillings@1318 2733 {
nickjillings@1318 2734 var node = event.currentTarget.parentElement;
nickjillings@1318 2735 var IDSplit = node.id.split("-");
nickjillings@1318 2736 var preTest = specificationNode.audioHolders[IDSplit[1]].preTest;
nickjillings@1318 2737 preTest.options.splice(IDSplit[3],1);
nickjillings@1318 2738 node.parentElement.removeChild(node);
nickjillings@1318 2739 };
nickjillings@1318 2740 node.appendChild(button_delete);
nickjillings@1318 2741 preTest.appendChild(node);
nickjillings@1318 2742 }
nickjillings@1318 2743
nickjillings@1318 2744 aHTML.appendChild(preTest);
nickjillings@1318 2745
nickjillings@1318 2746 // Test Session Post Test
nickjillings@1318 2747 var postTest = document.createElement("div");
nickjillings@1318 2748 postTest.id = aHTML.id+"-postTest";
nickjillings@1318 2749 postTest.className = "SecondLevel";
nickjillings@1318 2750 var title = document.createElement("h3");
nickjillings@1318 2751 title.textContent = "Post test Survey";
nickjillings@1318 2752 postTest.appendChild(title);
nickjillings@1318 2753 var div = document.createElement("div");
nickjillings@1318 2754 div.name = "attributes";
nickjillings@1318 2755
nickjillings@1318 2756 for (var j=0; j<aH.postTest.options.length; j++)
nickjillings@1318 2757 {
nickjillings@1318 2758 var node = PPSurveyToHTML(aH.postTest.options[j]);
nickjillings@1318 2759 node.className = "SecondLevel";
nickjillings@1318 2760 node.id = postTest.id+"-"+j;
nickjillings@1318 2761 var button_delete = document.createElement("button");
nickjillings@1318 2762 button_delete.textContent = "Delete";
nickjillings@1318 2763 button_delete.onclick = function(event)
nickjillings@1318 2764 {
nickjillings@1318 2765 var node = event.currentTarget.parentElement;
nickjillings@1318 2766 var IDSplit = node.id.split("-");
nickjillings@1318 2767 var postTest = specificationNode.audioHolders[IDSplit[1]].postTest;
nickjillings@1318 2768 postTest.options.splice(IDSplit[3],1);
nickjillings@1318 2769 node.parentElement.removeChild(node);
nickjillings@1318 2770 };
nickjillings@1318 2771 node.appendChild(button_delete);
nickjillings@1318 2772 postTest.appendChild(node);
nickjillings@1318 2773 }
nickjillings@1318 2774
nickjillings@1318 2775 aHTML.appendChild(postTest);
nickjillings@1318 2776
nickjillings@1318 2777 //Audio Elements
nickjillings@1318 2778 var audioElems = document.createElement("div");
nickjillings@1318 2779 audioElems.id = aHTML.id+"-audioElements";
nickjillings@1318 2780 audioElems.className = "SecondLevel";
nickjillings@1318 2781 var title = document.createElement("h3");
nickjillings@1318 2782 title.textContent = "Audio Elements";
nickjillings@1318 2783 audioElems.appendChild(title);
nickjillings@1318 2784 for (var j=0; j<aH.audioElements.length; j++)
nickjillings@1318 2785 {
nickjillings@1318 2786 var entry = document.createElement("div");
nickjillings@1318 2787 entry.className = "SecondLevel";
nickjillings@1318 2788 entry.id = audioElems.id+"-"+aH.audioElements[j].id;
nickjillings@1318 2789 var text = document.createElement("span");
nickjillings@1318 2790 text.textContent = "ID:";
nickjillings@1318 2791 var input = document.createElement("input");
nickjillings@1318 2792 input.id = entry.id+"-id";
nickjillings@1318 2793 input.value = aH.audioElements[j].id;
nickjillings@1318 2794 input.onchange = function() {
nickjillings@1318 2795 var IDSplit = event.currentTarget.id.split("-");
nickjillings@1318 2796 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1318 2797 ahNode.audioElements[IDSplit[3]].id = event.currentTarget.value;
nickjillings@1318 2798 };
nickjillings@1318 2799 text.style.margin = "5px";
nickjillings@1318 2800 input.style.margin = "5px";
nickjillings@1318 2801 entry.appendChild(text);
nickjillings@1318 2802 entry.appendChild(input);
nickjillings@1318 2803 text = document.createElement("span");
nickjillings@1318 2804 text.textContent = "URL:";
nickjillings@1318 2805 input = document.createElement("input");
nickjillings@1318 2806 input.id = entry.id+"-URL";
nickjillings@1318 2807 input.value = aH.audioElements[j].url;
nickjillings@1318 2808 input.onchange = function() {
nickjillings@1318 2809 var IDSplit = event.currentTarget.id.split("-");
nickjillings@1318 2810 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1318 2811 ahNode.audioElements[IDSplit[3]].url = event.currentTarget.value;
nickjillings@1318 2812 };
nickjillings@1318 2813 text.style.margin = "5px";
nickjillings@1318 2814 input.style.margin = "5px";
nickjillings@1318 2815 entry.appendChild(text);
nickjillings@1318 2816 entry.appendChild(input);
nickjillings@1318 2817 text = document.createElement("span");
nickjillings@1318 2818 text.textContent = "Gain:";
nickjillings@1318 2819 input = document.createElement("input");
nickjillings@1318 2820 input.type = "range";
nickjillings@1318 2821 input.id = entry.id+"-gain";
nickjillings@1318 2822 input.value = aH.audioElements[j].gain;
nickjillings@1318 2823 input.min = -25;
nickjillings@1318 2824 input.max = 6;
nickjillings@1318 2825 input.step = 1;
nickjillings@1318 2826 input.onchange = function() {
nickjillings@1318 2827 var IDSplit = event.currentTarget.id.split("-");
nickjillings@1318 2828 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1318 2829 ahNode.audioElements[IDSplit[3]].gain = decibelToLinear(Number(event.currentTarget.value));
nickjillings@1318 2830 var textRet = document.getElementById(event.currentTarget.id+"-ret");
nickjillings@1318 2831 textRet.textContent = String(event.currentTarget.value)+"dB";
nickjillings@1318 2832 };
nickjillings@1318 2833 var textRet = document.createElement("span");
nickjillings@1318 2834 textRet.textContent = String(linearToDecibel(aH.audioElements[j].gain))+"dB";
nickjillings@1318 2835 textRet.id = entry.id+"-gain-ret";
nickjillings@1318 2836 text.style.margin = "5px";
nickjillings@1318 2837 input.style.margin = "5px";
nickjillings@1318 2838 entry.appendChild(text);
nickjillings@1318 2839 entry.appendChild(input);
nickjillings@1318 2840 entry.appendChild(textRet);
nickjillings@1318 2841 var button_delete = document.createElement("button");
nickjillings@1318 2842 button_delete.textContent = "Delete";
nickjillings@1318 2843 button_delete.onclick = function() {
nickjillings@1318 2844 var node = event.currentTarget.parentElement;
nickjillings@1318 2845 var IDSplit = node.id.split("-");
nickjillings@1318 2846 var ahNode = specificationNode.audioHolders[IDSplit[1]];
nickjillings@1318 2847 ahNode.audioElements.splice(IDSplit[3],1);
nickjillings@1318 2848 node.parentElement.removeChild(node);
nickjillings@1318 2849 };
nickjillings@1318 2850 entry.appendChild(button_delete);
nickjillings@1318 2851 audioElems.appendChild(entry);
nickjillings@1318 2852 }
nickjillings@1318 2853 aHTML.appendChild(audioElems);
nickjillings@1318 2854 }
nickjillings@1318 2855
nickjillings@1318 2856 function PPSurveyToHTML(node)
nickjillings@1318 2857 {
nickjillings@1318 2858 var holder = document.createElement("div");
nickjillings@1318 2859 var title = document.createElement("h4");
nickjillings@1318 2860 holder.appendChild(title);
nickjillings@1318 2861 var attributes = document.createElement("div");
nickjillings@1318 2862 holder.appendChild(attributes);
nickjillings@1318 2863 switch(node.type)
nickjillings@1318 2864 {
nickjillings@1318 2865 case "statement":
nickjillings@1318 2866 title.textContent = "Statement";
nickjillings@1318 2867 var tA = document.createElement("textarea");
nickjillings@1318 2868 attributes.style.height = "150px";
nickjillings@1318 2869 tA.style.width = "500px";
nickjillings@1318 2870 tA.style.height = "100px";
nickjillings@1318 2871 tA.value = node.statement;
nickjillings@1318 2872 attributes.appendChild(tA);
nickjillings@1318 2873 break;
nickjillings@1318 2874 case "question":
nickjillings@1318 2875 title.textContent = "Question";
nickjillings@1318 2876 var text = document.createElement("span");
nickjillings@1318 2877 text.textContent = "ID :";
nickjillings@1318 2878 var input = document.createElement("input");
nickjillings@1318 2879 input.name = "id";
nickjillings@1318 2880 input.value = node.id;
nickjillings@1318 2881 text.style.margin = "5px";
nickjillings@1318 2882 input.style.margin = "5px";
nickjillings@1318 2883 attributes.appendChild(text);
nickjillings@1318 2884 attributes.appendChild(input);
nickjillings@1318 2885 text = document.createElement("span");
nickjillings@1318 2886 text.textContent = "Question";
nickjillings@1318 2887 input = document.createElement("input");
nickjillings@1318 2888 input.name = "question";
nickjillings@1318 2889 input.style.width = "400px";
nickjillings@1318 2890 input.value = node.question;
nickjillings@1318 2891 text.style.margin = "5px";
nickjillings@1318 2892 input.style.margin = "5px";
nickjillings@1318 2893 attributes.appendChild(text);
nickjillings@1318 2894 attributes.appendChild(input);
nickjillings@1318 2895 text = document.createElement("span");
nickjillings@1318 2896 text.textContent = "Mandatory";
nickjillings@1318 2897 input = document.createElement("input");
nickjillings@1318 2898 input.name = "mandatory";
nickjillings@1318 2899 input.type = "checkbox";
nickjillings@1318 2900 input.checked = node.mandatory;
nickjillings@1318 2901 text.style.margin = "5px";
nickjillings@1318 2902 input.style.margin = "5px";
nickjillings@1318 2903 attributes.appendChild(text);
nickjillings@1318 2904 attributes.appendChild(input);
nickjillings@1318 2905 text = document.createElement("span");
nickjillings@1318 2906 text.textContent = "Reply box size";
nickjillings@1318 2907 input = document.createElement("select");
nickjillings@1318 2908 input.name = "boxsize";
nickjillings@1318 2909 var option = document.createElement("option");
nickjillings@1318 2910 option.textContent = "Normal";
nickjillings@1318 2911 option.value = "normal";
nickjillings@1318 2912 input.appendChild(option);
nickjillings@1318 2913 option = document.createElement("option");
nickjillings@1318 2914 option.textContent = "Large";
nickjillings@1318 2915 option.value = "large";
nickjillings@1318 2916 input.appendChild(option);
nickjillings@1318 2917 option = document.createElement("option");
nickjillings@1318 2918 option.textContent = "Small";
nickjillings@1318 2919 option.value = "small";
nickjillings@1318 2920 input.appendChild(option);
nickjillings@1318 2921 option = document.createElement("option");
nickjillings@1318 2922 option.textContent = "Huge";
nickjillings@1318 2923 option.value = "huge";
nickjillings@1318 2924 input.appendChild(option);
nickjillings@1318 2925 text.style.margin = "5px";
nickjillings@1318 2926 input.style.margin = "5px";
nickjillings@1318 2927 attributes.appendChild(text);
nickjillings@1318 2928 attributes.appendChild(input);
nickjillings@1318 2929 input.value = node.boxsize;
nickjillings@1318 2930 break;
nickjillings@1318 2931 }
nickjillings@1318 2932 return holder;
nickjillings@1318 2933 }
nickjillings@1318 2934 }
nickjillings@1318 2935 function exportToXML()
nickjillings@1318 2936 {
nickjillings@1318 2937 var xmlDoc = specificationNode.encode();
nickjillings@1318 2938 var oSerializer = new XMLSerializer();
nickjillings@1318 2939 xmlDoc = oSerializer.serializeToString(xmlDoc);
nickjillings@1318 2940 var parent = document.createElement("div");
nickjillings@1318 2941 var file = [xmlDoc];
nickjillings@1318 2942 var bb = new Blob(file,{type : 'application/xml'});
nickjillings@1318 2943 var dnlk = window.URL.createObjectURL(bb);
nickjillings@1318 2944 var a = document.createElement("a");
nickjillings@1318 2945 a.hidden = '';
nickjillings@1318 2946 a.href = dnlk;
nickjillings@1318 2947 a.download = "save.xml";
nickjillings@1318 2948 a.textContent = "Save File";
nickjillings@1318 2949
nickjillings@1318 2950 popupInstance.showPopup();
nickjillings@1318 2951 popupInstance.popupBody.innerHTML = null;
nickjillings@1318 2952 var body = document.createElement("span");
nickjillings@1318 2953 body.textContent = "Right click and save the file using the link below. Place this file in your WAET directory as 'project.xml' in the example_eval/ directory. Place your media files in the location specified by the Host URL entries. If you wish to review this XML or edit it, refresh this tool and drag your XML document into the page on the welcome screen.";
nickjillings@1318 2954 popupInstance.popupBody.appendChild(body);
nickjillings@1318 2955 popupInstance.popupBody.appendChild(a);
nickjillings@1318 2956 popupInstance.popupTitle.innerHTML = "<span>Thank You</span>";
nickjillings@1318 2957 }
nickjillings@1318 2958 </script>
nickjillings@1318 2959 <style>
nickjillings@1318 2960 div.popup {
nickjillings@1318 2961 width: 500px;
nickjillings@1318 2962 position: absolute;
nickjillings@1318 2963 height: 400px;
nickjillings@1318 2964 background-color: #fff;
nickjillings@1318 2965 border-radius: 10px;
nickjillings@1318 2966 box-shadow: 0px 0px 50px #000;
nickjillings@1318 2967 z-index: 2;
nickjillings@1318 2968 }
nickjillings@1318 2969
nickjillings@1318 2970 button.popupButton {
nickjillings@1318 2971 /* Button for popup window
nickjillings@1318 2972 */
nickjillings@1318 2973 min-width: 50px;
nickjillings@1318 2974 height: 25px;
nickjillings@1318 2975 position: relative;
nickjillings@1318 2976 border-radius: 5px;
nickjillings@1318 2977 border: #444;
nickjillings@1318 2978 border-width: 1px;
nickjillings@1318 2979 border-style: solid;
nickjillings@1318 2980 background-color: #fff;
nickjillings@1318 2981 }
nickjillings@1318 2982
nickjillings@1318 2983 div.dragndrop {
nickjillings@1318 2984 margin-top: 10px;
nickjillings@1318 2985 border:#000000;
nickjillings@1318 2986 border-style: dashed;
nickjillings@1318 2987 border-width: 2px;
nickjillings@1318 2988 }
nickjillings@1318 2989 div.dndheaderelement {
nickjillings@1318 2990 float: left;
nickjillings@1318 2991 height: 100%;
nickjillings@1318 2992 border-right: #DDDDDD;
nickjillings@1318 2993 border-right-width: 1px;
nickjillings@1318 2994 border-right-style: solid;
nickjillings@1318 2995 }
nickjillings@1318 2996 div.dndheaderelement span{
nickjillings@1318 2997 padding-left: 5px;
nickjillings@1318 2998 }
nickjillings@1318 2999
nickjillings@1318 3000 div.topLevel {
nickjillings@1318 3001 border: #000;
nickjillings@1318 3002 border-style: solid;
nickjillings@1318 3003 border-width: 5px;
nickjillings@1318 3004 padding: 10px;
nickjillings@1318 3005 margin: 10px;
nickjillings@1318 3006 }
nickjillings@1318 3007
nickjillings@1318 3008 div.SecondLevel {
nickjillings@1318 3009 border: #000;
nickjillings@1318 3010 border-style: solid;
nickjillings@1318 3011 border-width: 1px;
nickjillings@1318 3012 padding: 10px;
nickjillings@1318 3013 margin: 10px;
nickjillings@1318 3014 }
nickjillings@1318 3015 </style>
nickjillings@1318 3016 </head>
nickjillings@1318 3017
nickjillings@1318 3018 <body>
nickjillings@1318 3019 <div id="export">
nickjillings@1318 3020 <button id="exportToXML" onclick="exportToXML();">Export XML</button>
nickjillings@1318 3021 </div>
nickjillings@1318 3022 <div id="content"></div>
nickjillings@1318 3023 </body>
nickjillings@1318 3024 </html>