Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 1521:dfbe08826f64
Fixing APE for Firefox builds
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Thu, 10 Sep 2015 15:22:58 +0100 |
parents | ae6c77e78494 |
children | 36a0054a0ee0 |
comparison
equal
deleted
inserted
replaced
1520:349e0572ca2c | 1521:dfbe08826f64 |
---|---|
237 var canvas = document.createElement('div'); | 237 var canvas = document.createElement('div'); |
238 canvas.id = 'slider'; | 238 canvas.id = 'slider'; |
239 canvas.align = "left"; | 239 canvas.align = "left"; |
240 canvas.addEventListener('dragover',function(event){ | 240 canvas.addEventListener('dragover',function(event){ |
241 event.preventDefault(); | 241 event.preventDefault(); |
242 event.dataTransfer.effectAllowed = 'none'; | |
243 event.dataTransfer.dropEffect = 'copy'; | |
242 return false; | 244 return false; |
243 },false); | 245 },false); |
244 var sliderMargin = document.createAttribute('marginsize'); | 246 var sliderMargin = document.createAttribute('marginsize'); |
245 sliderMargin.nodeValue = 42; // Set default margins to 42px either side | 247 sliderMargin.nodeValue = 42; // Set default margins to 42px either side |
246 // Must have a known EXACT width, as this is used later to determine the ratings | 248 // Must have a known EXACT width, as this is used later to determine the ratings |
450 | 452 |
451 this.trackSliderObj.setAttribute('trackIndex',audioObject.id); | 453 this.trackSliderObj.setAttribute('trackIndex',audioObject.id); |
452 this.trackSliderObj.innerHTML = '<span>'+audioObject.id+'</span>'; | 454 this.trackSliderObj.innerHTML = '<span>'+audioObject.id+'</span>'; |
453 this.trackSliderObj.draggable = true; | 455 this.trackSliderObj.draggable = true; |
454 this.trackSliderObj.ondragend = dragEnd; | 456 this.trackSliderObj.ondragend = dragEnd; |
457 | |
458 this.trackSliderObj.ondragstart = function(event){ | |
459 event.dataTransfer.setData('Text',null); | |
460 }; | |
461 | |
462 this.trackSliderObj.ondrop = function(event) | |
463 { | |
464 if(event.stopPropagation) {event.stopPropagation();} | |
465 return false; | |
466 }; | |
455 | 467 |
456 // Onclick, switch playback to that track | 468 // Onclick, switch playback to that track |
457 this.trackSliderObj.onclick = function() { | 469 this.trackSliderObj.onclick = function(event) { |
458 // Start the test on first click, that way timings are more accurate. | 470 // Start the test on first click, that way timings are more accurate. |
459 audioEngineContext.play(); | 471 audioEngineContext.play(); |
460 if (audioEngineContext.audioObjectsReady) { | 472 if (audioEngineContext.audioObjectsReady) { |
461 // Cannot continue to issue play command until audioObjects reported as ready! | 473 // Cannot continue to issue play command until audioObjects reported as ready! |
462 // Get the track ID from the object ID | 474 // Get the track ID from the object ID |
463 var element; | 475 var element; |
464 if (event.srcElement.nodeName == "SPAN") { | 476 if (event.currentTarget.nodeName == "SPAN") { |
465 element = event.srcElement.parentNode; | 477 element = event.currentTarget.parentNode; |
466 } else { | 478 } else { |
467 element = event.srcElement; | 479 element = event.currentTarget; |
468 } | 480 } |
469 var id = Number(element.attributes['trackIndex'].value); | 481 var id = Number(element.attributes['trackIndex'].value); |
470 //audioEngineContext.metric.sliderPlayed(id); | 482 //audioEngineContext.metric.sliderPlayed(id); |
471 audioEngineContext.play(id); | 483 audioEngineContext.play(id); |
472 // Currently playing track red, rest green | 484 // Currently playing track red, rest green |
504 // Function call when a div has been dropped | 516 // Function call when a div has been dropped |
505 var slider = document.getElementById('slider'); | 517 var slider = document.getElementById('slider'); |
506 var marginSize = Number(slider.attributes['marginsize'].value); | 518 var marginSize = Number(slider.attributes['marginsize'].value); |
507 var w = slider.style.width; | 519 var w = slider.style.width; |
508 w = Number(w.substr(0,w.length-2)); | 520 w = Number(w.substr(0,w.length-2)); |
509 var x = ev.x; | 521 var x = ev.screenX; |
510 x += Math.abs(ev.view.screenLeft); | 522 |
511 x = x % ev.view.outerWidth; | 523 x += Math.abs(window.screenX); |
524 x = x % window.outerWidth; | |
525 | |
512 if (x >= marginSize && x < w+marginSize) { | 526 if (x >= marginSize && x < w+marginSize) { |
513 this.style.left = (x)+'px'; | 527 this.style.left = (x)+'px'; |
514 } else { | 528 } else { |
515 if (x<marginSize) { | 529 if (x<marginSize) { |
516 this.style.left = marginSize+'px'; | 530 this.style.left = marginSize+'px'; |
517 } else { | 531 } else { |
518 this.style.left = (w+marginSize) + 'px'; | 532 this.style.left = (w+marginSize) + 'px'; |
519 } | 533 } |
520 } | 534 } |
521 var time = audioEngineContext.timer.getTestTime(); | 535 var time = audioEngineContext.timer.getTestTime(); |
522 var id = Number(ev.srcElement.getAttribute('trackindex')); | 536 var id = Number(ev.currentTarget.getAttribute('trackindex')); |
523 audioEngineContext.audioObjects[id].metric.moved(time,convSliderPosToRate(ev.srcElement)); | 537 audioEngineContext.audioObjects[id].metric.moved(time,convSliderPosToRate(ev.currentTarget)); |
524 console.log('slider '+id+' moved to '+convSliderPosToRate(ev.srcElement)+' ('+time+')'); | 538 console.log('slider '+id+' moved to '+convSliderPosToRate(ev.currentTarget)+' ('+time+')'); |
525 } | 539 } |
526 | 540 |
527 function buttonSubmitClick() | 541 function buttonSubmitClick() |
528 { | 542 { |
529 var checks = testState.currentStateMap[testState.currentIndex].interfaces[0].options; | 543 var checks = testState.currentStateMap[testState.currentIndex].interfaces[0].options; |