annotate test_create/test_create.html @ 1452:bd5cbaf775cd

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