Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 673:d4e55184f776
Added preliminary metrics functions
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Sun, 12 Apr 2015 18:20:39 +0100 |
parents | 9ea50bbcaf9a |
children | 436db2f29f73 |
comparison
equal
deleted
inserted
replaced
672:ef643c350f56 | 673:d4e55184f776 |
---|---|
99 downloadPoint.id = 'download-point'; | 99 downloadPoint.id = 'download-point'; |
100 | 100 |
101 // Create playback start/stop points | 101 // Create playback start/stop points |
102 var playback = document.createElement("button"); | 102 var playback = document.createElement("button"); |
103 playback.innerHTML = 'Start'; | 103 playback.innerHTML = 'Start'; |
104 playback.id = 'playback-button'; | |
104 // onclick function. Check if it is playing or not, call the correct function in the | 105 // onclick function. Check if it is playing or not, call the correct function in the |
105 // audioEngine, change the button text to reflect the next state. | 106 // audioEngine, change the button text to reflect the next state. |
106 playback.onclick = function() { | 107 playback.onclick = function() { |
107 if (audioEngineContext.status == 0) { | 108 if (audioEngineContext.status == 0) { |
108 audioEngineContext.play(); | 109 audioEngineContext.play(); |
114 }; | 115 }; |
115 // Create Submit (save) button | 116 // Create Submit (save) button |
116 var submit = document.createElement("button"); | 117 var submit = document.createElement("button"); |
117 submit.innerHTML = 'Submit'; | 118 submit.innerHTML = 'Submit'; |
118 submit.onclick = buttonSubmitClick; | 119 submit.onclick = buttonSubmitClick; |
120 submit.id = 'submit-button'; | |
119 // Append the interface buttons into the interfaceButtons object. | 121 // Append the interface buttons into the interfaceButtons object. |
120 interfaceButtons.appendChild(playback); | 122 interfaceButtons.appendChild(playback); |
121 interfaceButtons.appendChild(submit); | 123 interfaceButtons.appendChild(submit); |
122 interfaceButtons.appendChild(downloadPoint); | 124 interfaceButtons.appendChild(downloadPoint); |
123 | 125 |
303 w = Math.random()*w; | 305 w = Math.random()*w; |
304 trackSliderObj.style.left = Math.floor(w)+50+'px'; | 306 trackSliderObj.style.left = Math.floor(w)+50+'px'; |
305 trackSliderObj.innerHTML = '<span>'+index+'</span>'; | 307 trackSliderObj.innerHTML = '<span>'+index+'</span>'; |
306 trackSliderObj.draggable = true; | 308 trackSliderObj.draggable = true; |
307 trackSliderObj.ondragend = dragEnd; | 309 trackSliderObj.ondragend = dragEnd; |
310 trackSliderObj.ondragstart = function() | |
311 { | |
312 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! | |
313 audioEngineContext.metric.sliderMoveStart(id); | |
314 }; | |
308 | 315 |
309 // Onclick, switch playback to that track | 316 // Onclick, switch playback to that track |
310 trackSliderObj.onclick = function() { | 317 trackSliderObj.onclick = function() { |
311 // Get the track ID from the object ID | 318 // Get the track ID from the object ID |
312 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! | 319 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! |
320 audioEngineContext.metric.sliderPlayed(id); | |
313 audioEngineContext.selectedTrack(id); | 321 audioEngineContext.selectedTrack(id); |
314 }; | 322 }; |
315 | 323 |
316 canvas.appendChild(trackSliderObj); | 324 canvas.appendChild(trackSliderObj); |
317 }); | 325 }); |
490 this.style.left = '50px'; | 498 this.style.left = '50px'; |
491 } else { | 499 } else { |
492 this.style.left = window.innerWidth-50 + 'px'; | 500 this.style.left = window.innerWidth-50 + 'px'; |
493 } | 501 } |
494 } | 502 } |
503 audioEngineContext.metric.sliderMoved(); | |
495 } | 504 } |
496 | 505 |
497 function advanceState() | 506 function advanceState() |
498 { | 507 { |
499 console.log(currentState); | 508 console.log(currentState); |
551 } | 560 } |
552 } | 561 } |
553 | 562 |
554 function buttonSubmitClick() | 563 function buttonSubmitClick() |
555 { | 564 { |
565 if (audioEngineContext.status == 1) { | |
566 var playback = document.getElementById('playback-button'); | |
567 playback.click(); | |
556 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options | 568 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options |
569 } | |
557 if (currentState.substr(0,7) == 'testRun') | 570 if (currentState.substr(0,7) == 'testRun') |
558 { | 571 { |
572 audioEngineContext.timer.stopTest(); | |
559 advanceState(); | 573 advanceState(); |
560 } | 574 } |
561 } | 575 } |
562 | 576 |
563 function pageXMLSave(testId) | 577 function pageXMLSave(testId) |