annotate ape.js @ 911:c867677af7f4

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