From 72a4598a2eaf5c09048f8deb326f9710f2726a16 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 9 Apr 2013 01:06:13 -0400 Subject: [PATCH] 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);