comparison ape.js @ 178:510dbc57e97e Dev_main

ape.js pageSaveXML uses view from audioObjects.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 04 Jun 2015 11:18:21 +0100
parents 25c296b254f8
children 8655b05c874f
comparison
equal deleted inserted replaced
177:25c296b254f8 178:510dbc57e97e
332 // In this jQuery loop, variable 'this' holds the current audioElement. 332 // In this jQuery loop, variable 'this' holds the current audioElement.
333 333
334 // Now load each audio sample. First create the new track by passing the full URL 334 // Now load each audio sample. First create the new track by passing the full URL
335 var trackURL = hostURL + this.attributes['url'].value; 335 var trackURL = hostURL + this.attributes['url'].value;
336 audioEngineContext.newTrack(trackURL); 336 audioEngineContext.newTrack(trackURL);
337 audioEngineContext.audioObjects[index].id = this.attributes['id'].value;
337 338
338 if (commentShow) { 339 if (commentShow) {
339 // Create document objects to hold the comment boxes 340 // Create document objects to hold the comment boxes
340 var trackComment = document.createElement('div'); 341 var trackComment = document.createElement('div');
341 trackComment.className = 'comment-div'; 342 trackComment.className = 'comment-div';
353 // Add to the holder. 354 // Add to the holder.
354 trackComment.appendChild(trackString); 355 trackComment.appendChild(trackString);
355 trackComment.appendChild(br); 356 trackComment.appendChild(br);
356 trackComment.appendChild(trackCommentBox); 357 trackComment.appendChild(trackCommentBox);
357 feedbackHolder.appendChild(trackComment); 358 feedbackHolder.appendChild(trackComment);
358 audioEngineContext.audioObjects[index].commentDOM = trackCommentBox; 359 audioEngineContext.audioObjects[index].commentDOM = trackComment;
359 } 360 }
360 361
361 // Create a slider per track 362 // Create a slider per track
362 363
363 var trackSliderObj = document.createElement('div'); 364 var trackSliderObj = document.createElement('div');
559 testTime.id = 'testTime'; 560 testTime.id = 'testTime';
560 testTime.textContent = audioEngineContext.timer.testDuration; 561 testTime.textContent = audioEngineContext.timer.testDuration;
561 metric.appendChild(testTime); 562 metric.appendChild(testTime);
562 } 563 }
563 xmlDoc.appendChild(metric); 564 xmlDoc.appendChild(metric);
564 var trackSliderObjects = document.getElementsByClassName('track-slider'); 565 var audioObjects = audioEngineContext.audioObjects;
565 var commentObjects = document.getElementsByClassName('comment-div'); 566 for (var i=0; i<audioObjects.length; i++)
566 for (var i=0; i<trackSliderObjects.length; i++)
567 { 567 {
568 var audioElement = document.createElement('audioElement'); 568 var audioElement = document.createElement('audioElement');
569 audioElement.id = currentTrackOrder[i].attributes['id'].value; 569 audioElement.id = audioObjects[i].id;
570 audioElement.setAttribute('url',currentTrackOrder[i].attributes['url'].value); 570 audioElement.setAttribute('url',audioObjects[i].url);
571 var value = document.createElement('value'); 571 var value = document.createElement('value');
572 value.innerHTML = convSliderPosToRate(i); 572 value.innerHTML = convSliderPosToRate(i);
573 if (commentShow) { 573 if (commentShow) {
574 var comment = document.createElement("comment"); 574 var comment = document.createElement("comment");
575 var question = document.createElement("question"); 575 var question = document.createElement("question");
576 var response = document.createElement("response"); 576 var response = document.createElement("response");
577 question.textContent = commentObjects[i].children[0].textContent; 577 question.textContent = audioObjects[i].commentDOM.children[0].textContent;
578 response.textContent = commentObjects[i].children[2].value; 578 response.textContent = audioObjects[i].commentDOM.children[2].value;
579 console.log('Comment ' + i + ': ' + commentObjects[i].children[2].value); // DEBUG/SAFETY 579 console.log('Comment ' + i + ': ' + response.textContent); // DEBUG/SAFETY
580 comment.appendChild(question); 580 comment.appendChild(question);
581 comment.appendChild(response); 581 comment.appendChild(response);
582 audioElement.appendChild(comment); 582 audioElement.appendChild(comment);
583 } 583 }
584 audioElement.appendChild(value); 584 audioElement.appendChild(value);
585 // Check for any per element metrics 585 // Check for any per element metrics
586 586
587 audioElement.appendChild(audioEngineContext.audioObjects[i].metric.exportXMLDOM()); 587 audioElement.appendChild(audioObjects[i].metric.exportXMLDOM());
588 xmlDoc.appendChild(audioElement); 588 xmlDoc.appendChild(audioElement);
589 } 589 }
590 var commentQuestion = document.getElementsByClassName('commentQuestion'); 590 var commentQuestion = document.getElementsByClassName('commentQuestion');
591 for (var i=0; i<commentQuestion.length; i++) 591 for (var i=0; i<commentQuestion.length; i++)
592 { 592 {