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

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-06 14:12:44 -07:00
define(['events'], function (events) {
2016-10-22 22:11:46 -07:00
'use strict';
2016-06-06 14:12:44 -07:00
function onListingsSubmitted() {
Dashboard.navigate('livetvstatus.html');
}
2015-08-10 10:37:50 -07:00
2015-08-21 19:59:10 -07:00
function init(page, type, providerId) {
2015-08-10 10:37:50 -07:00
2015-10-17 09:29:42 -07:00
var url = 'components/tvproviders/' + type + '.js';
2015-08-10 10:37:50 -07:00
2015-08-21 19:59:10 -07:00
require([url], function (factory) {
2015-08-10 10:37:50 -07:00
2015-08-21 19:59:10 -07:00
var instance = new factory(page, providerId, {
2015-08-10 10:37:50 -07:00
});
2016-06-06 14:12:44 -07:00
events.on(instance, 'submitted', onListingsSubmitted);
2015-08-21 19:59:10 -07:00
instance.init();
2015-08-10 10:37:50 -07:00
});
}
2015-08-21 19:59:10 -07:00
function loadTemplate(page, type, providerId) {
2015-08-10 10:37:50 -07:00
2015-12-14 08:43:03 -07:00
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/tvproviders/' + type + '.template.html', true);
2015-08-10 10:37:50 -07:00
2015-12-14 08:43:03 -07:00
xhr.onload = function (e) {
2015-08-10 10:37:50 -07:00
2015-12-14 08:43:03 -07:00
var html = this.response;
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-10 10:37:50 -07:00
2015-08-21 19:59:10 -07:00
init(page, type, providerId);
2015-12-14 08:43:03 -07:00
}
xhr.send();
2015-08-10 10:37:50 -07:00
}
2016-06-06 14:12:44 -07:00
pageIdOn('pageshow', "liveTvGuideProviderPage", function () {
2015-08-10 10:37:50 -07:00
2015-08-21 19:59:10 -07:00
Dashboard.showLoadingMsg();
2015-08-10 10:37:50 -07:00
var providerId = getParameterByName('id');
2015-08-21 19:59:10 -07:00
var type = getParameterByName('type');
2015-08-10 10:37:50 -07:00
var page = this;
2015-08-21 19:59:10 -07:00
loadTemplate(page, type, providerId);
2015-08-10 10:37:50 -07:00
});
});