annotate test_create/test_create.html @ 1392:4a0c4119e00d

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