From 381834949675740ac631dfe910754f66633d3048 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 22 May 2015 15:16:14 -0400 Subject: [PATCH] lazy load scripts --- dashboard-ui/css/librarymenu.css | 8 +- dashboard-ui/livetvchannel.html | 2 +- dashboard-ui/livetvguide.html | 2 +- dashboard-ui/livetvnewrecording.html | 5 +- dashboard-ui/livetvprogram.html | 2 +- dashboard-ui/livetvrecording.html | 2 +- dashboard-ui/livetvrecordinglist.html | 2 +- dashboard-ui/livetvseriestimer.html | 2 +- dashboard-ui/livetvtimer.html | 2 +- dashboard-ui/scripts/librarybrowser.js | 52 +++- dashboard-ui/scripts/livetvchannel.js | 153 +-------- dashboard-ui/scripts/livetvcomponents.js | 291 ++++++++++++++++++ dashboard-ui/scripts/livetvguide.js | 214 +------------ dashboard-ui/scripts/livetvnewrecording.js | 12 +- dashboard-ui/scripts/livetvprogram.js | 4 +- dashboard-ui/scripts/livetvrecording.js | 4 +- dashboard-ui/scripts/livetvrecordinglist.js | 6 +- dashboard-ui/scripts/livetvseriestimer.js | 10 +- dashboard-ui/scripts/livetvseriestimers.js | 2 +- dashboard-ui/scripts/livetvtimer.js | 4 +- dashboard-ui/scripts/livetvtimers.js | 4 +- dashboard-ui/scripts/logpage.js | 2 +- dashboard-ui/scripts/mediacontroller.js | 41 ++- dashboard-ui/scripts/mediaplayer.js | 62 ++-- dashboard-ui/scripts/registrationservices.js | 6 + dashboard-ui/scripts/serversecurity.js | 2 +- .../cordova/registrationservices.js | 57 +++- 27 files changed, 510 insertions(+), 443 deletions(-) create mode 100644 dashboard-ui/scripts/livetvcomponents.js diff --git a/dashboard-ui/css/librarymenu.css b/dashboard-ui/css/librarymenu.css index ba94ad91a1..bfa482ffda 100644 --- a/dashboard-ui/css/librarymenu.css +++ b/dashboard-ui/css/librarymenu.css @@ -259,14 +259,14 @@ @media all and (min-width: 800px) { .dashboardDocument .dashboardMenuButton { - display: none; + display: none !important; } } @media all and (max-width: 800px) { .dashboardDocument .libraryMenuButton { - display: none; + display: none !important; } } @@ -282,10 +282,10 @@ /* They can use the left menu */ .dashboardEntryHeaderButton { - display: none; + display: none !important; } } .libraryDocument .dashboardMenuButton { - display: none; + display: none !important; } diff --git a/dashboard-ui/livetvchannel.html b/dashboard-ui/livetvchannel.html index 85e0c1d32a..4ab92ff6a8 100644 --- a/dashboard-ui/livetvchannel.html +++ b/dashboard-ui/livetvchannel.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/livetvguide.html b/dashboard-ui/livetvguide.html index be456b649f..6be147d3c1 100644 --- a/dashboard-ui/livetvguide.html +++ b/dashboard-ui/livetvguide.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/livetvnewrecording.html b/dashboard-ui/livetvnewrecording.html index a88644cf46..1266fe3fd2 100644 --- a/dashboard-ui/livetvnewrecording.html +++ b/dashboard-ui/livetvnewrecording.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} @@ -116,9 +116,6 @@
-
diff --git a/dashboard-ui/livetvprogram.html b/dashboard-ui/livetvprogram.html index 62d4cf5e45..25224b71ac 100644 --- a/dashboard-ui/livetvprogram.html +++ b/dashboard-ui/livetvprogram.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/livetvrecording.html b/dashboard-ui/livetvrecording.html index c5ef194477..5751de9ebe 100644 --- a/dashboard-ui/livetvrecording.html +++ b/dashboard-ui/livetvrecording.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/livetvrecordinglist.html b/dashboard-ui/livetvrecordinglist.html index 6d04cd265e..6c8a21854f 100644 --- a/dashboard-ui/livetvrecordinglist.html +++ b/dashboard-ui/livetvrecordinglist.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/livetvseriestimer.html b/dashboard-ui/livetvseriestimer.html index 6f3dd8a087..38fb626000 100644 --- a/dashboard-ui/livetvseriestimer.html +++ b/dashboard-ui/livetvseriestimer.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/livetvtimer.html b/dashboard-ui/livetvtimer.html index ce30c92aaa..9352c935ab 100644 --- a/dashboard-ui/livetvtimer.html +++ b/dashboard-ui/livetvtimer.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGuide} diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index bdd29390f5..7d0377f1c3 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -2619,6 +2619,56 @@ elem.lazyChildren(); }, + 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 = []; @@ -2649,7 +2699,7 @@ miscInfo.push(text); if (item.Type != "Recording") { - text = LiveTvHelpers.getDisplayTime(date); + text = LibraryBrowser.getDisplayTime(date); miscInfo.push(text); } } diff --git a/dashboard-ui/scripts/livetvchannel.js b/dashboard-ui/scripts/livetvchannel.js index 51c22664c6..056681dd96 100644 --- a/dashboard-ui/scripts/livetvchannel.js +++ b/dashboard-ui/scripts/livetvchannel.js @@ -35,7 +35,7 @@ } html += '
'; - html += '
' + LiveTvHelpers.getDisplayTime(startDate) + '
'; + html += '
' + LibraryBrowser.getDisplayTime(startDate) + '
'; html += '
'; cssClass = "tvProgramInfo"; @@ -162,154 +162,7 @@ }); } - window.LiveTvHelpers = { - - getDaysOfWeek: function () { - - var days = [ - 'Sunday', - 'Monday', - 'Tuesday', - 'Wednesday', - 'Thursday', - 'Friday', - 'Saturday' - ]; - - return days.map(function (d) { - - return { - name: d, - value: d - }; - - }); - }, - - 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; - }, - - renderMiscProgramInfo: function (elem, obj) { - - var html = []; - - if (obj.IsSeries && !obj.IsRepeat) { - - html.push(''+Globalize.translate('LabelNewProgram')+''); - - } - - if (obj.IsLive) { - - html.push(''+Globalize.translate('LabelLiveProgram')+''); - - } - - if (obj.ChannelId) { - html.push('' + obj.ChannelName + ''); - } - - if (obj.IsHD) { - - html.push(Globalize.translate('LabelHDProgram')); - - } - - if (obj.Audio) { - - html.push(obj.Audio); - - } - - html = html.join('     '); - - if (obj.SeriesTimerId) { - html += ''; - html += '
'; - html += '
'; - html += '
'; - html += '
'; - } - else if (obj.TimerId) { - - html += ''; - html += '
'; - html += '
'; - } - - elem.html(html).trigger('create'); - }, - - renderOriginalAirDate: function (elem, item) { - - var airDate = item.OriginalAirDate; - - if (airDate && item.IsRepeat) { - - try { - airDate = parseISO8601Date(airDate, { toLocal: true }).toLocaleDateString(); - } - catch (e) { - console.log("Error parsing date: " + airDate); - } - - - elem.html(Globalize.translate('ValueOriginalAirDate').replace('{0}', airDate)).show(); - } else { - elem.hide(); - } - } - - }; - - $(document).on('pageinit', "#liveTvChannelPage", function () { + $(document).on('pageinitdepends', "#liveTvChannelPage", function () { var page = this; @@ -323,7 +176,7 @@ Dashboard.navigate("edititemmetadata.html?channelid=" + currentItem.Id); }); - }).on('pageshow', "#liveTvChannelPage", function () { + }).on('pageshowready', "#liveTvChannelPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvcomponents.js b/dashboard-ui/scripts/livetvcomponents.js new file mode 100644 index 0000000000..aa38fe9e0a --- /dev/null +++ b/dashboard-ui/scripts/livetvcomponents.js @@ -0,0 +1,291 @@ +(function () { + + window.LiveTvHelpers = { + + getDaysOfWeek: function () { + + var days = [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday' + ]; + + return days.map(function (d) { + + return { + name: d, + value: d + }; + + }); + }, + + renderMiscProgramInfo: function (elem, obj) { + + var html = []; + + if (obj.IsSeries && !obj.IsRepeat) { + + html.push('' + Globalize.translate('LabelNewProgram') + ''); + + } + + if (obj.IsLive) { + + html.push('' + Globalize.translate('LabelLiveProgram') + ''); + + } + + if (obj.ChannelId) { + html.push('' + obj.ChannelName + ''); + } + + if (obj.IsHD) { + + html.push(Globalize.translate('LabelHDProgram')); + + } + + if (obj.Audio) { + + html.push(obj.Audio); + + } + + html = html.join('     '); + + if (obj.SeriesTimerId) { + html += ''; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + } + else if (obj.TimerId) { + + html += ''; + html += '
'; + html += '
'; + } + + elem.html(html).trigger('create'); + }, + + renderOriginalAirDate: function (elem, item) { + + var airDate = item.OriginalAirDate; + + if (airDate && item.IsRepeat) { + + try { + airDate = parseISO8601Date(airDate, { toLocal: true }).toLocaleDateString(); + } + catch (e) { + console.log("Error parsing date: " + airDate); + } + + + elem.html(Globalize.translate('ValueOriginalAirDate').replace('{0}', airDate)).show(); + } else { + elem.hide(); + } + } + + }; +})(); + +(function ($, document, window) { + + var showOverlayTimeout; + var hideOverlayTimeout; + var currentPosterItem; + + function onOverlayMouseOver() { + + if (hideOverlayTimeout) { + clearTimeout(hideOverlayTimeout); + hideOverlayTimeout = null; + } + } + + function onOverlayMouseOut() { + + startHideOverlayTimer(); + } + + function getOverlayHtml(item) { + + var html = ''; + + html += '
'; + + if (item.EpisodeTitle) { + html += '

'; + html += item.EpisodeTitle; + html += '

'; + } + + html += '

'; + + html += '

'; + html += ''; + html += LibraryBrowser.getRatingHtml(item); + html += ''; + html += ''; + html += LibraryBrowser.getUserDataIconsHtml(item); + html += ''; + html += '

'; + + html += '

'; + + html += '

'; + html += (item.Overview || ''); + html += '

'; + + html += '
'; + + return html; + } + + function showOverlay(elem, item) { + + $('.itemFlyout').popup('close').remove(); + + var html = '
'; + + html += '
'; + html += '

' + item.Name + '

'; + html += '
'; + + html += '
'; + html += getOverlayHtml(item); + html += '
'; + + html += '
'; + + $('.itemFlyout').popup('close').popup('destroy').remove(); + + $(document.body).append(html); + + var popup = $('.itemFlyout').on('mouseenter', onOverlayMouseOver).on('mouseleave', onOverlayMouseOut).popup({ + + positionTo: elem + + }).trigger('create').popup("open").on("popupafterclose", function () { + + $(this).off("popupafterclose").off("mouseenter").off("mouseleave").remove(); + }); + + LibraryBrowser.renderGenres($('.itemGenres', popup), item, 'livetv', 3); + LiveTvHelpers.renderMiscProgramInfo($('.miscTvProgramInfo', popup), item); + + popup.parents().prev('.ui-popup-screen').remove(); + currentPosterItem = elem; + } + + function onProgramClicked() { + + if (showOverlayTimeout) { + clearTimeout(showOverlayTimeout); + showOverlayTimeout = null; + } + + if (hideOverlayTimeout) { + clearTimeout(hideOverlayTimeout); + hideOverlayTimeout = null; + } + + hideOverlay(); + } + + function hideOverlay() { + + $('.itemFlyout').popup('close').remove(); + + if (currentPosterItem) { + + $(currentPosterItem).off('click.overlay'); + currentPosterItem = null; + } + } + + function startHideOverlayTimer() { + + if (hideOverlayTimeout) { + clearTimeout(hideOverlayTimeout); + hideOverlayTimeout = null; + } + + hideOverlayTimeout = setTimeout(hideOverlay, 200); + } + + function onHoverOut() { + + if (showOverlayTimeout) { + clearTimeout(showOverlayTimeout); + showOverlayTimeout = null; + } + + startHideOverlayTimer(); + } + + $.fn.createGuideHoverMenu = function (childSelector) { + + function onShowTimerExpired(elem) { + + var id = elem.getAttribute('data-programid'); + + ApiClient.getLiveTvProgram(id, Dashboard.getCurrentUserId()).done(function (item) { + + showOverlay(elem, item); + + }); + } + + function onHoverIn() { + + if (showOverlayTimeout) { + clearTimeout(showOverlayTimeout); + showOverlayTimeout = null; + } + + if (hideOverlayTimeout) { + clearTimeout(hideOverlayTimeout); + hideOverlayTimeout = null; + } + + var elem = this; + + if (currentPosterItem) { + if (currentPosterItem && currentPosterItem == elem) { + return; + } else { + hideOverlay(); + } + } + + showOverlayTimeout = setTimeout(function () { + + onShowTimerExpired(elem); + + }, 1000); + } + + // https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/ + + if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) { + /* browser with either Touch Events of Pointer Events + running on touch-capable device */ + return this; + } + + return this.on('mouseenter', childSelector, onHoverIn) + .on('mouseleave', childSelector, onHoverOut) + .on('click', childSelector, onProgramClicked); + }; + +})(jQuery, document, window); \ No newline at end of file diff --git a/dashboard-ui/scripts/livetvguide.js b/dashboard-ui/scripts/livetvguide.js index d5a93dc02a..1e3ad168ef 100644 --- a/dashboard-ui/scripts/livetvguide.js +++ b/dashboard-ui/scripts/livetvguide.js @@ -7,12 +7,16 @@ var currentDate; + var defaultChannels = 50; + var channelLimit = 1000; + var channelQuery = { StartIndex: 0, - Limit: 50, + Limit: defaultChannels, EnableFavoriteSorting: true }; + var channelsPromise; function showLoadingMessage(page) { @@ -51,6 +55,8 @@ channelQuery.userId = Dashboard.getCurrentUserId(); + channelQuery.Limit = Math.min(channelQuery.Limit || defaultChannels, channelLimit); + channelsPromise = channelsPromise || ApiClient.getLiveTvChannels(channelQuery); var date = currentDate; @@ -103,14 +109,14 @@ // clone startDate = new Date(startDate.getTime()); - html += '
' + html += '
'; while (startDate.getTime() < endDateTime) { html += '
'; html += '
'; - html += LiveTvHelpers.getDisplayTime(startDate); + html += LibraryBrowser.getDisplayTime(startDate); html += '
'; html += '
'; @@ -223,9 +229,9 @@ html += '' + Globalize.translate('LabelNewProgram') + '  '; } - html += LiveTvHelpers.getDisplayTime(program.StartDateLocal); + html += LibraryBrowser.getDisplayTime(program.StartDateLocal); html += ' - '; - html += LiveTvHelpers.getDisplayTime(program.EndDateLocal); + html += LibraryBrowser.getDisplayTime(program.EndDateLocal); if (program.SeriesTimerId) { html += '
'; @@ -385,7 +391,7 @@ changeDate(page, date); } - $(document).on('pageinit', "#liveTvGuidePage", function () { + $(document).on('pageinitdepends', "#liveTvGuidePage", function () { var page = this; @@ -433,7 +439,7 @@ }); } - }).on('pageshow', "#liveTvGuidePage", function () { + }).on('pageshowready', "#liveTvGuidePage", function () { var page = this; @@ -443,196 +449,4 @@ }); }); -})(jQuery, document); - -(function ($, document, window) { - - var showOverlayTimeout; - var hideOverlayTimeout; - var currentPosterItem; - - function onOverlayMouseOver() { - - if (hideOverlayTimeout) { - clearTimeout(hideOverlayTimeout); - hideOverlayTimeout = null; - } - } - - function onOverlayMouseOut() { - - startHideOverlayTimer(); - } - - function getOverlayHtml(item) { - - var html = ''; - - html += '
'; - - if (item.EpisodeTitle) { - html += '

'; - html += item.EpisodeTitle; - html += '

'; - } - - html += '

'; - - html += '

'; - html += ''; - html += LibraryBrowser.getRatingHtml(item); - html += ''; - html += ''; - html += LibraryBrowser.getUserDataIconsHtml(item); - html += ''; - html += '

'; - - html += '

'; - - html += '

'; - html += (item.Overview || ''); - html += '

'; - - html += '
'; - - return html; - } - - function showOverlay(elem, item) { - - $('.itemFlyout').popup('close').remove(); - - var html = '
'; - - html += '
'; - html += '

' + item.Name + '

'; - html += '
'; - - html += '
'; - html += getOverlayHtml(item); - html += '
'; - - html += '
'; - - $('.itemFlyout').popup('close').popup('destroy').remove(); - - $(document.body).append(html); - - var popup = $('.itemFlyout').on('mouseenter', onOverlayMouseOver).on('mouseleave', onOverlayMouseOut).popup({ - - positionTo: elem - - }).trigger('create').popup("open").on("popupafterclose", function () { - - $(this).off("popupafterclose").off("mouseenter").off("mouseleave").remove(); - }); - - LibraryBrowser.renderGenres($('.itemGenres', popup), item, 'livetv', 3); - LiveTvHelpers.renderMiscProgramInfo($('.miscTvProgramInfo', popup), item); - - popup.parents().prev('.ui-popup-screen').remove(); - currentPosterItem = elem; - } - - function onProgramClicked() { - - if (showOverlayTimeout) { - clearTimeout(showOverlayTimeout); - showOverlayTimeout = null; - } - - if (hideOverlayTimeout) { - clearTimeout(hideOverlayTimeout); - hideOverlayTimeout = null; - } - - hideOverlay(); - } - - function hideOverlay() { - - $('.itemFlyout').popup('close').remove(); - - if (currentPosterItem) { - - $(currentPosterItem).off('click.overlay'); - currentPosterItem = null; - } - } - - function startHideOverlayTimer() { - - if (hideOverlayTimeout) { - clearTimeout(hideOverlayTimeout); - hideOverlayTimeout = null; - } - - hideOverlayTimeout = setTimeout(hideOverlay, 200); - } - - function onHoverOut() { - - if (showOverlayTimeout) { - clearTimeout(showOverlayTimeout); - showOverlayTimeout = null; - } - - startHideOverlayTimer(); - } - - $.fn.createGuideHoverMenu = function (childSelector) { - - function onShowTimerExpired(elem) { - - var id = elem.getAttribute('data-programid'); - - ApiClient.getLiveTvProgram(id, Dashboard.getCurrentUserId()).done(function (item) { - - showOverlay(elem, item); - - }); - } - - function onHoverIn() { - - if (showOverlayTimeout) { - clearTimeout(showOverlayTimeout); - showOverlayTimeout = null; - } - - if (hideOverlayTimeout) { - clearTimeout(hideOverlayTimeout); - hideOverlayTimeout = null; - } - - var elem = this; - - if (currentPosterItem) { - if (currentPosterItem && currentPosterItem == elem) { - return; - } else { - hideOverlay(); - } - } - - showOverlayTimeout = setTimeout(function () { - - onShowTimerExpired(elem); - - }, 1000); - } - - // https://hacks.mozilla.org/2013/04/detecting-touch-its-the-why-not-the-how/ - - if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)) { - /* browser with either Touch Events of Pointer Events - running on touch-capable device */ - return this; - } - - return this.on('mouseenter', childSelector, onHoverIn) - .on('mouseleave', childSelector, onHoverOut) - .on('click', childSelector, onProgramClicked); - }; - -})(jQuery, document, window); +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/livetvnewrecording.js b/dashboard-ui/scripts/livetvnewrecording.js index 2afc3872f7..692a3d14fa 100644 --- a/dashboard-ui/scripts/livetvnewrecording.js +++ b/dashboard-ui/scripts/livetvnewrecording.js @@ -145,13 +145,7 @@ return false; } - window.LiveTvNewRecordingPage = { - - onSubmit: onSubmit - - }; - - $(document).on('pageinit', "#liveTvNewRecordingPage", function () { + $(document).on('pageinitdepends', "#liveTvNewRecordingPage", function () { var page = this; @@ -173,7 +167,9 @@ }); - }).on('pagebeforeshow', "#liveTvNewRecordingPage", function () { + $('.liveTvNewRecordingForm').off('submit', onSubmit).on('submit', onSubmit); + + }).on('pagebeforeshowready', "#liveTvNewRecordingPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvprogram.js b/dashboard-ui/scripts/livetvprogram.js index 0199ca7394..40483d1876 100644 --- a/dashboard-ui/scripts/livetvprogram.js +++ b/dashboard-ui/scripts/livetvprogram.js @@ -94,7 +94,7 @@ }); } - $(document).on('pageinit', "#liveTvProgramPage", function () { + $(document).on('pageinitdepends', "#liveTvProgramPage", function () { var page = this; @@ -121,7 +121,7 @@ deleteTimer(page, currentItem.TimerId); }); - }).on('pageshow', "#liveTvProgramPage", function () { + }).on('pageshowready', "#liveTvProgramPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvrecording.js b/dashboard-ui/scripts/livetvrecording.js index 3db48fdfc6..29aecfb05a 100644 --- a/dashboard-ui/scripts/livetvrecording.js +++ b/dashboard-ui/scripts/livetvrecording.js @@ -102,7 +102,7 @@ }); } - $(document).on('pageinit', "#liveTvRecordingPage", function () { + $(document).on('pageinitdepends', "#liveTvRecordingPage", function () { var page = this; @@ -116,7 +116,7 @@ }); }); - }).on('pagebeforeshow', "#liveTvRecordingPage", function () { + }).on('pagebeforeshowready', "#liveTvRecordingPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvrecordinglist.js b/dashboard-ui/scripts/livetvrecordinglist.js index ad91d1ca62..5d47f6dfcd 100644 --- a/dashboard-ui/scripts/livetvrecordinglist.js +++ b/dashboard-ui/scripts/livetvrecordinglist.js @@ -67,12 +67,12 @@ } - $(document).on('pageinit', "#liveTvRecordingListPage", function () { + $(document).on('pageinitdepends', "#liveTvRecordingListPage", function () { var page = this; - }).on('pagebeforeshow', "#liveTvRecordingListPage", function () { + }).on('pageshowready', "#liveTvRecordingListPage", function () { var page = this; @@ -101,8 +101,6 @@ $('.listName', page).html(Globalize.translate('HeaderAllRecordings')); } - }).on('pageshow', "#liveTvRecordingListPage", function () { - updateFilterControls(this); }); diff --git a/dashboard-ui/scripts/livetvseriestimer.js b/dashboard-ui/scripts/livetvseriestimer.js index 1da1f0bd7b..a46686b4dd 100644 --- a/dashboard-ui/scripts/livetvseriestimer.js +++ b/dashboard-ui/scripts/livetvseriestimer.js @@ -52,7 +52,7 @@ $('.time', page).html(Globalize.translate('LabelAnytime')).trigger('create'); } else if (item.ChannelId) { - $('.time', page).html(LiveTvHelpers.getDisplayTime(item.StartDate)).trigger('create'); + $('.time', page).html(LibraryBrowser.getDisplayTime(item.StartDate)).trigger('create'); } Dashboard.hideLoadingMsg(); @@ -198,8 +198,8 @@ html += '' + Globalize.translate('LabelNewProgram') + '  '; } - html += LiveTvHelpers.getDisplayTime(timer.StartDate); - html += ' - ' + LiveTvHelpers.getDisplayTime(timer.EndDate); + html += LibraryBrowser.getDisplayTime(timer.StartDate); + html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate); html += '

'; @@ -263,7 +263,7 @@ }); } - $(document).on('pageinit', "#liveTvSeriesTimerPage", function () { + $(document).on('pageinitdepends', "#liveTvSeriesTimerPage", function () { var page = this; @@ -274,7 +274,7 @@ }); - }).on('pagebeforeshow', "#liveTvSeriesTimerPage", function () { + }).on('pagebeforeshowready', "#liveTvSeriesTimerPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvseriestimers.js b/dashboard-ui/scripts/livetvseriestimers.js index b9294d95f7..fc363ef21b 100644 --- a/dashboard-ui/scripts/livetvseriestimers.js +++ b/dashboard-ui/scripts/livetvseriestimers.js @@ -57,7 +57,7 @@ html += ' - ' + Globalize.translate('LabelAnytime'); } else { - html += ' - ' + LiveTvHelpers.getDisplayTime(timer.StartDate); + html += ' - ' + LibraryBrowser.getDisplayTime(timer.StartDate); } html += '

'; diff --git a/dashboard-ui/scripts/livetvtimer.js b/dashboard-ui/scripts/livetvtimer.js index d10106f22c..1c923829ef 100644 --- a/dashboard-ui/scripts/livetvtimer.js +++ b/dashboard-ui/scripts/livetvtimer.js @@ -103,7 +103,7 @@ }); } - $(document).on('pageinit', "#liveTvTimerPage", function () { + $(document).on('pageinitdepends', "#liveTvTimerPage", function () { var page = this; @@ -113,7 +113,7 @@ }); - }).on('pagebeforeshow', "#liveTvTimerPage", function () { + }).on('pagebeforeshowready', "#liveTvTimerPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvtimers.js b/dashboard-ui/scripts/livetvtimers.js index d7be045b67..d318ea12db 100644 --- a/dashboard-ui/scripts/livetvtimers.js +++ b/dashboard-ui/scripts/livetvtimers.js @@ -62,8 +62,8 @@ html += ''; html += '

'; - html += LiveTvHelpers.getDisplayTime(timer.StartDate); - html += ' - ' + LiveTvHelpers.getDisplayTime(timer.EndDate); + html += LibraryBrowser.getDisplayTime(timer.StartDate); + html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate); html += '

'; diff --git a/dashboard-ui/scripts/logpage.js b/dashboard-ui/scripts/logpage.js index 05f0a85d6c..33f6a59e68 100644 --- a/dashboard-ui/scripts/logpage.js +++ b/dashboard-ui/scripts/logpage.js @@ -30,7 +30,7 @@ var text = date.toLocaleDateString(); - text += ' ' + LiveTvHelpers.getDisplayTime(date); + text += ' ' + LibraryBrowser.getDisplayTime(date); logHtml += '

' + text + '

'; diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index 0887999b36..21c363ba03 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -106,7 +106,7 @@ }; function triggerPlayerChange(newPlayer, newTarget) { - + $(self).trigger('playerchange', [newPlayer, newTarget]); } @@ -142,8 +142,8 @@ throw new Error('null player'); } - player.tryPair(targetInfo).done(function() { - + player.tryPair(targetInfo).done(function () { + currentPlayer = player; currentTargetInfo = targetInfo; @@ -176,7 +176,7 @@ } }; - self.getPlayers = function() { + self.getPlayers = function () { return players; }; @@ -220,22 +220,35 @@ return deferred.promise(); }; + function doWithPlaybackValidation(fn) { + + requirejs(["scripts/registrationservices"], function () { + RegistrationServices.validateFeature('playback').done(fn); + }); + } + self.play = function (options) { - if (typeof (options) === 'string') { - options = { ids: [options] }; - } + doWithPlaybackValidation(function() { + if (typeof (options) === 'string') { + options = { ids: [options] }; + } - currentPlayer.play(options); + currentPlayer.play(options); + }); }; self.shuffle = function (id) { - currentPlayer.shuffle(id); + doWithPlaybackValidation(function () { + currentPlayer.shuffle(id); + }); }; self.instantMix = function (id) { - currentPlayer.instantMix(id); + doWithPlaybackValidation(function () { + currentPlayer.instantMix(id); + }); }; self.queue = function (options) { @@ -370,10 +383,6 @@ currentPlayer.volumeUp(); }; - self.shuffle = function (id) { - currentPlayer.shuffle(id); - }; - self.playlist = function () { return currentPlayer.playlist || []; }; @@ -458,12 +467,12 @@ return bottomText ? topText + '
' + bottomText : topText; }; - self.showPlaybackInfoErrorMessage = function(errorCode) { + self.showPlaybackInfoErrorMessage = function (errorCode) { // This timeout is messy, but if jqm is in the act of hiding a popup, it will not show a new one // If we're coming from the popup play menu, this will be a problem - setTimeout(function() { + setTimeout(function () { Dashboard.alert({ message: Globalize.translate('MessagePlaybackError' + errorCode), title: Globalize.translate('HeaderPlaybackError') diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 02e42a0ffe..a38ab130f9 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -172,13 +172,24 @@ } profile.TranscodingProfiles = []; - profile.TranscodingProfiles.push({ - Container: 'mp3', - Type: 'Audio', - AudioCodec: 'mp3', - Context: 'Streaming', - Protocol: 'http' - }); + + if ($.browser.safari) { + profile.TranscodingProfiles.push({ + Container: 'aac', + Type: 'Audio', + AudioCodec: 'aac', + Context: 'Streaming', + Protocol: 'http' + }); + } else { + profile.TranscodingProfiles.push({ + Container: 'mp3', + Type: 'Audio', + AudioCodec: 'mp3', + Context: 'Streaming', + Protocol: 'http' + }); + } if (self.canPlayHls()) { profile.TranscodingProfiles.push({ @@ -1670,6 +1681,27 @@ return $('.mediaPlayerAudio'); } + function onTimeUpdate() { + + var currentTicks = self.getCurrentTicks(this); + self.setCurrentTime(currentTicks); + + if ($.browser.safari) { + + if (self.currentDurationTicks) { + + // Seeing transcoded audio looping in safari, going past the runtime but restarting the audio + if (currentTicks > self.currentDurationTicks) { + if (currentPlaylistIndex < self.playlist.length - 1) { + self.nextTrack(); + } else { + self.stop(); + } + } + } + } + } + function playAudio(item, mediaSource, startPositionTicks) { var streamInfo = self.createStreamInfo('Audio', item, mediaSource, startPositionTicks); @@ -1720,21 +1752,7 @@ // In the event timeupdate isn't firing, at least we can update when this happens self.setCurrentTime(self.getCurrentTicks()); - }).on("timeupdate.mediaplayerevent", function () { - - var currentTicks = self.getCurrentTicks(this); - // Seeing transcoded audio looping in safari, going past the runtime but restarting the audio - if ($.browser.safari && self.currentDurationTicks && (currentTicks > self.currentDurationTicks)) { - if (currentPlaylistIndex < self.playlist.length - 1) { - self.nextTrack(); - } else { - self.stop(); - } - } else { - self.setCurrentTime(currentTicks); - } - - })[0]; + }).on("timeupdate.mediaplayerevent", onTimeUpdate)[0]; }; var getItemFields = "MediaSources,Chapters"; diff --git a/dashboard-ui/scripts/registrationservices.js b/dashboard-ui/scripts/registrationservices.js index 239bd42454..f8a2ba3118 100644 --- a/dashboard-ui/scripts/registrationservices.js +++ b/dashboard-ui/scripts/registrationservices.js @@ -114,5 +114,11 @@ $('.supporterForm', page).attr('action', 'https://www.paypal.com/cgi-bin/webscr'); $('.recurringSubscriptionCancellationHelp', page).html(Globalize.translate('LabelRecurringDonationCanBeCancelledHelp')); + }, + + validateFeature: function () { + var deferred = DeferredBuilder.Deferred(); + deferred.resolve(); + return deferred.promise(); } }; \ No newline at end of file diff --git a/dashboard-ui/scripts/serversecurity.js b/dashboard-ui/scripts/serversecurity.js index 255ead936a..5620f95ade 100644 --- a/dashboard-ui/scripts/serversecurity.js +++ b/dashboard-ui/scripts/serversecurity.js @@ -62,7 +62,7 @@ var date = parseISO8601Date(item.DateCreated, { toLocal: true }); - html += date.toLocaleDateString() + ' ' + LiveTvHelpers.getDisplayTime(date); + html += date.toLocaleDateString() + ' ' + LibraryBrowser.getDisplayTime(date); html += ''; diff --git a/dashboard-ui/thirdparty/cordova/registrationservices.js b/dashboard-ui/thirdparty/cordova/registrationservices.js index 4f7f2a29d1..eb3813f1fe 100644 --- a/dashboard-ui/thirdparty/cordova/registrationservices.js +++ b/dashboard-ui/thirdparty/cordova/registrationservices.js @@ -1,16 +1,51 @@ -window.RegistrationServices = { +(function () { - renderPluginInfo: function (page, pkg, pluginSecurityInfo) { + function validatePlayback(deferred) { + var platform = (device.platform || '').toLowerCase(); - }, + if (platform.indexOf('android') != -1) { + deferred.resolve(); + return; + } - addRecurringFields: function (page, period) { - - }, - - initSupporterForm: function (page) { - - $('.recurringSubscriptionCancellationHelp', page).html(''); + deferred.resolve(); } -}; \ No newline at end of file + + function validateLiveTV(deferred) { + + deferred.resolve(); + } + + window.RegistrationServices = { + + renderPluginInfo: function (page, pkg, pluginSecurityInfo) { + + + }, + + addRecurringFields: function (page, period) { + + }, + + initSupporterForm: function (page) { + + $('.recurringSubscriptionCancellationHelp', page).html(''); + }, + + validateFeature: function (name) { + var deferred = DeferredBuilder.Deferred(); + + if (name == 'playback') { + validatePlayback(); + } else if (name == 'livetv') { + validateLiveTV(); + } else { + deferred.resolve(); + } + + return deferred.promise(); + } + }; + +})(); \ No newline at end of file