2013-09-13 13:45:27 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
SortBy: "SeriesSortName,SortName",
|
|
|
|
|
SortOrder: "Ascending",
|
|
|
|
|
IncludeItemTypes: "Episode",
|
|
|
|
|
Recursive: true,
|
2014-03-11 19:11:01 -07:00
|
|
|
|
Fields: "SeriesInfo,PrimaryImageAspectRatio",
|
2013-11-09 11:44:38 -07:00
|
|
|
|
StartIndex: 0,
|
|
|
|
|
IsMissing: false,
|
|
|
|
|
IsVirtualUnaired: false
|
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 = '';
|
|
|
|
|
|
|
|
|
|
$('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create');
|
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
updateFilterControls();
|
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
html += LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "backdrop",
|
|
|
|
|
showTitle: true,
|
2013-12-22 10:16:24 -07:00
|
|
|
|
showParentTitle: true,
|
2014-03-19 10:44:55 -07:00
|
|
|
|
overlayText: true,
|
2014-04-09 20:47:57 -07:00
|
|
|
|
selectionPanel: true,
|
|
|
|
|
lazy: true
|
2013-12-21 11:37:34 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.itemsContainer', page).removeClass('timelineItemsContainer');
|
2013-09-13 13:45:27 -07:00
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
|
|
|
|
|
2014-03-15 21:23:58 -07:00
|
|
|
|
$('#items', page).html(html).trigger('create').createPosterItemMenus();
|
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);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.selectPageSize', page).on('change', function () {
|
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
2013-10-16 16:35:11 -07:00
|
|
|
|
|
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');
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
$(document).on('pageinit', "#episodesPage", function () {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2013-09-13 13:45:27 -07:00
|
|
|
|
}).on('pagebeforeshow', "#episodesPage", function () {
|
|
|
|
|
|
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-05-01 19:54:33 -07:00
|
|
|
|
LibraryBrowser.loadSavedQueryValues(getSavedQueryKey(), 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
|
|
|
|
|
|
|
|
|
reloadItems(this);
|
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#episodesPage", function () {
|
|
|
|
|
|
2013-10-18 09:09:47 -07:00
|
|
|
|
updateFilterControls(this);
|
2013-09-13 13:45:27 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|