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

117 lines
3.4 KiB
JavaScript
Raw Normal View History

2013-11-27 12:04:19 -07:00
(function ($, document, apiClient) {
function deleteTimer(page, id) {
2013-12-19 14:51:32 -07:00
Dashboard.confirm("Are you sure you wish to cancel this recording?", "Confirm Recording Cancellation", function (result) {
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvTimer(id).done(function () {
2013-12-19 14:51:32 -07:00
Dashboard.alert('Recording cancelled.');
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;
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>';
html += LiveTvHelpers.getDisplayTime(timer.StartDate);
html += ' - ' + LiveTvHelpers.getDisplayTime(timer.EndDate);
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-01-10 22:49:18 -07:00
html += '<a data-timerid="' + timer.Id + '" href="#" title="Cancel Recording" class="btnDeleteTimer">Cancel Recording</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
2013-11-27 12:04:19 -07:00
apiClient.getLiveTvTimers().done(function (result) {
renderTimers(page, result.Items);
});
}
$(document).on('pagebeforeshow', "#liveTvTimersPage", function () {
var page = this;
reload(page);
});
})(jQuery, document, ApiClient);