jellyfin-web/dashboard-ui/scripts/wizardlivetvguide.js

102 lines
2.4 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2015-08-21 19:59:10 -07:00
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-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
2015-08-22 09:55:23 -07:00
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;
}
}
2015-10-27 11:21:30 -07:00
var url = 'components/tvproviders/' + type.toLowerCase() + '.js';
2015-08-22 09:55:23 -07:00
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',
2016-05-12 19:32:12 -07:00
url: 'components/tvproviders/' + type.toLowerCase() + '.template.html'
2015-08-21 19:59:10 -07:00
2015-12-14 08:43:03 -07:00
}).then(function (html) {
2015-08-21 19:59:10 -07:00
var elem = page.querySelector('.providerTemplate');
2016-03-05 12:07:58 -07:00
elem.innerHTML = Globalize.translateDocument(html);
2015-08-21 19:59:10 -07:00
2015-08-22 09:55:23 -07:00
init(page, type);
2015-08-21 19:59:10 -07:00
});
}
function skip() {
var apiClient = ApiClient;
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Info')).then(function (info) {
2015-08-21 19:59:10 -07:00
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
});
});