mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
118 lines
3.6 KiB
JavaScript
118 lines
3.6 KiB
JavaScript
(function ($, document) {
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
|
|
|
|
if (result) {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
ApiClient.cancelLiveTvTimer(id).done(function () {
|
|
|
|
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
|
|
|
|
reload(page);
|
|
});
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
function renderTimers(page, timers) {
|
|
|
|
var html = '';
|
|
|
|
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
|
|
|
|
var index = '';
|
|
|
|
for (var i = 0, length = timers.length; i < length; i++) {
|
|
|
|
var timer = timers[i];
|
|
|
|
var startDateText = LibraryBrowser.getFutureDateText(parseISO8601Date(timer.StartDate, { toLocal: true }));
|
|
|
|
if (startDateText != index) {
|
|
html += '<li data-role="list-divider">' + startDateText + '</li>';
|
|
index = startDateText;
|
|
}
|
|
|
|
html += '<li><a href="livetvtimer.html?id=' + timer.Id + '">';
|
|
|
|
var program = timer.ProgramInfo || {};
|
|
var imgUrl;
|
|
|
|
if (program.ImageTags && program.ImageTags.Primary) {
|
|
|
|
imgUrl = ApiClient.getScaledImageUrl(program.Id, {
|
|
height: 80,
|
|
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>';
|
|
|
|
html += '<h3>';
|
|
html += timer.Name;
|
|
html += '</h3>';
|
|
|
|
html += '<p>';
|
|
html += LibraryBrowser.getDisplayTime(timer.StartDate);
|
|
html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate);
|
|
html += '</p>';
|
|
|
|
|
|
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>';
|
|
}
|
|
|
|
html += '</a>';
|
|
|
|
html += '<a data-timerid="' + timer.Id + '" href="#" title="' + Globalize.translate('ButonCancelRecording') + '" class="btnDeleteTimer">' + Globalize.translate('ButonCancelRecording') + '</a>';
|
|
|
|
html += '</li>';
|
|
}
|
|
|
|
html += '</ul>';
|
|
|
|
var elem = $('#items', page).html(html).trigger('create');
|
|
|
|
$('.btnDeleteTimer', elem).on('click', function () {
|
|
|
|
var id = this.getAttribute('data-timerid');
|
|
|
|
deleteTimer(page, id);
|
|
});
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
}
|
|
|
|
function reload(page) {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
ApiClient.getLiveTvTimers().done(function (result) {
|
|
|
|
renderTimers(page, result.Items);
|
|
});
|
|
}
|
|
|
|
$(document).on('pagebeforeshowready', "#liveTvTimersPage", function () {
|
|
|
|
var page = this;
|
|
|
|
if (LibraryBrowser.needsRefresh(page)) {
|
|
reload(page);
|
|
}
|
|
});
|
|
|
|
})(jQuery, document); |