jellyfin-web/dashboard-ui/scripts/livetvtimers.js

125 lines
3.8 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-11-27 12:04:19 -07:00
function deleteTimer(page, id) {
2014-05-30 12:23:56 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvTimer(id).done(function () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
reload(page);
});
}
});
}
2013-11-27 12:04:19 -07:00
function renderTimers(page, timers) {
var html = '';
2014-01-10 22:49:18 -07:00
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
var index = '';
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
for (var i = 0, length = timers.length; i < length; i++) {
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
var timer = timers[i];
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
var startDateText = LibraryBrowser.getFutureDateText(parseISO8601Date(timer.StartDate, { toLocal: true }));
2014-01-10 22:49:18 -07:00
if (startDateText != index) {
html += '<li data-role="list-divider">' + startDateText + '</li>';
index = startDateText;
}
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
html += '<li><a href="livetvtimer.html?id=' + timer.Id + '">';
2013-11-27 12:04:19 -07:00
2014-01-12 10:45:45 -07:00
var program = timer.ProgramInfo || {};
2014-01-10 22:49:18 -07:00
var imgUrl;
2015-08-02 16:47:31 -07:00
2014-01-10 22:49:18 -07:00
if (program.ImageTags && program.ImageTags.Primary) {
imgUrl = ApiClient.getScaledImageUrl(program.Id, {
height: 80,
2014-01-10 22:49:18 -07:00
tag: program.ImageTags.Primary,
type: "Primary"
});
} else {
imgUrl = "css/images/items/searchhintsv2/tv.png";
}
html += '<img src="css/images/items/searchhintsv2/tv.png" style="display:none;">';
html += '<div class="ui-li-thumb" style="background-image:url(\'' + imgUrl + '\');width:5em;height:5em;background-repeat:no-repeat;background-position:center center;background-size: cover;"></div>';
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
html += '<h3>';
html += timer.Name;
html += '</h3>';
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
html += '<p>';
2015-05-22 12:16:14 -07:00
html += LibraryBrowser.getDisplayTime(timer.StartDate);
html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate);
2014-01-10 22:49:18 -07:00
html += '</p>';
2013-11-27 12:04:19 -07:00
2013-11-30 23:25:19 -07:00
2014-01-10 22:49:18 -07: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 13:10:31 -07:00
}
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
html += '</a>';
2013-11-27 12:04:19 -07:00
2014-05-30 12:23:56 -07:00
html += '<a data-timerid="' + timer.Id + '" href="#" title="' + Globalize.translate('ButonCancelRecording') + '" class="btnDeleteTimer">' + Globalize.translate('ButonCancelRecording') + '</a>';
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
html += '</li>';
}
2013-11-27 12:04:19 -07:00
2014-01-10 22:49:18 -07:00
html += '</ul>';
2013-11-27 12:04:19 -07:00
var elem = $('#items', page).html(html).trigger('create');
$('.btnDeleteTimer', elem).on('click', function () {
var id = this.getAttribute('data-timerid');
deleteTimer(page, id);
});
2013-11-29 11:44:51 -07:00
Dashboard.hideLoadingMsg();
2013-11-27 12:04:19 -07:00
}
function reload(page) {
2013-11-29 11:44:51 -07:00
Dashboard.showLoadingMsg();
2013-12-14 08:49:11 -07:00
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvTimers().done(function (result) {
2013-11-27 12:04:19 -07:00
renderTimers(page, result.Items);
});
}
2015-08-02 16:47:31 -07:00
$(document).on('pagebeforeshowready', "#liveTvSuggestedPage", function () {
2013-11-27 12:04:19 -07:00
var page = this;
2015-08-02 16:47:31 -07: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 12:04:19 -07:00
});
2014-10-15 20:26:39 -07:00
})(jQuery, document);