mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 18:08:17 -07:00
Migration of livetvguide and livetvcomponents to ES6 moduoles
This commit is contained in:
parent
6607718edb
commit
947f8ba05d
@ -209,6 +209,7 @@
|
||||
"src/controllers/playback/queue/index.js",
|
||||
"src/controllers/playback/video/index.js",
|
||||
"src/controllers/searchpage.js",
|
||||
"src/controllers/livetv/livetvguide.js",
|
||||
"src/controllers/livetvtuner.js",
|
||||
"src/controllers/livetvstatus.js",
|
||||
"src/controllers/livetvsettings.js",
|
||||
@ -270,6 +271,7 @@
|
||||
"src/scripts/inputManager.js",
|
||||
"src/scripts/keyboardNavigation.js",
|
||||
"src/scripts/libraryBrowser.js",
|
||||
"src/scripts/livetvcomponents.js",
|
||||
"src/scripts/mouseManager.js",
|
||||
"src/scripts/multiDownload.js",
|
||||
"src/scripts/playlists.js",
|
||||
|
@ -1,29 +1,27 @@
|
||||
define(['tvguide'], function (tvguide) {
|
||||
'use strict';
|
||||
import tvguide from 'tvguide';
|
||||
|
||||
return function (view, params, tabContent) {
|
||||
var guideInstance;
|
||||
var self = this;
|
||||
export default function (view, params, tabContent) {
|
||||
let guideInstance;
|
||||
const self = this;
|
||||
|
||||
self.renderTab = function () {
|
||||
if (!guideInstance) {
|
||||
guideInstance = new tvguide({
|
||||
element: tabContent,
|
||||
serverId: ApiClient.serverId()
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.onShow = function () {
|
||||
if (guideInstance) {
|
||||
guideInstance.resume();
|
||||
}
|
||||
};
|
||||
|
||||
self.onHide = function () {
|
||||
if (guideInstance) {
|
||||
guideInstance.pause();
|
||||
}
|
||||
};
|
||||
self.renderTab = function () {
|
||||
if (!guideInstance) {
|
||||
guideInstance = new tvguide({
|
||||
element: tabContent,
|
||||
serverId: ApiClient.serverId()
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
self.onShow = function () {
|
||||
if (guideInstance) {
|
||||
guideInstance.resume();
|
||||
}
|
||||
};
|
||||
|
||||
self.onHide = function () {
|
||||
if (guideInstance) {
|
||||
guideInstance.pause();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -1,115 +1,104 @@
|
||||
define(['layoutManager', 'datetime', 'cardBuilder', 'apphost'], function (layoutManager, datetime, cardBuilder, appHost) {
|
||||
'use strict';
|
||||
import layoutManager from 'layoutManager';
|
||||
import datetime from 'datetime';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop;
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop;
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
||||
}
|
||||
|
||||
function getTimersHtml(timers, options) {
|
||||
options = options || {};
|
||||
const items = timers.map(function (t) {
|
||||
t.Type = 'Timer';
|
||||
return t;
|
||||
});
|
||||
const groups = [];
|
||||
let currentGroupName = '';
|
||||
let currentGroup = [];
|
||||
|
||||
for (let i = 0, length = items.length; i < length; i++) {
|
||||
const item = items[i];
|
||||
let dateText = '';
|
||||
|
||||
if (options.indexByDate !== false && item.StartDate) {
|
||||
try {
|
||||
const premiereDate = datetime.parseISO8601Date(item.StartDate, true);
|
||||
dateText = datetime.toLocaleDateString(premiereDate, {
|
||||
weekday: 'long',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('error parsing premiereDate:' + item.StartDate + '; error: ' + err);
|
||||
}
|
||||
}
|
||||
|
||||
if (dateText != currentGroupName) {
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
currentGroupName = dateText;
|
||||
currentGroup = [item];
|
||||
} else {
|
||||
currentGroup.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
||||
}
|
||||
|
||||
function getTimersHtml(timers, options) {
|
||||
options = options || {};
|
||||
var i;
|
||||
var length;
|
||||
var items = timers.map(function (t) {
|
||||
t.Type = 'Timer';
|
||||
return t;
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
var groups = [];
|
||||
var currentGroupName = '';
|
||||
var currentGroup = [];
|
||||
|
||||
for (i = 0, length = items.length; i < length; i++) {
|
||||
var item = items[i];
|
||||
var dateText = '';
|
||||
|
||||
if (options.indexByDate !== false && item.StartDate) {
|
||||
try {
|
||||
var premiereDate = datetime.parseISO8601Date(item.StartDate, true);
|
||||
dateText = datetime.toLocaleDateString(premiereDate, {
|
||||
weekday: 'long',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('error parsing premiereDate:' + item.StartDate + '; error: ' + err);
|
||||
}
|
||||
}
|
||||
|
||||
if (dateText != currentGroupName) {
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
currentGroupName = dateText;
|
||||
currentGroup = [item];
|
||||
} else {
|
||||
currentGroup.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
var html = '';
|
||||
|
||||
for (i = 0, length = groups.length; i < length; i++) {
|
||||
var group = groups[i];
|
||||
|
||||
if (group.name) {
|
||||
html += '<div class="verticalSection">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + '</h2>';
|
||||
}
|
||||
if (enableScrollX()) {
|
||||
var scrollXClass = 'scrollX hiddenScrollX';
|
||||
|
||||
if (layoutManager.tv) {
|
||||
scrollXClass += ' smoothScrollX';
|
||||
}
|
||||
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
|
||||
} else {
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||
}
|
||||
|
||||
html += cardBuilder.getCardsHtml({
|
||||
items: group.items,
|
||||
shape: getBackdropShape(),
|
||||
showParentTitleOrTitle: true,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: false,
|
||||
cardLayout: true,
|
||||
centerText: false,
|
||||
action: 'edit',
|
||||
cardFooterAside: 'none',
|
||||
preferThumb: true,
|
||||
defaultShape: null,
|
||||
coverImage: true,
|
||||
allowBottomPadding: false,
|
||||
overlayText: false,
|
||||
showChannelLogo: true
|
||||
});
|
||||
html += '</div>';
|
||||
|
||||
if (group.name) {
|
||||
html += '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(html);
|
||||
}
|
||||
let html = '';
|
||||
for (let i = 0, length = groups.length; i < length; i++) {
|
||||
const group = groups[i];
|
||||
if (group.name) {
|
||||
html += '<div class="verticalSection">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + '</h2>';
|
||||
}
|
||||
if (enableScrollX()) {
|
||||
let scrollXClass = 'scrollX hiddenScrollX';
|
||||
if (layoutManager.tv) {
|
||||
scrollXClass += ' smoothScrollX';
|
||||
}
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
|
||||
} else {
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||
}
|
||||
html += cardBuilder.getCardsHtml({
|
||||
items: group.items,
|
||||
shape: getBackdropShape(),
|
||||
showParentTitleOrTitle: true,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: false,
|
||||
cardLayout: true,
|
||||
centerText: false,
|
||||
action: 'edit',
|
||||
cardFooterAside: 'none',
|
||||
preferThumb: true,
|
||||
defaultShape: null,
|
||||
coverImage: true,
|
||||
allowBottomPadding: false,
|
||||
overlayText: false,
|
||||
showChannelLogo: true
|
||||
});
|
||||
html += '</div>';
|
||||
if (group.name) {
|
||||
html += '</div>';
|
||||
}
|
||||
}
|
||||
return Promise.resolve(html);
|
||||
}
|
||||
|
||||
window.LiveTvHelpers = {
|
||||
getTimersHtml: getTimersHtml
|
||||
};
|
||||
});
|
||||
window.LiveTvHelpers = {
|
||||
getTimersHtml: getTimersHtml
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user