jam-cloud/app/assets/javascripts/ftueAudioTesting.js

98 lines
3.1 KiB
JavaScript

/**
* FtueAudioTestingScreen
* Javascript that goes with the screen where
* testing of selected audio devices happens.
* Corresponds to /#ftue3
*/
(function(context,$) {
"use strict";
context.JK = context.JK || {};
context.JK.FtueAudioTestingScreen = function(app) {
var logger = context.JK.logger;
var jamClient = context.jamClient;
var selectors = {
step1: 'div[layout-id="ftue3"] div[data-step="step1"]',
step2: 'div[layout-id="ftue3"] div[data-step="step2"]',
step3: 'div[layout-id="ftue3"] div[data-step="step3"]',
good: 'div[layout-id="ftue3"] div[data-step="good"]',
bad: 'div[layout-id="ftue3"] div[data-step="bad"]',
progress1: '#recordingTestProgress1',
progress1Int: '#___recordingTestProgress1___',
progress2: '#recordingTestProgress2',
progress2Int: '#___recordingTestProgress2___'
};
function beforeShow(data) {
$(selectors.step1).show();
$(selectors.step2).hide();
$(selectors.step3).hide();
$(selectors.good).hide();
$(selectors.bad).hide();
}
function afterShow(data) {}
function runProgressBar(selector, seconds, doneFunction) {
var id = "___" + selector.substr(1) + "___";
$(selector).html('<div id="' + id + '" class="progressFull"></div>');
$("#" + id).animate({
width: "400px"
}, seconds * 1000, doneFunction);
}
function startTestButtonHandler(evt) {
$(selectors.step1).hide();
$(selectors.step3).hide();
$(selectors.good).hide();
$(selectors.bad).hide();
$(selectors.step2).show();
runProgressBar(selectors.progress1, 10, good);
context.jamClient.RecordTestBegin();
}
function poorAudioButtonHandler(evt) {
$(selectors.progress1Int).stop();
$(selectors.step2).hide();
$(selectors.step3).show();
runProgressBar(selectors.progress2, 10, bad);
//context.jamClient.RecordTestBegin();
}
function goodAudioButtonHandler(evt) {
good();
}
function good() {
$(selectors.step2).hide();
$(selectors.step3).hide();
$(selectors.good).show();
}
function bad() {
$(selectors.step3).hide();
$(selectors.bad).show();
}
function events() {
$('.startTestButton').click(startTestButtonHandler);
$('#poorAudioButton').click(poorAudioButtonHandler);
$('#goodAudioButton').click(goodAudioButtonHandler);
}
function initialize() {
events();
var screenBindings = { 'beforeShow': beforeShow, 'afterShow': afterShow };
app.bindScreen('ftue3', screenBindings);
}
// Expose publics
this.initialize = initialize;
//context.JK.playbackTestComplete = playbackTestComplete;
return this;
};
})(window,jQuery);