2016-10-12 11:23:09 -07:00
|
|
|
|
define(['components/categorysyncbuttons', 'cardBuilder', 'apphost', 'scripts/livetvcomponents', 'emby-button', 'listViewStyle', 'emby-itemscontainer'], function (categorysyncbuttons, cardBuilder, appHost) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-09-07 00:08:20 -07:00
|
|
|
|
function getRecordingGroupHtml(group) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="listItem">';
|
|
|
|
|
|
|
|
|
|
html += '<button type="button" is="emby-button" class="fab mini autoSize blue" item-icon><i class="md-icon">live_tv</i></button>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="listItemBody two-line">';
|
|
|
|
|
html += '<a href="livetvitems.html?type=Recordings&groupid=' + group.Id + '" class="clearLink">';
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
html += group.Name;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="secondary">';
|
|
|
|
|
if (group.RecordingCount == 1) {
|
|
|
|
|
html += Globalize.translate('ValueItemCount', group.RecordingCount);
|
|
|
|
|
} else {
|
|
|
|
|
html += Globalize.translate('ValueItemCountPlural', group.RecordingCount);
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderRecordingGroups(context, groups) {
|
|
|
|
|
|
|
|
|
|
if (groups.length) {
|
|
|
|
|
context.querySelector('#recordingGroups').classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
context.querySelector('#recordingGroups').classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="paperList">';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = groups.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
html += getRecordingGroupHtml(groups[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
context.querySelector('#recordingGroupItems').innerHTML = html;
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 22:46:23 -07:00
|
|
|
|
function enableScrollX() {
|
|
|
|
|
return browserInfo.mobile && AppInfo.enableAppLayouts;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
function renderRecordings(elem, recordings, cardOptions) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
|
|
|
|
if (recordings.length) {
|
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var recordingItems = elem.querySelector('.recordingItems');
|
2016-05-15 22:46:23 -07:00
|
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
|
recordingItems.classList.add('hiddenScrollX');
|
2016-07-29 23:23:56 -07:00
|
|
|
|
recordingItems.classList.remove('vertical-wrap');
|
2016-05-15 22:46:23 -07:00
|
|
|
|
} else {
|
|
|
|
|
recordingItems.classList.remove('hiddenScrollX');
|
2016-07-29 23:23:56 -07:00
|
|
|
|
recordingItems.classList.add('vertical-wrap');
|
2016-05-15 22:46:23 -07:00
|
|
|
|
}
|
2016-06-06 18:55:16 -07:00
|
|
|
|
|
2016-10-12 11:23:09 -07:00
|
|
|
|
var supportsImageAnalysis = appHost.supports('imageanalysis');
|
|
|
|
|
var cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
|
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
|
2016-05-15 10:11:26 -07:00
|
|
|
|
items: recordings,
|
2016-05-18 10:02:56 -07:00
|
|
|
|
shape: (enableScrollX() ? 'autooverflow' : 'auto'),
|
2016-05-15 10:11:26 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
coverImage: true,
|
|
|
|
|
lazy: true,
|
2016-10-12 11:23:09 -07:00
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
|
centerText: !cardLayout,
|
|
|
|
|
vibrant: supportsImageAnalysis,
|
2016-09-14 09:20:03 -07:00
|
|
|
|
allowBottomPadding: !enableScrollX(),
|
2016-10-13 08:07:21 -07:00
|
|
|
|
preferThumb: 'auto',
|
|
|
|
|
overlayText: false
|
2016-09-14 09:20:03 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
}, cardOptions || {}));
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
|
|
|
|
ImageLoader.lazyChildren(recordingItems);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-09 00:18:43 -07:00
|
|
|
|
function getBackdropShape() {
|
|
|
|
|
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderActiveRecordings(context, promise) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
// The IsActive param is new, so handle older servers that don't support it
|
|
|
|
|
if (result.Items.length && result.Items[0].Status != 'InProgress') {
|
|
|
|
|
result.Items = [];
|
|
|
|
|
}
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-10-09 00:18:43 -07:00
|
|
|
|
renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
|
|
|
|
|
shape: getBackdropShape(),
|
|
|
|
|
showParentTitle: false,
|
|
|
|
|
showTitle: true,
|
|
|
|
|
showAirTime: true,
|
|
|
|
|
showAirEndTime: true,
|
|
|
|
|
showChannelName: true,
|
|
|
|
|
cardLayout: true,
|
|
|
|
|
vibrant: true,
|
|
|
|
|
preferThumb: true,
|
2016-10-13 08:07:21 -07:00
|
|
|
|
coverImage: true
|
2016-06-19 10:41:49 -07:00
|
|
|
|
});
|
2016-05-15 10:11:26 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderLatestRecordings(context, promise) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-10-17 09:41:18 -07:00
|
|
|
|
renderRecordings(context.querySelector('#latestRecordings'), result.Items, {
|
|
|
|
|
shape: (enableScrollX() ? 'overflowBackdrop' : 'backdrop')
|
|
|
|
|
});
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderMovieRecordings(context, promise) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
|
|
|
|
renderRecordings(context.querySelector('#movieRecordings'), result.Items, {
|
|
|
|
|
showYear: true,
|
|
|
|
|
showParentTitle: false
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderEpisodeRecordings(context, promise) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
2016-09-06 10:59:10 -07:00
|
|
|
|
renderRecordings(context.querySelector('#episodeRecordings'), result.Items, {
|
|
|
|
|
showItemCounts: true,
|
|
|
|
|
showParentTitle: false
|
|
|
|
|
});
|
2016-09-04 22:39:14 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderSportsRecordings(context, promise) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
2016-09-06 10:59:10 -07:00
|
|
|
|
renderRecordings(context.querySelector('#sportsRecordings'), result.Items, {
|
|
|
|
|
showYear: true,
|
|
|
|
|
showParentTitle: false
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderKidsRecordings(context, promise) {
|
2016-09-06 10:59:10 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-09-06 10:59:10 -07:00
|
|
|
|
|
|
|
|
|
renderRecordings(context.querySelector('#kidsRecordings'), result.Items, {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
showYear: true,
|
|
|
|
|
showParentTitle: false
|
|
|
|
|
});
|
2016-05-15 10:11:26 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
function onMoreClick(e) {
|
|
|
|
|
|
|
|
|
|
var type = this.getAttribute('data-type');
|
|
|
|
|
|
2016-10-09 00:18:43 -07:00
|
|
|
|
switch (type) {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
case 'latest':
|
|
|
|
|
Dashboard.navigate('livetvitems.html?type=Recordings');
|
|
|
|
|
break;
|
|
|
|
|
case 'movies':
|
|
|
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsMovie=true');
|
|
|
|
|
break;
|
|
|
|
|
case 'episodes':
|
2016-09-06 22:48:14 -07:00
|
|
|
|
Dashboard.navigate('livetvitems.html?type=RecordingSeries');
|
2016-09-04 22:39:14 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'programs':
|
|
|
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsSeries=false&IsMovie=false');
|
|
|
|
|
break;
|
2016-09-06 10:59:10 -07:00
|
|
|
|
case 'kids':
|
|
|
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsKids=true');
|
|
|
|
|
break;
|
|
|
|
|
case 'sports':
|
|
|
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsSports=true');
|
|
|
|
|
break;
|
2016-09-04 22:39:14 -07:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-05-15 10:11:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function (view, params, tabContent) {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
2016-10-02 23:28:45 -07:00
|
|
|
|
var activeRecordingsPromise;
|
|
|
|
|
var sportsPromise;
|
|
|
|
|
var kidsPromise;
|
|
|
|
|
var moviesPromise;
|
|
|
|
|
var seriesPromise;
|
|
|
|
|
var latestPromise;
|
2016-10-13 08:07:21 -07:00
|
|
|
|
var lastFullRender = 0;
|
2016-07-18 20:57:55 -07:00
|
|
|
|
|
|
|
|
|
categorysyncbuttons.init(tabContent);
|
2016-09-04 22:39:14 -07:00
|
|
|
|
|
|
|
|
|
var moreButtons = tabContent.querySelectorAll('.more');
|
|
|
|
|
for (var i = 0, length = moreButtons.length; i < length; i++) {
|
|
|
|
|
moreButtons[i].addEventListener('click', onMoreClick);
|
|
|
|
|
}
|
2016-06-19 10:41:49 -07:00
|
|
|
|
tabContent.querySelector('#activeRecordings .recordingItems').addEventListener('timercancelled', function () {
|
2016-10-02 23:28:45 -07:00
|
|
|
|
self.preRender();
|
|
|
|
|
self.renderTab();
|
2016-06-19 10:41:49 -07:00
|
|
|
|
});
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-10-13 08:07:21 -07:00
|
|
|
|
function enableFullRender() {
|
|
|
|
|
return (new Date().getTime() - lastFullRender) > 300000;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
self.preRender = function () {
|
2016-10-09 00:18:43 -07:00
|
|
|
|
|
|
|
|
|
activeRecordingsPromise = ApiClient.getLiveTvRecordings({
|
|
|
|
|
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
IsInProgress: true,
|
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
EnableImageTypes: "Primary,Thumb,Backdrop"
|
2016-10-02 23:28:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-10-13 08:07:21 -07:00
|
|
|
|
if (!enableFullRender()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
latestPromise = ApiClient.getLiveTvRecordings({
|
|
|
|
|
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
|
|
|
IsInProgress: false,
|
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
EnableImageTypes: "Primary,Thumb,Backdrop"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
moviesPromise = ApiClient.getLiveTvRecordings({
|
|
|
|
|
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
|
|
|
IsInProgress: false,
|
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
IsMovie: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
seriesPromise = ApiClient.getLiveTvRecordingSeries({
|
|
|
|
|
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
|
|
|
IsInProgress: false,
|
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
IsSeries: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
kidsPromise = ApiClient.getLiveTvRecordings({
|
|
|
|
|
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
|
|
|
IsInProgress: false,
|
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
IsKids: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
sportsPromise = ApiClient.getLiveTvRecordings({
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
|
|
|
IsInProgress: false,
|
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
IsSports: true
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-15 10:11:26 -07:00
|
|
|
|
self.renderTab = function () {
|
2016-10-02 23:28:45 -07:00
|
|
|
|
|
|
|
|
|
renderActiveRecordings(tabContent, activeRecordingsPromise);
|
|
|
|
|
|
2016-10-13 08:07:21 -07:00
|
|
|
|
if (enableFullRender()) {
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2016-10-02 23:28:45 -07:00
|
|
|
|
|
2016-10-13 08:07:21 -07:00
|
|
|
|
renderLatestRecordings(tabContent, latestPromise);
|
|
|
|
|
renderMovieRecordings(tabContent, moviesPromise);
|
|
|
|
|
renderEpisodeRecordings(tabContent, seriesPromise);
|
|
|
|
|
renderSportsRecordings(tabContent, sportsPromise);
|
|
|
|
|
renderKidsRecordings(tabContent, kidsPromise);
|
2016-10-02 23:28:45 -07:00
|
|
|
|
|
2016-10-13 08:07:21 -07:00
|
|
|
|
ApiClient.getLiveTvRecordingGroups({
|
2016-10-02 23:28:45 -07:00
|
|
|
|
|
2016-10-13 08:07:21 -07:00
|
|
|
|
userId: Dashboard.getCurrentUserId()
|
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
renderRecordingGroups(tabContent, result.Items);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
lastFullRender = new Date().getTime();
|
|
|
|
|
}
|
2016-05-15 10:11:26 -07:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|