Merge pull request #1743 from matjaz321/migrated-livetvschedule-to-es6-module

Migrated livetvschedule.js to ES6 module
This commit is contained in:
dkanada 2020-08-06 01:29:50 +09:00 committed by GitHub
commit df9303aabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 110 additions and 107 deletions

View File

@ -224,6 +224,7 @@
"src/controllers/livetvstatus.js", "src/controllers/livetvstatus.js",
"src/controllers/livetvguideprovider.js", "src/controllers/livetvguideprovider.js",
"src/controllers/livetvsettings.js", "src/controllers/livetvsettings.js",
"src/controllers/livetv/livetvschedule.js",
"src/controllers/livetv/livetvseriestimers.js", "src/controllers/livetv/livetvseriestimers.js",
"src/controllers/livetv/livetvchannels.js", "src/controllers/livetv/livetvchannels.js",
"src/controllers/shows/episodes.js", "src/controllers/shows/episodes.js",

View File

@ -1,20 +1,23 @@
define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'scripts/livetvcomponents', 'emby-button', 'emby-itemscontainer'], function (layoutManager, cardBuilder, appHost, imageLoader, loading) { import layoutManager from 'layoutManager';
'use strict'; import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
import loading from 'loading';
import 'scripts/livetvcomponents';
import 'emby-button';
import 'emby-itemscontainer';
loading = loading.default || loading; function enableScrollX() {
function enableScrollX() {
return !layoutManager.desktop; return !layoutManager.desktop;
} }
function renderRecordings(elem, recordings, cardOptions) { function renderRecordings(elem, recordings, cardOptions) {
if (recordings.length) { if (recordings.length) {
elem.classList.remove('hide'); elem.classList.remove('hide');
} else { } else {
elem.classList.add('hide'); elem.classList.add('hide');
} }
var recordingItems = elem.querySelector('.recordingItems'); const recordingItems = elem.querySelector('.recordingItems');
if (enableScrollX()) { if (enableScrollX()) {
recordingItems.classList.add('scrollX'); recordingItems.classList.add('scrollX');
@ -44,13 +47,13 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
preferThumb: 'auto' preferThumb: 'auto'
}, cardOptions || {})); }, cardOptions || {}));
imageLoader.lazyChildren(recordingItems); imageLoader.lazyChildren(recordingItems);
} }
function getBackdropShape() { function getBackdropShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop'; return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
} }
function renderActiveRecordings(context, promise) { function renderActiveRecordings(context, promise) {
promise.then(function (result) { promise.then(function (result) {
renderRecordings(context.querySelector('#activeRecordings'), result.Items, { renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
shape: enableScrollX() ? 'autooverflow' : 'auto', shape: enableScrollX() ? 'autooverflow' : 'auto',
@ -66,11 +69,11 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
overlayMoreButton: true overlayMoreButton: true
}); });
}); });
} }
function renderTimers(context, timers, options) { function renderTimers(context, timers, options) {
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) { LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
var elem = context; const elem = context;
if (html) { if (html) {
elem.classList.remove('hide'); elem.classList.remove('hide');
@ -81,19 +84,19 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
elem.querySelector('.recordingItems').innerHTML = html; elem.querySelector('.recordingItems').innerHTML = html;
imageLoader.lazyChildren(elem); imageLoader.lazyChildren(elem);
}); });
} }
function renderUpcomingRecordings(context, promise) { function renderUpcomingRecordings(context, promise) {
promise.then(function (result) { promise.then(function (result) {
renderTimers(context.querySelector('#upcomingRecordings'), result.Items); renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
loading.hide(); loading.hide();
}); });
} }
return function (view, params, tabContent) { export default function (view, params, tabContent) {
var activeRecordingsPromise; let activeRecordingsPromise;
var upcomingRecordingsPromise; let upcomingRecordingsPromise;
var self = this; const self = this;
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () { tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
self.preRender(); self.preRender();
self.renderTab(); self.renderTab();
@ -118,5 +121,4 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
renderActiveRecordings(tabContent, activeRecordingsPromise); renderActiveRecordings(tabContent, activeRecordingsPromise);
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise); renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
}; };
}; }
});