From ae312524dd49723c05f28531e917dfcf2a66853c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 1 Apr 2013 11:59:56 -0400 Subject: [PATCH] progress on movies home page --- dashboard-ui/css/site.css | 8 ++-- dashboard-ui/movies.html | 2 +- dashboard-ui/moviesrecommended.html | 17 ++++--- dashboard-ui/scripts/aboutpage.js | 30 ++++-------- dashboard-ui/scripts/indexpage.js | 15 +++--- dashboard-ui/scripts/moviesrecommended.js | 56 +++++++++++++++++++++++ dashboard-ui/scripts/site.js | 20 ++++++-- 7 files changed, 103 insertions(+), 45 deletions(-) create mode 100644 dashboard-ui/scripts/moviesrecommended.js diff --git a/dashboard-ui/css/site.css b/dashboard-ui/css/site.css index a61a726237..d5b257839c 100644 --- a/dashboard-ui/css/site.css +++ b/dashboard-ui/css/site.css @@ -424,7 +424,7 @@ form, .readOnlyContent { .posterViewItem img { max-width: 155px; - max-height: 148px; + max-height: 125px; vertical-align: bottom; } @@ -486,7 +486,7 @@ form, .readOnlyContent { .posterViewItem img { max-width: 190px; - max-height: 190px; + max-height: 160px; } } @@ -494,7 +494,7 @@ form, .readOnlyContent { .posterViewItem img { max-width: 250px; - max-height: 250px; + max-height: 200px; } } @@ -519,7 +519,7 @@ form, .readOnlyContent { .posterViewItem img { max-width: 300px; - max-height: 300px; + max-height: 250px; } } diff --git a/dashboard-ui/movies.html b/dashboard-ui/movies.html index 95d1fbfca1..0dba8a58bc 100644 --- a/dashboard-ui/movies.html +++ b/dashboard-ui/movies.html @@ -5,7 +5,7 @@
-

+

Movies

diff --git a/dashboard-ui/moviesrecommended.html b/dashboard-ui/moviesrecommended.html index 88e7e69d09..33ee98b284 100644 --- a/dashboard-ui/moviesrecommended.html +++ b/dashboard-ui/moviesrecommended.html @@ -18,15 +18,20 @@ Favorites
-

Latest Movies

+
+

Latest Movies

-
+
+
+ +
-

Resume

- -
-
diff --git a/dashboard-ui/scripts/aboutpage.js b/dashboard-ui/scripts/aboutpage.js index 14c593d541..bc6ceda14d 100644 --- a/dashboard-ui/scripts/aboutpage.js +++ b/dashboard-ui/scripts/aboutpage.js @@ -1,24 +1,12 @@ -var AboutPage = { +(function ($, document) { - onPageShow: function () { - AboutPage.pollForInfo(); - }, + $(document).on('pageshow', "#aboutPage", function () { + var page = this; + + ApiClient.getSystemInfo().done(function(info) { + $('#appVersionNumber', page).html(info.Version); + }); + }); - pollForInfo: function () { - ApiClient.getSystemInfo().done(AboutPage.renderInfo); - }, - - renderInfo: function (info) { - AboutPage.renderSystemInfo(info); - }, - - - renderSystemInfo: function (info) { - var page = $.mobile.activePage; - $('#appVersionNumber', page).html(info.Version); - }, - -}; - -$(document).on('pageshow', "#aboutPage", AboutPage.onPageShow); \ No newline at end of file +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js index 0a996e0573..57648592bd 100644 --- a/dashboard-ui/scripts/indexpage.js +++ b/dashboard-ui/scripts/indexpage.js @@ -1,11 +1,11 @@ -var IndexPage = { +(function ($, document) { - onPageShow: function () { - IndexPage.loadLibrary(Dashboard.getCurrentUserId(), this); - }, + $(document).on('pageshow', "#indexPage", function () { - loadLibrary: function (userId, page) { + var page = this; + var userId = Dashboard.getCurrentUserId(); + if (!userId) { return; } @@ -25,7 +25,6 @@ })); }); - } -}; + }); -$(document).on('pageshow', "#indexPage", IndexPage.onPageShow); \ No newline at end of file +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js new file mode 100644 index 0000000000..7ede94fb58 --- /dev/null +++ b/dashboard-ui/scripts/moviesrecommended.js @@ -0,0 +1,56 @@ +(function ($, document) { + + $(document).on('pageshow', "#moviesRecommendedPage", function () { + + var page = this; + + var options = { + + SortBy: "DateCreated", + SortOrder: "Descending", + IncludeItemTypes: "Movie", + Limit: 5, + Recursive: true, + Fields: "PrimaryImageAspectRatio" + }; + + ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { + + $('#recentlyAddedItems', page).html(Dashboard.getPosterViewHtml({ + items: result.Items, + useAverageAspectRatio: true + })); + + }); + + + options = { + + SortBy: "DatePlayed", + SortOrder: "Descending", + IncludeItemTypes: "Movie", + Filters: "IsResumable", + Limit: 5, + Recursive: true, + Fields: "PrimaryImageAspectRatio" + }; + + ApiClient.getItems(Dashboard.getCurrentUserId(), options).done(function (result) { + + if (result.Items.length) { + $('#resumableSection', page).show(); + } else { + $('#resumableSection', page).hide(); + } + + $('#resumableItems', page).html(Dashboard.getPosterViewHtml({ + items: result.Items, + useAverageAspectRatio: true + })); + + }); + + }); + + +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 69771500eb..838e5fa2a5 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -493,8 +493,7 @@ var Dashboard = { getAveragePrimaryImageAspectRatio: function (items) { - var total = 0; - var count = 0; + var values = []; for (var i = 0, length = items.length; i < length; i++) { @@ -504,11 +503,22 @@ var Dashboard = { continue; } - total += ratio; - count++; + values[values.length] = ratio; + } + + if (!values.length) { + return null; } - return count == 0 ? 1 : total / count; + // Use the median + values.sort(function (a, b) { return a - b; }); + + var half = Math.floor(values.length / 2); + + if (values.length % 2) + return values[half]; + else + return (values[half - 1] + values[half]) / 2.0; }, showUserFlyout: function () {