diff --git a/dashboard-ui/bower_components/emby-webcomponents/datetime.js b/dashboard-ui/bower_components/emby-webcomponents/datetime.js index 92c7afa59b..dc9f11309d 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/datetime.js +++ b/dashboard-ui/bower_components/emby-webcomponents/datetime.js @@ -114,6 +114,16 @@ function getDisplayTime(date) { + if ((typeof date).toString().toLowerCase() === 'string') { + try { + + date = parseISO8601Date(date, true); + + } catch (err) { + return date; + } + } + var currentLocale = globalize.getCurrentLocale(); var time = currentLocale && toLocaleTimeStringSupportsLocales ? @@ -124,7 +134,6 @@ if (timeLower.indexOf('am') != -1 || timeLower.indexOf('pm') != -1) { - time = timeLower; var hour = date.getHours() % 12; var suffix = date.getHours() > 11 ? 'pm' : 'am'; if (!hour) { diff --git a/dashboard-ui/components/remotecontrolautoplay.js b/dashboard-ui/components/remotecontrolautoplay.js index 6689ea3005..adae740796 100644 --- a/dashboard-ui/components/remotecontrolautoplay.js +++ b/dashboard-ui/components/remotecontrolautoplay.js @@ -1,4 +1,4 @@ -(function () { +define(['events'], function (events) { function transferPlayback(oldPlayer) { @@ -25,7 +25,7 @@ }); } - Events.on(MediaController, 'playerchange', function (e, newPlayer, newTarget, oldPlayer) { + events.on(MediaController, 'playerchange', function (e, newPlayer, newTarget, oldPlayer) { if (!oldPlayer) { console.log('Skipping remote control autoplay because oldPlayer is null'); @@ -48,4 +48,4 @@ } }); -})(); \ No newline at end of file +}); \ No newline at end of file diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 53d93cfad1..9d9cdefcde 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -1,4 +1,4 @@ -define(['playlistManager', 'appSettings', 'appStorage', 'apphost', 'jQuery', 'scrollStyles'], function (playlistManager, appSettings, appStorage, appHost, $) { +define(['playlistManager', 'appSettings', 'appStorage', 'apphost', 'datetime', 'jQuery', 'scrollStyles'], function (playlistManager, appSettings, appStorage, appHost, datetime, $) { var libraryBrowser = (function (window, document, screen) { @@ -3413,56 +3413,6 @@ detailImageProgressContainer.innerHTML = progressHtml || ''; }, - getDisplayTime: function (date) { - - if ((typeof date).toString().toLowerCase() === 'string') { - try { - - date = parseISO8601Date(date, { toLocal: true }); - - } catch (err) { - return date; - } - } - - var lower = date.toLocaleTimeString().toLowerCase(); - - var hours = date.getHours(); - var minutes = date.getMinutes(); - - var text; - - if (lower.indexOf('am') != -1 || lower.indexOf('pm') != -1) { - - var suffix = hours > 11 ? 'pm' : 'am'; - - hours = (hours % 12) || 12; - - text = hours; - - if (minutes) { - - text += ':'; - if (minutes < 10) { - text += '0'; - } - text += minutes; - } - - text += suffix; - - } else { - text = hours + ':'; - - if (minutes < 10) { - text += '0'; - } - text += minutes; - } - - return text; - }, - getMiscInfoHtml: function (item) { var miscInfo = []; @@ -3512,7 +3462,7 @@ miscInfo.push(text); if (item.Type != "Recording") { - text = LibraryBrowser.getDisplayTime(date); + text = datetime.getDisplayTime(date); miscInfo.push(text); } } diff --git a/dashboard-ui/scripts/livetvchannel.js b/dashboard-ui/scripts/livetvchannel.js index 72a25b500f..1e6800b1b5 100644 --- a/dashboard-ui/scripts/livetvchannel.js +++ b/dashboard-ui/scripts/livetvchannel.js @@ -1,4 +1,4 @@ -define(['jQuery'], function ($) { +define(['datetime'], function (datetime) { function renderPrograms(page, result) { @@ -32,7 +32,7 @@ } html += '
'; - html += '
' + LibraryBrowser.getDisplayTime(startDate) + '
'; + html += '
' + datetime.getDisplayTime(startDate) + '
'; html += '
'; cssClass = "tvProgramInfo"; @@ -96,7 +96,7 @@ html += ''; } - $('#childrenContent', page).html(html); + page.querySelector('#childrenContent').innerHTML = html; } function loadPrograms(page, channelId) { diff --git a/dashboard-ui/scripts/livetvcomponents.js b/dashboard-ui/scripts/livetvcomponents.js index a0e81b1e4a..51a39a9752 100644 --- a/dashboard-ui/scripts/livetvcomponents.js +++ b/dashboard-ui/scripts/livetvcomponents.js @@ -1,4 +1,4 @@ -define([], function () { +define(['datetime'], function (datetime) { function getTimersHtml(timers) { @@ -69,8 +69,8 @@ html += ''; html += '
'; - html += LibraryBrowser.getDisplayTime(timer.StartDate); - html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate); + html += datetime.getDisplayTime(timer.StartDate); + html += ' - ' + datetime.getDisplayTime(timer.EndDate); html += '
'; html += ''; diff --git a/dashboard-ui/scripts/livetvseriestimer.js b/dashboard-ui/scripts/livetvseriestimer.js index 3d9ffbec83..ce841aad59 100644 --- a/dashboard-ui/scripts/livetvseriestimer.js +++ b/dashboard-ui/scripts/livetvseriestimer.js @@ -1,4 +1,4 @@ -define(['jQuery'], function ($) { +define(['datetime', 'jQuery'], function (datetime, $) { var currentItem; @@ -52,7 +52,7 @@ $('.time', page).html(Globalize.translate('LabelAnytime')).trigger('create'); } else if (item.ChannelId) { - $('.time', page).html(LibraryBrowser.getDisplayTime(item.StartDate)).trigger('create'); + $('.time', page).html(datetime.getDisplayTime(item.StartDate)).trigger('create'); } Dashboard.hideLoadingMsg(); diff --git a/dashboard-ui/scripts/livetvseriestimers.js b/dashboard-ui/scripts/livetvseriestimers.js index 88994f7734..3035e4f004 100644 --- a/dashboard-ui/scripts/livetvseriestimers.js +++ b/dashboard-ui/scripts/livetvseriestimers.js @@ -1,4 +1,4 @@ -define(['jQuery'], function ($) { +define(['datetime', 'jQuery'], function (datetime, $) { var query = { @@ -63,7 +63,7 @@ html += ' - ' + Globalize.translate('LabelAnytime'); } else { - html += ' - ' + LibraryBrowser.getDisplayTime(timer.StartDate); + html += ' - ' + datetime.getDisplayTime(timer.StartDate); } html += ''; diff --git a/dashboard-ui/scripts/logpage.js b/dashboard-ui/scripts/logpage.js index 46b3e59885..2e71e14aea 100644 --- a/dashboard-ui/scripts/logpage.js +++ b/dashboard-ui/scripts/logpage.js @@ -1,4 +1,4 @@ -define(['jQuery', 'paper-fab', 'paper-item-body', 'paper-icon-item'], function ($) { +define(['datetime', 'jQuery', 'paper-fab', 'paper-item-body', 'paper-icon-item'], function (datetime, $) { function getTabs() { return [ @@ -65,7 +65,7 @@ var text = date.toLocaleDateString(); - text += ' ' + LibraryBrowser.getDisplayTime(date); + text += ' ' + datetime.getDisplayTime(date); logHtml += '
' + text + '
'; diff --git a/dashboard-ui/scripts/serversecurity.js b/dashboard-ui/scripts/serversecurity.js index 0c966d6d59..3b39c2b59b 100644 --- a/dashboard-ui/scripts/serversecurity.js +++ b/dashboard-ui/scripts/serversecurity.js @@ -1,4 +1,4 @@ -define(['jQuery'], function ($) { +define(['datetime', 'jQuery'], function (datetime, $) { function revoke(page, key) { @@ -61,7 +61,7 @@ var date = parseISO8601Date(item.DateCreated, { toLocal: true }); - html += date.toLocaleDateString() + ' ' + LibraryBrowser.getDisplayTime(date); + html += datetime.toLocaleDateString(date) + ' ' + datetime.getDisplayTime(date); html += '';