2014-05-09 18:39:27 +00:00
|
|
|
(function (context, $) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
context.JK = context.JK || {};
|
|
|
|
|
context.JK.GearWizard = function (app) {
|
|
|
|
|
|
2014-05-23 03:05:05 +00:00
|
|
|
var logger = context.JK.logger;
|
2014-08-29 02:11:25 +00:00
|
|
|
var sessionUtils = context.JK.SessionUtils;
|
2014-05-23 03:05:05 +00:00
|
|
|
|
2014-05-09 18:39:27 +00:00
|
|
|
var $dialog = null;
|
2014-05-22 16:26:56 +00:00
|
|
|
var wizard = null;
|
2014-05-09 18:39:27 +00:00
|
|
|
var $wizardSteps = null;
|
|
|
|
|
var $templateSteps = null;
|
2014-06-03 21:19:39 +00:00
|
|
|
var loopbackWizard = null;
|
2014-11-15 02:47:56 +00:00
|
|
|
var adjustGearSettings = null;
|
2014-07-01 20:02:30 +00:00
|
|
|
var inputs = null;
|
2014-05-09 18:39:27 +00:00
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
var STEP_INTRO = 0;
|
|
|
|
|
var STEP_SELECT_DEVICE = 1;
|
|
|
|
|
var STEP_SELECT_TRACKS = 2;
|
|
|
|
|
var STEP_SELECT_CHAT = 3;
|
|
|
|
|
var STEP_DIRECT_MONITOR = 4;
|
2015-02-04 19:00:19 +00:00
|
|
|
var STEP_VIDEO_GEAR = 5;
|
|
|
|
|
var STEP_ROUTER_NETWORK = 6;
|
|
|
|
|
var STEP_SUCCESS = 7;
|
2014-05-09 18:39:27 +00:00
|
|
|
|
|
|
|
|
var stepUnderstandGear = new context.JK.StepUnderstandGear(app, this);
|
|
|
|
|
var stepSelectGear = new context.JK.StepSelectGear(app, this);
|
|
|
|
|
var stepConfigureTracks = new context.JK.StepConfigureTracks(app, this);
|
|
|
|
|
var stepConfigureVoiceChat = new context.JK.StepConfigureVoiceChat(app, this);
|
|
|
|
|
var stepDirectMonitoring = new context.JK.StepDirectMonitoring(app, this);
|
2015-02-04 19:00:19 +00:00
|
|
|
var stepVideoGear = new context.JK.StepVideoGear(app, this);
|
2014-05-09 18:39:27 +00:00
|
|
|
var stepNetworkTest = new context.JK.StepNetworkTest(app, this);
|
|
|
|
|
var stepSuccess = new context.JK.StepSuccess(app, this);
|
|
|
|
|
|
|
|
|
|
var STEPS = {
|
|
|
|
|
0: stepUnderstandGear,
|
|
|
|
|
1: stepSelectGear,
|
|
|
|
|
2: stepConfigureTracks,
|
|
|
|
|
3: stepConfigureVoiceChat,
|
2015-04-21 14:23:57 +00:00
|
|
|
4: stepDirectMonitoring
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-16 19:39:37 +00:00
|
|
|
function newSession() {
|
2014-07-01 20:02:30 +00:00
|
|
|
inputs = null;
|
|
|
|
|
|
2014-05-16 19:39:37 +00:00
|
|
|
context._.each(STEPS, function(stepInfo, stepNumber) {
|
|
|
|
|
if(stepInfo.newSession) {
|
|
|
|
|
stepInfo.newSession.call(stepInfo);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-23 03:05:05 +00:00
|
|
|
function onStepChanged(e, data) {
|
|
|
|
|
var step = wizard.getCurrentStep();
|
|
|
|
|
var $currentWizardStep = wizard.getCurrentWizardStep();
|
2014-05-09 18:39:27 +00:00
|
|
|
|
2014-05-23 03:05:05 +00:00
|
|
|
// update ftue step numbers
|
|
|
|
|
var $ftueSteps = $(context._.template($templateSteps.html(), {}, { variable: 'data' }));
|
|
|
|
|
var $activeStep = $ftueSteps.find('.ftue-stepnumber[data-step-number="' + step + '"]');
|
|
|
|
|
$activeStep.addClass('.active');
|
|
|
|
|
$activeStep.next().show(); // show the .ftue-step-title
|
|
|
|
|
$currentWizardStep.find('.ftuesteps').replaceWith($ftueSteps);
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// checks if we already have a profile called 'FTUE...'; if not, create one. if so, re-use it.
|
2014-05-30 17:07:27 +00:00
|
|
|
function createFTUEProfile() {
|
2014-05-09 18:39:27 +00:00
|
|
|
var profileName = context.jamClient.FTUEGetMusicProfileName();
|
|
|
|
|
|
|
|
|
|
logger.debug("current profile name: " + profileName);
|
|
|
|
|
|
|
|
|
|
if(profileName && profileName.indexOf('FTUE') == 0) {
|
2014-05-30 17:07:27 +00:00
|
|
|
// remove junk
|
|
|
|
|
context.jamClient.TrackDeleteProfile(profileName);
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-30 17:07:27 +00:00
|
|
|
var newProfileName = 'FTUEAttempt-' + new Date().getTime().toString();
|
|
|
|
|
logger.debug("setting FTUE-prefixed profile name to: " + newProfileName);
|
|
|
|
|
context.jamClient.FTUESetMusicProfileName(newProfileName);
|
2015-05-08 20:35:17 +00:00
|
|
|
if(context.jamClient.FTUESetPreferredMixerSampleRate) {
|
|
|
|
|
context.jamClient.FTUESetPreferredMixerSampleRate(1);
|
|
|
|
|
context.jamClient.FTUESetPreferredOutputSampleRate(1);
|
|
|
|
|
context.jamClient.FTUESetPreferredChatSampleRate(1);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 14:44:50 +00:00
|
|
|
context.jamClient.FTUEClearChannelAssignments();
|
2014-05-30 17:07:27 +00:00
|
|
|
newSession();
|
|
|
|
|
|
2014-05-09 18:39:27 +00:00
|
|
|
var profileName = context.jamClient.FTUEGetMusicProfileName();
|
|
|
|
|
|
|
|
|
|
logger.debug("name on exit: " + profileName);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function beforeShow(args) {
|
2014-08-29 02:11:25 +00:00
|
|
|
//context.jamClient.FTUECancel();
|
2014-05-09 18:39:27 +00:00
|
|
|
context.jamClient.FTUESetStatus(false);
|
2014-05-30 17:07:27 +00:00
|
|
|
createFTUEProfile();
|
2014-08-29 02:11:25 +00:00
|
|
|
sessionUtils.FTUEPageEnter();
|
2014-05-09 18:39:27 +00:00
|
|
|
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard.onBeforeShow(args);
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function afterShow() {
|
2018-04-21 16:33:18 +00:00
|
|
|
if(window.olark) olark('api.box.show');
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function afterHide() {
|
2018-04-21 16:33:18 +00:00
|
|
|
if(window.olark) olark('api.box.hide');
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard.onAfterHide();
|
|
|
|
|
|
2014-05-09 18:39:27 +00:00
|
|
|
context.jamClient.FTUESetStatus(true);
|
|
|
|
|
context.jamClient.FTUECancel();
|
2014-08-29 02:11:25 +00:00
|
|
|
sessionUtils.FTUEPageLeave();
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-06-19 01:59:52 +00:00
|
|
|
function reportFailureAnalytics() {
|
|
|
|
|
// on cancel, see if the user is leaving without having passed the audio test; if so, report it
|
|
|
|
|
var lastAnalytics = stepSelectGear.getLastAudioTestFailAnalytics();
|
|
|
|
|
if(lastAnalytics) {
|
|
|
|
|
logger.debug("reporting audio test failed")
|
|
|
|
|
context.JK.GA.trackAudioTestFailure(lastAnalytics.platform, lastAnalytics.reason, lastAnalytics.data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
logger.debug("audiotest failure: nothing to report");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var lastAnalytics = stepNetworkTest.getLastNetworkFailAnalytics();
|
|
|
|
|
if(lastAnalytics) {
|
|
|
|
|
logger.debug("reporting network test failed");
|
|
|
|
|
context.JK.GA.trackNetworkTestFailure(lastAnalytics.reason, lastAnalytics.data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
logger.debug("network test failure: nothing to report");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-27 15:23:16 +00:00
|
|
|
function onCanceled() {
|
2014-06-19 01:59:52 +00:00
|
|
|
reportFailureAnalytics();
|
|
|
|
|
|
2014-05-27 15:23:16 +00:00
|
|
|
if (app.cancelFtue) {
|
|
|
|
|
app.cancelFtue();
|
|
|
|
|
app.afterFtue = null;
|
|
|
|
|
app.cancelFtue = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return closeDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onClosed() {
|
2014-06-19 01:59:52 +00:00
|
|
|
reportFailureAnalytics();
|
|
|
|
|
|
2014-05-27 15:23:16 +00:00
|
|
|
if (app.afterFtue) {
|
|
|
|
|
// If there's a function to invoke, invoke it.
|
|
|
|
|
app.afterFtue();
|
|
|
|
|
app.afterFtue = null;
|
|
|
|
|
app.cancelFtue = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return closeDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 18:39:27 +00:00
|
|
|
function closeDialog() {
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard.onCloseDialog();
|
2014-05-09 18:39:27 +00:00
|
|
|
app.layout.closeDialog('gear-wizard');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function events() {
|
2014-05-23 03:05:05 +00:00
|
|
|
$(wizard).on('step_changed', onStepChanged);
|
2014-05-27 15:23:16 +00:00
|
|
|
$(wizard).on('wizard_cancel', onCanceled);
|
|
|
|
|
$(wizard).on('wizard_close', onClosed);
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setNextState(enabled) {
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard.setNextState(enabled);
|
2014-05-09 18:39:27 +00:00
|
|
|
}
|
|
|
|
|
|
2014-05-13 13:20:41 +00:00
|
|
|
function setBackState(enabled) {
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard.setBackState(enabled);
|
2014-05-13 13:20:41 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-16 17:16:09 +00:00
|
|
|
function moveToNext() {
|
|
|
|
|
wizard.moveToNext();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 20:02:30 +00:00
|
|
|
function setChosenInputs(_inputs) {
|
|
|
|
|
inputs = _inputs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getChosenInputs() {
|
|
|
|
|
return inputs;
|
|
|
|
|
}
|
2014-05-13 13:20:41 +00:00
|
|
|
|
2014-11-15 02:47:56 +00:00
|
|
|
function initialize(_loopbackWizard, _adjustGearSettings) {
|
2014-06-03 21:19:39 +00:00
|
|
|
|
|
|
|
|
loopbackWizard = _loopbackWizard;
|
2014-11-15 02:47:56 +00:00
|
|
|
adjustGearSettings = _adjustGearSettings;
|
2014-05-09 18:39:27 +00:00
|
|
|
|
|
|
|
|
// on initial page load, we are not in the FTUE. so cancel the FTUE and call FTUESetStatus(true) if needed
|
|
|
|
|
if(context.jamClient.FTUEGetStatus() == false) {
|
|
|
|
|
context.jamClient.FTUESetStatus(true);
|
|
|
|
|
}
|
2014-08-29 02:11:25 +00:00
|
|
|
//context.jamClient.FTUECancel();
|
2014-05-09 18:39:27 +00:00
|
|
|
|
|
|
|
|
var dialogBindings = { beforeShow: beforeShow, afterShow: afterShow, afterHide: afterHide };
|
|
|
|
|
|
|
|
|
|
app.bindDialog('gear-wizard', dialogBindings);
|
|
|
|
|
|
|
|
|
|
$dialog = $('#gear-wizard-dialog');
|
|
|
|
|
$wizardSteps = $dialog.find('.wizard-step');
|
|
|
|
|
$templateSteps = $('#template-ftuesteps');
|
2015-04-21 14:23:57 +00:00
|
|
|
var videoGear = $wizardSteps.filter($('.video-gear'))
|
2016-04-13 17:05:04 +00:00
|
|
|
var networkTest = $wizardSteps.filter($('.network-test'))
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard = new context.JK.Wizard(app);
|
2014-07-01 20:02:30 +00:00
|
|
|
|
|
|
|
|
stepUnderstandGear.initialize($wizardSteps.filter($('[layout-wizard-step=0]')), self);
|
|
|
|
|
stepSelectGear.initialize($wizardSteps.filter($('[layout-wizard-step=1]')), self);
|
|
|
|
|
stepConfigureTracks.initialize($wizardSteps.filter($('[layout-wizard-step=2]')), self);
|
|
|
|
|
stepConfigureVoiceChat.initialize($wizardSteps.filter($('[layout-wizard-step=3]')), self);
|
|
|
|
|
stepDirectMonitoring.initialize($wizardSteps.filter($('[layout-wizard-step=4]')), self);
|
2015-04-21 14:23:57 +00:00
|
|
|
stepSuccess.initialize($wizardSteps.filter($('.success')), self);
|
2016-04-13 17:05:04 +00:00
|
|
|
|
|
|
|
|
var dynamicStepCount = 5
|
2015-04-21 14:23:57 +00:00
|
|
|
if(videoGear.length) {
|
|
|
|
|
stepVideoGear.initialize(videoGear, self);
|
2016-04-13 17:05:04 +00:00
|
|
|
STEPS[dynamicStepCount++] = stepVideoGear
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(networkTest.length) {
|
|
|
|
|
stepNetworkTest.initialize($wizardSteps.filter($('.network-test')), self);
|
|
|
|
|
STEPS[dynamicStepCount++] = stepNetworkTest
|
2015-04-21 14:23:57 +00:00
|
|
|
}
|
2016-04-13 17:05:04 +00:00
|
|
|
|
|
|
|
|
STEPS[dynamicStepCount++]=stepSuccess
|
|
|
|
|
|
2014-05-23 03:05:05 +00:00
|
|
|
wizard.initialize($dialog, $wizardSteps, STEPS);
|
2014-05-09 18:39:27 +00:00
|
|
|
events();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 20:02:30 +00:00
|
|
|
this.setChosenInputs = setChosenInputs; // so step 2 can 'talk' to step 3
|
|
|
|
|
this.getChosenInputs = getChosenInputs;
|
2014-05-09 18:39:27 +00:00
|
|
|
this.setNextState = setNextState;
|
2014-05-13 13:20:41 +00:00
|
|
|
this.setBackState = setBackState;
|
2015-04-16 17:16:09 +00:00
|
|
|
this.moveToNext = moveToNext;
|
2014-05-09 18:39:27 +00:00
|
|
|
this.initialize = initialize;
|
2014-05-30 17:07:27 +00:00
|
|
|
this.createFTUEProfile = createFTUEProfile;
|
2014-06-03 21:19:39 +00:00
|
|
|
this.getWizard = function() {return wizard; }
|
|
|
|
|
this.getLoopbackWizard = function() { return loopbackWizard; };
|
2014-11-15 02:47:56 +00:00
|
|
|
this.getAdjustGearSettings = function() { return adjustGearSettings; };
|
2014-05-09 18:39:27 +00:00
|
|
|
|
|
|
|
|
self = this;
|
|
|
|
|
return this;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(window, jQuery);
|