2016-10-07 08:08:13 -07:00
|
|
|
|
define(['cardBuilder', 'apphost', 'emby-itemscontainer'], function (cardBuilder, appHost) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
return function (view, params) {
|
|
|
|
|
|
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
StartIndex: 0,
|
|
|
|
|
Fields: "ChannelInfo"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (params.type == 'Recordings') {
|
|
|
|
|
query.IsInProgress = false;
|
2016-09-07 00:08:20 -07:00
|
|
|
|
|
|
|
|
|
if (params.groupid) {
|
|
|
|
|
query.GroupId = params.groupid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (params.type == 'RecordingSeries') {
|
|
|
|
|
query.SortOrder = 'SortName';
|
|
|
|
|
query.SortOrder = 'Ascending';
|
2016-09-04 22:39:14 -07:00
|
|
|
|
} else {
|
|
|
|
|
query.HasAired = false;
|
|
|
|
|
query.SortBy = 'StartDate,SortName';
|
|
|
|
|
query.SortOrder = 'Ascending';
|
|
|
|
|
}
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
return LibraryBrowser.getSavedQueryKey();
|
|
|
|
|
}
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var promise = params.type == 'Recordings' ?
|
|
|
|
|
ApiClient.getLiveTvRecordings(query) :
|
2016-09-06 22:48:14 -07:00
|
|
|
|
params.type == 'RecordingSeries' ?
|
|
|
|
|
ApiClient.getLiveTvRecordingSeries(query) :
|
2016-09-08 13:32:30 -07:00
|
|
|
|
params.IsAiring == 'true' ?
|
|
|
|
|
ApiClient.getLiveTvRecommendedPrograms(query) :
|
2016-09-04 22:39:14 -07:00
|
|
|
|
ApiClient.getLiveTvPrograms(query);
|
|
|
|
|
|
|
|
|
|
promise.then(function (result) {
|
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
showLimit: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
page.querySelector('.listTopPaging').innerHTML = pagingHtml;
|
|
|
|
|
|
2016-10-07 08:08:13 -07:00
|
|
|
|
var supportsImageAnalysis = appHost.supports('imageanalysis') && (params.type == 'Recordings' || params.type == 'RecordingSeries');
|
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
html = cardBuilder.getCardsHtml({
|
|
|
|
|
items: result.Items,
|
2016-09-06 22:48:14 -07:00
|
|
|
|
shape: query.IsMovie || params.type == 'RecordingSeries' ? 'portrait' : "backdrop",
|
|
|
|
|
preferThumb: !query.IsMovie && params.type != 'RecordingSeries',
|
2016-09-16 22:47:49 -07:00
|
|
|
|
inheritThumb: params.type == 'Recordings',
|
2016-09-04 22:39:14 -07:00
|
|
|
|
context: 'livetv',
|
2016-10-13 08:07:21 -07:00
|
|
|
|
centerText: !supportsImageAnalysis,
|
2016-09-04 22:39:14 -07:00
|
|
|
|
lazy: true,
|
|
|
|
|
overlayText: false,
|
2016-09-30 11:57:56 -07:00
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
|
showTitle: false,
|
2016-09-07 13:11:16 -07:00
|
|
|
|
showParentTitle: query.IsSeries !== false && !query.IsMovie,
|
2016-09-30 11:43:59 -07:00
|
|
|
|
showAirTime: params.type != 'Recordings' && params.type != 'RecordingSeries',
|
|
|
|
|
showAirDateTime: params.type != 'Recordings' && params.type != 'RecordingSeries',
|
|
|
|
|
showChannelName: params.type != 'Recordings' && params.type != 'RecordingSeries',
|
2016-10-07 08:08:13 -07:00
|
|
|
|
overlayMoreButton: !supportsImageAnalysis,
|
2016-09-08 13:32:30 -07:00
|
|
|
|
showYear: query.IsMovie && params.type == 'Recordings',
|
2016-10-07 08:08:13 -07:00
|
|
|
|
coverImage: true,
|
|
|
|
|
cardLayout: supportsImageAnalysis,
|
|
|
|
|
vibrant: supportsImageAnalysis
|
2016-09-04 22:39:14 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var elem = page.querySelector('.itemsContainer');
|
|
|
|
|
elem.innerHTML = html + pagingHtml;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
|
|
|
|
|
var i, length;
|
|
|
|
|
var elems;
|
|
|
|
|
|
|
|
|
|
function onNextPageClick() {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPreviousPageClick() {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elems = page.querySelectorAll('.btnNextPage');
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
elems[i].addEventListener('click', onNextPageClick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elems = page.querySelectorAll('.btnPreviousPage');
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
elems[i].addEventListener('click', onPreviousPageClick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
2016-09-04 22:39:14 -07:00
|
|
|
|
}
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
view.addEventListener('viewbeforeshow', function () {
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
query.ParentId = LibraryMenu.getTopParentId();
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
var limit = LibraryBrowser.getDefaultPageSize();
|
2016-06-18 10:26:42 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
// If the default page size has changed, the start index will have to be reset
|
|
|
|
|
if (limit != query.Limit) {
|
|
|
|
|
query.Limit = limit;
|
|
|
|
|
query.StartIndex = 0;
|
2016-06-18 10:26:42 -07:00
|
|
|
|
}
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
if (params.IsMovie == 'true') {
|
|
|
|
|
query.IsMovie = true;
|
2016-06-18 10:26:42 -07:00
|
|
|
|
}
|
2016-09-06 10:59:10 -07:00
|
|
|
|
else if (params.IsMovie == 'false') {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
query.IsMovie = false;
|
2016-06-18 10:26:42 -07:00
|
|
|
|
}
|
2016-09-04 22:39:14 -07:00
|
|
|
|
if (params.IsSports == 'true') {
|
|
|
|
|
query.IsSports = true;
|
|
|
|
|
}
|
2016-09-06 10:59:10 -07:00
|
|
|
|
else if (params.IsSports == 'false') {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
query.IsSports = false;
|
|
|
|
|
}
|
|
|
|
|
if (params.IsKids == 'true') {
|
|
|
|
|
query.IsKids = true;
|
|
|
|
|
}
|
2016-09-06 10:59:10 -07:00
|
|
|
|
else if (params.IsKids == 'false') {
|
2016-09-04 22:39:14 -07:00
|
|
|
|
query.IsKids = false;
|
2016-06-18 10:26:42 -07:00
|
|
|
|
}
|
2016-09-08 13:32:30 -07:00
|
|
|
|
if (params.IsAiring == 'true') {
|
|
|
|
|
query.IsAiring = true;
|
|
|
|
|
}
|
|
|
|
|
else if (params.IsAiring == 'false') {
|
|
|
|
|
query.IsAiring = false;
|
|
|
|
|
}
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-07 23:15:44 -07:00
|
|
|
|
if (params.type == 'Recordings') {
|
|
|
|
|
|
2016-09-08 13:32:30 -07:00
|
|
|
|
if (params.IsMovie == 'true') {
|
2016-09-07 23:15:44 -07:00
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('TabMovies'));
|
2016-09-08 13:32:30 -07:00
|
|
|
|
} else if (params.IsSports == 'true') {
|
2016-09-07 23:15:44 -07:00
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('Sports'));
|
2016-09-08 13:32:30 -07:00
|
|
|
|
} else if (params.IsKids == 'true') {
|
2016-09-07 23:15:44 -07:00
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('HeaderForKids'));
|
|
|
|
|
} else {
|
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('TabRecordings'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (params.type == 'RecordingSeries') {
|
|
|
|
|
|
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('TabSeries'));
|
|
|
|
|
} else {
|
|
|
|
|
|
2016-09-08 13:32:30 -07:00
|
|
|
|
if (params.IsMovie == 'true') {
|
2016-09-07 23:15:44 -07:00
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('HeaderUpcomingMovies'));
|
2016-09-08 13:32:30 -07:00
|
|
|
|
} else if (params.IsSports == 'true') {
|
2016-09-07 23:15:44 -07:00
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('HeaderUpcomingSports'));
|
2016-09-08 13:32:30 -07:00
|
|
|
|
} else if (params.IsKids == 'true') {
|
2016-09-07 23:15:44 -07:00
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('HeaderUpcomingForKids'));
|
2016-09-08 13:32:30 -07:00
|
|
|
|
} else if (params.IsAiring == 'true') {
|
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('HeaderWhatsOnTV'));
|
2016-09-07 23:15:44 -07:00
|
|
|
|
} else {
|
|
|
|
|
LibraryMenu.setTitle(Globalize.translate('HeaderUpcomingPrograms'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
var viewkey = getSavedQueryKey();
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
LibraryBrowser.loadSavedQueryValues(viewkey, query);
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
2016-09-04 22:39:14 -07:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|