2013-09-13 13:45:27 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2015-05-26 08:31:50 -07:00
|
|
|
|
var view = LibraryBrowser.getDefaultItemsView('Poster', 'Poster');
|
2014-07-05 12:57:18 -07:00
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
SortBy: "SeriesSortName,SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Episode",
|
|
|
|
|
Recursive: true,
|
2014-12-10 23:20:28 -07:00
|
|
|
|
Fields: "PrimaryImageAspectRatio,MediaSourceCount,IsUnidentified,UserData,SyncInfo",
|
2013-11-09 11:44:38 -07:00
|
|
|
|
StartIndex: 0,
|
|
|
|
|
IsMissing: false,
|
2014-11-30 12:01:33 -07:00
|
|
|
|
IsVirtualUnaired: false,
|
|
|
|
|
ImageTypeLimit: 1,
|
2014-12-01 05:43:34 -07:00
|
|
|
|
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
|
2013-09-13 13:45:27 -07:00
|
|
|
|
};
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getSavedQueryKey() {
|
|
|
|
|
|
|
|
|
|
return 'episodes' + (query.ParentId || '');
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
$(document).scrollTop(0);
|
|
|
|
|
|
|
|
|
|
var html = '';
|
2015-01-28 12:30:45 -07:00
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
2014-07-19 21:46:29 -07:00
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
viewButton: true,
|
|
|
|
|
showLimit: false,
|
|
|
|
|
addSelectionButton: true
|
2015-01-28 12:30:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.listTopPaging', page).html(pagingHtml).trigger('create');
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
updateFilterControls();
|
2015-01-22 23:15:15 -07:00
|
|
|
|
var trigger = false;
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
if (view == "List") {
|
|
|
|
|
|
|
|
|
|
html = LibraryBrowser.getListViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
context: 'tv',
|
|
|
|
|
sortBy: query.SortBy
|
|
|
|
|
});
|
2015-01-22 23:15:15 -07:00
|
|
|
|
trigger = true;
|
2014-07-05 12:57:18 -07:00
|
|
|
|
}
|
|
|
|
|
else if (view == "Poster") {
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
2014-08-01 19:34:45 -07:00
|
|
|
|
overlayText: true,
|
2014-07-10 21:27:46 -07:00
|
|
|
|
lazy: true,
|
2015-05-14 19:16:57 -07:00
|
|
|
|
context: 'tv',
|
|
|
|
|
showDetailsMenu: true
|
2014-07-05 12:57:18 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-11-10 20:41:19 -07:00
|
|
|
|
else if (view == "PosterCard") {
|
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
lazy: true,
|
|
|
|
|
context: 'tv',
|
2015-05-14 19:16:57 -07:00
|
|
|
|
cardLayout: true,
|
|
|
|
|
showDetailsMenu: true
|
2014-11-10 20:41:19 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-21 11:37:34 -07:00
|
|
|
|
|
2015-01-28 12:30:45 -07:00
|
|
|
|
var elem = $('.itemsContainer', page).html(html).lazyChildren();
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
if (trigger) {
|
2015-01-28 12:30:45 -07:00
|
|
|
|
elem.trigger('create');
|
2015-01-22 23:15:15 -07:00
|
|
|
|
}
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2015-01-28 12:30:45 -07:00
|
|
|
|
$(pagingHtml).appendTo(elem).trigger('create');
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
function updateFilterControls(page) {
|
2013-11-09 11:44:38 -07:00
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
|
|
|
|
// Reset form values using the last used query
|
|
|
|
|
$('.radioSortBy', page).each(function () {
|
|
|
|
|
|
|
|
|
|
this.checked = (query.SortBy || '').toLowerCase() == this.getAttribute('data-sortby').toLowerCase();
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
$('.radioSortOrder', page).each(function () {
|
|
|
|
|
|
|
|
|
|
this.checked = (query.SortOrder || '').toLowerCase() == this.getAttribute('data-sortorder').toLowerCase();
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
$('.chkStandardFilter', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var filters = "," + (query.Filters || "");
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
|
|
|
|
|
this.checked = filters.toLowerCase().indexOf(',' + filterName.toLowerCase()) != -1;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
$('.chkVideoTypeFilter', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var filters = "," + (query.VideoTypes || "");
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
|
|
|
|
|
this.checked = filters.indexOf(',' + filterName) != -1;
|
|
|
|
|
|
|
|
|
|
}).checkboxradio('refresh');
|
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
$('#selectView', page).val(view).selectmenu('refresh');
|
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
$('#chkHD', page).checked(query.IsHD == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkSD', page).checked(query.IsHD == false).checkboxradio('refresh');
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
|
|
|
|
$('#chkSubtitle', page).checked(query.HasSubtitles == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkTrailer', page).checked(query.HasTrailer == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkThemeSong', page).checked(query.HasThemeSong == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkThemeVideo', page).checked(query.HasThemeVideo == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkSpecialFeature', page).checked(query.ParentIndexNumber == 0).checkboxradio('refresh');
|
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
$('#chkMissingEpisode', page).checked(query.IsMissing == true).checkboxradio('refresh');
|
|
|
|
|
$('#chkFutureEpisode', page).checked(query.IsUnaired == true).checkboxradio('refresh');
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
|
|
|
|
$('.alphabetPicker', page).alphaValue(query.NameStartsWithOrGreater);
|
2014-07-19 21:46:29 -07:00
|
|
|
|
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
|
2013-10-18 09:09:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-15 08:46:20 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#episodesPage", function () {
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.radioSortBy', this).on('click', function () {
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.SortBy = this.getAttribute('data-sortby');
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.radioSortOrder', this).on('click', function () {
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.SortOrder = this.getAttribute('data-sortorder');
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.chkStandardFilter', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
var filters = query.Filters || "";
|
|
|
|
|
|
|
|
|
|
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
filters = filters ? (filters + ',' + filterName) : filterName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.Filters = filters;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.chkVideoTypeFilter', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
var filterName = this.getAttribute('data-filter');
|
|
|
|
|
var filters = query.VideoTypes || "";
|
|
|
|
|
|
|
|
|
|
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
filters = filters ? (filters + ',' + filterName) : filterName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.VideoTypes = filters;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#chkSubtitle', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasSubtitles = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#chkTrailer', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasTrailer = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#chkThemeSong', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasThemeSong = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#chkThemeVideo', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.HasThemeVideo = this.checked ? true : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#chkSpecialFeature', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.ParentIndexNumber = this.checked ? 0 : null;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-16 16:35:11 -07:00
|
|
|
|
$('#chkMissingEpisode', this).on('change', function () {
|
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
query.StartIndex = 0;
|
2013-11-09 11:44:38 -07:00
|
|
|
|
query.IsMissing = this.checked ? true : false;
|
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
$('#chkFutureEpisode', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
query.StartIndex = 0;
|
2013-11-09 11:44:38 -07:00
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
query.IsUnaired = true;
|
|
|
|
|
query.IsVirtualUnaired = null;
|
|
|
|
|
} else {
|
|
|
|
|
query.IsUnaired = null;
|
|
|
|
|
query.IsVirtualUnaired = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
$('#chkHD', this).on('change', function () {
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.IsHD = this.checked ? true : null;
|
2013-10-16 19:43:55 -07:00
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-10-24 11:38:57 -07:00
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
$('#chkSD', this).on('change', function () {
|
2013-10-24 11:38:57 -07:00
|
|
|
|
|
2013-10-26 15:01:21 -07:00
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
query.IsHD = this.checked ? false : null;
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
$('.alphabetPicker', this).on('alphaselect', function (e, character) {
|
|
|
|
|
|
|
|
|
|
query.NameStartsWithOrGreater = character;
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
}).on('alphaclear', function (e) {
|
|
|
|
|
|
|
|
|
|
query.NameStartsWithOrGreater = '';
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2014-03-19 10:44:55 -07:00
|
|
|
|
$('.itemsContainer', page).on('needsrefresh', function () {
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
$('#selectView', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
view = this.value;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveViewSetting(getSavedQueryKey(), view);
|
|
|
|
|
});
|
|
|
|
|
|
2014-07-19 21:46:29 -07:00
|
|
|
|
$('#selectPageSize', page).on('change', function () {
|
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-19 12:15:40 -07:00
|
|
|
|
}).on('pageshowready', "#episodesPage", function () {
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
var page = this;
|
2014-05-01 19:54:33 -07:00
|
|
|
|
query.ParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
var limit = LibraryBrowser.getDefaultPageSize();
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
2013-10-18 09:09:47 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
var viewkey = getSavedQueryKey();
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues(viewkey, query);
|
2013-10-17 11:24:27 -07:00
|
|
|
|
|
|
|
|
|
var filters = getParameterByName('filters');
|
|
|
|
|
if (filters) {
|
|
|
|
|
query.Filters = filters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortby = getParameterByName('sortby');
|
|
|
|
|
if (sortby) {
|
|
|
|
|
query.SortBy = sortby;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sortorder = getParameterByName('sortorder');
|
|
|
|
|
if (sortorder) {
|
|
|
|
|
query.SortOrder = sortorder;
|
|
|
|
|
}
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2014-07-05 12:57:18 -07:00
|
|
|
|
LibraryBrowser.getSavedViewSetting(viewkey).done(function (val) {
|
|
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
|
$('#selectView', page).val(val).selectmenu('refresh').trigger('change');
|
|
|
|
|
} else {
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
updateFilterControls(this);
|
2015-05-15 08:46:20 -07:00
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|