From 0d19fce987cfa84dabdb81202a0840133b8f7d56 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 12 Apr 2013 14:22:40 -0400 Subject: [PATCH] display new fields on person page --- dashboard-ui/itembynamedetails.html | 7 +++-- dashboard-ui/scripts/extensions.js | 32 +++++++++++--------- dashboard-ui/scripts/itembynamedetailpage.js | 27 +++++++++++++++++ dashboard-ui/scripts/site.js | 4 +-- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/dashboard-ui/itembynamedetails.html b/dashboard-ui/itembynamedetails.html index 6fbe3d7349..2931825b2e 100644 --- a/dashboard-ui/itembynamedetails.html +++ b/dashboard-ui/itembynamedetails.html @@ -17,10 +17,13 @@
-

-

+

+

+

+

+
diff --git a/dashboard-ui/scripts/extensions.js b/dashboard-ui/scripts/extensions.js index 87ed8972f2..6fb690a9cb 100644 --- a/dashboard-ui/scripts/extensions.js +++ b/dashboard-ui/scripts/extensions.js @@ -109,7 +109,7 @@ function humane_date(date_str) { ]; var dt = new Date; - var date = parseISO8601Date(date_str, true); + var date = parseISO8601Date(date_str, { toLocal: true }); var seconds = ((dt - date) / 1000); var token = ' ago'; @@ -173,7 +173,9 @@ function getParameterByName(name) { return decodeURIComponent(results[1].replace(/\+/g, " ")); } -function parseISO8601Date(s, toLocal) { +function parseISO8601Date(s, options) { + + options = options || {}; // parenthese matches: // year month day hours minutes seconds @@ -181,8 +183,7 @@ function parseISO8601Date(s, toLocal) { // tzstring plusminus hours minutes var re = /(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)(\.\d+)?(Z|([+-])(\d\d):(\d\d))/; - var d = []; - d = s.match(re); + var d = s.match(re); // "2010-12-07T11:00:00.000-09:00" parses to: // ["2010-12-07T11:00:00.000-09:00", "2010", "12", "07", "11", @@ -192,6 +193,7 @@ function parseISO8601Date(s, toLocal) { // "00", "00", ".000", "Z", undefined, undefined, undefined] if (!d) { + throw "Couldn't parse ISO 8601 date string '" + s + "'"; } @@ -223,7 +225,7 @@ function parseISO8601Date(s, toLocal) { } else { ms += offset; } - } else if (!toLocal) { + } else if (!options.toLocal) { ms += new Date().getTimezoneOffset() * 60000; } @@ -334,19 +336,19 @@ function parseISO8601Date(s, toLocal) { //convert Ticks to human hr:min:sec format function ticks_to_human(str) { - var in_seconds = (str / 10000000); - var hours = Math.floor(in_seconds / 3600); - var minutes = Math.floor((in_seconds - (hours * 3600)) / 60); - var seconds = '0' + Math.round(in_seconds - (hours * 3600) - (minutes * 60)); + var in_seconds = (str / 10000000); + var hours = Math.floor(in_seconds / 3600); + var minutes = Math.floor((in_seconds - (hours * 3600)) / 60); + var seconds = '0' + Math.round(in_seconds - (hours * 3600) - (minutes * 60)); - var time = ''; + var time = ''; - if (hours > 0) time += hours + ":"; - if (minutes < 10 && hours == 0) time += minutes; - else time += ('0' + minutes).substr(-2); - time += ":" + seconds.substr(-2); + if (hours > 0) time += hours + ":"; + if (minutes < 10 && hours == 0) time += minutes; + else time += ('0' + minutes).substr(-2); + time += ":" + seconds.substr(-2); - return time; + return time; }; //parse video player src URL diff --git a/dashboard-ui/scripts/itembynamedetailpage.js b/dashboard-ui/scripts/itembynamedetailpage.js index c0ed3c70a4..6a8098c19c 100644 --- a/dashboard-ui/scripts/itembynamedetailpage.js +++ b/dashboard-ui/scripts/itembynamedetailpage.js @@ -52,6 +52,33 @@ renderUserDataIcons(page, item); renderLinks(page, item); + + if (item.Type == "Person" && item.PremiereDate) { + + var birthday = parseISO8601Date(item.PremiereDate, { toLocal: true }).toDateString(); + + $('#itemBirthday', page).show().html("Birthday:  " + birthday); + } else { + $('#itemBirthday', page).hide(); + } + + if (item.Type == "Person" && item.EndDate) { + + var deathday = parseISO8601Date(item.EndDate, { toLocal: true }).toDateString(); + + $('#itemDeathDate', page).show().html("Death day:  " + deathday); + } else { + $('#itemDeathDate', page).hide(); + } + + if (item.Type == "Person" && item.ProductionLocations && item.ProductionLocations.length) { + + var gmap = '' + item.ProductionLocations[0] + ''; + + $('#itemBirthLocation', page).show().html("Birth place:  " + gmap).trigger('create'); + } else { + $('#itemBirthLocation', page).hide(); + } } function renderLinks(page, item) { diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 382a9ac3db..38e856e725 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1,7 +1,7 @@ $.ajaxSetup({ crossDomain: true, - error: function (event, jqxhr, settings, exception) { + error: function (event) { Dashboard.hideLoadingMsg(); if (!Dashboard.suppressAjaxErrors) { @@ -23,8 +23,6 @@ $(document).one('click', WebNotifications.requestPermission); var Dashboard = { jQueryMobileInit: function () { - //$.mobile.defaultPageTransition = 'slide'; - // Page //$.mobile.page.prototype.options.theme = "a"; //$.mobile.page.prototype.options.headerTheme = "a";