comparison ape.js @ 154:61f8e66d119d Dev_main

Feature #1253: Comment box backgrounds light up when selected track playing. Colours for sliders and comment boxes now in ape.css for quick adjustments
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Mon, 01 Jun 2015 10:16:04 +0100
parents 789c3cd06290
children 2847fab8918e
comparison
equal deleted inserted replaced
153:789c3cd06290 154:61f8e66d119d
405 405
406 if (commentShow) { 406 if (commentShow) {
407 // Create document objects to hold the comment boxes 407 // Create document objects to hold the comment boxes
408 var trackComment = document.createElement('div'); 408 var trackComment = document.createElement('div');
409 trackComment.className = 'comment-div'; 409 trackComment.className = 'comment-div';
410 trackComment.id = 'comment-div-'+index;
410 // Create a string next to each comment asking for a comment 411 // Create a string next to each comment asking for a comment
411 var trackString = document.createElement('span'); 412 var trackString = document.createElement('span');
412 trackString.innerHTML = 'Comment on track '+index; 413 trackString.innerHTML = 'Comment on track '+index;
413 // Create the HTML5 comment box 'textarea' 414 // Create the HTML5 comment box 'textarea'
414 var trackCommentBox = document.createElement('textarea'); 415 var trackCommentBox = document.createElement('textarea');
427 // Create a slider per track 428 // Create a slider per track
428 429
429 var trackSliderObj = document.createElement('div'); 430 var trackSliderObj = document.createElement('div');
430 trackSliderObj.className = 'track-slider'; 431 trackSliderObj.className = 'track-slider';
431 trackSliderObj.id = 'track-slider-'+index; 432 trackSliderObj.id = 'track-slider-'+index;
433
434 var trackSliderAOIndex = document.createAttribute('trackIndex');
435 trackSliderAOIndex.nodeValue = index;
436 trackSliderObj.setAttributeNode(trackSliderAOIndex);
437
432 // Distribute it randomnly 438 // Distribute it randomnly
433 var w = window.innerWidth - (offset+8)*2; 439 var w = window.innerWidth - (offset+8)*2;
434 w = Math.random()*w; 440 w = Math.random()*w;
435 w = Math.floor(w+(offset+8)); 441 w = Math.floor(w+(offset+8));
436 trackSliderObj.style.left = w+'px'; 442 trackSliderObj.style.left = w+'px';
437 trackSliderObj.innerHTML = '<span>'+index+'</span>'; 443 trackSliderObj.innerHTML = '<span>'+index+'</span>';
438 trackSliderObj.draggable = true; 444 trackSliderObj.draggable = true;
439 trackSliderObj.ondragend = dragEnd; 445 trackSliderObj.ondragend = dragEnd;
440 trackSliderObj.ondragstart = function() 446 trackSliderObj.ondragstart = function()
441 { 447 {
442 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! 448 var id = Number(event.srcElement.attributes['trackIndex'].value);
443 audioEngineContext.metric.sliderMoveStart(id); 449 audioEngineContext.metric.sliderMoveStart(id);
444 }; 450 };
445 451
446 // Onclick, switch playback to that track 452 // Onclick, switch playback to that track
447 trackSliderObj.onclick = function() { 453 trackSliderObj.onclick = function() {
448 // Start the test on first click, that way timings are more accurate. 454 // Start the test on first click, that way timings are more accurate.
449 audioEngineContext.play(); 455 audioEngineContext.play();
450 if (audioEngineContext.audioObjectsReady) { 456 if (audioEngineContext.audioObjectsReady) {
451 // Cannot continue to issue play command until audioObjects reported as ready! 457 // Cannot continue to issue play command until audioObjects reported as ready!
452 // Get the track ID from the object ID 458 // Get the track ID from the object ID
453 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! 459 var id = Number(event.srcElement.attributes['trackIndex'].value);
454 //audioEngineContext.metric.sliderPlayed(id); 460 //audioEngineContext.metric.sliderPlayed(id);
455 audioEngineContext.selectedTrack(id); 461 audioEngineContext.selectedTrack(id);
456 // Currently playing track red, rest green 462 // Currently playing track red, rest green
457 document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; 463
458 for (var i = 0; i<$(currentTrackOrder).length; i++) 464 //document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
459 { 465 $('.track-slider').removeClass('track-slider-playing');
460 if (i!=index) // Make all other sliders green 466 $(event.srcElement).addClass('track-slider-playing');
461 { 467 $('.comment-div').removeClass('comment-box-playing');
462 document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; 468 $('#comment-div-'+id).addClass('comment-box-playing');
463 }
464
465 }
466 } 469 }
467 }; 470 };
468 471
469 canvas.appendChild(trackSliderObj); 472 canvas.appendChild(trackSliderObj);
470 audioEngineContext.audioObjects[index].metric.initialised(convSliderPosToRate(index)); 473 audioEngineContext.audioObjects[index].metric.initialised(convSliderPosToRate(index));