annotate ape.js @ 181:eb164638be5e Dev_main

Everything tied into Specification object which needs information from specification document.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 04 Jun 2015 15:54:56 +0100
parents 8655b05c874f
children 105b6bd810e9
rev   line source
nicholas@2 1 /**
nicholas@2 2 * ape.js
nicholas@2 3 * Create the APE interface
nicholas@2 4 */
nicholas@2 5
n@38 6 // preTest - In preTest state
n@38 7 // testRun-ID - In test running, test Id number at the end 'testRun-2'
n@38 8 // testRunPost-ID - Post test of test ID
n@38 9 // testRunPre-ID - Pre-test of test ID
n@38 10 // postTest - End of test, final submission!
n@38 11
n@32 12
nicholas@2 13 // Once this is loaded and parsed, begin execution
n@181 14 loadInterface();
nicholas@2 15
n@181 16 function loadInterface() {
nicholas@2 17
n@16 18 // Get the dimensions of the screen available to the page
nicholas@2 19 var width = window.innerWidth;
nicholas@2 20 var height = window.innerHeight;
nicholas@2 21
nicholas@2 22 // The injection point into the HTML page
nicholas@2 23 var insertPoint = document.getElementById("topLevelBody");
n@22 24 var testContent = document.createElement('div');
nicholas@135 25
n@22 26 testContent.id = 'testContent';
n@176 27
n@34 28
n@52 29 // Create APE specific metric functions
n@52 30 audioEngineContext.metric.initialiseTest = function()
n@52 31 {
n@52 32 };
n@52 33
n@52 34 audioEngineContext.metric.sliderMoveStart = function(id)
n@52 35 {
n@52 36 if (this.data == -1)
n@52 37 {
n@52 38 this.data = id;
n@52 39 } else {
n@52 40 console.log('ERROR: Metric tracker detecting two moves!');
n@52 41 this.data = -1;
n@52 42 }
n@52 43 };
n@52 44 audioEngineContext.metric.sliderMoved = function()
n@52 45 {
n@52 46 var time = audioEngineContext.timer.getTestTime();
n@52 47 var id = this.data;
n@52 48 this.data = -1;
n@52 49 var position = convSliderPosToRate(id);
b@115 50 console.log('slider ' + id + ': '+ position + ' (' + time + ')'); // DEBUG/SAFETY: show position and slider id
n@52 51 if (audioEngineContext.timer.testStarted)
n@52 52 {
n@52 53 audioEngineContext.audioObjects[id].metric.moved(time,position);
n@52 54 }
n@52 55 };
n@52 56
n@52 57 audioEngineContext.metric.sliderPlayed = function(id)
n@52 58 {
n@52 59 var time = audioEngineContext.timer.getTestTime();
n@52 60 if (audioEngineContext.timer.testStarted)
n@52 61 {
n@52 62 if (this.lastClicked >= 0)
n@52 63 {
n@52 64 audioEngineContext.audioObjects[this.lastClicked].metric.listening(time);
n@52 65 }
n@52 66 this.lastClicked = id;
n@52 67 audioEngineContext.audioObjects[id].metric.listening(time);
n@52 68 }
b@115 69 console.log('slider ' + id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id
n@52 70 };
n@52 71
n@177 72 // Bindings for audioObjects
n@177 73
nicholas@2 74 // Create the top div for the Title element
n@181 75 var titleAttr = specification.title;
nicholas@2 76 var title = document.createElement('div');
nicholas@2 77 title.className = "title";
nicholas@2 78 title.align = "center";
nicholas@2 79 var titleSpan = document.createElement('span');
nicholas@2 80
nicholas@2 81 // Set title to that defined in XML, else set to default
nicholas@2 82 if (titleAttr != undefined) {
n@181 83 titleSpan.textContent = titleAttr;
nicholas@2 84 } else {
n@181 85 titleSpan.textContent = 'Listening test';
nicholas@2 86 }
nicholas@2 87 // Insert the titleSpan element into the title div element.
nicholas@2 88 title.appendChild(titleSpan);
nicholas@2 89
n@47 90 var pagetitle = document.createElement('div');
n@47 91 pagetitle.className = "pageTitle";
n@47 92 pagetitle.align = "center";
n@47 93 var titleSpan = document.createElement('span');
n@47 94 titleSpan.id = "pageTitle";
n@47 95 pagetitle.appendChild(titleSpan);
n@47 96
nicholas@7 97 // Create Interface buttons!
nicholas@7 98 var interfaceButtons = document.createElement('div');
nicholas@7 99 interfaceButtons.id = 'interface-buttons';
nicholas@7 100
nicholas@7 101 // Create playback start/stop points
nicholas@7 102 var playback = document.createElement("button");
b@101 103 playback.innerHTML = 'Stop';
n@49 104 playback.id = 'playback-button';
n@16 105 // onclick function. Check if it is playing or not, call the correct function in the
n@16 106 // audioEngine, change the button text to reflect the next state.
nicholas@7 107 playback.onclick = function() {
b@101 108 if (audioEngineContext.status == 1) {
b@101 109 audioEngineContext.stop();
n@25 110 this.innerHTML = 'Stop';
b@115 111 var time = audioEngineContext.timer.getTestTime();
b@115 112 console.log('Stopped at ' + time); // DEBUG/SAFETY
nicholas@7 113 }
n@16 114 };
nicholas@7 115 // Create Submit (save) button
nicholas@7 116 var submit = document.createElement("button");
n@25 117 submit.innerHTML = 'Submit';
n@43 118 submit.onclick = buttonSubmitClick;
n@49 119 submit.id = 'submit-button';
n@16 120 // Append the interface buttons into the interfaceButtons object.
nicholas@7 121 interfaceButtons.appendChild(playback);
nicholas@7 122 interfaceButtons.appendChild(submit);
nicholas@7 123
nicholas@2 124 // Now create the slider and HTML5 canvas boxes
nicholas@2 125
n@16 126 // Create the div box to center align
nicholas@2 127 var sliderBox = document.createElement('div');
nicholas@2 128 sliderBox.className = 'sliderCanvasDiv';
n@16 129 sliderBox.id = 'sliderCanvasHolder';
nicholas@2 130
n@16 131 // Create the slider box to hold the slider elements
nicholas@5 132 var canvas = document.createElement('div');
nicholas@2 133 canvas.id = 'slider';
n@127 134 canvas.align = "left";
n@127 135 canvas.addEventListener('dragover',function(event){
n@127 136 event.preventDefault();
n@127 137 return false;
n@127 138 },false);
n@127 139 var sliderMargin = document.createAttribute('marginsize');
n@127 140 sliderMargin.nodeValue = 42; // Set default margins to 42px either side
n@16 141 // Must have a known EXACT width, as this is used later to determine the ratings
n@127 142 var w = (Number(sliderMargin.nodeValue)+8)*2;
n@127 143 canvas.style.width = width - w +"px";
n@127 144 canvas.style.marginLeft = sliderMargin.nodeValue +'px';
n@127 145 canvas.setAttributeNode(sliderMargin);
nicholas@2 146 sliderBox.appendChild(canvas);
n@16 147
n@47 148 // Create the div to hold any scale objects
n@47 149 var scale = document.createElement('div');
n@47 150 scale.className = 'sliderScale';
n@47 151 scale.id = 'sliderScaleHolder';
n@47 152 scale.align = 'left';
n@47 153 sliderBox.appendChild(scale);
n@47 154
n@16 155 // Global parent for the comment boxes on the page
nicholas@3 156 var feedbackHolder = document.createElement('div');
n@34 157 feedbackHolder.id = 'feedbackHolder';
nicholas@2 158
n@38 159 testContent.style.zIndex = 1;
n@38 160 insertPoint.innerHTML = null; // Clear the current schema
n@38 161
n@38 162 // Inject into HTML
n@38 163 testContent.appendChild(title); // Insert the title
n@47 164 testContent.appendChild(pagetitle);
n@38 165 testContent.appendChild(interfaceButtons);
n@38 166 testContent.appendChild(sliderBox);
n@38 167 testContent.appendChild(feedbackHolder);
n@38 168 insertPoint.appendChild(testContent);
n@22 169
n@36 170 // Load the full interface
nicholas@129 171 testState.initialise();
nicholas@129 172 testState.advanceState();
nicholas@135 173
nicholas@2 174 }
nicholas@5 175
n@181 176 function loadTest(audioHolderObject)
n@34 177 {
nicholas@110 178
nicholas@110 179 // Reset audioEngineContext.Metric globals for new test
n@113 180 audioEngineContext.newTestPage();
nicholas@110 181
n@181 182 var id = audioHolderObject.id;
n@34 183
n@34 184 var feedbackHolder = document.getElementById('feedbackHolder');
n@34 185 var canvas = document.getElementById('slider');
n@34 186 feedbackHolder.innerHTML = null;
n@34 187 canvas.innerHTML = null;
n@47 188
n@47 189 // Setup question title
n@181 190 var interfaceObj = $(audioHolderObject).find('interface');
n@47 191 var titleNode = interfaceObj.find('title');
n@47 192 if (titleNode[0] != undefined)
n@47 193 {
n@47 194 document.getElementById('pageTitle').textContent = titleNode[0].textContent;
n@47 195 }
n@47 196 var positionScale = canvas.style.width.substr(0,canvas.style.width.length-2);
n@127 197 var offset = Number(document.getElementById('slider').attributes['marginsize'].value);
n@47 198 var scale = document.getElementById('sliderScaleHolder');
n@47 199 scale.innerHTML = null;
n@47 200 interfaceObj.find('scale').each(function(index,scaleObj){
n@127 201 var value = document.createAttribute('value');
n@47 202 var position = Number(scaleObj.attributes['position'].value)*0.01;
n@127 203 value.nodeValue = position;
n@47 204 var pixelPosition = (position*positionScale)+offset;
n@47 205 var scaleDOM = document.createElement('span');
n@47 206 scaleDOM.textContent = scaleObj.textContent;
n@47 207 scale.appendChild(scaleDOM);
n@47 208 scaleDOM.style.left = Math.floor((pixelPosition-($(scaleDOM).width()/2)))+'px';
n@127 209 scaleDOM.setAttributeNode(value);
n@47 210 });
n@174 211
n@174 212 var commentBoxPrefix = interfaceObj.find('commentBoxPrefix');
n@174 213 if (commentBoxPrefix.length != 0) {
n@174 214 commentBoxPrefix = commentBoxPrefix[0].textContent;
n@174 215 } else {
n@174 216 commentBoxPrefix = "Comment on track";
n@174 217 }
n@34 218
n@34 219 /// CHECK FOR SAMPLE RATE COMPATIBILITY
n@181 220 if (audioHolderObject.sampleRate != undefined) {
n@181 221 if (Number(audioHolderObject.sampleRate) != audioContext.sampleRate) {
n@34 222 var errStr = 'Sample rates do not match! Requested '+Number(hostFs)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.';
n@34 223 alert(errStr);
n@34 224 return;
n@34 225 }
n@34 226 }
n@45 227
n@181 228 var commentShow = audioHolderObject.elementComments;
nicholas@66 229
n@181 230 var loopPlayback = audioHolderObject.loop;
n@181 231
n@57 232 audioEngineContext.loopPlayback = loopPlayback;
n@57 233 // Create AudioEngine bindings for playback
n@57 234 if (loopPlayback) {
n@57 235 audioEngineContext.selectedTrack = function(id) {
n@57 236 for (var i=0; i<this.audioObjects.length; i++)
n@57 237 {
n@57 238 if (id == i) {
nicholas@132 239 this.audioObjects[i].loopStart();
n@57 240 } else {
nicholas@132 241 this.audioObjects[i].loopStop();
n@57 242 }
n@57 243 }
n@57 244 };
n@57 245 } else {
n@57 246 audioEngineContext.selectedTrack = function(id) {
n@57 247 for (var i=0; i<this.audioObjects.length; i++)
n@57 248 {
n@97 249 this.audioObjects[i].outputGain.gain.value = 0.0;
n@97 250 this.audioObjects[i].stop();
n@57 251 }
n@99 252 if (this.status == 1) {
n@99 253 this.audioObjects[id].outputGain.gain.value = 1.0;
n@99 254 this.audioObjects[id].play(audioContext.currentTime+0.01);
n@99 255 }
n@57 256 };
n@57 257 }
n@57 258
n@46 259 currentTestHolder = document.createElement('audioHolder');
n@181 260 currentTestHolder.id = audioHolderObject.id;
n@181 261 currentTestHolder.repeatCount = audioHolderObject.repeatCount;
n@46 262
n@181 263 var randomise = audioHolderObject.randomiseOrder;
n@45 264
n@181 265 var audioElements = audioHolderObject.audioElements;
nicholas@58 266 currentTrackOrder = [];
n@45 267 if (randomise) {
n@181 268 audioHolderObject.audioElements = randomiseOrder(audioHolderObject.audioElements);
n@45 269 }
n@45 270
nicholas@58 271 // Delete any previous audioObjects associated with the audioEngine
nicholas@58 272 audioEngineContext.audioObjects = [];
nicholas@58 273
n@45 274 // Find all the audioElements from the audioHolder
n@181 275 $(audioHolderObject.audioElements).each(function(index,element){
n@34 276 // Find URL of track
n@34 277 // In this jQuery loop, variable 'this' holds the current audioElement.
n@34 278
n@34 279 // Now load each audio sample. First create the new track by passing the full URL
n@181 280 var trackURL = audioHolderObject.hostURL + element.url;
n@179 281 var audioObject = audioEngineContext.newTrack(trackURL);
nicholas@66 282
nicholas@66 283 if (commentShow) {
nicholas@66 284 // Create document objects to hold the comment boxes
nicholas@66 285 var trackComment = document.createElement('div');
nicholas@66 286 trackComment.className = 'comment-div';
n@154 287 trackComment.id = 'comment-div-'+index;
nicholas@66 288 // Create a string next to each comment asking for a comment
nicholas@66 289 var trackString = document.createElement('span');
n@174 290 trackString.innerHTML = commentBoxPrefix+' '+index;
nicholas@66 291 // Create the HTML5 comment box 'textarea'
nicholas@66 292 var trackCommentBox = document.createElement('textarea');
nicholas@66 293 trackCommentBox.rows = '4';
nicholas@66 294 trackCommentBox.cols = '100';
nicholas@66 295 trackCommentBox.name = 'trackComment'+index;
nicholas@66 296 trackCommentBox.className = 'trackComment';
nicholas@66 297 var br = document.createElement('br');
nicholas@66 298 // Add to the holder.
nicholas@66 299 trackComment.appendChild(trackString);
nicholas@66 300 trackComment.appendChild(br);
nicholas@66 301 trackComment.appendChild(trackCommentBox);
nicholas@66 302 feedbackHolder.appendChild(trackComment);
n@179 303 audioObject.commentDOM = trackComment;
nicholas@66 304 }
n@34 305
n@34 306 // Create a slider per track
n@34 307
n@34 308 var trackSliderObj = document.createElement('div');
n@34 309 trackSliderObj.className = 'track-slider';
n@34 310 trackSliderObj.id = 'track-slider-'+index;
n@154 311
n@154 312 var trackSliderAOIndex = document.createAttribute('trackIndex');
n@154 313 trackSliderAOIndex.nodeValue = index;
n@154 314 trackSliderObj.setAttributeNode(trackSliderAOIndex);
n@154 315
n@34 316 // Distribute it randomnly
n@138 317 var w = window.innerWidth - (offset+8)*2;
n@34 318 w = Math.random()*w;
n@138 319 w = Math.floor(w+(offset+8));
n@138 320 trackSliderObj.style.left = w+'px';
n@34 321 trackSliderObj.innerHTML = '<span>'+index+'</span>';
n@34 322 trackSliderObj.draggable = true;
n@34 323 trackSliderObj.ondragend = dragEnd;
n@49 324 trackSliderObj.ondragstart = function()
n@49 325 {
n@154 326 var id = Number(event.srcElement.attributes['trackIndex'].value);
n@49 327 audioEngineContext.metric.sliderMoveStart(id);
n@49 328 };
n@34 329
n@34 330 // Onclick, switch playback to that track
n@34 331 trackSliderObj.onclick = function() {
nicholas@108 332 // Start the test on first click, that way timings are more accurate.
nicholas@108 333 audioEngineContext.play();
nicholas@135 334 if (audioEngineContext.audioObjectsReady) {
nicholas@135 335 // Cannot continue to issue play command until audioObjects reported as ready!
nicholas@135 336 // Get the track ID from the object ID
n@154 337 var id = Number(event.srcElement.attributes['trackIndex'].value);
nicholas@135 338 //audioEngineContext.metric.sliderPlayed(id);
nicholas@135 339 audioEngineContext.selectedTrack(id);
nicholas@135 340 // Currently playing track red, rest green
n@154 341
n@154 342 //document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
n@154 343 $('.track-slider').removeClass('track-slider-playing');
n@154 344 $(event.srcElement).addClass('track-slider-playing');
n@154 345 $('.comment-div').removeClass('comment-box-playing');
n@154 346 $('#comment-div-'+id).addClass('comment-box-playing');
nicholas@135 347 }
n@34 348 };
n@34 349
n@177 350 // Attach binding
n@179 351 audioObject.sliderDOM = trackSliderObj;
n@177 352
n@34 353 canvas.appendChild(trackSliderObj);
n@179 354 audioObject.metric.initialised(convSliderPosToRate(index));
b@102 355
n@34 356 });
n@39 357
nicholas@65 358 // Append any commentQuestion boxes
n@181 359 $(audioHolderObject.commentQuestions).each(function(index,element) {
nicholas@65 360 // Create document objects to hold the comment boxes
nicholas@65 361 var trackComment = document.createElement('div');
nicholas@65 362 trackComment.className = 'comment-div commentQuestion';
n@181 363 trackComment.id = element.id;
nicholas@65 364 // Create a string next to each comment asking for a comment
nicholas@65 365 var trackString = document.createElement('span');
n@181 366 trackString.innerHTML = element.question;
nicholas@65 367 // Create the HTML5 comment box 'textarea'
nicholas@65 368 var trackCommentBox = document.createElement('textarea');
nicholas@65 369 trackCommentBox.rows = '4';
nicholas@65 370 trackCommentBox.cols = '100';
nicholas@65 371 trackCommentBox.name = 'commentQuestion'+index;
nicholas@65 372 trackCommentBox.className = 'trackComment';
nicholas@65 373 var br = document.createElement('br');
nicholas@65 374 // Add to the holder.
nicholas@65 375 trackComment.appendChild(trackString);
nicholas@65 376 trackComment.appendChild(br);
nicholas@65 377 trackComment.appendChild(trackCommentBox);
nicholas@65 378 feedbackHolder.appendChild(trackComment);
nicholas@65 379 });
n@153 380
n@153 381
n@153 382 testWaitIndicator();
n@39 383 }
n@39 384
nicholas@119 385
nicholas@5 386 function dragEnd(ev) {
nicholas@5 387 // Function call when a div has been dropped
n@33 388 var slider = document.getElementById('slider');
n@127 389 var marginSize = Number(slider.attributes['marginsize'].value);
n@51 390 var w = slider.style.width;
n@51 391 w = Number(w.substr(0,w.length-2));
nicholas@133 392 var x = ev.x;
n@127 393 if (x >= marginSize && x < w+marginSize) {
n@51 394 this.style.left = (x)+'px';
nicholas@5 395 } else {
n@127 396 if (x<marginSize) {
n@127 397 this.style.left = marginSize+'px';
nicholas@5 398 } else {
n@127 399 this.style.left = (w+marginSize) + 'px';
nicholas@5 400 }
nicholas@5 401 }
n@49 402 audioEngineContext.metric.sliderMoved();
nicholas@5 403 }
nicholas@7 404
b@101 405 function buttonSubmitClick() // TODO: Only when all songs have been played!
n@40 406 {
nicholas@107 407 hasBeenPlayed = audioEngineContext.checkAllPlayed();
nicholas@107 408 if (hasBeenPlayed.length == 0) {
nicholas@107 409 if (audioEngineContext.status == 1) {
nicholas@107 410 var playback = document.getElementById('playback-button');
nicholas@107 411 playback.click();
nicholas@107 412 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
nicholas@107 413 } else
nicholas@107 414 {
nicholas@107 415 if (audioEngineContext.timer.testStarted == false)
nicholas@107 416 {
nicholas@107 417 alert('You have not started the test! Please press start to begin the test!');
nicholas@107 418 return;
nicholas@107 419 }
nicholas@107 420 }
nicholas@129 421 testState.advanceState();
b@102 422 } else // if a fragment has not been played yet
b@102 423 {
nicholas@107 424 str = "";
nicholas@107 425 if (hasBeenPlayed.length > 1) {
nicholas@107 426 for (var i=0; i<hasBeenPlayed.length; i++) {
nicholas@107 427 str = str + hasBeenPlayed[i];
nicholas@107 428 if (i < hasBeenPlayed.length-2){
nicholas@107 429 str += ", ";
nicholas@107 430 } else if (i == hasBeenPlayed.length-2) {
nicholas@107 431 str += " or ";
nicholas@107 432 }
nicholas@107 433 }
nicholas@107 434 alert('You have not played fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.');
nicholas@107 435 } else {
nicholas@107 436 alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.');
nicholas@107 437 }
b@102 438 return;
b@102 439 }
n@40 440 }
n@40 441
n@51 442 function convSliderPosToRate(id)
n@51 443 {
n@51 444 var w = document.getElementById('slider').style.width;
n@127 445 var marginsize = Number(document.getElementById('slider').attributes['marginsize'].value);
n@51 446 var maxPix = w.substr(0,w.length-2);
n@51 447 var slider = document.getElementsByClassName('track-slider')[id];
n@51 448 var pix = slider.style.left;
n@51 449 pix = pix.substr(0,pix.length-2);
n@127 450 var rate = (pix-marginsize)/maxPix;
n@51 451 return rate;
n@51 452 }
n@51 453
n@127 454 function resizeWindow(event){
n@127 455 // Function called when the window has been resized.
n@127 456 // MANDATORY FUNCTION
n@127 457
n@127 458 // Store the slider marker values
n@127 459 var holdValues = [];
n@127 460 $(".track-slider").each(function(index,sliderObj){
n@127 461 holdValues.push(convSliderPosToRate(index));
n@127 462 });
n@127 463
n@127 464 var width = event.target.innerWidth;
n@127 465 var canvas = document.getElementById('sliderCanvasHolder');
n@127 466 var sliderDiv = canvas.children[0];
n@127 467 var sliderScaleDiv = canvas.children[1];
n@127 468 var marginsize = Number(sliderDiv.attributes['marginsize'].value);
n@127 469 var w = (marginsize+8)*2;
n@127 470 sliderDiv.style.width = width - w + 'px';
n@127 471 var width = width - w;
n@127 472 // Move sliders into new position
n@127 473 $(".track-slider").each(function(index,sliderObj){
n@127 474 var pos = holdValues[index];
n@127 475 var pix = pos * width;
n@127 476 sliderObj.style.left = pix+marginsize+'px';
n@127 477 });
n@127 478
n@127 479 // Move scale labels
n@127 480 $(sliderScaleDiv.children).each(function(index,scaleObj){
n@127 481 var position = Number(scaleObj.attributes['value'].value);
n@127 482 var pixelPosition = (position*width)+marginsize;
n@127 483 scaleObj.style.left = Math.floor((pixelPosition-($(scaleObj).width()/2)))+'px';
n@127 484 });
n@127 485 }
n@127 486
n@181 487 function pageXMLSave(store, testXML)
n@44 488 {
n@44 489 // Saves a specific test page
nicholas@129 490 var xmlDoc = store;
n@50 491 // Check if any session wide metrics are enabled
nicholas@67 492
n@181 493 var commentShow = testXML.elementComments;
nicholas@67 494
n@50 495 var metric = document.createElement('metric');
n@50 496 if (audioEngineContext.metric.enableTestTimer)
n@50 497 {
n@50 498 var testTime = document.createElement('metricResult');
n@50 499 testTime.id = 'testTime';
n@50 500 testTime.textContent = audioEngineContext.timer.testDuration;
n@50 501 metric.appendChild(testTime);
n@50 502 }
n@50 503 xmlDoc.appendChild(metric);
n@178 504 var audioObjects = audioEngineContext.audioObjects;
n@178 505 for (var i=0; i<audioObjects.length; i++)
n@45 506 {
n@45 507 var audioElement = document.createElement('audioElement');
n@178 508 audioElement.id = audioObjects[i].id;
n@178 509 audioElement.setAttribute('url',audioObjects[i].url);
n@51 510 var value = document.createElement('value');
n@51 511 value.innerHTML = convSliderPosToRate(i);
nicholas@67 512 if (commentShow) {
nicholas@67 513 var comment = document.createElement("comment");
nicholas@67 514 var question = document.createElement("question");
nicholas@67 515 var response = document.createElement("response");
n@178 516 question.textContent = audioObjects[i].commentDOM.children[0].textContent;
n@178 517 response.textContent = audioObjects[i].commentDOM.children[2].value;
n@178 518 console.log('Comment ' + i + ': ' + response.textContent); // DEBUG/SAFETY
nicholas@67 519 comment.appendChild(question);
nicholas@67 520 comment.appendChild(response);
nicholas@67 521 audioElement.appendChild(comment);
nicholas@67 522 }
n@45 523 audioElement.appendChild(value);
n@50 524 // Check for any per element metrics
n@177 525
n@178 526 audioElement.appendChild(audioObjects[i].metric.exportXMLDOM());
n@45 527 xmlDoc.appendChild(audioElement);
n@45 528 }
nicholas@65 529 var commentQuestion = document.getElementsByClassName('commentQuestion');
nicholas@65 530 for (var i=0; i<commentQuestion.length; i++)
nicholas@65 531 {
nicholas@65 532 var cqHolder = document.createElement('CommentQuestion');
nicholas@65 533 var comment = document.createElement('comment');
nicholas@65 534 var question = document.createElement('question');
nicholas@65 535 cqHolder.id = commentQuestion[i].id;
nicholas@65 536 comment.textContent = commentQuestion[i].children[2].value;
nicholas@65 537 question.textContent = commentQuestion[i].children[0].textContent;
n@124 538 console.log('Question ' + i + ': ' + commentQuestion[i].children[2].value); // DEBUG/SAFETY
nicholas@65 539 cqHolder.appendChild(question);
nicholas@65 540 cqHolder.appendChild(comment);
nicholas@65 541 xmlDoc.appendChild(cqHolder);
nicholas@65 542 }
nicholas@129 543 store = xmlDoc;
nicholas@67 544 }