lazy load scripts

This commit is contained in:
Luke Pulverenti 2015-05-22 15:16:14 -04:00
parent 7e55abc130
commit 3818349496
27 changed files with 510 additions and 443 deletions

View File

@ -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;
}

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvChannelPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvChannelPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents,scripts/livetvchannel">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvGuidePage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvGuidePage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/registrationservices,scripts/livetvcomponents,scripts/livetvguide">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html" class="ui-btn-active">${TabGuide}</a>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvNewRecordingPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvNewRecordingPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents,scripts/livetvnewrecording">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>
@ -116,9 +116,6 @@
</ul>
</form>
</div>
<script type="text/javascript">
$('.liveTvNewRecordingForm').off('submit', LiveTvNewRecordingPage.onSubmit).on('submit', LiveTvNewRecordingPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvProgramPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvProgramPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents,scripts/livetvprogram">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvRecordingPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvRecordingPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvRecordingListPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvRecordingListPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvrecordinglist">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvSeriesTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvSeriesTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="liveTvTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}">
<div id="liveTvTimerPage" data-role="page" class="page libraryPage liveTvPage" data-contextname="${HeaderLiveTv}" data-require="scripts/livetvcomponents">
<div class="libraryViewNav">
<a href="livetvsuggested.html">${TabSuggestions}</a>
<a href="livetvguide.html">${TabGuide}</a>

View File

@ -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);
}
}

View File

@ -35,7 +35,7 @@
}
html += '<div class="' + cssClass + '">';
html += '<div class="tvProgramTimeSlotInner">' + LiveTvHelpers.getDisplayTime(startDate) + '</div>';
html += '<div class="tvProgramTimeSlotInner">' + LibraryBrowser.getDisplayTime(startDate) + '</div>';
html += '</div>';
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('<span class="newTvProgram">'+Globalize.translate('LabelNewProgram')+'</span>');
}
if (obj.IsLive) {
html.push('<span class="liveTvProgram">'+Globalize.translate('LabelLiveProgram')+'</span>');
}
if (obj.ChannelId) {
html.push('<a class="textlink" href="livetvchannel.html?id=' + obj.ChannelId + '">' + obj.ChannelName + '</a>');
}
if (obj.IsHD) {
html.push(Globalize.translate('LabelHDProgram'));
}
if (obj.Audio) {
html.push(obj.Audio);
}
html = html.join('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
if (obj.SeriesTimerId) {
html += '<a href="livetvseriestimer.html?id=' + obj.SeriesTimerId + '" title="'+Globalize.translate('ButtonViewSeriesRecording')+'">';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '</a>';
}
else if (obj.TimerId) {
html += '<a href="livetvtimer.html?id=' + obj.TimerId + '">';
html += '<div class="timerCircle"></div>';
html += '</a>';
}
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;

View File

@ -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('<span class="newTvProgram">' + Globalize.translate('LabelNewProgram') + '</span>');
}
if (obj.IsLive) {
html.push('<span class="liveTvProgram">' + Globalize.translate('LabelLiveProgram') + '</span>');
}
if (obj.ChannelId) {
html.push('<a class="textlink" href="livetvchannel.html?id=' + obj.ChannelId + '">' + obj.ChannelName + '</a>');
}
if (obj.IsHD) {
html.push(Globalize.translate('LabelHDProgram'));
}
if (obj.Audio) {
html.push(obj.Audio);
}
html = html.join('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
if (obj.SeriesTimerId) {
html += '<a href="livetvseriestimer.html?id=' + obj.SeriesTimerId + '" title="' + Globalize.translate('ButtonViewSeriesRecording') + '">';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '</a>';
}
else if (obj.TimerId) {
html += '<a href="livetvtimer.html?id=' + obj.TimerId + '">';
html += '<div class="timerCircle"></div>';
html += '</a>';
}
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 += '<div class="itemOverlayContent">';
if (item.EpisodeTitle) {
html += '<p>';
html += item.EpisodeTitle;
html += '</p>';
}
html += '<p class="itemMiscInfo miscTvProgramInfo"></p>';
html += '<p style="margin: 1.25em 0;">';
html += '<span class="itemCommunityRating">';
html += LibraryBrowser.getRatingHtml(item);
html += '</span>';
html += '<span class="userDataIcons">';
html += LibraryBrowser.getUserDataIconsHtml(item);
html += '</span>';
html += '</p>';
html += '<p class="itemGenres"></p>';
html += '<p class="itemOverlayHtml">';
html += (item.Overview || '');
html += '</p>';
html += '</div>';
return html;
}
function showOverlay(elem, item) {
$('.itemFlyout').popup('close').remove();
var html = '<div data-role="popup" class="itemFlyout" data-theme="b" data-arrow="true" data-history="false">';
html += '<div class="ui-bar-b" style="text-align:center;">';
html += '<h3 style="margin: .5em 0;padding:0 1em;font-weight:normal;">' + item.Name + '</h3>';
html += '</div>';
html += '<div style="padding: 0 1em;">';
html += getOverlayHtml(item);
html += '</div>';
html += '</div>';
$('.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);

View File

@ -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 += '<div class="timeslotHeadersInner">'
html += '<div class="timeslotHeadersInner">';
while (startDate.getTime() < endDateTime) {
html += '<div class="timeslotHeader">';
html += '<div class="timeslotHeaderInner">';
html += LiveTvHelpers.getDisplayTime(startDate);
html += LibraryBrowser.getDisplayTime(startDate);
html += '</div>';
html += '</div>';
@ -223,9 +229,9 @@
html += '<span class="newTvProgram">' + Globalize.translate('LabelNewProgram') + '&nbsp;&nbsp;</span>';
}
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 += '<div class="timerCircle seriesTimerCircle"></div>';
@ -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 += '<div class="itemOverlayContent">';
if (item.EpisodeTitle) {
html += '<p>';
html += item.EpisodeTitle;
html += '</p>';
}
html += '<p class="itemMiscInfo miscTvProgramInfo"></p>';
html += '<p style="margin: 1.25em 0;">';
html += '<span class="itemCommunityRating">';
html += LibraryBrowser.getRatingHtml(item);
html += '</span>';
html += '<span class="userDataIcons">';
html += LibraryBrowser.getUserDataIconsHtml(item);
html += '</span>';
html += '</p>';
html += '<p class="itemGenres"></p>';
html += '<p class="itemOverlayHtml">';
html += (item.Overview || '');
html += '</p>';
html += '</div>';
return html;
}
function showOverlay(elem, item) {
$('.itemFlyout').popup('close').remove();
var html = '<div data-role="popup" class="itemFlyout" data-theme="b" data-arrow="true" data-history="false">';
html += '<div class="ui-bar-b" style="text-align:center;">';
html += '<h3 style="margin: .5em 0;padding:0 1em;font-weight:normal;">' + item.Name + '</h3>';
html += '</div>';
html += '<div style="padding: 0 1em;">';
html += getOverlayHtml(item);
html += '</div>';
html += '</div>';
$('.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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
});

View File

@ -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 += '<span class="newTvProgram">' + Globalize.translate('LabelNewProgram') + '&nbsp;&nbsp;</span>';
}
html += LiveTvHelpers.getDisplayTime(timer.StartDate);
html += ' - ' + LiveTvHelpers.getDisplayTime(timer.EndDate);
html += LibraryBrowser.getDisplayTime(timer.StartDate);
html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate);
html += '</p>';
@ -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;

