2015-08-21 19:59:10 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
|
|
|
|
var guideController;
|
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
function init(page, type) {
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
var apiClient = ApiClient;
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).done(function (config) {
|
|
|
|
|
|
|
|
|
|
var providerId = null;
|
|
|
|
|
|
2015-08-22 11:09:02 -07:00
|
|
|
|
if ((config.LiveTvGuideProviderType || '').toLowerCase() == type.toLowerCase()) {
|
2015-08-22 09:55:23 -07:00
|
|
|
|
if (config.LiveTvGuideProviderId) {
|
|
|
|
|
providerId = config.LiveTvGuideProviderId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var url = 'tvproviders/' + type.toLowerCase() + '.js';
|
|
|
|
|
|
|
|
|
|
require([url], function (factory) {
|
|
|
|
|
|
|
|
|
|
var instance = new factory(page, providerId, {
|
|
|
|
|
showCancelButton: false,
|
|
|
|
|
showSubmitButton: false,
|
|
|
|
|
showConfirmation: false
|
|
|
|
|
});
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
instance.init();
|
|
|
|
|
guideController = instance;
|
|
|
|
|
|
|
|
|
|
$(guideController).on('submitted', skip);
|
|
|
|
|
});
|
2015-08-21 19:59:10 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
function loadTemplate(page, type) {
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
|
|
|
|
guideController = null;
|
|
|
|
|
|
|
|
|
|
ApiClient.ajax({
|
|
|
|
|
|
|
|
|
|
type: 'GET',
|
|
|
|
|
url: 'tvproviders/' + type + '.template.html'
|
|
|
|
|
|
|
|
|
|
}).done(function (html) {
|
|
|
|
|
|
|
|
|
|
var elem = page.querySelector('.providerTemplate');
|
|
|
|
|
elem.innerHTML = Globalize.translateDocument(html);
|
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
init(page, type);
|
2015-08-21 19:59:10 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function skip() {
|
|
|
|
|
var apiClient = ApiClient;
|
|
|
|
|
|
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Startup/Info')).done(function (info) {
|
|
|
|
|
|
|
|
|
|
if (info.SupportsRunningAsService) {
|
|
|
|
|
Dashboard.navigate('wizardservice.html');
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Dashboard.navigate('wizardagreement.html');
|
|
|
|
|
}
|
2015-08-22 11:15:35 -07:00
|
|
|
|
|
2015-08-21 19:59:10 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function next() {
|
|
|
|
|
guideController.submit();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
$('#selectType', page).trigger('change');
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#wizardGuidePage", function () {
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#selectType', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
loadTemplate(page, this.value);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnSkip', page).on('click', skip);
|
|
|
|
|
$('.btnNext', page).on('click', next);
|
|
|
|
|
|
2015-09-24 10:08:10 -07:00
|
|
|
|
}).on('pageshow', "#wizardGuidePage", function () {
|
2015-08-21 19:59:10 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-08-22 09:55:23 -07:00
|
|
|
|
reload(page);
|
2015-08-21 19:59:10 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, window);
|