# HG changeset patch # User Nicholas Jillings # Date 1452618639 0 # Node ID afbb999e97cb53201ebe14a527413232cddac019 # Parent e3155b62af12d41e238a6ba98418f4be6ac91d8c Interfaces properly handle outside reference objects. Better core.js comment box handling. InterfaceDOM return their presented ID rather than assumed index. diff -r e3155b62af12 -r afbb999e97cb AB.js --- a/AB.js Tue Jan 12 14:58:22 2016 +0000 +++ b/AB.js Tue Jan 12 17:10:39 2016 +0000 @@ -203,6 +203,10 @@ this.getValue = function() { return this.value; }; + this.getPresentedId = function() + { + return this.selector.children[0].textContent; + }; }; this.boxHolders = document.getElementById('box-holders'); diff -r e3155b62af12 -r afbb999e97cb ape.js --- a/ape.js Tue Jan 12 14:58:22 2016 +0000 +++ b/ape.js Tue Jan 12 17:10:39 2016 +0000 @@ -346,12 +346,13 @@ outsideReferenceHolderspan = document.createElement('span'); outsideReferenceHolderspan.textContent = 'Reference'; outsideReferenceHolder.appendChild(outsideReferenceHolderspan); + outsideReferenceHolder.setAttribute('track-id',index); var audioObject = audioEngineContext.newTrack(element); outsideReferenceHolder.onclick = function(event) { - audioEngineContext.play(audioEngineContext.audioObjects.length-1); + audioEngineContext.play(event.currentTarget.getAttribute('track-id')); $('.track-slider').removeClass('track-slider-playing'); $('.comment-div').removeClass('comment-box-playing'); if (event.currentTarget.nodeName == 'DIV') { @@ -362,17 +363,17 @@ }; document.getElementById('interface-buttons').appendChild(outsideReferenceHolder); - return; + } else { + + // Now load each audio sample. First create the new track by passing the full URL + var trackURL = audioHolderObject.hostURL + element.url; + var audioObject = audioEngineContext.newTrack(element); + + var node = interfaceContext.createCommentBox(audioObject); + // Create a slider per track + var sliderNode = new sliderObject(audioObject,interfaceObj); + audioObject.bindInterface(sliderNode); } - - // Now load each audio sample. First create the new track by passing the full URL - var trackURL = audioHolderObject.hostURL + element.url; - var audioObject = audioEngineContext.newTrack(element); - - var node = interfaceContext.createCommentBox(audioObject); - // Create a slider per track - var sliderNode = new sliderObject(audioObject,interfaceObj); - audioObject.bindInterface(sliderNode); }); // Initialse the interfaceSlider object metrics @@ -549,7 +550,6 @@ trackObj.className = 'track-slider track-slider-disabled track-slider-'+audioObject.id; trackObj.id = 'track-slider-'+this.id+'-'+audioObject.id; trackObj.setAttribute('trackIndex',audioObject.id); - trackObj.innerHTML = ''+audioObject.id+''; if (this.name != undefined) { trackObj.setAttribute('interface-name',this.name); } else { @@ -564,6 +564,7 @@ this.canvas.appendChild(trackObj); this.sliders.push(trackObj); this.metrics.push(new metricTracker(this)); + trackObj.innerHTML = ''+(this.metrics.length-1)+''; this.metrics[this.metrics.length-1].initialise(convSliderPosToRate(trackObj)); return trackObj; }; @@ -647,6 +648,10 @@ this.getValue = function() { return convSliderPosToRate(this.trackSliderObjects[0]); }; + this.getPresentedId = function() + { + return this.trackSliderObjects[0].children[0].textContent; + }; } function buttonSubmitClick() diff -r e3155b62af12 -r afbb999e97cb core.js --- a/core.js Tue Jan 12 14:58:22 2016 +0000 +++ b/core.js Tue Jan 12 17:10:39 2016 +0000 @@ -1146,8 +1146,6 @@ this.interfaceDOM.enable(); } this.onplayGain = decibelToLinear(this.specification.gain)*this.buffer.buffer.playbackGain; - - this.storeDOM.setAttribute('presentedId',this.id); this.storeDOM.setAttribute('playGain',linearToDecibel(this.onplayGain)); }; @@ -1159,6 +1157,7 @@ { this.interfaceDOM.enable(); } + this.storeDOM.setAttribute('presentedId',interfaceObject.getPresentedId()); }; this.loopStart = function() { @@ -2543,18 +2542,13 @@ }; this.sortCommentBoxes = function() { - var holder = []; - while (this.commentBoxes.length > 0) { - var node = this.commentBoxes.pop(0); - holder[node.id] = node; - } - this.commentBoxes = holder; + this.commentBoxes.sort(function(a,b){return a.id - b.id;}); }; this.showCommentBoxes = function(inject, sort) { if (sort) {interfaceContext.sortCommentBoxes();} - for (var i=0; i