annotate test_create/test_create.html @ 1386:345974f8794a

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