From 72a4598a2eaf5c09048f8deb326f9710f2726a16 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 9 Apr 2013 01:06:13 -0400 Subject: [PATCH 1/2] paging progress --- dashboard-ui/css/librarybrowser.css | 3 +- dashboard-ui/scripts/librarybrowser.js | 209 ++++++++++++++----------- dashboard-ui/scripts/mediaplayer.js | 4 +- dashboard-ui/scripts/movies.js | 29 +--- 4 files changed, 124 insertions(+), 121 deletions(-) diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index 6eaf1c086b..d2b0f722f2 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -87,9 +87,10 @@ .libraryItemsGrid th { padding-bottom: 10px; + border-bottom: 1px solid #555; } - .libraryItemsGrid td, .libraryItemsGrid th { + .libraryItemsGrid td { border-top: 1px solid #555; border-bottom: 1px solid #555; } diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index fa6030abd8..f05bcd64a5 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -1,5 +1,5 @@ var LibraryBrowser = { - + getPosterViewHtml: function (options) { var items = options.items; @@ -148,72 +148,72 @@ return html; }, - getBoxsetPosterViewHtml: function (options) { + getBoxsetPosterViewHtml: function (options) { - var items = options.items; + var items = options.items; - var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null; + var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null; - var html = ""; + var html = ""; - for (var i = 0, length = items.length; i < length; i++) { - var item = items[i]; + for (var i = 0, length = items.length; i < length; i++) { + var item = items[i]; - var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary; + var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary; - var href = item.url || ("boxset.html?id=" + item.Id); + var href = item.url || ("boxset.html?id=" + item.Id); - var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer'); + var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer'); - var cssClass = showText ? "posterViewItem posterViewItemWithDualText" : "posterViewItem posterViewItemWithNoText"; + var cssClass = showText ? "posterViewItem posterViewItemWithDualText" : "posterViewItem posterViewItemWithNoText"; - html += "
"; + html += ""; - } + html += "
"; + } - return html; - }, + return html; + }, getAveragePrimaryImageAspectRatio: function (items) { @@ -258,10 +258,10 @@ if (str) { var char = String(str.substr(0, 1).charCodeAt()); - var sum = 0; - for (var i = 0; i < char.length; i++) { - sum += parseInt(char.charAt(i)); - } + var sum = 0; + for (var i = 0; i < char.length; i++) { + sum += parseInt(char.charAt(i)); + } var index = String(sum).substr(-1); return LibraryBrowser.metroColors[index]; @@ -271,45 +271,72 @@ }, - renderLinks: function (item) { - var page = $.mobile.activePage; -//console.log(item); - if (item.ProviderIds) { + renderLinks: function (item) { + var page = $.mobile.activePage; + //console.log(item); + if (item.ProviderIds) { - var html = 'Links:  '; - var links = []; + var html = 'Links:  '; + var links = []; - if (item.ProviderIds.Imdb) { - if (item.Type == "Movie" || item.Type == "Episode") - links.push('IMDb'); - else if (item.Type == "Person") - links.push('IMDb'); - } - if (item.ProviderIds.Tmdb) { - if (item.Type == "Movie") - links.push('TMDB'); - else if (item.Type == "Person") - links.push('TMDB'); - } - if (item.ProviderIds.Tvdb) - links.push('TVDB'); - if (item.ProviderIds.Tvcom) { - if (item.Type == "Episode") - links.push('TV.com'); - else if (item.Type == "Person") - links.push('TV.com'); - } - if (item.ProviderIds.Musicbrainz) - links.push('MusicBrainz'); - if (item.ProviderIds.Gamesdb) - links.push('GamesDB'); + if (item.ProviderIds.Imdb) { + if (item.Type == "Movie" || item.Type == "Episode") + links.push('IMDb'); + else if (item.Type == "Person") + links.push('IMDb'); + } + if (item.ProviderIds.Tmdb) { + if (item.Type == "Movie") + links.push('TMDB'); + else if (item.Type == "Person") + links.push('TMDB'); + } + if (item.ProviderIds.Tvdb) + links.push('TVDB'); + if (item.ProviderIds.Tvcom) { + if (item.Type == "Episode") + links.push('TV.com'); + else if (item.Type == "Person") + links.push('TV.com'); + } + if (item.ProviderIds.Musicbrainz) + links.push('MusicBrainz'); + if (item.ProviderIds.Gamesdb) + links.push('GamesDB'); - html += links.join('  /  '); + html += links.join('  /  '); - $('#itemLinks', page).html(html); + $('#itemLinks', page).html(html); - } else { - $('#itemLinks', page).hide(); - } - } + } else { + $('#itemLinks', page).hide(); + } + }, + + getPagingHtml: function (query, totalRecordCount) { + + var html = ''; + + var pageCount = Math.ceil(totalRecordCount / query.Limit); + var pageNumber = (query.StartIndex / query.Limit) + 1; + + var dropdownHtml = ''; + + var recordsEnd = Math.min(query.StartIndex + query.Limit, totalRecordCount); + + html += '
'; + html += 'Results ' + (query.StartIndex + 1) + '-' + recordsEnd + ' of ' + totalRecordCount + ', page ' + dropdownHtml + ' of ' + pageCount; + html += '
'; + + return html; + } }; \ No newline at end of file diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index bdb8c52734..b4e6b06e73 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -1,4 +1,4 @@ -var MediaPlayer = (function (document, clearTimeout, screen, localStorage, _V_, $) { +var MediaPlayer = (function (document, clearTimeout, screen, localStorage, _V_, $, setInterval) { var testableAudioElement = document.createElement('audio'); var testableVideoElement = document.createElement('video'); @@ -360,4 +360,4 @@ return self; -})(document, clearTimeout, screen, localStorage, _V_, $); \ No newline at end of file +})(document, clearTimeout, screen, localStorage, _V_, $, setInterval); \ No newline at end of file diff --git a/dashboard-ui/scripts/movies.js b/dashboard-ui/scripts/movies.js index 1cf2449410..015a8aa078 100644 --- a/dashboard-ui/scripts/movies.js +++ b/dashboard-ui/scripts/movies.js @@ -138,31 +138,6 @@ return html; } - function getPagingHtml(result) { - - var html = ''; - - var pageCount = Math.round(result.TotalRecordCount / query.Limit); - var pageNumber = (query.StartIndex / query.Limit) + 1; - - var dropdownHtml = ''; - - html += '
'; - html += 'Results ' + (query.StartIndex + 1) + '-' + (query.StartIndex + query.Limit) + ' of ' + result.TotalRecordCount + ', page ' + dropdownHtml + ' of ' + pageCount; - html += '
'; - - return html; - } - function reloadItems(page) { Dashboard.showLoadingMsg(); @@ -174,7 +149,7 @@ var showPaging = result.TotalRecordCount > query.Limit; if (showPaging) { - html += getPagingHtml(result); + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); } if (view == "Poster") { @@ -188,7 +163,7 @@ } if (showPaging) { - html += getPagingHtml(result); + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); } var elem = $('#items', page); From 282f3a31c92a1e0a078f889f9ff017ec1af876f1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 9 Apr 2013 08:31:43 -0400 Subject: [PATCH 2/2] added series status filter --- dashboard-ui/scripts/librarybrowser.js | 2 +- dashboard-ui/scripts/tvshows.js | 223 ++++++++++++++----------- dashboard-ui/tvshows.html | 10 ++ 3 files changed, 135 insertions(+), 100 deletions(-) diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index f05bcd64a5..0333057367 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -52,7 +52,7 @@ html += ""; } - else if (item.MediaType == "Video") { + else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") { html += ""; } diff --git a/dashboard-ui/scripts/tvshows.js b/dashboard-ui/scripts/tvshows.js index 0e637014ab..26d716f47c 100644 --- a/dashboard-ui/scripts/tvshows.js +++ b/dashboard-ui/scripts/tvshows.js @@ -1,159 +1,184 @@ (function ($, document) { - // The base query options - var query = { + // The base query options + var query = { - SortBy: "SortName", - SortOrder: "Ascending", - IncludeItemTypes: "Series", - Recursive: true, - Fields: "PrimaryImageAspectRatio,SeriesInfo" - }; + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Series", + Recursive: true, + Fields: "PrimaryImageAspectRatio,SeriesInfo" + }; - function getTableHtml(items) { + function getTableHtml(items) { - var html = '
'; + var html = '
'; - html += ''; + html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; - html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; - html += ''; + html += ''; - html += ''; + html += ''; - for (var i = 0, length = items.length; i < length; i++) { + for (var i = 0, length = items.length; i < length; i++) { - html += getRowHtml(items[i]); - } + html += getRowHtml(items[i]); + } - html += ''; + html += ''; - html += '
 NameYearOfficial RatingRuntimeCommunity Rating
 NameYearOfficial RatingRuntimeCommunity Rating
'; + html += ''; - return html; - } + return html; + } - function getRowHtml(item) { + function getRowHtml(item) { - var html = ''; + var html = ''; - html += ''; + html += ''; - var url = "itemdetails.html?id=" + item.Id; + var url = "itemdetails.html?id=" + item.Id; - var imageTags = item.ImageTags; + var imageTags = item.ImageTags; - html += ''; + html += ''; - if (imageTags.Primary) { + if (imageTags.Primary) { - html += ''; + html += ''; - } - else { - html += ''; - } + } + else { + html += ''; + } - html += ''; + html += ''; - html += '' + item.Name + ''; + html += '' + item.Name + ''; - html += '' + (item.ProductionYear || "") + ''; + html += '' + (item.ProductionYear || "") + ''; - html += '' + (item.OfficialRating || "") + ''; - html += '' + (item.RunTimeTicks || "") + ''; - html += '' + (item.CommunityRating || "") + ''; + html += '' + (item.OfficialRating || "") + ''; + html += '' + (item.RunTimeTicks || "") + ''; + html += '' + (item.CommunityRating || "") + ''; - html += ''; - return html; - } + html += ''; + return html; + } - function reloadItems(page) { + function reloadItems(page) { - Dashboard.showLoadingMsg(); + Dashboard.showLoadingMsg(); - ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { - $('#items', page).html(LibraryBrowser.getPosterViewHtml({ + $('#items', page).html(LibraryBrowser.getPosterViewHtml({ - items: result.Items, - useAverageAspectRatio: true + items: result.Items, + useAverageAspectRatio: true - }))/*.html(getTableHtml(result.Items)).trigger('create')*/; + }))/*.html(getTableHtml(result.Items)).trigger('create')*/; - Dashboard.hideLoadingMsg(); - }); - } + Dashboard.hideLoadingMsg(); + }); + } - $(document).on('pageinit', "#tvShowsPage", function () { + $(document).on('pageinit', "#tvShowsPage", function () { - var page = this; + var page = this; - $('.radioSortBy', this).on('click', function () { - query.SortBy = this.getAttribute('data-sortby'); - reloadItems(page); - }); + $('.radioSortBy', this).on('click', function () { + query.SortBy = this.getAttribute('data-sortby'); + reloadItems(page); + }); - $('.radioSortOrder', this).on('click', function () { - query.SortOrder = this.getAttribute('data-sortorder'); - reloadItems(page); - }); + $('.radioSortOrder', this).on('click', function () { + query.SortOrder = this.getAttribute('data-sortorder'); + reloadItems(page); + }); - $('.chkStandardFilter', this).on('change', function () { + $('.chkStandardFilter', this).on('change', function () { - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; + var filterName = this.getAttribute('data-filter'); + var filters = query.Filters || ""; - filters = (',' + filters).replace(',' + filterName, '').substring(1); + filters = (',' + filters).replace(',' + filterName, '').substring(1); - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } - query.Filters = filters; + query.Filters = filters; - reloadItems(page); - }); + reloadItems(page); + }); - }).on('pagebeforeshow', "#tvShowsPage", function () { + $('.chkStatus', this).on('change', function () { - reloadItems(this); + var filterName = this.getAttribute('data-filter'); + var filters = query.SeriesStatus || ""; - }).on('pageshow', "#tvShowsPage", function () { + filters = (',' + filters).replace(',' + filterName, '').substring(1); - // Reset form values using the last used query - $('.radioSortBy', this).each(function () { + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } - this.checked = query.SortBy == this.getAttribute('data-sortby'); + query.SeriesStatus = filters; - }).checkboxradio('refresh'); + reloadItems(page); + }); - $('.radioSortOrder', this).each(function () { + }).on('pagebeforeshow', "#tvShowsPage", function () { - this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + reloadItems(this); - }).checkboxradio('refresh'); + }).on('pageshow', "#tvShowsPage", function () { - $('.chkStandardFilter', this).each(function () { + // Reset form values using the last used query + $('.radioSortBy', this).each(function () { - var filters = "," + (query.Filters || ""); - var filterName = this.getAttribute('data-filter'); + this.checked = query.SortBy == this.getAttribute('data-sortby'); - this.checked = filters.indexOf(',' + filterName) != -1; + }).checkboxradio('refresh'); - }).checkboxradio('refresh'); - }); + $('.chkStatus', this).each(function () { + + var filters = "," + (query.SeriesStatus || ""); + var filterName = this.getAttribute('data-filter'); + + this.checked = filters.indexOf(',' + filterName) != -1; + + }).checkboxradio('refresh'); + + $('.radioSortOrder', this).each(function () { + + this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + + }).checkboxradio('refresh'); + + $('.chkStandardFilter', this).each(function () { + + var filters = "," + (query.Filters || ""); + var filterName = this.getAttribute('data-filter'); + + this.checked = filters.indexOf(',' + filterName) != -1; + + }).checkboxradio('refresh'); + }); })(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/tvshows.html b/dashboard-ui/tvshows.html index 0e790a5664..518c38d57f 100644 --- a/dashboard-ui/tvshows.html +++ b/dashboard-ui/tvshows.html @@ -74,6 +74,16 @@ + +
+ +

Status:

+
+ + + + +