annotate test_create/test_create.html @ 1450:bc074d4ee760

Resolved #1394: Python returns same XML responses as the PHP server
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Fri, 27 Nov 2015 12:09:49 +0000
parents
children 1b6fa37d46a4
rev   line source
nickjillings@1450 1 <!DOCTYPE html>
nickjillings@1450 2 <html lang="en">
nickjillings@1450 3 <head>
nickjillings@1450 4 <meta charset="utf-8">
nickjillings@1450 5
nickjillings@1450 6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
nickjillings@1450 7 Remove this if you use the .htaccess -->
nickjillings@1450 8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
nickjillings@1450 9
nickjillings@1450 10 <title>WAET: Test Creator</title>
nickjillings@1450 11
nickjillings@1450 12 <meta name="viewport" content="width=device-width; initial-scale=1.0">
nickjillings@1450 13 <script type="text/javascript">
nickjillings@1450 14
nickjillings@1450 15 var APEInterfaceOptions = [["playhead","page-count"],["Show the playhead/scrubber bar", "Show test page count"]];
nickjillings@1450 16 var APEInterfaceChecks = [["fragmentPlayed","fragmentFullPlayback","fragmentMoved","fragmentComments"],["All Fragments Played","All Fragments Played in entirety","All sliders moved","All fragments have comments"]];
nickjillings@1450 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@1450 18 var MUSHRAInterfaceOptions = [[],[]];
nickjillings@1450 19 var MUSHRAInterfaceChecks = [["fragmentPlayed","fragmentMoved","fragmentComments"],["All Fragments Played","All sliders moved","All fragments have comments"]];
nickjillings@1450 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@1450 21 var popupInstance;
nickjillings@1450 22 var specificationNode;
nickjillings@1450 23 var audioContext;
nickjillings@1450 24 var audioObjects = [];
nickjillings@1450 25 window.onload = function()
nickjillings@1450 26 {
nickjillings@1450 27 var AudioContext = window.AudioContext || window.webkitAudioContext;
nickjillings@1450 28 audioContext = new AudioContext;
nickjillings@1450 29 popupInstance = new popup();
nickjillings@1450 30 popupInstance.advanceState();
nickjillings@1450 31 specificationNode = new Specification();
nickjillings@1450 32 specificationNode.projectReturn = "null";
nickjillings@1450 33 };
nickjillings@1450 34
nickjillings@1450 35 function popup()
nickjillings@1450 36 {
nickjillings@1450 37 var x = window.innerWidth;
nickjillings@1450 38 var y = window.innerHeight;
nickjillings@1450 39 this.popupHolder = document.createElement('div');
nickjillings@1450 40 this.popupHolder.style.visibility = 'hidden';
nickjillings@1450 41 this.popupContent = document.createElement('div');
nickjillings@1450 42 this.popupTitle = document.createElement('div');
nickjillings@1450 43 this.popupBody = document.createElement('div');
nickjillings@1450 44 this.popupFooter = document.createElement('div');
nickjillings@1450 45 this.popupTitleText = document.createElement('span');
nickjillings@1450 46 this.popupTitle.appendChild(this.popupTitleText);
nickjillings@1450 47
nickjillings@1450 48 this.popupHolder.className = "popup";
nickjillings@1450 49 this.popupHolder.style.left = (x-500)/2 +'px';
nickjillings@1450 50 this.popupHolder.style.top = (y-400)/2 + 'px';
nickjillings@1450 51 this.popupContent.style.padding = "20px";
nickjillings@1450 52 this.popupHolder.appendChild(this.popupContent);
nickjillings@1450 53
nickjillings@1450 54 this.popupTitle.style.width = "100%";
nickjillings@1450 55 this.popupTitle.style.height = "50px";
nickjillings@1450 56 this.popupTitle.style.fontSize = "xx-large";
nickjillings@1450 57 this.popupContent.appendChild(this.popupTitle);
nickjillings@1450 58
nickjillings@1450 59 this.popupBody.style.width = "100%";
nickjillings@1450 60 this.popupBody.style.height = "280px";
nickjillings@1450 61 this.popupContent.appendChild(this.popupBody);
nickjillings@1450 62
nickjillings@1450 63 this.popupFooter.style.width = "100%";
nickjillings@1450 64 this.popupFooter.style.height = "30px";
nickjillings@1450 65 this.popupContent.appendChild(this.popupFooter);
nickjillings@1450 66 var body = document.getElementsByTagName('body')[0];
nickjillings@1450 67 body.appendChild(this.popupHolder);
nickjillings@1450 68
nickjillings@1450 69 this.pageBlank = document.createElement('div');
nickjillings@1450 70 body.appendChild(this.pageBlank);
nickjillings@1450 71 this.pageBlank.style.width = "100%";
nickjillings@1450 72 this.pageBlank.style.height = "100%";
nickjillings@1450 73 this.pageBlank.style.position = "absolute";
nickjillings@1450 74 this.pageBlank.style.left = "0px";
nickjillings@1450 75 this.pageBlank.style.top = "0px";
nickjillings@1450 76 this.pageBlank.style.backgroundColor = "rgba(0,0,0,0.5)";
nickjillings@1450 77 this.pageBlank.style.visibility = 'hidden';
nickjillings@1450 78
nickjillings@1450 79 this.state = 0;
nickjillings@1450 80 this.dataTransfer = null;
nickjillings@1450 81
nickjillings@1450 82 this.showPopup = function()
nickjillings@1450 83 {
nickjillings@1450 84 this.popupHolder.style.visibility = 'visible';
nickjillings@1450 85 this.popupHolder.style.zIndex = "3";
nickjillings@1450 86 this.pageBlank.style.visibility = 'visible';
nickjillings@1450 87 this.pageBlank.style.zIndex = "2";
nickjillings@1450 88 };
nickjillings@1450 89
nickjillings@1450 90 this.hidePopup = function()
nickjillings@1450 91 {
nickjillings@1450 92 this.popupHolder.style.visibility = 'hidden';
nickjillings@1450 93 this.popupHolder.style.zIndex = "-1";
nickjillings@1450 94 this.pageBlank.style.visibility = 'hidden';
nickjillings@1450 95 this.pageBlank.style.zIndex = "-2";
nickjillings@1450 96 };
nickjillings@1450 97
nickjillings@1450 98 this.init = function()
nickjillings@1450 99 {
nickjillings@1450 100 this.popupTitleText.textContent = "Welcome";
nickjillings@1450 101 var text = document.createElement('span');
nickjillings@1450 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@1450 103 var dnd = document.createElement('div');
nickjillings@1450 104 dnd.style.width = "100%";
nickjillings@1450 105 dnd.style.height = "50px";
nickjillings@1450 106 dnd.className = "dragndrop";
nickjillings@1450 107 this.popupBody.appendChild(text);
nickjillings@1450 108 this.popupBody.appendChild(dnd);
nickjillings@1450 109 this.showPopup();
nickjillings@1450 110
nickjillings@1450 111 var button = document.createElement('button');
nickjillings@1450 112 button.className = "popupButton";
nickjillings@1450 113 button.textContent = "New File";
nickjillings@1450 114 button.onclick = function(event) {
nickjillings@1450 115 popupInstance.advanceState();
nickjillings@1450 116 };
nickjillings@1450 117 this.popupFooter.appendChild(button);
nickjillings@1450 118 };
nickjillings@1450 119
nickjillings@1450 120 this.advanceState = function()
nickjillings@1450 121 {
nickjillings@1450 122 this.popupBody.innerHTML = null;
nickjillings@1450 123 this.popupFooter.innerHTML = null;
nickjillings@1450 124 this.popupTitleText.textContent = null;
nickjillings@1450 125 switch(this.state)
nickjillings@1450 126 {
nickjillings@1450 127 case 0:
nickjillings@1450 128 this.init();
nickjillings@1450 129 break;
nickjillings@1450 130 case 1:
nickjillings@1450 131 this.popupTitleText.textContent = "Test Type";
nickjillings@1450 132 var text = document.createElement("span");
nickjillings@1450 133 text.textContent = "What type of test would you like to use. Currently APE (Audio Perceptual Evaluation) and MUSHRA style interfaces are available";
nickjillings@1450 134 this.popupBody.appendChild(text);
nickjillings@1450 135 var select = document.createElement("select");
nickjillings@1450 136 select.id="interface-select";
nickjillings@1450 137 var opt1 = document.createElement("option");
nickjillings@1450 138 opt1.value = "APE";
nickjillings@1450 139 opt1.textContent = "APE";
nickjillings@1450 140 select.appendChild(opt1);
nickjillings@1450 141 var opt2 = document.createElement("option");
nickjillings@1450 142 opt2.value = "MUSHRA";
nickjillings@1450 143 opt2.textContent = "MUSHRA";
nickjillings@1450 144 select.appendChild(opt2);
nickjillings@1450 145 this.popupBody.appendChild(select);
nickjillings@1450 146
nickjillings@1450 147 var button = document.createElement('button');
nickjillings@1450 148 button.className = "popupButton";
nickjillings@1450 149 button.textContent = "Submit";
nickjillings@1450 150 button.onclick = function(event) {
nickjillings@1450 151 var select = document.getElementById("interface-select");
nickjillings@1450 152 specificationNode.interfaceType = select.value;
nickjillings@1450 153 specificationNode.collectMetrics = true;
nickjillings@1450 154 popupInstance.advanceState();
nickjillings@1450 155 };
nickjillings@1450 156 this.popupFooter.appendChild(button);
nickjillings@1450 157 break;
nickjillings@1450 158 case 2:
nickjillings@1450 159 this.popupTitleText.textContent = "Test Options";
nickjillings@1450 160 var holder = document.createElement('div');
nickjillings@1450 161 holder.style.margin = "5px";
nickjillings@1450 162 var checkbox = document.createElement('input');
nickjillings@1450 163 checkbox.type = 'checkbox';
nickjillings@1450 164 checkbox.id = "Randomise-Page";
nickjillings@1450 165 var text = document.createElement('span');
nickjillings@1450 166 text.textContent = "Randomise Page Order";
nickjillings@1450 167 holder.appendChild(checkbox);
nickjillings@1450 168 holder.appendChild(text);
nickjillings@1450 169 this.popupBody.appendChild(holder);
nickjillings@1450 170 switch(specificationNode.interfaceType)
nickjillings@1450 171 {
nickjillings@1450 172 case "APE":
nickjillings@1450 173 for (var i=0; i<APEInterfaceOptions[0].length; i++)
nickjillings@1450 174 {
nickjillings@1450 175 holder = document.createElement('div');
nickjillings@1450 176 holder.style.margin = "5px";
nickjillings@1450 177 checkbox = document.createElement('input');
nickjillings@1450 178 checkbox.type = 'checkbox';
nickjillings@1450 179 checkbox.setAttribute("name","option");
nickjillings@1450 180 checkbox.id = APEInterfaceOptions[0][i];
nickjillings@1450 181 text = document.createElement('span');
nickjillings@1450 182 text.textContent = APEInterfaceOptions[1][i];
nickjillings@1450 183 holder.appendChild(checkbox);
nickjillings@1450 184 holder.appendChild(text);
nickjillings@1450 185 this.popupBody.appendChild(holder);
nickjillings@1450 186 }
nickjillings@1450 187 for (var i=0; i<APEInterfaceChecks[0].length; i++)
nickjillings@1450 188 {
nickjillings@1450 189 holder = document.createElement('div');
nickjillings@1450 190 holder.style.margin = "5px";
nickjillings@1450 191 checkbox = document.createElement('input');
nickjillings@1450 192 checkbox.type = 'checkbox';
nickjillings@1450 193 checkbox.setAttribute("name","check");
nickjillings@1450 194 checkbox.id = APEInterfaceChecks[0][i];
nickjillings@1450 195 text = document.createElement('span');
nickjillings@1450 196 text.textContent = APEInterfaceChecks[1][i];
nickjillings@1450 197 holder.appendChild(checkbox);
nickjillings@1450 198 holder.appendChild(text);
nickjillings@1450 199 this.popupBody.appendChild(holder);
nickjillings@1450 200 }
nickjillings@1450 201 break;
nickjillings@1450 202 case "MUSHRA":
nickjillings@1450 203 for (var i=0; i<MUSHRAInterfaceOptions[0].length; i++)
nickjillings@1450 204 {
nickjillings@1450 205 holder = document.createElement('div');
nickjillings@1450 206 holder.style.margin = "5px";
nickjillings@1450 207 checkbox = document.createElement('input');
nickjillings@1450 208 checkbox.type = 'checkbox';
nickjillings@1450 209 checkbox.setAttribute("name","option");
nickjillings@1450 210 checkbox.id = MUSHRAInterfaceOptions[0][i];
nickjillings@1450 211 text = document.createElement('span');
nickjillings@1450 212 text.textContent = MUSHRAInterfaceOptions[1][i];
nickjillings@1450 213 holder.appendChild(checkbox);
nickjillings@1450 214 holder.appendChild(text);
nickjillings@1450 215 this.popupBody.appendChild(holder);
nickjillings@1450 216 }
nickjillings@1450 217 for (var i=0; i<MUSHRAInterfaceChecks[0].length; i++)
nickjillings@1450 218 {
nickjillings@1450 219 holder = document.createElement('div');
nickjillings@1450 220 holder.style.margin = "5px";
nickjillings@1450 221 checkbox = document.createElement('input');
nickjillings@1450 222 checkbox.type = 'checkbox';
nickjillings@1450 223 checkbox.setAttribute("name","check");
nickjillings@1450 224 checkbox.id = MUSHRAInterfaceChecks[0][i];
nickjillings@1450 225 text = document.createElement('span');
nickjillings@1450 226 text.textContent = MUSHRAInterfaceChecks[1][i];
nickjillings@1450 227 holder.appendChild(checkbox);
nickjillings@1450 228 holder.appendChild(text);
nickjillings@1450 229 this.popupBody.appendChild(holder);
nickjillings@1450 230 }
nickjillings@1450 231 }
nickjillings@1450 232 var button = document.createElement('button');
nickjillings@1450 233 button.className = "popupButton";
nickjillings@1450 234 button.textContent = "Submit";
nickjillings@1450 235 button.onclick = function(event) {
nickjillings@1450 236 var optHold = popupInstance.popupBody;
nickjillings@1450 237 var opt = optHold.firstChild;
nickjillings@1450 238 var input = opt.getElementsByTagName('input')[0];
nickjillings@1450 239 specificationNode.randomiseOrder = input.checked;
nickjillings@1450 240 while(opt.nextSibling != null)
nickjillings@1450 241 {
nickjillings@1450 242 opt = opt.nextSibling;
nickjillings@1450 243 input = opt.getElementsByTagName('input')[0];
nickjillings@1450 244 if (input.checked)
nickjillings@1450 245 {
nickjillings@1450 246 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(input));
nickjillings@1450 247 }
nickjillings@1450 248
nickjillings@1450 249 }
nickjillings@1450 250 popupInstance.advanceState();
nickjillings@1450 251 };
nickjillings@1450 252 this.popupFooter.appendChild(button);
nickjillings@1450 253 break;
nickjillings@1450 254 case 3:
nickjillings@1450 255 audioObjects = [];
nickjillings@1450 256 this.popupTitleText.textContent = "Test Page";
nickjillings@1450 257 var span = document.createElement('span');
nickjillings@1450 258 span.textContent = "Drag and drop your audio files into the box below to add them to a test page";
nickjillings@1450 259 this.popupBody.appendChild(span);
nickjillings@1450 260 var dnd = document.createElement('div');
nickjillings@1450 261 dnd.id = "audio-holder-drop";
nickjillings@1450 262 dnd.style.width = "100%";
nickjillings@1450 263 dnd.style.minHeight = "50px";
nickjillings@1450 264 dnd.style.maxHeight = "220px";
nickjillings@1450 265 dnd.style.overflow = 'auto';
nickjillings@1450 266 dnd.className = "dragndrop";
nickjillings@1450 267 dnd.ondragover = function(e) {
nickjillings@1450 268 if(e.preventDefault) {e.preventDefault();}
nickjillings@1450 269 return false;
nickjillings@1450 270 };
nickjillings@1450 271 dnd.ondragenter = function(e) {
nickjillings@1450 272 if(e.preventDefault) {e.preventDefault();}
nickjillings@1450 273 return false;
nickjillings@1450 274 };
nickjillings@1450 275 dnd.ondrop = function(e) {
nickjillings@1450 276 if(e.preventDefault) {e.preventDefault();}
nickjillings@1450 277 var dt = e.dataTransfer;
nickjillings@1450 278 var body = document.getElementById("audio-holder-drop");
nickjillings@1450 279 var files = dt.files;
nickjillings@1450 280 for (var i = 0, f; f = files[i]; i++)
nickjillings@1450 281 {
nickjillings@1450 282 var ao = new audioObject();
nickjillings@1450 283 ao.constructTrack(f);
nickjillings@1450 284 audioObjects.push(ao);
nickjillings@1450 285 var dndHeader = document.createElement('div');
nickjillings@1450 286 dndHeader.style.width = "100%";
nickjillings@1450 287 dndHeader.style.height = "20px";
nickjillings@1450 288 dndHeader.style.borderBottom = "#DDD";
nickjillings@1450 289 dndHeader.style.borderBottomWidth = "1px";
nickjillings@1450 290 dndHeader.style.borderBottomStyle = "solid";
nickjillings@1450 291 dndHeader.setAttribute('aoID',audioObjects.length-1);
nickjillings@1450 292 var dndHInclude = document.createElement('div');
nickjillings@1450 293 dndHInclude.style.width = "30px";
nickjillings@1450 294 dndHInclude.className = "dndheaderelement";
nickjillings@1450 295 var includeCheck = document.createElement('input');
nickjillings@1450 296 includeCheck.type = "checkbox";
nickjillings@1450 297 includeCheck.name = "include-check";
nickjillings@1450 298 includeCheck.checked = true;
nickjillings@1450 299 includeCheck.onchange = function()
nickjillings@1450 300 {
nickjillings@1450 301 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
nickjillings@1450 302 audioObjects[i].include = event.currentTarget.checked;
nickjillings@1450 303 };
nickjillings@1450 304 dndHInclude.appendChild(includeCheck);
nickjillings@1450 305 dndHeader.appendChild(dndHInclude);
nickjillings@1450 306 var dndHTitle = document.createElement('div');
nickjillings@1450 307 dndHTitle.style.width = "180px";
nickjillings@1450 308 dndHTitle.className = "dndheaderelement";
nickjillings@1450 309 var text = document.createElement('span');
nickjillings@1450 310 text.textContent = f.name;
nickjillings@1450 311 dndHTitle.appendChild(text);
nickjillings@1450 312 dndHeader.appendChild(dndHTitle);
nickjillings@1450 313 var dndHID = document.createElement('div');
nickjillings@1450 314 dndHID.style.width = "100px";
nickjillings@1450 315 dndHID.className = "dndheaderelement";
nickjillings@1450 316 var IDInput = document.createElement('input');
nickjillings@1450 317 IDInput.name = "audio-fragment-ID";
nickjillings@1450 318 IDInput.value = f.name.split('.')[0];
nickjillings@1450 319 IDInput.onchange = function()
nickjillings@1450 320 {
nickjillings@1450 321 var allIDInput = document.getElementsByName("audio-fragment-ID");
nickjillings@1450 322 var isCopy = new Array(allIDInput.length);
nickjillings@1450 323 isCopy.fill(0,0,this.length);
nickjillings@1450 324 if (allIDInput.length > 1)
nickjillings@1450 325 {
nickjillings@1450 326 for (var j=0; j<allIDInput.length; j++)
nickjillings@1450 327 {
nickjillings@1450 328 var textCompare1 = allIDInput[j].value;
nickjillings@1450 329 for (var k=j+1; k<allIDInput.length; k++)
nickjillings@1450 330 {
nickjillings@1450 331 var textCompare2 = allIDInput[k].value;
nickjillings@1450 332 if (textCompare1 == textCompare2)
nickjillings@1450 333 {
nickjillings@1450 334 isCopy[j] = 1;
nickjillings@1450 335 isCopy[k] = 1;
nickjillings@1450 336 }
nickjillings@1450 337 }
nickjillings@1450 338 }
nickjillings@1450 339 }
nickjillings@1450 340 var button = document.getElementById('submit');
nickjillings@1450 341 button.disabled = false;
nickjillings@1450 342 for (var j=0; j<allIDInput.length; j++)
nickjillings@1450 343 {
nickjillings@1450 344 if (isCopy[j] == 1)
nickjillings@1450 345 {
nickjillings@1450 346 allIDInput[j].style.backgroundColor = '#F22';
nickjillings@1450 347 button.disabled = true;
nickjillings@1450 348 }
nickjillings@1450 349 else
nickjillings@1450 350 {
nickjillings@1450 351 allIDInput[j].style.backgroundColor = '#FFF';
nickjillings@1450 352 audioObjects[j].id = allIDInput[j].value;
nickjillings@1450 353 }
nickjillings@1450 354 }
nickjillings@1450 355 };
nickjillings@1450 356 IDInput.style.width = "96px";
nickjillings@1450 357 dndHID.appendChild(IDInput);
nickjillings@1450 358 dndHeader.appendChild(dndHID);
nickjillings@1450 359 var dndHPlay = document.createElement('div');
nickjillings@1450 360 dndHPlay.style.width = "100px";
nickjillings@1450 361 dndHPlay.className = "dndheaderelement";
nickjillings@1450 362 var audio = document.createElement('button');
nickjillings@1450 363 audio.textContent = 'Play';
nickjillings@1450 364 audio.className = "popupButton";
nickjillings@1450 365 audio.style.height = "inherit";
nickjillings@1450 366 audio.onclick = function()
nickjillings@1450 367 {
nickjillings@1450 368 var i = event.currentTarget.parentElement.parentElement.getAttribute('aoID');
nickjillings@1450 369 audioObjects[i].play();
nickjillings@1450 370 };
nickjillings@1450 371 dndHPlay.appendChild(audio);
nickjillings@1450 372 dndHeader.appendChild(dndHPlay);
nickjillings@1450 373 dnd.appendChild(dndHeader);
nickjillings@1450 374 IDInput.onchange();
nickjillings@1450 375 }
nickjillings@1450 376 };
nickjillings@1450 377 var dndHeader = document.createElement('div');
nickjillings@1450 378 dndHeader.style.width = "100%";
nickjillings@1450 379 dndHeader.style.height = "15px";
nickjillings@1450 380 dndHeader.style.borderBottom = "#DDD";
nickjillings@1450 381 dndHeader.style.borderBottomWidth = "1px";
nickjillings@1450 382 dndHeader.style.borderBottomStyle = "solid";
nickjillings@1450 383 var dndHInclude = document.createElement('div');
nickjillings@1450 384 dndHInclude.style.width = "30px";
nickjillings@1450 385 dndHInclude.className = "dndheaderelement";
nickjillings@1450 386 var text = document.createElement('span');
nickjillings@1450 387 text.textContent = "Inc.";
nickjillings@1450 388 dndHInclude.appendChild(text);
nickjillings@1450 389 dndHeader.appendChild(dndHInclude);
nickjillings@1450 390 var dndHTitle = document.createElement('div');
nickjillings@1450 391 dndHTitle.style.width = "180px";
nickjillings@1450 392 dndHTitle.className = "dndheaderelement";
nickjillings@1450 393 text = document.createElement('span');
nickjillings@1450 394 text.textContent = "File Name";
nickjillings@1450 395 dndHTitle.appendChild(text);
nickjillings@1450 396 dndHeader.appendChild(dndHTitle);
nickjillings@1450 397 var dndHID = document.createElement('div');
nickjillings@1450 398 dndHID.style.width = "100px";
nickjillings@1450 399 dndHID.className = "dndheaderelement";
nickjillings@1450 400 text = document.createElement('span');
nickjillings@1450 401 text.textContent = "ID";
nickjillings@1450 402 dndHID.appendChild(text);
nickjillings@1450 403 dndHeader.appendChild(dndHID);
nickjillings@1450 404 var dndHPlay = document.createElement('div');
nickjillings@1450 405 dndHPlay.style.width = "100px";
nickjillings@1450 406 dndHPlay.className = "dndheaderelement";
nickjillings@1450 407 text = document.createElement('span');
nickjillings@1450 408 text.textContent = "Sample";
nickjillings@1450 409 dndHPlay.appendChild(text);
nickjillings@1450 410 dndHeader.appendChild(dndHPlay);
nickjillings@1450 411 dnd.appendChild(dndHeader);
nickjillings@1450 412 this.popupBody.appendChild(dnd);
nickjillings@1450 413 var button = document.createElement('button');
nickjillings@1450 414 button.id = 'submit';
nickjillings@1450 415 button.className = "popupButton";
nickjillings@1450 416 button.textContent = "Submit";
nickjillings@1450 417 button.onclick = function(event)
nickjillings@1450 418 {
nickjillings@1450 419 // Construct the audio-holder nodes;
nickjillings@1450 420 for (var i=0; i<audioObjects.length; i++)
nickjillings@1450 421 {
nickjillings@1450 422 if (!audioObjects[i].include)
nickjillings@1450 423 {
nickjillings@1450 424 audioObjects.pop(audioObjects[i]);
nickjillings@1450 425 }
nickjillings@1450 426 }
nickjillings@1450 427 if (audioObjects.length != 0)
nickjillings@1450 428 {
nickjillings@1450 429 popupInstance.advanceState();
nickjillings@1450 430 }
nickjillings@1450 431 };
nickjillings@1450 432 this.popupFooter.appendChild(button);
nickjillings@1450 433 break;
nickjillings@1450 434 case 4:
nickjillings@1450 435 this.popupTitleText.textContent = "Test Page - Options";
nickjillings@1450 436 var span = document.createElement('span');
nickjillings@1450 437 span.textContent = "Set your test page options here";
nickjillings@1450 438 this.popupBody.appendChild(span);
nickjillings@1450 439 var pair = document.createElement('div');
nickjillings@1450 440 pair.style.margin = '5px';
nickjillings@1450 441 var text = document.createElement('span');
nickjillings@1450 442 text.textContent = "Page ID:";
nickjillings@1450 443 var input = document.createElement('input');
nickjillings@1450 444 input.value = specificationNode.audioHolders.length;
nickjillings@1450 445 input.id = "id";
nickjillings@1450 446 pair.appendChild(text);
nickjillings@1450 447 pair.appendChild(input);
nickjillings@1450 448 this.popupBody.appendChild(pair);
nickjillings@1450 449 pair = document.createElement('div');
nickjillings@1450 450 pair.style.margin = '5px';
nickjillings@1450 451 text = document.createElement('span');
nickjillings@1450 452 text.textContent = "Randomise Fragment Order";
nickjillings@1450 453 input = document.createElement('input');
nickjillings@1450 454 input.type = "checkbox";
nickjillings@1450 455 input.id = "randomiseOrder";
nickjillings@1450 456 pair.appendChild(input);
nickjillings@1450 457 pair.appendChild(text);
nickjillings@1450 458 this.popupBody.appendChild(pair);
nickjillings@1450 459 pair = document.createElement('div');
nickjillings@1450 460 pair.style.margin = '5px';
nickjillings@1450 461 text = document.createElement('span');
nickjillings@1450 462 text.textContent = "Loop Fragment Playback";
nickjillings@1450 463 input = document.createElement('input');
nickjillings@1450 464 input.type = "checkbox";
nickjillings@1450 465 input.id = "loop";
nickjillings@1450 466 pair.appendChild(input);
nickjillings@1450 467 pair.appendChild(text);
nickjillings@1450 468 this.popupBody.appendChild(pair);
nickjillings@1450 469 pair = document.createElement('div');
nickjillings@1450 470 pair.style.margin = '5px';
nickjillings@1450 471 text = document.createElement('span');
nickjillings@1450 472 text.textContent = "Show fragment comment boxes";
nickjillings@1450 473 input = document.createElement('input');
nickjillings@1450 474 input.type = "checkbox";
nickjillings@1450 475 input.id = "elementComments";
nickjillings@1450 476 pair.appendChild(input);
nickjillings@1450 477 pair.appendChild(text);
nickjillings@1450 478 this.popupBody.appendChild(pair);
nickjillings@1450 479 var button = document.createElement('button');
nickjillings@1450 480 button.id = 'submit';
nickjillings@1450 481 button.className = "popupButton";
nickjillings@1450 482 button.textContent = "Next";
nickjillings@1450 483 button.onclick = function(event)
nickjillings@1450 484 {
nickjillings@1450 485 var ah = new specificationNode.audioHolderNode(specificationNode);
nickjillings@1450 486 ah.id = document.getElementById('id').value;
nickjillings@1450 487 ah.presentedId = specificationNode.audioHolders.length;
nickjillings@1450 488 ah.hostURL = ah.id+'/';
nickjillings@1450 489 ah.randomiseOrder = document.getElementById('randomiseOrder').checked;
nickjillings@1450 490 ah.loop = document.getElementById('loop').checked;
nickjillings@1450 491 ah.elementComments = document.getElementById('elementComments').checked;
nickjillings@1450 492 for (var i=0; i<audioObjects.length; i++)
nickjillings@1450 493 {
nickjillings@1450 494 ah.audioElements.push(new ah.audioElementNode(ah,audioObjects[i]));
nickjillings@1450 495 }
nickjillings@1450 496 specificationNode.audioHolders.push(ah);
nickjillings@1450 497 popupInstance.advanceState();
nickjillings@1450 498 };
nickjillings@1450 499 this.popupFooter.appendChild(button);
nickjillings@1450 500 break;
nickjillings@1450 501 case 5:
nickjillings@1450 502 this.dataTransfer = null;
nickjillings@1450 503 this.popupTitleText.textContent = "Test Page - Pre/Post Survey";
nickjillings@1450 504 var span = document.createElement('span');
nickjillings@1450 505 span.textContent = "Add your pre test page options here";
nickjillings@1450 506 this.popupBody.appendChild(span);
nickjillings@1450 507 var preHolder = document.createElement('div');
nickjillings@1450 508 preHolder.id = "preHolder";
nickjillings@1450 509 preHolder.style.width = "460px";
nickjillings@1450 510 preHolder.style.minHeight = "100px";
nickjillings@1450 511 preHolder.style.maxHeight = "220px";
nickjillings@1450 512 preHolder.style.overflow = 'auto';
nickjillings@1450 513 preHolder.style.border = "black";
nickjillings@1450 514 preHolder.style.borderStyle = "solid";
nickjillings@1450 515 preHolder.style.borderWidth = "1px";
nickjillings@1450 516 this.popupBody.appendChild(preHolder);
nickjillings@1450 517 var audioHolder = specificationNode.audioHolders[specificationNode.audioHolders.length-1];
nickjillings@1450 518 var preHeaderHolder = document.createElement('div');
nickjillings@1450 519 preHeaderHolder.style.width = "456px";
nickjillings@1450 520 preHeaderHolder.style.height= "20px";
nickjillings@1450 521 preHeaderHolder.style.margin= "2px";
nickjillings@1450 522 preHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1450 523 preHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1450 524 preHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1450 525 var mvH = document.createElement('div');
nickjillings@1450 526 mvH.className = "dndheaderelement";
nickjillings@1450 527 mvH.style.width = "50px";
nickjillings@1450 528 var text = document.createElement('span');
nickjillings@1450 529 text.textContent = "Order";
nickjillings@1450 530 mvH.appendChild(text);
nickjillings@1450 531 preHeaderHolder.appendChild(mvH);
nickjillings@1450 532 var idH = document.createElement('div');
nickjillings@1450 533 idH.className = "dndheaderelement";
nickjillings@1450 534 idH.style.width = "150px";
nickjillings@1450 535 text = document.createElement('span');
nickjillings@1450 536 text.textContent = "ID";
nickjillings@1450 537 idH.appendChild(text);
nickjillings@1450 538 preHeaderHolder.appendChild(idH);
nickjillings@1450 539 var tH = document.createElement('div');
nickjillings@1450 540 tH.className = "dndheaderelement";
nickjillings@1450 541 tH.style.width = "150px";
nickjillings@1450 542 text = document.createElement('span');
nickjillings@1450 543 text.textContent = "Type";
nickjillings@1450 544 tH.appendChild(text);
nickjillings@1450 545 preHeaderHolder.appendChild(tH);
nickjillings@1450 546 var editH = document.createElement('div');
nickjillings@1450 547 editH.className = "dndheaderelement";
nickjillings@1450 548 editH.style.width = "50px";
nickjillings@1450 549 text = document.createElement('span');
nickjillings@1450 550 text.textContent = "Edit";
nickjillings@1450 551 editH.appendChild(text);
nickjillings@1450 552 preHeaderHolder.appendChild(editH);
nickjillings@1450 553 var deleteH = document.createElement('div');
nickjillings@1450 554 deleteH.className = "dndheaderelement";
nickjillings@1450 555 deleteH.style.width = "50px";
nickjillings@1450 556 text = document.createElement('span');
nickjillings@1450 557 text.textContent = "Delete";
nickjillings@1450 558 deleteH.appendChild(text);
nickjillings@1450 559 preHeaderHolder.appendChild(deleteH);
nickjillings@1450 560 preHolder.appendChild(preHeaderHolder);
nickjillings@1450 561
nickjillings@1450 562
nickjillings@1450 563 for (var i=0; i<audioHolder.preTest.options.length; i++)
nickjillings@1450 564 {
nickjillings@1450 565 var optionNode = audioHolder.preTest.options[i];
nickjillings@1450 566 var entry = document.createElement('div');
nickjillings@1450 567 entry.style.width = "456px";
nickjillings@1450 568 entry.style.height= "20px";
nickjillings@1450 569 entry.style.margin= "2px";
nickjillings@1450 570 entry.style.borderBottom = "#DDD";
nickjillings@1450 571 entry.style.borderBottomWidth = "1px";
nickjillings@1450 572 entry.style.borderBottomStyle = "solid";
nickjillings@1450 573 entry.setAttribute("node-id",i);
nickjillings@1450 574 var node = audioHolder.preTest.options[i];
nickjillings@1450 575 var mvH = document.createElement('div');
nickjillings@1450 576 mvH.className = "dndheaderelement";
nickjillings@1450 577 mvH.style.width = "50px";
nickjillings@1450 578 var mvup = document.createElement("button");
nickjillings@1450 579 mvup.textContent = "Up";
nickjillings@1450 580 mvup.style.width = "25px";
nickjillings@1450 581 mvup.style.padding = "1px 0px";
nickjillings@1450 582 mvup.onclick = function()
nickjillings@1450 583 {
nickjillings@1450 584 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 585 if (i != 0)
nickjillings@1450 586 {
nickjillings@1450 587 var next = audioHolder.preTest.options[i-1];
nickjillings@1450 588 var cur = audioHolder.preTest.options[i];
nickjillings@1450 589 audioHolder.preTest.options[i-1] = cur;
nickjillings@1450 590 audioHolder.preTest.options[i] = next;
nickjillings@1450 591 popupInstance.state = 5;
nickjillings@1450 592 popupInstance.advanceState();
nickjillings@1450 593 }
nickjillings@1450 594 };
nickjillings@1450 595 mvH.appendChild(mvup);
nickjillings@1450 596 var mvdn = document.createElement("button");
nickjillings@1450 597 mvdn.textContent = "Dn";
nickjillings@1450 598 mvdn.style.width = "25px";
nickjillings@1450 599 mvdn.style.padding = "1px 0px";
nickjillings@1450 600 mvdn.onclick = function()
nickjillings@1450 601 {
nickjillings@1450 602 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 603 if (i != audioHolder.preTest.options.length-1)
nickjillings@1450 604 {
nickjillings@1450 605 var next = audioHolder.preTest.options[i+1];
nickjillings@1450 606 var cur = audioHolder.preTest.options[i];
nickjillings@1450 607 audioHolder.preTest.options[i+1] = cur;
nickjillings@1450 608 audioHolder.preTest.options[i] = next;
nickjillings@1450 609 popupInstance.state = 5;
nickjillings@1450 610 popupInstance.advanceState();
nickjillings@1450 611 }
nickjillings@1450 612 };
nickjillings@1450 613 mvH.appendChild(mvdn);
nickjillings@1450 614 entry.appendChild(mvH);
nickjillings@1450 615 var idH = document.createElement('div');
nickjillings@1450 616 idH.className = "dndheaderelement";
nickjillings@1450 617 idH.style.width = "150px";
nickjillings@1450 618 if (optionNode.type != "statement")
nickjillings@1450 619 {
nickjillings@1450 620 var span = document.createElement('span');
nickjillings@1450 621 span.textContent = optionNode.id;
nickjillings@1450 622 idH.appendChild(span);
nickjillings@1450 623 }
nickjillings@1450 624 entry.appendChild(idH);
nickjillings@1450 625 var typeH = document.createElement('div');
nickjillings@1450 626 typeH.className = "dndheaderelement";
nickjillings@1450 627 typeH.style.width = "150px";
nickjillings@1450 628 var span = document.createElement('span');
nickjillings@1450 629 span.textContent = optionNode.type;
nickjillings@1450 630 typeH.appendChild(span);
nickjillings@1450 631 entry.appendChild(typeH);
nickjillings@1450 632 var editH = document.createElement('div');
nickjillings@1450 633 editH.className = "dndheaderelement";
nickjillings@1450 634 editH.style.width = "50px";
nickjillings@1450 635 var editButton = document.createElement("button");
nickjillings@1450 636 editButton.textContent = "Edit";
nickjillings@1450 637 editButton.style.width = "48px";
nickjillings@1450 638 editButton.style.padding = "1px 0px";
nickjillings@1450 639 editButton.onclick = function()
nickjillings@1450 640 {
nickjillings@1450 641 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 642 popupInstance.dataTransfer = new function() {
nickjillings@1450 643 this.title = "Edit Test Node";
nickjillings@1450 644 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
nickjillings@1450 645 this.node = this.parent.options[i];
nickjillings@1450 646 this.previousState = 5;
nickjillings@1450 647 };
nickjillings@1450 648 popupInstance.advanceState();
nickjillings@1450 649 };
nickjillings@1450 650 editH.appendChild(editButton);
nickjillings@1450 651 entry.appendChild(editH);
nickjillings@1450 652 var deleteH = document.createElement('div');
nickjillings@1450 653 deleteH.className = "dndheaderelement";
nickjillings@1450 654 deleteH.style.width = "50px";
nickjillings@1450 655 var deleteButton = document.createElement("button");
nickjillings@1450 656 deleteButton.textContent = "Del";
nickjillings@1450 657 deleteButton.style.width = "48px";
nickjillings@1450 658 deleteButton.style.padding = "1px 0px";
nickjillings@1450 659 deleteButton.onclick = function()
nickjillings@1450 660 {
nickjillings@1450 661 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 662 var j = i+1;
nickjillings@1450 663 while(j < audioHolder.preTest.options.length)
nickjillings@1450 664 {
nickjillings@1450 665 audioHolder.preTest.options[i] = audioHolder.preTest.options[j];
nickjillings@1450 666 j++;
nickjillings@1450 667 i++;
nickjillings@1450 668 }
nickjillings@1450 669 audioHolder.preTest.options.pop();
nickjillings@1450 670 popupInstance.state = 5;
nickjillings@1450 671 popupInstance.advanceState();
nickjillings@1450 672 };
nickjillings@1450 673 deleteH.appendChild(deleteButton);
nickjillings@1450 674 entry.appendChild(deleteH);
nickjillings@1450 675 preHolder.appendChild(entry);
nickjillings@1450 676 }
nickjillings@1450 677 var entry = document.createElement('div');
nickjillings@1450 678 entry.style.width = "456px";
nickjillings@1450 679 entry.style.height= "20px";
nickjillings@1450 680 entry.style.margin= "2px";
nickjillings@1450 681 entry.style.borderBottom = "#DDD";
nickjillings@1450 682 entry.style.borderBottomWidth = "1px";
nickjillings@1450 683 entry.style.borderBottomStyle = "solid";
nickjillings@1450 684 entry.align = "center";
nickjillings@1450 685 var addPre = document.createElement('button');
nickjillings@1450 686 addPre.className = "popupButton";
nickjillings@1450 687 addPre.textContent = "Add New Entry";
nickjillings@1450 688 addPre.style.height = "20px";
nickjillings@1450 689 addPre.onclick = function()
nickjillings@1450 690 {
nickjillings@1450 691 popupInstance.dataTransfer = new function() {
nickjillings@1450 692 this.title = "New Pre Test Node";
nickjillings@1450 693 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].preTest;
nickjillings@1450 694 this.node = null;
nickjillings@1450 695 this.previousState = 5;
nickjillings@1450 696 };
nickjillings@1450 697 popupInstance.advanceState();
nickjillings@1450 698 };
nickjillings@1450 699 entry.appendChild(addPre);
nickjillings@1450 700 preHolder.appendChild(entry);
nickjillings@1450 701
nickjillings@1450 702 var span = document.createElement('span');
nickjillings@1450 703 span.textContent = "Add your post test page options here";
nickjillings@1450 704 this.popupBody.appendChild(span);
nickjillings@1450 705 var postHolder = document.createElement('div');
nickjillings@1450 706 postHolder.id = "preHolder";
nickjillings@1450 707 postHolder.style.width = "100%";
nickjillings@1450 708 postHolder.style.minHeight = "100px";
nickjillings@1450 709 postHolder.style.maxHeight = "220px";
nickjillings@1450 710 postHolder.style.overflow = 'auto';
nickjillings@1450 711 postHolder.style.border = "black";
nickjillings@1450 712 postHolder.style.borderStyle = "solid";
nickjillings@1450 713 postHolder.style.borderWidth = "1px";
nickjillings@1450 714 this.popupBody.appendChild(postHolder);
nickjillings@1450 715 var postHeaderHolder = document.createElement('div');
nickjillings@1450 716 postHeaderHolder.style.width = "456px";
nickjillings@1450 717 postHeaderHolder.style.height= "20px";
nickjillings@1450 718 postHeaderHolder.style.margin= "2px";
nickjillings@1450 719 postHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1450 720 postHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1450 721 postHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1450 722 var mvH = document.createElement('div');
nickjillings@1450 723 mvH.className = "dndheaderelement";
nickjillings@1450 724 mvH.style.width = "50px";
nickjillings@1450 725 var text = document.createElement('span');
nickjillings@1450 726 text.textContent = "Order";
nickjillings@1450 727 mvH.appendChild(text);
nickjillings@1450 728 postHeaderHolder.appendChild(mvH);
nickjillings@1450 729 var idH = document.createElement('div');
nickjillings@1450 730 idH.className = "dndheaderelement";
nickjillings@1450 731 idH.style.width = "150px";
nickjillings@1450 732 text = document.createElement('span');
nickjillings@1450 733 text.textContent = "ID";
nickjillings@1450 734 idH.appendChild(text);
nickjillings@1450 735 postHeaderHolder.appendChild(idH);
nickjillings@1450 736 var tH = document.createElement('div');
nickjillings@1450 737 tH.className = "dndheaderelement";
nickjillings@1450 738 tH.style.width = "150px";
nickjillings@1450 739 text = document.createElement('span');
nickjillings@1450 740 text.textContent = "Type";
nickjillings@1450 741 tH.appendChild(text);
nickjillings@1450 742 postHeaderHolder.appendChild(tH);
nickjillings@1450 743 var editH = document.createElement('div');
nickjillings@1450 744 editH.className = "dndheaderelement";
nickjillings@1450 745 editH.style.width = "50px";
nickjillings@1450 746 text = document.createElement('span');
nickjillings@1450 747 text.textContent = "Edit";
nickjillings@1450 748 editH.appendChild(text);
nickjillings@1450 749 postHeaderHolder.appendChild(editH);
nickjillings@1450 750 var deleteH = document.createElement('div');
nickjillings@1450 751 deleteH.className = "dndheaderelement";
nickjillings@1450 752 deleteH.style.width = "50px";
nickjillings@1450 753 text = document.createElement('span');
nickjillings@1450 754 text.textContent = "Delete";
nickjillings@1450 755 deleteH.appendChild(text);
nickjillings@1450 756 postHeaderHolder.appendChild(deleteH);
nickjillings@1450 757 postHolder.appendChild(postHeaderHolder);
nickjillings@1450 758
nickjillings@1450 759 for (var i=0; i<audioHolder.postTest.options.length; i++)
nickjillings@1450 760 {
nickjillings@1450 761 var optionNode = audioHolder.postTest.options[i];
nickjillings@1450 762 var entry = document.createElement('div');
nickjillings@1450 763 entry.style.width = "456px";
nickjillings@1450 764 entry.style.height= "20px";
nickjillings@1450 765 entry.style.margin= "2px";
nickjillings@1450 766 entry.style.borderBottom = "#DDD";
nickjillings@1450 767 entry.style.borderBottomWidth = "1px";
nickjillings@1450 768 entry.style.borderBottomStyle = "solid";
nickjillings@1450 769 entry.setAttribute("node-id",i);
nickjillings@1450 770 var node = audioHolder.postTest.options[i];
nickjillings@1450 771 var mvH = document.createElement('div');
nickjillings@1450 772 mvH.className = "dndheaderelement";
nickjillings@1450 773 mvH.style.width = "50px";
nickjillings@1450 774 var mvup = document.createElement("button");
nickjillings@1450 775 mvup.textContent = "Up";
nickjillings@1450 776 mvup.style.width = "25px";
nickjillings@1450 777 mvup.style.padding = "1px 0px";
nickjillings@1450 778 mvup.onclick = function()
nickjillings@1450 779 {
nickjillings@1450 780 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 781 if (i != 0)
nickjillings@1450 782 {
nickjillings@1450 783 var next = audioHolder.postTest.options[i-1];
nickjillings@1450 784 var cur = audioHolder.postTest.options[i];
nickjillings@1450 785 audioHolder.postTest.options[i-1] = cur;
nickjillings@1450 786 audioHolder.postTest.options[i] = next;
nickjillings@1450 787 popupInstance.state = 5;
nickjillings@1450 788 popupInstance.advanceState();
nickjillings@1450 789 }
nickjillings@1450 790 };
nickjillings@1450 791 mvH.appendChild(mvup);
nickjillings@1450 792 var mvdn = document.createElement("button");
nickjillings@1450 793 mvdn.textContent = "Dn";
nickjillings@1450 794 mvdn.style.width = "25px";
nickjillings@1450 795 mvdn.style.padding = "1px 0px";
nickjillings@1450 796 mvdn.onclick = function()
nickjillings@1450 797 {
nickjillings@1450 798 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 799 if (i != audioHolder.postTest.options.length-1)
nickjillings@1450 800 {
nickjillings@1450 801 var next = audioHolder.postTest.options[i+1];
nickjillings@1450 802 var cur = audioHolder.postTest.options[i];
nickjillings@1450 803 audioHolder.postTest.options[i+1] = cur;
nickjillings@1450 804 audioHolder.postTest.options[i] = next;
nickjillings@1450 805 popupInstance.state = 5;
nickjillings@1450 806 popupInstance.advanceState();
nickjillings@1450 807 }
nickjillings@1450 808 };
nickjillings@1450 809 mvH.appendChild(mvdn);
nickjillings@1450 810 entry.appendChild(mvH);
nickjillings@1450 811 var idH = document.createElement('div');
nickjillings@1450 812 idH.className = "dndheaderelement";
nickjillings@1450 813 idH.style.width = "150px";
nickjillings@1450 814 if (optionNode.type != "statement")
nickjillings@1450 815 {
nickjillings@1450 816 var span = document.createElement('span');
nickjillings@1450 817 span.textContent = optionNode.id;
nickjillings@1450 818 idH.appendChild(span);
nickjillings@1450 819 }
nickjillings@1450 820 entry.appendChild(idH);
nickjillings@1450 821 var typeH = document.createElement('div');
nickjillings@1450 822 typeH.className = "dndheaderelement";
nickjillings@1450 823 typeH.style.width = "150px";
nickjillings@1450 824 var span = document.createElement('span');
nickjillings@1450 825 span.textContent = optionNode.type;
nickjillings@1450 826 typeH.appendChild(span);
nickjillings@1450 827 entry.appendChild(typeH);
nickjillings@1450 828 var editH = document.createElement('div');
nickjillings@1450 829 editH.className = "dndheaderelement";
nickjillings@1450 830 editH.style.width = "50px";
nickjillings@1450 831 var editButton = document.createElement("button");
nickjillings@1450 832 editButton.textContent = "Edit";
nickjillings@1450 833 editButton.style.width = "48px";
nickjillings@1450 834 editButton.style.padding = "1px 0px";
nickjillings@1450 835 editButton.onclick = function()
nickjillings@1450 836 {
nickjillings@1450 837 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 838 popupInstance.dataTransfer = new function() {
nickjillings@1450 839 this.title = "Edit Test Node";
nickjillings@1450 840 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
nickjillings@1450 841 this.node = this.parent.options[i];
nickjillings@1450 842 this.previousState = 5;
nickjillings@1450 843 };
nickjillings@1450 844 popupInstance.advanceState();
nickjillings@1450 845 };
nickjillings@1450 846 editH.appendChild(editButton);
nickjillings@1450 847 entry.appendChild(editH);
nickjillings@1450 848 var deleteH = document.createElement('div');
nickjillings@1450 849 deleteH.className = "dndheaderelement";
nickjillings@1450 850 deleteH.style.width = "50px";
nickjillings@1450 851 var deleteButton = document.createElement("button");
nickjillings@1450 852 deleteButton.textContent = "Del";
nickjillings@1450 853 deleteButton.style.width = "48px";
nickjillings@1450 854 deleteButton.style.padding = "1px 0px";
nickjillings@1450 855 deleteButton.onclick = function()
nickjillings@1450 856 {
nickjillings@1450 857 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 858 var j = i+1;
nickjillings@1450 859 while(j < audioHolder.postTest.options.length)
nickjillings@1450 860 {
nickjillings@1450 861 audioHolder.postTest.options[i] = audioHolder.postTest.options[j];
nickjillings@1450 862 j++;
nickjillings@1450 863 i++;
nickjillings@1450 864 }
nickjillings@1450 865 audioHolder.postTest.options.pop();
nickjillings@1450 866 popupInstance.state = 5;
nickjillings@1450 867 popupInstance.advanceState();
nickjillings@1450 868 };
nickjillings@1450 869 deleteH.appendChild(deleteButton);
nickjillings@1450 870 entry.appendChild(deleteH);
nickjillings@1450 871 postHolder.appendChild(entry);
nickjillings@1450 872 }
nickjillings@1450 873
nickjillings@1450 874 var entry = document.createElement('div');
nickjillings@1450 875 entry.style.width = "456px";
nickjillings@1450 876 entry.style.height= "20px";
nickjillings@1450 877 entry.style.margin= "2px";
nickjillings@1450 878 entry.style.borderBottom = "#DDD";
nickjillings@1450 879 entry.style.borderBottomWidth = "1px";
nickjillings@1450 880 entry.style.borderBottomStyle = "solid";
nickjillings@1450 881 entry.align = "center";
nickjillings@1450 882 var addPost = document.createElement('button');
nickjillings@1450 883 addPost.className = "popupButton";
nickjillings@1450 884 addPost.textContent = "Add New Entry";
nickjillings@1450 885 addPost.style.height = "20px";
nickjillings@1450 886 addPost.onclick = function()
nickjillings@1450 887 {
nickjillings@1450 888 popupInstance.dataTransfer = new function() {
nickjillings@1450 889 this.title = "New Pre Test Node";
nickjillings@1450 890 this.parent = specificationNode.audioHolders[specificationNode.audioHolders.length-1].postTest;
nickjillings@1450 891 this.node = null;
nickjillings@1450 892 this.previousState = 5;
nickjillings@1450 893 };
nickjillings@1450 894 popupInstance.advanceState();
nickjillings@1450 895 };
nickjillings@1450 896 entry.appendChild(addPost);
nickjillings@1450 897 postHolder.appendChild(entry);
nickjillings@1450 898
nickjillings@1450 899 var button = document.createElement('button');
nickjillings@1450 900 button.id = 'submit';
nickjillings@1450 901 button.className = "popupButton";
nickjillings@1450 902 button.textContent = "Finish";
nickjillings@1450 903 button.onclick = function(event)
nickjillings@1450 904 {
nickjillings@1450 905 popupInstance.state = 7;
nickjillings@1450 906 popupInstance.advanceState();
nickjillings@1450 907 };
nickjillings@1450 908 this.popupFooter.appendChild(button);
nickjillings@1450 909 button = document.createElement('button');
nickjillings@1450 910 button.id = 'submit';
nickjillings@1450 911 button.className = "popupButton";
nickjillings@1450 912 button.textContent = "Add Another Page";
nickjillings@1450 913 button.onclick = function(event)
nickjillings@1450 914 {
nickjillings@1450 915 popupInstance.state = 3;
nickjillings@1450 916 popupInstance.advanceState();
nickjillings@1450 917 };
nickjillings@1450 918 this.popupFooter.appendChild(button);
nickjillings@1450 919 break;
nickjillings@1450 920 case 6:
nickjillings@1450 921 this.popupTitleText.textContent = this.dataTransfer.title;
nickjillings@1450 922 var span = document.createElement('span');
nickjillings@1450 923 span.textContent = "Select survey settings here";
nickjillings@1450 924 this.popupBody.appendChild(span);
nickjillings@1450 925 var div = document.createElement('div');
nickjillings@1450 926 span = document.createElement("span");
nickjillings@1450 927 span.textContent = "Survey Type";
nickjillings@1450 928 var select = document.createElement("select");
nickjillings@1450 929 select.id="survey-select";
nickjillings@1450 930 var option = document.createElement('option');
nickjillings@1450 931 option.textContent = "Statement";
nickjillings@1450 932 option.value = "statement";
nickjillings@1450 933 select.appendChild(option);
nickjillings@1450 934 option = document.createElement('option');
nickjillings@1450 935 option.textContent = "Question";
nickjillings@1450 936 option.value = "question";
nickjillings@1450 937 select.appendChild(option);
nickjillings@1450 938 option = document.createElement('option');
nickjillings@1450 939 option.textContent = "Number";
nickjillings@1450 940 option.value = "number";
nickjillings@1450 941 select.appendChild(option);
nickjillings@1450 942 option = document.createElement('option');
nickjillings@1450 943 option.textContent = "Radio";
nickjillings@1450 944 option.value = "radio";
nickjillings@1450 945 select.appendChild(option);
nickjillings@1450 946 option = document.createElement('option');
nickjillings@1450 947 option.textContent = "Checkbox";
nickjillings@1450 948 option.value = "checkbox";
nickjillings@1450 949 select.appendChild(option);
nickjillings@1450 950 this.popupBody.appendChild(select);
nickjillings@1450 951 var options = document.createElement('div');
nickjillings@1450 952 options.id = "survey-options";
nickjillings@1450 953 this.popupBody.appendChild(options);
nickjillings@1450 954 var button = document.createElement('button');
nickjillings@1450 955 button.id = 'submit';
nickjillings@1450 956 button.className = "popupButton";
nickjillings@1450 957 button.textContent = "Add";
nickjillings@1450 958 button.onclick = function(event)
nickjillings@1450 959 {
nickjillings@1450 960 var parent = popupInstance.dataTransfer.parent;
nickjillings@1450 961 if (popupInstance.dataTransfer.node == null)
nickjillings@1450 962 {
nickjillings@1450 963 var node = new parent.OptionNode();
nickjillings@1450 964 } else
nickjillings@1450 965 {
nickjillings@1450 966 var node = popupInstance.dataTransfer.node;
nickjillings@1450 967 }
nickjillings@1450 968 node.type = document.getElementById("survey-select").value;
nickjillings@1450 969 switch(node.type)
nickjillings@1450 970 {
nickjillings@1450 971 case "statement":
nickjillings@1450 972 node.statement = document.getElementById("statement").value;
nickjillings@1450 973 break;
nickjillings@1450 974 case "question":
nickjillings@1450 975 node.question = document.getElementById("question").value;
nickjillings@1450 976 node.id = document.getElementById("ID").value;
nickjillings@1450 977 node.mandatory = document.getElementById("mandatory").checked;
nickjillings@1450 978 node.boxsize = document.getElementById("boxsize").value;
nickjillings@1450 979 break;
nickjillings@1450 980 }
nickjillings@1450 981 if (popupInstance.dataTransfer.node == null)
nickjillings@1450 982 {parent.options.push(node);}
nickjillings@1450 983 popupInstance.state = popupInstance.dataTransfer.previousState;
nickjillings@1450 984 popupInstance.advanceState();
nickjillings@1450 985 };
nickjillings@1450 986 this.popupFooter.appendChild(button);
nickjillings@1450 987 select.onchange = function()
nickjillings@1450 988 {
nickjillings@1450 989 var options = document.getElementById("survey-options");
nickjillings@1450 990 options.innerHTML = null;
nickjillings@1450 991 switch(this.value)
nickjillings@1450 992 {
nickjillings@1450 993 case "statement":
nickjillings@1450 994 var span = document.createElement('span');
nickjillings@1450 995 span.textContent = "Enter Statement";
nickjillings@1450 996 var tA = document.createElement('textarea');
nickjillings@1450 997 tA.id = "statement";
nickjillings@1450 998 tA.style.width = "460px";
nickjillings@1450 999 tA.style.height = "96px";
nickjillings@1450 1000 if (popupInstance.dataTransfer.node != null)
nickjillings@1450 1001 {tA.value = this.dataTransfer.node.statement;}
nickjillings@1450 1002 options.appendChild(span);
nickjillings@1450 1003 options.appendChild(tA);
nickjillings@1450 1004 break;
nickjillings@1450 1005 case "question":
nickjillings@1450 1006 var span = document.createElement('span');
nickjillings@1450 1007 span.textContent = "Enter Question";
nickjillings@1450 1008 var tA = document.createElement('textarea');
nickjillings@1450 1009 tA.style.width = "460px";
nickjillings@1450 1010 tA.style.height = "54px";
nickjillings@1450 1011 tA.id = "question";
nickjillings@1450 1012 options.appendChild(span);
nickjillings@1450 1013 options.appendChild(tA);
nickjillings@1450 1014 var div = document.createElement('div');
nickjillings@1450 1015 var input = document.createElement('input');
nickjillings@1450 1016 input.id = "ID";
nickjillings@1450 1017 span = document.createElement('span');
nickjillings@1450 1018 span.textContent = "ID:";
nickjillings@1450 1019 div.appendChild(span);
nickjillings@1450 1020 div.appendChild(input);
nickjillings@1450 1021 options.appendChild(div);
nickjillings@1450 1022 div = document.createElement('div');
nickjillings@1450 1023 input = document.createElement('input');
nickjillings@1450 1024 input.type = "checkbox";
nickjillings@1450 1025 input.id = "mandatory";
nickjillings@1450 1026 span = document.createElement('span');
nickjillings@1450 1027 span.textContent = "Mandatory";
nickjillings@1450 1028 div.appendChild(span);
nickjillings@1450 1029 div.appendChild(input);
nickjillings@1450 1030 options.appendChild(div);
nickjillings@1450 1031 div = document.createElement('div');
nickjillings@1450 1032 var boxsize = document.createElement("select");
nickjillings@1450 1033 boxsize.id = "boxsize";
nickjillings@1450 1034 var selOpt = document.createElement("option");
nickjillings@1450 1035 selOpt.value = "normal";
nickjillings@1450 1036 selOpt.textContent = "Normal";
nickjillings@1450 1037 boxsize.appendChild(selOpt);
nickjillings@1450 1038 selOpt = document.createElement("option");
nickjillings@1450 1039 selOpt.value = "small";
nickjillings@1450 1040 selOpt.textContent = "Small";
nickjillings@1450 1041 boxsize.appendChild(selOpt);
nickjillings@1450 1042 selOpt = document.createElement("option");
nickjillings@1450 1043 selOpt.value = "large";
nickjillings@1450 1044 selOpt.textContent = "Large";
nickjillings@1450 1045 boxsize.appendChild(selOpt);
nickjillings@1450 1046 selOpt = document.createElement("option");
nickjillings@1450 1047 selOpt.value = "huge";
nickjillings@1450 1048 selOpt.textContent = "Huge";
nickjillings@1450 1049 boxsize.appendChild(selOpt);
nickjillings@1450 1050 span = document.createElement('span');
nickjillings@1450 1051 span.textContent = "Response Text Area";
nickjillings@1450 1052 div.appendChild(span);
nickjillings@1450 1053 div.appendChild(boxsize);
nickjillings@1450 1054 options.appendChild(div);
nickjillings@1450 1055 if (popupInstance.dataTransfer.node != null)
nickjillings@1450 1056 {
nickjillings@1450 1057 tA.value = popupInstance.dataTransfer.node.question;
nickjillings@1450 1058 document.getElementById("ID").value = popupInstance.dataTransfer.node.id;
nickjillings@1450 1059 document.getElementById("mandatory").value = popupInstance.dataTransfer.node.mandatory;
nickjillings@1450 1060 document.getElementById("boxsize").value = popupInstance.dataTransfer.node.boxsize;
nickjillings@1450 1061 }
nickjillings@1450 1062 break;
nickjillings@1450 1063 case "number":
nickjillings@1450 1064 var span = document.createElement('span');
nickjillings@1450 1065 span.textContent = "Enter Question";
nickjillings@1450 1066 var tA = document.createElement('textarea');
nickjillings@1450 1067 tA.style.width = "460px";
nickjillings@1450 1068 tA.style.height = "54px";
nickjillings@1450 1069 tA.id = "question";
nickjillings@1450 1070 options.appendChild(span);
nickjillings@1450 1071 options.appendChild(tA);
nickjillings@1450 1072 var div = document.createElement('div');
nickjillings@1450 1073 var input = document.createElement('input');
nickjillings@1450 1074 input.id = "ID";
nickjillings@1450 1075 span = document.createElement('span');
nickjillings@1450 1076 span.textContent = "ID:";
nickjillings@1450 1077 div.appendChild(span);
nickjillings@1450 1078 div.appendChild(input);
nickjillings@1450 1079 options.appendChild(div);
nickjillings@1450 1080 div = document.createElement('div');
nickjillings@1450 1081 input = document.createElement('input');
nickjillings@1450 1082 input.type = "checkbox";
nickjillings@1450 1083 input.id = "mandatory";
nickjillings@1450 1084 span = document.createElement('span');
nickjillings@1450 1085 span.textContent = "Mandatory";
nickjillings@1450 1086 div.appendChild(span);
nickjillings@1450 1087 div.appendChild(input);
nickjillings@1450 1088 options.appendChild(div);
nickjillings@1450 1089 div = document.createElement('div');
nickjillings@1450 1090 break;
nickjillings@1450 1091 }
nickjillings@1450 1092 };
nickjillings@1450 1093 if (this.dataTransfer.node != null)
nickjillings@1450 1094 {
nickjillings@1450 1095 select.value = this.dataTransfer.node.type;
nickjillings@1450 1096 }
nickjillings@1450 1097 select.onchange();
nickjillings@1450 1098 break;
nickjillings@1450 1099 case 7:
nickjillings@1450 1100 this.dataTransfer = null;
nickjillings@1450 1101 this.popupTitleText.textContent = "Test Session - Pre/Post Survey";
nickjillings@1450 1102 var span = document.createElement('span');
nickjillings@1450 1103 span.textContent = "Add your pre test session and post test session survey options here";
nickjillings@1450 1104 this.popupBody.appendChild(span);
nickjillings@1450 1105 var preHolder = document.createElement('div');
nickjillings@1450 1106 preHolder.id = "preHolder";
nickjillings@1450 1107 preHolder.style.width = "460px";
nickjillings@1450 1108 preHolder.style.minHeight = "100px";
nickjillings@1450 1109 preHolder.style.maxHeight = "220px";
nickjillings@1450 1110 preHolder.style.overflow = 'auto';
nickjillings@1450 1111 preHolder.style.border = "black";
nickjillings@1450 1112 preHolder.style.borderStyle = "solid";
nickjillings@1450 1113 preHolder.style.borderWidth = "1px";
nickjillings@1450 1114 this.popupBody.appendChild(preHolder);
nickjillings@1450 1115 var preHeaderHolder = document.createElement('div');
nickjillings@1450 1116 preHeaderHolder.style.width = "456px";
nickjillings@1450 1117 preHeaderHolder.style.height= "20px";
nickjillings@1450 1118 preHeaderHolder.style.margin= "2px";
nickjillings@1450 1119 preHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1450 1120 preHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1450 1121 preHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1450 1122 var mvH = document.createElement('div');
nickjillings@1450 1123 mvH.className = "dndheaderelement";
nickjillings@1450 1124 mvH.style.width = "50px";
nickjillings@1450 1125 var text = document.createElement('span');
nickjillings@1450 1126 text.textContent = "Order";
nickjillings@1450 1127 mvH.appendChild(text);
nickjillings@1450 1128 preHeaderHolder.appendChild(mvH);
nickjillings@1450 1129 var idH = document.createElement('div');
nickjillings@1450 1130 idH.className = "dndheaderelement";
nickjillings@1450 1131 idH.style.width = "150px";
nickjillings@1450 1132 text = document.createElement('span');
nickjillings@1450 1133 text.textContent = "ID";
nickjillings@1450 1134 idH.appendChild(text);
nickjillings@1450 1135 preHeaderHolder.appendChild(idH);
nickjillings@1450 1136 var tH = document.createElement('div');
nickjillings@1450 1137 tH.className = "dndheaderelement";
nickjillings@1450 1138 tH.style.width = "150px";
nickjillings@1450 1139 text = document.createElement('span');
nickjillings@1450 1140 text.textContent = "Type";
nickjillings@1450 1141 tH.appendChild(text);
nickjillings@1450 1142 preHeaderHolder.appendChild(tH);
nickjillings@1450 1143 var editH = document.createElement('div');
nickjillings@1450 1144 editH.className = "dndheaderelement";
nickjillings@1450 1145 editH.style.width = "50px";
nickjillings@1450 1146 text = document.createElement('span');
nickjillings@1450 1147 text.textContent = "Edit";
nickjillings@1450 1148 editH.appendChild(text);
nickjillings@1450 1149 preHeaderHolder.appendChild(editH);
nickjillings@1450 1150 var deleteH = document.createElement('div');
nickjillings@1450 1151 deleteH.className = "dndheaderelement";
nickjillings@1450 1152 deleteH.style.width = "50px";
nickjillings@1450 1153 text = document.createElement('span');
nickjillings@1450 1154 text.textContent = "Delete";
nickjillings@1450 1155 deleteH.appendChild(text);
nickjillings@1450 1156 preHeaderHolder.appendChild(deleteH);
nickjillings@1450 1157 preHolder.appendChild(preHeaderHolder);
nickjillings@1450 1158
nickjillings@1450 1159
nickjillings@1450 1160 for (var i=0; i<specificationNode.preTest.options.length; i++)
nickjillings@1450 1161 {
nickjillings@1450 1162 var optionNode = specificationNode.preTest.options[i];
nickjillings@1450 1163 var entry = document.createElement('div');
nickjillings@1450 1164 entry.style.width = "456px";
nickjillings@1450 1165 entry.style.height= "20px";
nickjillings@1450 1166 entry.style.margin= "2px";
nickjillings@1450 1167 entry.style.borderBottom = "#DDD";
nickjillings@1450 1168 entry.style.borderBottomWidth = "1px";
nickjillings@1450 1169 entry.style.borderBottomStyle = "solid";
nickjillings@1450 1170 entry.setAttribute("node-id",i);
nickjillings@1450 1171 var node = specificationNode.preTest.options[i];
nickjillings@1450 1172 var mvH = document.createElement('div');
nickjillings@1450 1173 mvH.className = "dndheaderelement";
nickjillings@1450 1174 mvH.style.width = "50px";
nickjillings@1450 1175 var mvup = document.createElement("button");
nickjillings@1450 1176 mvup.textContent = "Up";
nickjillings@1450 1177 mvup.style.width = "25px";
nickjillings@1450 1178 mvup.style.padding = "1px 0px";
nickjillings@1450 1179 mvup.onclick = function()
nickjillings@1450 1180 {
nickjillings@1450 1181 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1182 if (i != 0)
nickjillings@1450 1183 {
nickjillings@1450 1184 var next = specificationNode.preTest.options[i-1];
nickjillings@1450 1185 var cur = specificationNode.preTest.options[i];
nickjillings@1450 1186 specificationNode.preTest.options[i-1] = cur;
nickjillings@1450 1187 specificationNode.preTest.options[i] = next;
nickjillings@1450 1188 popupInstance.state = 7;
nickjillings@1450 1189 popupInstance.advanceState();
nickjillings@1450 1190 }
nickjillings@1450 1191 };
nickjillings@1450 1192 mvH.appendChild(mvup);
nickjillings@1450 1193 var mvdn = document.createElement("button");
nickjillings@1450 1194 mvdn.textContent = "Dn";
nickjillings@1450 1195 mvdn.style.width = "25px";
nickjillings@1450 1196 mvdn.style.padding = "1px 0px";
nickjillings@1450 1197 mvdn.onclick = function()
nickjillings@1450 1198 {
nickjillings@1450 1199 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1200 if (i != specificationNode.preTest.options.length-1)
nickjillings@1450 1201 {
nickjillings@1450 1202 var next = specificationNode.preTest.options[i+1];
nickjillings@1450 1203 var cur = specificationNode.preTest.options[i];
nickjillings@1450 1204 specificationNode.preTest.options[i+1] = cur;
nickjillings@1450 1205 specificationNode.preTest.options[i] = next;
nickjillings@1450 1206 popupInstance.state = 7;
nickjillings@1450 1207 popupInstance.advanceState();
nickjillings@1450 1208 }
nickjillings@1450 1209 };
nickjillings@1450 1210 mvH.appendChild(mvdn);
nickjillings@1450 1211 entry.appendChild(mvH);
nickjillings@1450 1212 var idH = document.createElement('div');
nickjillings@1450 1213 idH.className = "dndheaderelement";
nickjillings@1450 1214 idH.style.width = "150px";
nickjillings@1450 1215 if (optionNode.type != "statement")
nickjillings@1450 1216 {
nickjillings@1450 1217 var span = document.createElement('span');
nickjillings@1450 1218 span.textContent = optionNode.id;
nickjillings@1450 1219 idH.appendChild(span);
nickjillings@1450 1220 }
nickjillings@1450 1221 entry.appendChild(idH);
nickjillings@1450 1222 var typeH = document.createElement('div');
nickjillings@1450 1223 typeH.className = "dndheaderelement";
nickjillings@1450 1224 typeH.style.width = "150px";
nickjillings@1450 1225 var span = document.createElement('span');
nickjillings@1450 1226 span.textContent = optionNode.type;
nickjillings@1450 1227 typeH.appendChild(span);
nickjillings@1450 1228 entry.appendChild(typeH);
nickjillings@1450 1229 var editH = document.createElement('div');
nickjillings@1450 1230 editH.className = "dndheaderelement";
nickjillings@1450 1231 editH.style.width = "50px";
nickjillings@1450 1232 var editButton = document.createElement("button");
nickjillings@1450 1233 editButton.textContent = "Edit";
nickjillings@1450 1234 editButton.style.width = "48px";
nickjillings@1450 1235 editButton.style.padding = "1px 0px";
nickjillings@1450 1236 editButton.onclick = function()
nickjillings@1450 1237 {
nickjillings@1450 1238 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1239 popupInstance.dataTransfer = new function() {
nickjillings@1450 1240 this.title = "Edit Test Node";
nickjillings@1450 1241 this.parent = specificationNode.preTest;
nickjillings@1450 1242 this.node = this.parent.options[i];
nickjillings@1450 1243 this.previousState = 7;
nickjillings@1450 1244 };
nickjillings@1450 1245 popupInstace.state = 6;
nickjillings@1450 1246 popupInstance.advanceState();
nickjillings@1450 1247 };
nickjillings@1450 1248 editH.appendChild(editButton);
nickjillings@1450 1249 entry.appendChild(editH);
nickjillings@1450 1250 var deleteH = document.createElement('div');
nickjillings@1450 1251 deleteH.className = "dndheaderelement";
nickjillings@1450 1252 deleteH.style.width = "50px";
nickjillings@1450 1253 var deleteButton = document.createElement("button");
nickjillings@1450 1254 deleteButton.textContent = "Del";
nickjillings@1450 1255 deleteButton.style.width = "48px";
nickjillings@1450 1256 deleteButton.style.padding = "1px 0px";
nickjillings@1450 1257 deleteButton.onclick = function()
nickjillings@1450 1258 {
nickjillings@1450 1259 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1260 var j = i+1;
nickjillings@1450 1261 while(j < specificationNode.preTest.options.length)
nickjillings@1450 1262 {
nickjillings@1450 1263 specificationNode.preTest.options[i] = specificationNode.preTest.options[j];
nickjillings@1450 1264 j++;
nickjillings@1450 1265 i++;
nickjillings@1450 1266 }
nickjillings@1450 1267 specificationNode.preTest.options.pop();
nickjillings@1450 1268 popupInstance.state = 7;
nickjillings@1450 1269 popupInstance.advanceState();
nickjillings@1450 1270 };
nickjillings@1450 1271 deleteH.appendChild(deleteButton);
nickjillings@1450 1272 entry.appendChild(deleteH);
nickjillings@1450 1273 preHolder.appendChild(entry);
nickjillings@1450 1274 }
nickjillings@1450 1275 var entry = document.createElement('div');
nickjillings@1450 1276 entry.style.width = "456px";
nickjillings@1450 1277 entry.style.height= "20px";
nickjillings@1450 1278 entry.style.margin= "2px";
nickjillings@1450 1279 entry.style.borderBottom = "#DDD";
nickjillings@1450 1280 entry.style.borderBottomWidth = "1px";
nickjillings@1450 1281 entry.style.borderBottomStyle = "solid";
nickjillings@1450 1282 entry.align = "center";
nickjillings@1450 1283 var addPre = document.createElement('button');
nickjillings@1450 1284 addPre.className = "popupButton";
nickjillings@1450 1285 addPre.textContent = "Add New Entry";
nickjillings@1450 1286 addPre.style.height = "20px";
nickjillings@1450 1287 addPre.onclick = function()
nickjillings@1450 1288 {
nickjillings@1450 1289 popupInstance.dataTransfer = new function() {
nickjillings@1450 1290 this.title = "New Pre Test Node";
nickjillings@1450 1291 this.parent = specificationNode.preTest;
nickjillings@1450 1292 this.node = null;
nickjillings@1450 1293 this.previousState = 7;
nickjillings@1450 1294 };
nickjillings@1450 1295 popupInstance.state = 6;
nickjillings@1450 1296 popupInstance.advanceState();
nickjillings@1450 1297 };
nickjillings@1450 1298 entry.appendChild(addPre);
nickjillings@1450 1299 preHolder.appendChild(entry);
nickjillings@1450 1300
nickjillings@1450 1301 var span = document.createElement('span');
nickjillings@1450 1302 span.textContent = "Add your post test page options here";
nickjillings@1450 1303 this.popupBody.appendChild(span);
nickjillings@1450 1304 var postHolder = document.createElement('div');
nickjillings@1450 1305 postHolder.id = "preHolder";
nickjillings@1450 1306 postHolder.style.width = "100%";
nickjillings@1450 1307 postHolder.style.minHeight = "100px";
nickjillings@1450 1308 postHolder.style.maxHeight = "220px";
nickjillings@1450 1309 postHolder.style.overflow = 'auto';
nickjillings@1450 1310 postHolder.style.border = "black";
nickjillings@1450 1311 postHolder.style.borderStyle = "solid";
nickjillings@1450 1312 postHolder.style.borderWidth = "1px";
nickjillings@1450 1313 this.popupBody.appendChild(postHolder);
nickjillings@1450 1314 var postHeaderHolder = document.createElement('div');
nickjillings@1450 1315 postHeaderHolder.style.width = "456px";
nickjillings@1450 1316 postHeaderHolder.style.height= "20px";
nickjillings@1450 1317 postHeaderHolder.style.margin= "2px";
nickjillings@1450 1318 postHeaderHolder.style.borderBottom = "#DDD";
nickjillings@1450 1319 postHeaderHolder.style.borderBottomWidth = "1px";
nickjillings@1450 1320 postHeaderHolder.style.borderBottomStyle = "solid";
nickjillings@1450 1321 var mvH = document.createElement('div');
nickjillings@1450 1322 mvH.className = "dndheaderelement";
nickjillings@1450 1323 mvH.style.width = "50px";
nickjillings@1450 1324 var text = document.createElement('span');
nickjillings@1450 1325 text.textContent = "Order";
nickjillings@1450 1326 mvH.appendChild(text);
nickjillings@1450 1327 postHeaderHolder.appendChild(mvH);
nickjillings@1450 1328 var idH = document.createElement('div');
nickjillings@1450 1329 idH.className = "dndheaderelement";
nickjillings@1450 1330 idH.style.width = "150px";
nickjillings@1450 1331 text = document.createElement('span');
nickjillings@1450 1332 text.textContent = "ID";
nickjillings@1450 1333 idH.appendChild(text);
nickjillings@1450 1334 postHeaderHolder.appendChild(idH);
nickjillings@1450 1335 var tH = document.createElement('div');
nickjillings@1450 1336 tH.className = "dndheaderelement";
nickjillings@1450 1337 tH.style.width = "150px";
nickjillings@1450 1338 text = document.createElement('span');
nickjillings@1450 1339 text.textContent = "Type";
nickjillings@1450 1340 tH.appendChild(text);
nickjillings@1450 1341 postHeaderHolder.appendChild(tH);
nickjillings@1450 1342 var editH = document.createElement('div');
nickjillings@1450 1343 editH.className = "dndheaderelement";
nickjillings@1450 1344 editH.style.width = "50px";
nickjillings@1450 1345 text = document.createElement('span');
nickjillings@1450 1346 text.textContent = "Edit";
nickjillings@1450 1347 editH.appendChild(text);
nickjillings@1450 1348 postHeaderHolder.appendChild(editH);
nickjillings@1450 1349 var deleteH = document.createElement('div');
nickjillings@1450 1350 deleteH.className = "dndheaderelement";
nickjillings@1450 1351 deleteH.style.width = "50px";
nickjillings@1450 1352 text = document.createElement('span');
nickjillings@1450 1353 text.textContent = "Delete";
nickjillings@1450 1354 deleteH.appendChild(text);
nickjillings@1450 1355 postHeaderHolder.appendChild(deleteH);
nickjillings@1450 1356 postHolder.appendChild(postHeaderHolder);
nickjillings@1450 1357
nickjillings@1450 1358 for (var i=0; i<specificationNode.postTest.options.length; i++)
nickjillings@1450 1359 {
nickjillings@1450 1360 var optionNode = specificationNode.postTest.options[i];
nickjillings@1450 1361 var entry = document.createElement('div');
nickjillings@1450 1362 entry.style.width = "456px";
nickjillings@1450 1363 entry.style.height= "20px";
nickjillings@1450 1364 entry.style.margin= "2px";
nickjillings@1450 1365 entry.style.borderBottom = "#DDD";
nickjillings@1450 1366 entry.style.borderBottomWidth = "1px";
nickjillings@1450 1367 entry.style.borderBottomStyle = "solid";
nickjillings@1450 1368 entry.setAttribute("node-id",i);
nickjillings@1450 1369 var node = specificationNode.postTest.options[i];
nickjillings@1450 1370 var mvH = document.createElement('div');
nickjillings@1450 1371 mvH.className = "dndheaderelement";
nickjillings@1450 1372 mvH.style.width = "50px";
nickjillings@1450 1373 var mvup = document.createElement("button");
nickjillings@1450 1374 mvup.textContent = "Up";
nickjillings@1450 1375 mvup.style.width = "25px";
nickjillings@1450 1376 mvup.style.padding = "1px 0px";
nickjillings@1450 1377 mvup.onclick = function()
nickjillings@1450 1378 {
nickjillings@1450 1379 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1380 if (i != 0)
nickjillings@1450 1381 {
nickjillings@1450 1382 var next = specificationNode.postTest.options[i-1];
nickjillings@1450 1383 var cur = specificationNode.postTest.options[i];
nickjillings@1450 1384 specificationNode.postTest.options[i-1] = cur;
nickjillings@1450 1385 specificationNode.postTest.options[i] = next;
nickjillings@1450 1386 popupInstance.state = 7;
nickjillings@1450 1387 popupInstance.advanceState();
nickjillings@1450 1388 }
nickjillings@1450 1389 };
nickjillings@1450 1390 mvH.appendChild(mvup);
nickjillings@1450 1391 var mvdn = document.createElement("button");
nickjillings@1450 1392 mvdn.textContent = "Dn";
nickjillings@1450 1393 mvdn.style.width = "25px";
nickjillings@1450 1394 mvdn.style.padding = "1px 0px";
nickjillings@1450 1395 mvdn.onclick = function()
nickjillings@1450 1396 {
nickjillings@1450 1397 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1398 if (i != specificationNode.postTest.options.length-1)
nickjillings@1450 1399 {
nickjillings@1450 1400 var next = specificationNode.postTest.options[i+1];
nickjillings@1450 1401 var cur = specificationNode.postTest.options[i];
nickjillings@1450 1402 specificationNode.postTest.options[i+1] = cur;
nickjillings@1450 1403 specificationNode.postTest.options[i] = next;
nickjillings@1450 1404 popupInstance.state = 7;
nickjillings@1450 1405 popupInstance.advanceState();
nickjillings@1450 1406 }
nickjillings@1450 1407 };
nickjillings@1450 1408 mvH.appendChild(mvdn);
nickjillings@1450 1409 entry.appendChild(mvH);
nickjillings@1450 1410 var idH = document.createElement('div');
nickjillings@1450 1411 idH.className = "dndheaderelement";
nickjillings@1450 1412 idH.style.width = "150px";
nickjillings@1450 1413 if (optionNode.type != "statement")
nickjillings@1450 1414 {
nickjillings@1450 1415 var span = document.createElement('span');
nickjillings@1450 1416 span.textContent = optionNode.id;
nickjillings@1450 1417 idH.appendChild(span);
nickjillings@1450 1418 }
nickjillings@1450 1419 entry.appendChild(idH);
nickjillings@1450 1420 var typeH = document.createElement('div');
nickjillings@1450 1421 typeH.className = "dndheaderelement";
nickjillings@1450 1422 typeH.style.width = "150px";
nickjillings@1450 1423 var span = document.createElement('span');
nickjillings@1450 1424 span.textContent = optionNode.type;
nickjillings@1450 1425 typeH.appendChild(span);
nickjillings@1450 1426 entry.appendChild(typeH);
nickjillings@1450 1427 var editH = document.createElement('div');
nickjillings@1450 1428 editH.className = "dndheaderelement";
nickjillings@1450 1429 editH.style.width = "50px";
nickjillings@1450 1430 var editButton = document.createElement("button");
nickjillings@1450 1431 editButton.textContent = "Edit";
nickjillings@1450 1432 editButton.style.width = "48px";
nickjillings@1450 1433 editButton.style.padding = "1px 0px";
nickjillings@1450 1434 editButton.onclick = function()
nickjillings@1450 1435 {
nickjillings@1450 1436 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1437 popupInstance.dataTransfer = new function() {
nickjillings@1450 1438 this.title = "Edit Test Node";
nickjillings@1450 1439 this.parent = specificationNode.postTest;
nickjillings@1450 1440 this.node = this.parent.options[i];
nickjillings@1450 1441 this.previousState = 7;
nickjillings@1450 1442 };
nickjillings@1450 1443 popupInstance.state = 6;
nickjillings@1450 1444 popupInstance.advanceState();
nickjillings@1450 1445 };
nickjillings@1450 1446 editH.appendChild(editButton);
nickjillings@1450 1447 entry.appendChild(editH);
nickjillings@1450 1448 var deleteH = document.createElement('div');
nickjillings@1450 1449 deleteH.className = "dndheaderelement";
nickjillings@1450 1450 deleteH.style.width = "50px";
nickjillings@1450 1451 var deleteButton = document.createElement("button");
nickjillings@1450 1452 deleteButton.textContent = "Del";
nickjillings@1450 1453 deleteButton.style.width = "48px";
nickjillings@1450 1454 deleteButton.style.padding = "1px 0px";
nickjillings@1450 1455 deleteButton.onclick = function()
nickjillings@1450 1456 {
nickjillings@1450 1457 var i = Number(event.currentTarget.parentElement.parentElement.getAttribute("node-id"));
nickjillings@1450 1458 var j = i+1;
nickjillings@1450 1459 while(j < specificationNode.postTest.options.length)
nickjillings@1450 1460 {
nickjillings@1450 1461 specificationNode.postTest.options[i] = specificationNode.postTest.options[j];
nickjillings@1450 1462 j++;
nickjillings@1450 1463 i++;
nickjillings@1450 1464 }
nickjillings@1450 1465 audioHolder.postTest.options.pop();
nickjillings@1450 1466 popupInstance.state = 7;
nickjillings@1450 1467 popupInstance.advanceState();
nickjillings@1450 1468 };
nickjillings@1450 1469 deleteH.appendChild(deleteButton);
nickjillings@1450 1470 entry.appendChild(deleteH);
nickjillings@1450 1471 postHolder.appendChild(entry);
nickjillings@1450 1472 }
nickjillings@1450 1473
nickjillings@1450 1474 var entry = document.createElement('div');
nickjillings@1450 1475 entry.style.width = "456px";
nickjillings@1450 1476 entry.style.height= "20px";
nickjillings@1450 1477 entry.style.margin= "2px";
nickjillings@1450 1478 entry.style.borderBottom = "#DDD";
nickjillings@1450 1479 entry.style.borderBottomWidth = "1px";
nickjillings@1450 1480 entry.style.borderBottomStyle = "solid";
nickjillings@1450 1481 entry.align = "center";
nickjillings@1450 1482 var addPost = document.createElement('button');
nickjillings@1450 1483 addPost.className = "popupButton";
nickjillings@1450 1484 addPost.textContent = "Add New Entry";
nickjillings@1450 1485 addPost.style.height = "20px";
nickjillings@1450 1486 addPost.onclick = function()
nickjillings@1450 1487 {
nickjillings@1450 1488 popupInstance.dataTransfer = new function() {
nickjillings@1450 1489 this.title = "New Pre Test Node";
nickjillings@1450 1490 this.parent = specificationNode.postTest;
nickjillings@1450 1491 this.node = null;
nickjillings@1450 1492 this.previousState = 7;
nickjillings@1450 1493 };
nickjillings@1450 1494 popupInstance.state = 6;
nickjillings@1450 1495 popupInstance.advanceState();
nickjillings@1450 1496 };
nickjillings@1450 1497 entry.appendChild(addPost);
nickjillings@1450 1498 postHolder.appendChild(entry);
nickjillings@1450 1499
nickjillings@1450 1500 var button = document.createElement('button');
nickjillings@1450 1501 button.id = 'submit';
nickjillings@1450 1502 button.className = "popupButton";
nickjillings@1450 1503 button.textContent = "Finish";
nickjillings@1450 1504 button.onclick = function(event)
nickjillings@1450 1505 {
nickjillings@1450 1506 popupInstance.state = 8;
nickjillings@1450 1507 popupInstance.advanceState();
nickjillings@1450 1508 };
nickjillings@1450 1509 this.popupFooter.appendChild(button);
nickjillings@1450 1510 break;
nickjillings@1450 1511 case 8:
nickjillings@1450 1512 this.hidePopup();
nickjillings@1450 1513 this.state = 0;
nickjillings@1450 1514 SpecficationToHTML();
nickjillings@1450 1515 }
nickjillings@1450 1516 this.state++;
nickjillings@1450 1517 };
nickjillings@1450 1518 };
nickjillings@1450 1519
nickjillings@1450 1520 function audioObject()
nickjillings@1450 1521 {
nickjillings@1450 1522 // Used to hold audio information in buffers for quick playback
nickjillings@1450 1523 this.bufferObject;
nickjillings@1450 1524 this.bufferNode = undefined;
nickjillings@1450 1525 this.state = 0;
nickjillings@1450 1526 this.gain = audioContext.createGain();
nickjillings@1450 1527 this.gain.connect(audioContext.destination);
nickjillings@1450 1528 this.include = true;
nickjillings@1450 1529 this.id = undefined;
nickjillings@1450 1530 this.file = undefined;
nickjillings@1450 1531
nickjillings@1450 1532 this.play = function()
nickjillings@1450 1533 {
nickjillings@1450 1534 if (this.bufferNode != undefined)
nickjillings@1450 1535 {
nickjillings@1450 1536 this.bufferNode.stop(0);
nickjillings@1450 1537 this.bufferNode = undefined;
nickjillings@1450 1538 }
nickjillings@1450 1539 if(this.state == 1)
nickjillings@1450 1540 {
nickjillings@1450 1541 this.bufferNode = audioContext.createBufferSource();
nickjillings@1450 1542 this.bufferNode.connect(this.gain);
nickjillings@1450 1543 this.bufferNode.buffer = this.bufferObject;
nickjillings@1450 1544 this.bufferNode.onended = function(event) {
nickjillings@1450 1545 // Safari does not like using 'this' to reference the calling object!
nickjillings@1450 1546 event.currentTarget = undefined;
nickjillings@1450 1547 };
nickjillings@1450 1548 this.bufferNode.start(audioContext.currentTime);
nickjillings@1450 1549 this.bufferNode.stop(audioContext.currentTime+3);
nickjillings@1450 1550 }
nickjillings@1450 1551 };
nickjillings@1450 1552
nickjillings@1450 1553 this.constructTrack = function(file) {
nickjillings@1450 1554 var reader = new FileReader();
nickjillings@1450 1555 this.file = file;
nickjillings@1450 1556 var audioObj = this;
nickjillings@1450 1557 // Create callback to decode the data asynchronously
nickjillings@1450 1558 reader.onloadend = function() {
nickjillings@1450 1559 audioContext.decodeAudioData(reader.result, function(decodedData) {
nickjillings@1450 1560 audioObj.bufferObject = decodedData;
nickjillings@1450 1561 audioObj.state = 1;
nickjillings@1450 1562 }, function(){});
nickjillings@1450 1563 };
nickjillings@1450 1564 reader.readAsArrayBuffer(file);
nickjillings@1450 1565 };
nickjillings@1450 1566 };
nickjillings@1450 1567
nickjillings@1450 1568 function Specification() {
nickjillings@1450 1569 // Handles the decoding of the project specification XML into a simple JavaScript Object.
nickjillings@1450 1570
nickjillings@1450 1571 this.interfaceType = null;
nickjillings@1450 1572 this.commonInterface = new function()
nickjillings@1450 1573 {
nickjillings@1450 1574 this.options = [];
nickjillings@1450 1575 this.optionNode = function(input)
nickjillings@1450 1576 {
nickjillings@1450 1577 var name = input.getAttribute('name');
nickjillings@1450 1578 this.type = name;
nickjillings@1450 1579 if(this.type == "option")
nickjillings@1450 1580 {
nickjillings@1450 1581 this.name = input.id;
nickjillings@1450 1582 } else if (this.type == "check")
nickjillings@1450 1583 {
nickjillings@1450 1584 this.check = input.id;
nickjillings@1450 1585 }
nickjillings@1450 1586 };
nickjillings@1450 1587 };
nickjillings@1450 1588 this.projectReturn = null;
nickjillings@1450 1589 this.randomiseOrder = null;
nickjillings@1450 1590 this.collectMetrics = null;
nickjillings@1450 1591 this.testPages = null;
nickjillings@1450 1592 this.audioHolders = [];
nickjillings@1450 1593 this.metrics = [];
nickjillings@1450 1594
nickjillings@1450 1595 this.decode = function() {
nickjillings@1450 1596 // projectXML - DOM Parsed document
nickjillings@1450 1597 this.projectXML = projectXML.childNodes[0];
nickjillings@1450 1598 var setupNode = projectXML.getElementsByTagName('setup')[0];
nickjillings@1450 1599 this.interfaceType = setupNode.getAttribute('interface');
nickjillings@1450 1600 this.projectReturn = setupNode.getAttribute('projectReturn');
nickjillings@1450 1601 this.testPages = setupNode.getAttribute('testPages');
nickjillings@1450 1602 if (setupNode.getAttribute('randomiseOrder') == "true") {
nickjillings@1450 1603 this.randomiseOrder = true;
nickjillings@1450 1604 } else {this.randomiseOrder = false;}
nickjillings@1450 1605 if (setupNode.getAttribute('collectMetrics') == "true") {
nickjillings@1450 1606 this.collectMetrics = true;
nickjillings@1450 1607 } else {this.collectMetrics = false;}
nickjillings@1450 1608 if (isNaN(Number(this.testPages)) || this.testPages == undefined)
nickjillings@1450 1609 {
nickjillings@1450 1610 this.testPages = null;
nickjillings@1450 1611 } else {
nickjillings@1450 1612 this.testPages = Number(this.testPages);
nickjillings@1450 1613 if (this.testPages == 0) {this.testPages = null;}
nickjillings@1450 1614 }
nickjillings@1450 1615 var metricCollection = setupNode.getElementsByTagName('Metric');
nickjillings@1450 1616
nickjillings@1450 1617 this.preTest = new this.prepostNode('pretest',setupNode.getElementsByTagName('PreTest'));
nickjillings@1450 1618 this.postTest = new this.prepostNode('posttest',setupNode.getElementsByTagName('PostTest'));
nickjillings@1450 1619
nickjillings@1450 1620 if (metricCollection.length > 0) {
nickjillings@1450 1621 metricCollection = metricCollection[0].getElementsByTagName('metricEnable');
nickjillings@1450 1622 for (var i=0; i<metricCollection.length; i++) {
nickjillings@1450 1623 this.metrics.push(new this.metricNode(metricCollection[i].textContent));
nickjillings@1450 1624 }
nickjillings@1450 1625 }
nickjillings@1450 1626
nickjillings@1450 1627 var commonInterfaceNode = setupNode.getElementsByTagName('interface');
nickjillings@1450 1628 if (commonInterfaceNode.length > 0) {
nickjillings@1450 1629 commonInterfaceNode = commonInterfaceNode[0];
nickjillings@1450 1630 } else {
nickjillings@1450 1631 commonInterfaceNode = undefined;
nickjillings@1450 1632 }
nickjillings@1450 1633
nickjillings@1450 1634 this.commonInterface = new function() {
nickjillings@1450 1635 this.OptionNode = function(child) {
nickjillings@1450 1636 this.type = child.nodeName;
nickjillings@1450 1637 if (this.type == 'option')
nickjillings@1450 1638 {
nickjillings@1450 1639 this.name = child.getAttribute('name');
nickjillings@1450 1640 }
nickjillings@1450 1641 else if (this.type == 'check') {
nickjillings@1450 1642 this.check = child.getAttribute('name');
nickjillings@1450 1643 if (this.check == 'scalerange') {
nickjillings@1450 1644 this.min = child.getAttribute('min');
nickjillings@1450 1645 this.max = child.getAttribute('max');
nickjillings@1450 1646 if (this.min == null) {this.min = 1;}
nickjillings@1450 1647 else if (Number(this.min) > 1 && this.min != null) {
nickjillings@1450 1648 this.min = Number(this.min)/100;
nickjillings@1450 1649 } else {
nickjillings@1450 1650 this.min = Number(this.min);
nickjillings@1450 1651 }
nickjillings@1450 1652 if (this.max == null) {this.max = 0;}
nickjillings@1450 1653 else if (Number(this.max) > 1 && this.max != null) {
nickjillings@1450 1654 this.max = Number(this.max)/100;
nickjillings@1450 1655 } else {
nickjillings@1450 1656 this.max = Number(this.max);
nickjillings@1450 1657 }
nickjillings@1450 1658 }
nickjillings@1450 1659 } else if (this.type == 'anchor' || this.type == 'reference') {
nickjillings@1450 1660 this.value = Number(child.textContent);
nickjillings@1450 1661 this.enforce = child.getAttribute('enforce');
nickjillings@1450 1662 if (this.enforce == 'true') {this.enforce = true;}
nickjillings@1450 1663 else {this.enforce = false;}
nickjillings@1450 1664 }
nickjillings@1450 1665 };
nickjillings@1450 1666 this.options = [];
nickjillings@1450 1667 if (commonInterfaceNode != undefined) {
nickjillings@1450 1668 var child = commonInterfaceNode.firstElementChild;
nickjillings@1450 1669 while (child != undefined) {
nickjillings@1450 1670 this.options.push(new this.OptionNode(child));
nickjillings@1450 1671 child = child.nextElementSibling;
nickjillings@1450 1672 }
nickjillings@1450 1673 }
nickjillings@1450 1674 };
nickjillings@1450 1675
nickjillings@1450 1676 var audioHolders = projectXML.getElementsByTagName('audioHolder');
nickjillings@1450 1677 for (var i=0; i<audioHolders.length; i++) {
nickjillings@1450 1678 this.audioHolders.push(new this.audioHolderNode(this,audioHolders[i]));
nickjillings@1450 1679 }
nickjillings@1450 1680
nickjillings@1450 1681 // New check if we need to randomise the test order
nickjillings@1450 1682 if (this.randomiseOrder)
nickjillings@1450 1683 {
nickjillings@1450 1684 this.audioHolders = randomiseOrder(this.audioHolders);
nickjillings@1450 1685 for (var i=0; i<this.audioHolders.length; i++)
nickjillings@1450 1686 {
nickjillings@1450 1687 this.audioHolders[i].presentedId = i;
nickjillings@1450 1688 }
nickjillings@1450 1689 }
nickjillings@1450 1690
nickjillings@1450 1691 if (this.testPages != null || this.testPages != undefined)
nickjillings@1450 1692 {
nickjillings@1450 1693 if (this.testPages > audioHolders.length)
nickjillings@1450 1694 {
nickjillings@1450 1695 console.log('Warning: You have specified '+audioHolders.length+' tests but requested '+this.testPages+' be completed!');
nickjillings@1450 1696 this.testPages = audioHolders.length;
nickjillings@1450 1697 }
nickjillings@1450 1698 var aH = this.audioHolders;
nickjillings@1450 1699 this.audioHolders = [];
nickjillings@1450 1700 for (var i=0; i<this.testPages; i++)
nickjillings@1450 1701 {
nickjillings@1450 1702 this.audioHolders.push(aH[i]);
nickjillings@1450 1703 }
nickjillings@1450 1704 }
nickjillings@1450 1705 };
nickjillings@1450 1706
nickjillings@1450 1707 this.prepostNode = function(type) {
nickjillings@1450 1708 this.type = type;
nickjillings@1450 1709 this.options = [];
nickjillings@1450 1710
nickjillings@1450 1711 this.OptionNode = function() {
nickjillings@1450 1712
nickjillings@1450 1713 this.childOption = function() {
nickjillings@1450 1714 this.type = 'option';
nickjillings@1450 1715 this.id = element.id;
nickjillings@1450 1716 this.name = element.getAttribute('name');
nickjillings@1450 1717 this.text = element.textContent;
nickjillings@1450 1718 };
nickjillings@1450 1719
nickjillings@1450 1720 this.type = undefined;
nickjillings@1450 1721 this.id = undefined;
nickjillings@1450 1722 this.mandatory = undefined;
nickjillings@1450 1723 this.question = undefined;
nickjillings@1450 1724 this.statement = undefined;
nickjillings@1450 1725 this.boxsize = undefined;
nickjillings@1450 1726 this.options = [];
nickjillings@1450 1727 this.min = undefined;
nickjillings@1450 1728 this.max = undefined;
nickjillings@1450 1729 this.step = undefined;
nickjillings@1450 1730
nickjillings@1450 1731 };
nickjillings@1450 1732 };
nickjillings@1450 1733
nickjillings@1450 1734 this.metricNode = function(name) {
nickjillings@1450 1735 this.enabled = name;
nickjillings@1450 1736 };
nickjillings@1450 1737
nickjillings@1450 1738 this.audioHolderNode = function(parent) {
nickjillings@1450 1739 this.type = 'audioHolder';
nickjillings@1450 1740 this.presentedId = undefined;
nickjillings@1450 1741 this.id = undefined;
nickjillings@1450 1742 this.hostURL = undefined;
nickjillings@1450 1743 this.sampleRate = undefined;
nickjillings@1450 1744 this.randomiseOrder = undefined;
nickjillings@1450 1745 this.loop = undefined;
nickjillings@1450 1746 this.elementComments = undefined;
nickjillings@1450 1747 this.preTest = new parent.prepostNode('pretest');
nickjillings@1450 1748 this.postTest = new parent.prepostNode('posttest');
nickjillings@1450 1749 this.interfaces = [];
nickjillings@1450 1750 this.commentBoxPrefix = "Comment on track";
nickjillings@1450 1751 this.audioElements = [];
nickjillings@1450 1752 this.commentQuestions = [];
nickjillings@1450 1753
nickjillings@1450 1754 this.interfaceNode = function(DOM) {
nickjillings@1450 1755 var title = DOM.getElementsByTagName('title');
nickjillings@1450 1756 if (title.length == 0) {this.title = null;}
nickjillings@1450 1757 else {this.title = title[0].textContent;}
nickjillings@1450 1758 this.options = parent.commonInterface.options;
nickjillings@1450 1759 var scale = DOM.getElementsByTagName('scale');
nickjillings@1450 1760 this.scale = [];
nickjillings@1450 1761 for (var i=0; i<scale.length; i++) {
nickjillings@1450 1762 var arr = [null, null];
nickjillings@1450 1763 arr[0] = scale[i].getAttribute('position');
nickjillings@1450 1764 arr[1] = scale[i].textContent;
nickjillings@1450 1765 this.scale.push(arr);
nickjillings@1450 1766 }
nickjillings@1450 1767 };
nickjillings@1450 1768
nickjillings@1450 1769 this.audioElementNode = function(parent,audioObject) {
nickjillings@1450 1770 this.url = audioObject.file.name;
nickjillings@1450 1771 this.id = audioObject.id;
nickjillings@1450 1772 this.parent = parent;
nickjillings@1450 1773 this.type = "normal";
nickjillings@1450 1774
nickjillings@1450 1775 this.marker = undefined;
nickjillings@1450 1776 };
nickjillings@1450 1777
nickjillings@1450 1778 this.commentQuestionNode = function(xml) {
nickjillings@1450 1779 this.childOption = function(element) {
nickjillings@1450 1780 this.type = 'option';
nickjillings@1450 1781 this.name = element.getAttribute('name');
nickjillings@1450 1782 this.text = element.textContent;
nickjillings@1450 1783 };
nickjillings@1450 1784 this.id = xml.id;
nickjillings@1450 1785 if (xml.getAttribute('mandatory') == 'true') {this.mandatory = true;}
nickjillings@1450 1786 else {this.mandatory = false;}
nickjillings@1450 1787 this.type = xml.getAttribute('type');
nickjillings@1450 1788 if (this.type == undefined) {this.type = 'text';}
nickjillings@1450 1789 switch (this.type) {
nickjillings@1450 1790 case 'text':
nickjillings@1450 1791 this.question = xml.textContent;
nickjillings@1450 1792 break;
nickjillings@1450 1793 case 'radio':
nickjillings@1450 1794 var child = xml.firstElementChild;
nickjillings@1450 1795 this.options = [];
nickjillings@1450 1796 while (child != undefined) {
nickjillings@1450 1797 if (child.nodeName == 'statement' && this.statement == undefined) {
nickjillings@1450 1798 this.statement = child.textContent;
nickjillings@1450 1799 } else if (child.nodeName == 'option') {
nickjillings@1450 1800 this.options.push(new this.childOption(child));
nickjillings@1450 1801 }
nickjillings@1450 1802 child = child.nextElementSibling;
nickjillings@1450 1803 }
nickjillings@1450 1804 break;
nickjillings@1450 1805 case 'checkbox':
nickjillings@1450 1806 var child = xml.firstElementChild;
nickjillings@1450 1807 this.options = [];
nickjillings@1450 1808 while (child != undefined) {
nickjillings@1450 1809 if (child.nodeName == 'statement' && this.statement == undefined) {
nickjillings@1450 1810 this.statement = child.textContent;
nickjillings@1450 1811 } else if (child.nodeName == 'option') {
nickjillings@1450 1812 this.options.push(new this.childOption(child));
nickjillings@1450 1813 }
nickjillings@1450 1814 child = child.nextElementSibling;
nickjillings@1450 1815 }
nickjillings@1450 1816 break;
nickjillings@1450 1817 }
nickjillings@1450 1818 };
nickjillings@1450 1819 };
nickjillings@1450 1820
nickjillings@1450 1821 this.preTest = new this.prepostNode("pretest");
nickjillings@1450 1822 this.postTest = new this.prepostNode("posttest");
nickjillings@1450 1823 }
nickjillings@1450 1824
nickjillings@1450 1825 function createDeleteNodeButton(node)
nickjillings@1450 1826 {
nickjillings@1450 1827 var button = document.createElement("button");
nickjillings@1450 1828 button.textContent = "Delete";
nickjillings@1450 1829 button.onclick = function(event)
nickjillings@1450 1830 {
nickjillings@1450 1831 var node = event.target.parentElement;
nickjillings@1450 1832 node.parentElement.removeChild(node);
nickjillings@1450 1833 }
nickjillings@1450 1834 return button;
nickjillings@1450 1835 }
nickjillings@1450 1836
nickjillings@1450 1837 function SpecficationToHTML()
nickjillings@1450 1838 {
nickjillings@1450 1839 // Take information from Specification Node and format it into an HTML layout
nickjillings@1450 1840 var destination = document.getElementById("content");
nickjillings@1450 1841 // Setup Header Node
nickjillings@1450 1842 var setupNode = document.createElement("div");
nickjillings@1450 1843 setupNode.className = "topLevel";
nickjillings@1450 1844 setupNode.name = "setup";
nickjillings@1450 1845 var title = document.createElement("h2");
nickjillings@1450 1846 title.textContent = "Setup";
nickjillings@1450 1847 setupNode.appendChild(title);
nickjillings@1450 1848 // Interface Type
nickjillings@1450 1849 var div = document.createElement("div");
nickjillings@1450 1850 div.name = "attributes";
nickjillings@1450 1851 div.style.margin = "5px";
nickjillings@1450 1852 var select = document.createElement("select");
nickjillings@1450 1853 select.id = "interfaceSelect";
nickjillings@1450 1854 select.style.margin = "5px";
nickjillings@1450 1855 var option = document.createElement("option");
nickjillings@1450 1856 option.value = "APE";
nickjillings@1450 1857 option.textContent = "APE";
nickjillings@1450 1858 select.appendChild(option);
nickjillings@1450 1859 option = document.createElement("option");
nickjillings@1450 1860 option.value = "MUSHRA";
nickjillings@1450 1861 option.textContent = "MUSHRA";
nickjillings@1450 1862 select.appendChild(option);
nickjillings@1450 1863 select.value = specificationNode.interfaceType;
nickjillings@1450 1864 var span = document.createElement("span");
nickjillings@1450 1865 span.textContent = "Interface Type";
nickjillings@1450 1866 div.appendChild(span);
nickjillings@1450 1867 div.appendChild(select);
nickjillings@1450 1868 // Project Return Attribute
nickjillings@1450 1869 span = document.createElement("span");
nickjillings@1450 1870 span.style.margin = "5px";
nickjillings@1450 1871 span.textContent = "Project Return";
nickjillings@1450 1872 var input = document.createElement("input");
nickjillings@1450 1873 input.value = specificationNode.projectReturn;
nickjillings@1450 1874 input.id = "projectReturn";
nickjillings@1450 1875 input.style.margin = "5px";
nickjillings@1450 1876 div.appendChild(span);
nickjillings@1450 1877 div.appendChild(input);
nickjillings@1450 1878 // Randomise Order
nickjillings@1450 1879 span = document.createElement("span");
nickjillings@1450 1880 span.textContent = "Randomise Order";
nickjillings@1450 1881 input = document.createElement("input");
nickjillings@1450 1882 input.id = "randomiseOrder";
nickjillings@1450 1883 input.style.margin = "5px";
nickjillings@1450 1884 input.type = "checkbox";
nickjillings@1450 1885 input.value = specificationNode.projectReturn;
nickjillings@1450 1886 div.appendChild(span);
nickjillings@1450 1887 div.appendChild(input);
nickjillings@1450 1888 setupNode.appendChild(div);
nickjillings@1450 1889
nickjillings@1450 1890 // Now create the common Interface Node
nickjillings@1450 1891 var commonInterface = document.createElement("div");
nickjillings@1450 1892 commonInterface.id = "interface";
nickjillings@1450 1893 commonInterface.className = "SecondLevel";
nickjillings@1450 1894 var title = document.createElement("h3");
nickjillings@1450 1895 title.textContent = "Common Interface";
nickjillings@1450 1896 commonInterface.appendChild(title);
nickjillings@1450 1897 var div = document.createElement("div");
nickjillings@1450 1898 div.name = "attributes";
nickjillings@1450 1899 var interfaceOptions;
nickjillings@1450 1900 var interfaceChecks;
nickjillings@1450 1901 switch(select.value)
nickjillings@1450 1902 {
nickjillings@1450 1903 case "APE":
nickjillings@1450 1904 interfaceOptions = APEInterfaceOptions;
nickjillings@1450 1905 interfaceChecks = APEInterfaceChecks;
nickjillings@1450 1906 break;
nickjillings@1450 1907 case "MUSHRA":
nickjillings@1450 1908 interfaceOptions = MUSHRAInterfaceOptions;
nickjillings@1450 1909 interfaceChecks = MUSHRAInterfaceChecks;
nickjillings@1450 1910 break;
nickjillings@1450 1911 }
nickjillings@1450 1912 for (var i=0; i<interfaceOptions[0].length; i++)
nickjillings@1450 1913 {
nickjillings@1450 1914 var span = document.createElement("span");
nickjillings@1450 1915 span.textContent = interfaceOptions[1][i];
nickjillings@1450 1916 var input = document.createElement("input");
nickjillings@1450 1917 input.type = "checkbox";
nickjillings@1450 1918 input.id = interfaceOptions[0][i];
nickjillings@1450 1919 div.appendChild(input);
nickjillings@1450 1920 div.appendChild(span);
nickjillings@1450 1921 commonInterface.appendChild(div);
nickjillings@1450 1922 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1450 1923 {
nickjillings@1450 1924 if (specificationNode.commonInterface.options[j].name == interfaceOptions[0][i])
nickjillings@1450 1925 {
nickjillings@1450 1926 input.checked = true;
nickjillings@1450 1927 break;
nickjillings@1450 1928 }
nickjillings@1450 1929 }
nickjillings@1450 1930 }
nickjillings@1450 1931 for (var i=0; i<interfaceChecks[0].length; i++)
nickjillings@1450 1932 {
nickjillings@1450 1933 var span = document.createElement("span");
nickjillings@1450 1934 span.textContent = interfaceChecks[1][i];
nickjillings@1450 1935 var input = document.createElement("input");
nickjillings@1450 1936 input.type = "checkbox";
nickjillings@1450 1937 input.id = interfaceChecks[0][i];
nickjillings@1450 1938 div.appendChild(input);
nickjillings@1450 1939 div.appendChild(span);
nickjillings@1450 1940 commonInterface.appendChild(div);
nickjillings@1450 1941 for (var j=0; j<specificationNode.commonInterface.options.length; j++)
nickjillings@1450 1942 {
nickjillings@1450 1943 if (specificationNode.commonInterface.options[j].check == interfaceChecks[0][i])
nickjillings@1450 1944 {
nickjillings@1450 1945 input.checked = true;
nickjillings@1450 1946 break;
nickjillings@1450 1947 }
nickjillings@1450 1948 }
nickjillings@1450 1949 }
nickjillings@1450 1950 setupNode.appendChild(commonInterface);
nickjillings@1450 1951 // Now the Metric Node
nickjillings@1450 1952 var metrics = document.createElement("div");
nickjillings@1450 1953 metrics.id = "metrics";
nickjillings@1450 1954 metrics.className = "SecondLevel";
nickjillings@1450 1955 var title = document.createElement("h3");
nickjillings@1450 1956 title.textContent = "Metric Collections";
nickjillings@1450 1957 metrics.appendChild(title);
nickjillings@1450 1958 var div = document.createElement("div");
nickjillings@1450 1959 div.name = "attributes";
nickjillings@1450 1960 metrics.appendChild(div);
nickjillings@1450 1961 var supportedMetrics;
nickjillings@1450 1962 switch(select.value)
nickjillings@1450 1963 {
nickjillings@1450 1964 case "APE":
nickjillings@1450 1965 supportedMetrics = APEInterfaceMetrics;
nickjillings@1450 1966 break;
nickjillings@1450 1967 case "MUSHRA":
nickjillings@1450 1968 supportedMetrics = MUSHRAInterfaceMetrics;
nickjillings@1450 1969 break;
nickjillings@1450 1970 }
nickjillings@1450 1971
nickjillings@1450 1972 for (var i=0; i<supportedMetrics[0].length; i++)
nickjillings@1450 1973 {
nickjillings@1450 1974 var span = document.createElement("span");
nickjillings@1450 1975 span.textContent = supportedMetrics[1][i];
nickjillings@1450 1976 var input = document.createElement("input");
nickjillings@1450 1977 input.type = "checkbox";
nickjillings@1450 1978 input.id = supportedMetrics[0][i];
nickjillings@1450 1979 div.appendChild(input);
nickjillings@1450 1980 div.appendChild(span);
nickjillings@1450 1981 for (var j=0; j<specificationNode.metrics.length; j++)
nickjillings@1450 1982 {
nickjillings@1450 1983 if (specificationNode.metrics[j].enabled == supportedMetrics[0][i])
nickjillings@1450 1984 {
nickjillings@1450 1985 input.checked = true;
nickjillings@1450 1986 }
nickjillings@1450 1987 }
nickjillings@1450 1988 }
nickjillings@1450 1989
nickjillings@1450 1990 setupNode.appendChild(metrics);
nickjillings@1450 1991
nickjillings@1450 1992 // Test Session Pre Test
nickjillings@1450 1993 var preTest = document.createElement("div");
nickjillings@1450 1994 preTest.id = "preTest";
nickjillings@1450 1995 preTest.className = "SecondLevel";
nickjillings@1450 1996 var title = document.createElement("h3");
nickjillings@1450 1997 title.textContent = "Pre test Survey";
nickjillings@1450 1998 preTest.appendChild(title);
nickjillings@1450 1999 var div = document.createElement("div");
nickjillings@1450 2000 div.name = "attributes";
nickjillings@1450 2001 for (var j=0; j<specificationNode.preTest.options.length; j++)
nickjillings@1450 2002 {
nickjillings@1450 2003 var node = PPSurveyToHTML(specificationNode.preTest.options[j]);
nickjillings@1450 2004 node.className = "SecondLevel";
nickjillings@1450 2005 node.id = preTest.id+"-"+j;
nickjillings@1450 2006 node.appendChild(createDeleteNodeButton());
nickjillings@1450 2007 preTest.appendChild(node);
nickjillings@1450 2008 }
nickjillings@1450 2009 setupNode.appendChild(preTest);
nickjillings@1450 2010
nickjillings@1450 2011 // Test Session Post Test
nickjillings@1450 2012 var postTest = document.createElement("div");
nickjillings@1450 2013 postTest.id = "postTest";
nickjillings@1450 2014 postTest.className = "SecondLevel";
nickjillings@1450 2015 var title = document.createElement("h3");
nickjillings@1450 2016 title.textContent = "Post test Survey";
nickjillings@1450 2017 postTest.appendChild(title);
nickjillings@1450 2018 var div = document.createElement("div");
nickjillings@1450 2019 div.name = "attributes";
nickjillings@1450 2020
nickjillings@1450 2021 for (var j=0; j<specificationNode.postTest.options.length; j++)
nickjillings@1450 2022 {
nickjillings@1450 2023 var node = PPSurveyToHTML(specificationNode.postTest.options[j]);
nickjillings@1450 2024 node.className = "SecondLevel";
nickjillings@1450 2025 node.id = postTest.id+"-"+j;
nickjillings@1450 2026 node.appendChild(createDeleteNodeButton());
nickjillings@1450 2027 postTest.appendChild(node);
nickjillings@1450 2028 }
nickjillings@1450 2029
nickjillings@1450 2030 setupNode.appendChild(postTest);
nickjillings@1450 2031
nickjillings@1450 2032 destination.appendChild(setupNode);
nickjillings@1450 2033
nickjillings@1450 2034 // Now we step through the AudioHolders
nickjillings@1450 2035 for (var i=0; i<specificationNode.audioHolders.length; i++)
nickjillings@1450 2036 {
nickjillings@1450 2037 var aH = specificationNode.audioHolders[i];
nickjillings@1450 2038 var aHTML = document.createElement("div");
nickjillings@1450 2039 aHTML.name = "audioHolder";
nickjillings@1450 2040 aHTML.id = "audioHolder-"+aH.id;
nickjillings@1450 2041 aHTML.className = "topLevel";
nickjillings@1450 2042 aHTML.appendChild(createDeleteNodeButton());
nickjillings@1450 2043 destination.appendChild(aHTML);
nickjillings@1450 2044 var title = document.createElement("h2");
nickjillings@1450 2045 title.textContent = "Audio Holder "+aH.id;
nickjillings@1450 2046 aHTML.appendChild(title);
nickjillings@1450 2047 var attributes = document.createElement("div");
nickjillings@1450 2048 attributes.name = "attributes";
nickjillings@1450 2049 aHTML.appendChild(attributes);
nickjillings@1450 2050 var text = document.createElement("span");
nickjillings@1450 2051 text.textContent = "ID: ";
nickjillings@1450 2052 var input = document.createElement("input");
nickjillings@1450 2053 input.id = aHTML.id+"-id";
nickjillings@1450 2054 input.value = aH.id;
nickjillings@1450 2055 input.onchange = function()
nickjillings@1450 2056 {
nickjillings@1450 2057 event.currentTarget.parentElement.parentElement.childNodes[0].textContent = "Audio Holder "+event.currentTarget.value;
nickjillings@1450 2058 };
nickjillings@1450 2059 text.style.margin = "5px";
nickjillings@1450 2060 input.style.margin = "5px";
nickjillings@1450 2061 attributes.appendChild(text);
nickjillings@1450 2062 attributes.appendChild(input);
nickjillings@1450 2063 text = document.createElement("span");
nickjillings@1450 2064 text.textContent = "Host URL: ";
nickjillings@1450 2065 input = document.createElement("input");
nickjillings@1450 2066 input.id = aHTML.id+"-hostURL";
nickjillings@1450 2067 input.value = aH.hostURL;
nickjillings@1450 2068 text.style.margin = "5px";
nickjillings@1450 2069 input.style.margin = "5px";
nickjillings@1450 2070 attributes.appendChild(text);
nickjillings@1450 2071 attributes.appendChild(input);
nickjillings@1450 2072 text = document.createElement("span");
nickjillings@1450 2073 text.textContent = "Loop Fragments: ";
nickjillings@1450 2074 input = document.createElement("input");
nickjillings@1450 2075 input.id = aHTML.id+"-loop";
nickjillings@1450 2076 input.type = "checkbox";
nickjillings@1450 2077 input.checked = aH.loop;
nickjillings@1450 2078 text.style.margin = "5px";
nickjillings@1450 2079 input.style.margin = "5px";
nickjillings@1450 2080 attributes.appendChild(text);
nickjillings@1450 2081 attributes.appendChild(input);
nickjillings@1450 2082 text = document.createElement("span");
nickjillings@1450 2083 text.textContent = "Randomise Order: ";
nickjillings@1450 2084 input = document.createElement("input");
nickjillings@1450 2085 input.id = aHTML.id+"-randomiseOrder";
nickjillings@1450 2086 input.type = "checkbox";
nickjillings@1450 2087 input.checked = aH.randomiseOrder;
nickjillings@1450 2088 text.style.margin = "5px";
nickjillings@1450 2089 input.style.margin = "5px";
nickjillings@1450 2090 attributes.appendChild(text);
nickjillings@1450 2091 attributes.appendChild(input);
nickjillings@1450 2092 text = document.createElement("span");
nickjillings@1450 2093 text.textContent = "Show Fragment Comments";
nickjillings@1450 2094 input = document.createElement("input");
nickjillings@1450 2095 input.id = aHTML.id+"-elementComments";
nickjillings@1450 2096 input.type = "checkbox";
nickjillings@1450 2097 input.checked = aH.elementComments;
nickjillings@1450 2098 text.style.margin = "5px";
nickjillings@1450 2099 input.style.margin = "5px";
nickjillings@1450 2100 attributes.appendChild(text);
nickjillings@1450 2101 attributes.appendChild(input);
nickjillings@1450 2102
nickjillings@1450 2103 // Test Session Pre Test
nickjillings@1450 2104 var preTest = document.createElement("div");
nickjillings@1450 2105 preTest.id = aHTML.id+"-pretest";
nickjillings@1450 2106 preTest.className = "SecondLevel";
nickjillings@1450 2107 var title = document.createElement("h3");
nickjillings@1450 2108 title.textContent = "Pre test Survey";
nickjillings@1450 2109 preTest.appendChild(title);
nickjillings@1450 2110 var div = document.createElement("div");
nickjillings@1450 2111 div.name = "attributes";
nickjillings@1450 2112
nickjillings@1450 2113 for (var j=0; j<aH.preTest.options.length; j++)
nickjillings@1450 2114 {
nickjillings@1450 2115 var node = PPSurveyToHTML(aH.preTest.options[j]);
nickjillings@1450 2116 node.className = "SecondLevel";
nickjillings@1450 2117 node.id = preTest.id+"-"+j;
nickjillings@1450 2118 node.appendChild(createDeleteNodeButton());
nickjillings@1450 2119 preTest.appendChild(node);
nickjillings@1450 2120 }
nickjillings@1450 2121
nickjillings@1450 2122 aHTML.appendChild(preTest);
nickjillings@1450 2123
nickjillings@1450 2124 // Test Session Post Test
nickjillings@1450 2125 var postTest = document.createElement("div");
nickjillings@1450 2126 postTest.id = aHTML.id+"-postTest";
nickjillings@1450 2127 postTest.className = "SecondLevel";
nickjillings@1450 2128 var title = document.createElement("h3");
nickjillings@1450 2129 title.textContent = "Post test Survey";
nickjillings@1450 2130 postTest.appendChild(title);
nickjillings@1450 2131 var div = document.createElement("div");
nickjillings@1450 2132 div.name = "attributes";
nickjillings@1450 2133
nickjillings@1450 2134 for (var j=0; j<aH.postTest.options.length; j++)
nickjillings@1450 2135 {
nickjillings@1450 2136 var node = PPSurveyToHTML(aH.postTest.options[j]);
nickjillings@1450 2137 node.className = "SecondLevel";
nickjillings@1450 2138 node.id = postTest.id+"-"+j;
nickjillings@1450 2139 node.appendChild(createDeleteNodeButton());
nickjillings@1450 2140 postTest.appendChild(node);
nickjillings@1450 2141 }
nickjillings@1450 2142
nickjillings@1450 2143 aHTML.appendChild(postTest);
nickjillings@1450 2144
nickjillings@1450 2145 //Audio Elements
nickjillings@1450 2146 var audioElems = document.createElement("div");
nickjillings@1450 2147 audioElems.id = aHTML.id+"-audioElements";
nickjillings@1450 2148 audioElems.className = "SecondLevel";
nickjillings@1450 2149 var title = document.createElement("h3");
nickjillings@1450 2150 title.textContent = "Audio Elements";
nickjillings@1450 2151 audioElems.appendChild(title);
nickjillings@1450 2152 for (var i=0; i<aH.audioElements.length; i++)
nickjillings@1450 2153 {
nickjillings@1450 2154 var entry = document.createElement("div");
nickjillings@1450 2155 entry.className = "SecondLevel";
nickjillings@1450 2156 entry.id = audioElems.id+"-"+aH.audioElements[i].id;
nickjillings@1450 2157 var text = document.createElement("span");
nickjillings@1450 2158 text.textContent = "ID:";
nickjillings@1450 2159 var input = document.createElement("input");
nickjillings@1450 2160 input.id = entry.id+"-id";
nickjillings@1450 2161 input.value = aH.audioElements[i].id;
nickjillings@1450 2162 text.style.margin = "5px";
nickjillings@1450 2163 input.style.margin = "5px";
nickjillings@1450 2164 entry.appendChild(text);
nickjillings@1450 2165 entry.appendChild(input);
nickjillings@1450 2166 text = document.createElement("span");
nickjillings@1450 2167 text.textContent = "URL:";
nickjillings@1450 2168 input = document.createElement("input");
nickjillings@1450 2169 input.id = entry.id+"-URL";
nickjillings@1450 2170 input.value = aH.audioElements[i].url;
nickjillings@1450 2171 text.style.margin = "5px";
nickjillings@1450 2172 input.style.margin = "5px";
nickjillings@1450 2173 entry.appendChild(text);
nickjillings@1450 2174 entry.appendChild(input);
nickjillings@1450 2175 entry.appendChild(createDeleteNodeButton());
nickjillings@1450 2176 audioElems.appendChild(entry);
nickjillings@1450 2177 }
nickjillings@1450 2178 aHTML.appendChild(audioElems);
nickjillings@1450 2179 }
nickjillings@1450 2180
nickjillings@1450 2181 function PPSurveyToHTML(node)
nickjillings@1450 2182 {
nickjillings@1450 2183 var holder = document.createElement("div");
nickjillings@1450 2184 var title = document.createElement("h4");
nickjillings@1450 2185 holder.appendChild(title);
nickjillings@1450 2186 var attributes = document.createElement("div");
nickjillings@1450 2187 holder.appendChild(attributes);
nickjillings@1450 2188 switch(node.type)
nickjillings@1450 2189 {
nickjillings@1450 2190 case "statement":
nickjillings@1450 2191 title.textContent = "Statement";
nickjillings@1450 2192 var tA = document.createElement("textarea");
nickjillings@1450 2193 attributes.style.height = "150px";
nickjillings@1450 2194 tA.style.width = "500px";
nickjillings@1450 2195 tA.style.height = "100px";
nickjillings@1450 2196 tA.value = node.statement;
nickjillings@1450 2197 attributes.appendChild(tA);
nickjillings@1450 2198 break;
nickjillings@1450 2199 case "question":
nickjillings@1450 2200 title.textContent = "Question";
nickjillings@1450 2201 var text = document.createElement("span");
nickjillings@1450 2202 text.textContent = "ID :";
nickjillings@1450 2203 var input = document.createElement("input");
nickjillings@1450 2204 input.name = "id";
nickjillings@1450 2205 input.value = node.id;
nickjillings@1450 2206 text.style.margin = "5px";
nickjillings@1450 2207 input.style.margin = "5px";
nickjillings@1450 2208 attributes.appendChild(text);
nickjillings@1450 2209 attributes.appendChild(input);
nickjillings@1450 2210 text = document.createElement("span");
nickjillings@1450 2211 text.textContent = "Question";
nickjillings@1450 2212 input = document.createElement("input");
nickjillings@1450 2213 input.name = "question";
nickjillings@1450 2214 input.style.width = "400px";
nickjillings@1450 2215 input.value = node.question;
nickjillings@1450 2216 text.style.margin = "5px";
nickjillings@1450 2217 input.style.margin = "5px";
nickjillings@1450 2218 attributes.appendChild(text);
nickjillings@1450 2219 attributes.appendChild(input);
nickjillings@1450 2220 text = document.createElement("span");
nickjillings@1450 2221 text.textContent = "Mandatory";
nickjillings@1450 2222 input = document.createElement("input");
nickjillings@1450 2223 input.name = "mandatory";
nickjillings@1450 2224 input.type = "checkbox";
nickjillings@1450 2225 input.checked = node.mandatory;
nickjillings@1450 2226 text.style.margin = "5px";
nickjillings@1450 2227 input.style.margin = "5px";
nickjillings@1450 2228 attributes.appendChild(text);
nickjillings@1450 2229 attributes.appendChild(input);
nickjillings@1450 2230 text = document.createElement("span");
nickjillings@1450 2231 text.textContent = "Reply box size";
nickjillings@1450 2232 input = document.createElement("select");
nickjillings@1450 2233 input.name = "boxsize";
nickjillings@1450 2234 var option = document.createElement("option");
nickjillings@1450 2235 option.textContent = "Normal";
nickjillings@1450 2236 option.value = "normal";
nickjillings@1450 2237 input.appendChild(option);
nickjillings@1450 2238 option = document.createElement("option");
nickjillings@1450 2239 option.textContent = "Large";
nickjillings@1450 2240 option.value = "large";
nickjillings@1450 2241 input.appendChild(option);
nickjillings@1450 2242 option = document.createElement("option");
nickjillings@1450 2243 option.textContent = "Small";
nickjillings@1450 2244 option.value = "small";
nickjillings@1450 2245 input.appendChild(option);
nickjillings@1450 2246 option = document.createElement("option");
nickjillings@1450 2247 option.textContent = "Huge";
nickjillings@1450 2248 option.value = "huge";
nickjillings@1450 2249 input.appendChild(option);
nickjillings@1450 2250 text.style.margin = "5px";
nickjillings@1450 2251 input.style.margin = "5px";
nickjillings@1450 2252 attributes.appendChild(text);
nickjillings@1450 2253 attributes.appendChild(input);
nickjillings@1450 2254 input.value = node.boxsize;
nickjillings@1450 2255 break;
nickjillings@1450 2256 }
nickjillings@1450 2257 return holder;
nickjillings@1450 2258 }
nickjillings@1450 2259 }
nickjillings@1450 2260 </script>
nickjillings@1450 2261 <style>
nickjillings@1450 2262 div.popup {
nickjillings@1450 2263 width: 500px;
nickjillings@1450 2264 position: absolute;
nickjillings@1450 2265 height: 400px;
nickjillings@1450 2266 background-color: #fff;
nickjillings@1450 2267 border-radius: 10px;
nickjillings@1450 2268 box-shadow: 0px 0px 50px #000;
nickjillings@1450 2269 z-index: 2;
nickjillings@1450 2270 }
nickjillings@1450 2271
nickjillings@1450 2272 button.popupButton {
nickjillings@1450 2273 /* Button for popup window
nickjillings@1450 2274 */
nickjillings@1450 2275 min-width: 50px;
nickjillings@1450 2276 height: 25px;
nickjillings@1450 2277 position: relative;
nickjillings@1450 2278 border-radius: 5px;
nickjillings@1450 2279 border: #444;
nickjillings@1450 2280 border-width: 1px;
nickjillings@1450 2281 border-style: solid;
nickjillings@1450 2282 background-color: #fff;
nickjillings@1450 2283 }
nickjillings@1450 2284
nickjillings@1450 2285 div.dragndrop {
nickjillings@1450 2286 margin-top: 10px;
nickjillings@1450 2287 border:#000000;
nickjillings@1450 2288 border-style: dashed;
nickjillings@1450 2289 border-width: 2px;
nickjillings@1450 2290 }
nickjillings@1450 2291 div.dndheaderelement {
nickjillings@1450 2292 float: left;
nickjillings@1450 2293 height: 100%;
nickjillings@1450 2294 border-right: #DDDDDD;
nickjillings@1450 2295 border-right-width: 1px;
nickjillings@1450 2296 border-right-style: solid;
nickjillings@1450 2297 }
nickjillings@1450 2298 div.dndheaderelement span{
nickjillings@1450 2299 padding-left: 5px;
nickjillings@1450 2300 }
nickjillings@1450 2301
nickjillings@1450 2302 div.topLevel {
nickjillings@1450 2303 border: #000;
nickjillings@1450 2304 border-style: solid;
nickjillings@1450 2305 border-width: 5px;
nickjillings@1450 2306 padding: 10px;
nickjillings@1450 2307 margin: 10px;
nickjillings@1450 2308 }
nickjillings@1450 2309
nickjillings@1450 2310 div.SecondLevel {
nickjillings@1450 2311 border: #000;
nickjillings@1450 2312 border-style: solid;
nickjillings@1450 2313 border-width: 1px;
nickjillings@1450 2314 padding: 10px;
nickjillings@1450 2315 margin: 10px;
nickjillings@1450 2316 }
nickjillings@1450 2317 </style>
nickjillings@1450 2318 </head>
nickjillings@1450 2319
nickjillings@1450 2320 <body>
nickjillings@1450 2321 <div id="content"></div>
nickjillings@1450 2322 </body>
nickjillings@1450 2323 </html>