View File

@ -57,7 +57,7 @@
html += ' - ' + Globalize.translate('LabelAnytime');
} else {
html += ' - ' + LiveTvHelpers.getDisplayTime(timer.StartDate);
html += ' - ' + LibraryBrowser.getDisplayTime(timer.StartDate);
}
html += '</p>';

View File

@ -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;

View File

@ -62,8 +62,8 @@
html += '</h3>';
html += '<p>';
html += LiveTvHelpers.getDisplayTime(timer.StartDate);
html += ' - ' + LiveTvHelpers.getDisplayTime(timer.EndDate);
html += LibraryBrowser.getDisplayTime(timer.StartDate);
html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate);
html += '</p>';

View File

@ -30,7 +30,7 @@
var text = date.toLocaleDateString();
text += ' ' + LiveTvHelpers.getDisplayTime(date);
text += ' ' + LibraryBrowser.getDisplayTime(date);
logHtml += '<p>' + text + '</p>';

View File

@ -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 + '<br/>' + 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')

View File

@ -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";

View File

@ -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();
}
};

View File

@ -62,7 +62,7 @@
var date = parseISO8601Date(item.DateCreated, { toLocal: true });
html += date.toLocaleDateString() + ' ' + LiveTvHelpers.getDisplayTime(date);
html += date.toLocaleDateString() + ' ' + LibraryBrowser.getDisplayTime(date);
html += '</td>';

View File

@ -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();
}
};
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();
}
};
})();