2014-10-15 23:26:39 -04:00
|
|
|
|
(function ($, document) {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2013-11-29 11:58:24 -05:00
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
|
|
2014-05-30 15:23:56 -04:00
|
|
|
|
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
|
2013-11-29 11:58:24 -05:00
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.cancelLiveTvTimer(id).done(function () {
|
|
|
|
|
|
2014-05-30 15:23:56 -04:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
|
2013-11-29 11:58:24 -05:00
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-27 14:04:19 -05:00
|
|
|
|
function renderTimers(page, timers) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
var index = '';
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
for (var i = 0, length = timers.length; i < length; i++) {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
var timer = timers[i];
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
var startDateText = LibraryBrowser.getFutureDateText(parseISO8601Date(timer.StartDate, { toLocal: true }));
|
2014-01-01 13:26:31 -05:00
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
if (startDateText != index) {
|
2015-08-16 18:03:22 -04:00
|
|
|
|
|
|
|
|
|
if (index) {
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div class="homePageSection">';
|
|
|
|
|
html += '<h1>' + startDateText + '</h1>';
|
|
|
|
|
//html += '<ul data-role="listview" data-split-icon="delete">';
|
|
|
|
|
html += '<div class="paperList">';
|
2014-01-11 00:49:18 -05:00
|
|
|
|
index = startDateText;
|
|
|
|
|
}
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '<paper-icon-item>';
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2014-01-12 12:45:45 -05:00
|
|
|
|
var program = timer.ProgramInfo || {};
|
2014-01-11 00:49:18 -05:00
|
|
|
|
var imgUrl;
|
2015-08-02 19:47:31 -04:00
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
if (program.ImageTags && program.ImageTags.Primary) {
|
|
|
|
|
|
2014-05-23 19:58:28 -04:00
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(program.Id, {
|
|
|
|
|
height: 80,
|
2014-01-11 00:49:18 -05:00
|
|
|
|
tag: program.ImageTags.Primary,
|
|
|
|
|
type: "Primary"
|
|
|
|
|
});
|
2015-08-16 18:03:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (imgUrl) {
|
|
|
|
|
html += '<paper-fab class="listAvatar blue" style="background-image:url(\'' + imgUrl + '\');background-repeat:no-repeat;background-position:center center;background-size: cover;" item-icon></paper-fab>';
|
2015-08-17 00:08:33 -04:00
|
|
|
|
}
|
|
|
|
|
else if (program.IsKids) {
|
|
|
|
|
html += '<paper-fab class="listAvatar" style="background:#2196F3;" icon="person" item-icon></paper-fab>';
|
|
|
|
|
}
|
|
|
|
|
else if (program.IsSports) {
|
|
|
|
|
html += '<paper-fab class="listAvatar" style="background:#8BC34A;" icon="person" item-icon></paper-fab>';
|
|
|
|
|
}
|
|
|
|
|
else if (program.IsMovie) {
|
|
|
|
|
html += '<paper-fab class="listAvatar" icon="movie" item-icon></paper-fab>';
|
|
|
|
|
}
|
|
|
|
|
else if (program.IsNews) {
|
|
|
|
|
html += '<paper-fab class="listAvatar" style="background:#673AB7;" icon="new-releases" item-icon></paper-fab>';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += '<paper-fab class="listAvatar blue" icon="live-tv" item-icon></paper-fab>';
|
2014-01-11 00:49:18 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '<paper-item-body two-line>';
|
|
|
|
|
html += '<a class="clearLink" href="livetvtimer.html?id=' + timer.Id + '">';
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '<div>';
|
2014-01-11 00:49:18 -05:00
|
|
|
|
html += timer.Name;
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '</div>';
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '<div secondary>';
|
2015-05-22 15:16:14 -04:00
|
|
|
|
html += LibraryBrowser.getDisplayTime(timer.StartDate);
|
|
|
|
|
html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate);
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '</div>';
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '</a>';
|
|
|
|
|
html += '</paper-item-body>';
|
2013-12-01 01:25:19 -05:00
|
|
|
|
|
2014-01-11 00:49:18 -05:00
|
|
|
|
if (timer.SeriesTimerId) {
|
|
|
|
|
html += '<div class="ui-li-aside" style="right:0;">';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '<div class="timerCircle seriesTimerCircle"></div>';
|
|
|
|
|
html += '</div>';
|
2013-11-29 15:10:31 -05:00
|
|
|
|
}
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '<paper-icon-button icon="delete" data-timerid="' + timer.Id + '" title="' + Globalize.translate('ButonCancelRecording') + '" class="btnDeleteTimer"></paper-icon-button>';
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
html += '</paper-icon-item>';
|
2014-01-11 00:49:18 -05:00
|
|
|
|
}
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2015-08-16 18:03:22 -04:00
|
|
|
|
if (timers.length) {
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
|
|
|
|
var elem = $('#items', page).html(html).trigger('create');
|
2013-11-29 11:58:24 -05:00
|
|
|
|
|
|
|
|
|
$('.btnDeleteTimer', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var id = this.getAttribute('data-timerid');
|
|
|
|
|
|
|
|
|
|
deleteTimer(page, id);
|
|
|
|
|
});
|
2013-11-29 13:44:51 -05:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-11-27 14:04:19 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
2013-11-29 13:44:51 -05:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2013-12-14 10:49:11 -05:00
|
|
|
|
|
2014-10-15 23:26:39 -04:00
|
|
|
|
ApiClient.getLiveTvTimers().done(function (result) {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
|
|
|
|
renderTimers(page, result.Items);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 14:17:22 -04:00
|
|
|
|
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-08-02 19:47:31 -04:00
|
|
|
|
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
|
|
|
|
|
|
|
|
|
|
if (parseInt(this.selected) == 4) {
|
|
|
|
|
var tabContent = page.querySelector('.timersTabContent');
|
|
|
|
|
|
|
|
|
|
if (LibraryBrowser.needsRefresh(tabContent)) {
|
|
|
|
|
reload(tabContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-11-27 14:04:19 -05:00
|
|
|
|
});
|
|
|
|
|
|
2014-10-15 23:26:39 -04:00
|
|
|
|
})(jQuery, document);
|