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

113 lines
2.4 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-11-27 12:04:19 -07:00
2013-12-28 14:37:01 -07:00
function getRecordingGroupHtml(group) {
2013-11-27 12:04:19 -07:00
var html = '';
html += '<li><a href="livetvrecordinglist.html?groupid=' + group.Id + '">';
2013-11-27 12:04:19 -07:00
html += '<h3>';
html += group.Name;
html += '</h3>';
2013-11-27 12:04:19 -07:00
html += '<span class="ui-li-count">' + group.RecordingCount + '</span>';
2013-11-27 12:04:19 -07:00
html += '</li>';
2013-11-27 12:04:19 -07:00
2013-12-28 14:37:01 -07:00
return html;
}
2013-11-30 23:25:19 -07:00
2013-12-28 14:37:01 -07:00
function renderRecordingGroups(page, groups) {
2013-12-28 16:09:24 -07:00
if (groups.length) {
$('#recordingGroups', page).show();
} else {
$('#recordingGroups', page).hide();
}
2013-12-28 14:37:01 -07:00
var html = '';
html += '<ul data-role="listview" data-inset="true">';
2013-12-28 14:37:01 -07:00
for (var i = 0, length = groups.length; i < length; i++) {
html += getRecordingGroupHtml(groups[i]);
}
html += '</ul>';
2013-12-28 14:37:01 -07:00
$('#recordingGroupItems', page).html(html).trigger('create');
2013-12-28 14:37:01 -07:00
Dashboard.hideLoadingMsg();
}
function renderRecordings(elem, recordings) {
2013-11-27 12:04:19 -07:00
2014-05-09 12:43:06 -07:00
var screenWidth = $(window).width();
2013-12-28 16:09:24 -07:00
if (recordings.length) {
elem.show();
2013-12-28 16:09:24 -07:00
} else {
elem.hide();
2013-12-28 16:09:24 -07:00
}
$('.recordingItems', elem).html(LibraryBrowser.getPosterViewHtml({
2013-12-28 16:09:24 -07:00
items: recordings,
2014-05-29 07:19:12 -07:00
shape: "auto",
2013-12-28 16:09:24 -07:00
showTitle: true,
showParentTitle: true,
2014-05-09 12:43:06 -07:00
overlayText: screenWidth >= 600,
2015-04-11 18:38:38 -07:00
coverImage: true,
lazy: true
2013-12-28 16:09:24 -07:00
2015-04-11 18:38:38 -07:00
})).lazyChildren();
2013-12-28 16:09:24 -07:00
}
2013-11-27 12:04:19 -07:00
function reload(page) {
Dashboard.showLoadingMsg();
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvRecordings({
2013-11-27 12:04:19 -07:00
userId: Dashboard.getCurrentUserId(),
IsInProgress: true
2013-12-28 14:37:01 -07:00
}).done(function (result) {
renderRecordings($('#activeRecordings', page), result.Items);
2013-11-27 12:04:19 -07:00
});
2013-12-28 16:09:24 -07:00
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvRecordings({
2013-12-28 16:09:24 -07:00
userId: Dashboard.getCurrentUserId(),
2014-01-12 22:41:00 -07:00
limit: 12,
IsInProgress: false
}).done(function (result) {
renderRecordings($('#latestRecordings', page), result.Items);
});
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvRecordingGroups({
userId: Dashboard.getCurrentUserId()
2013-12-28 16:09:24 -07:00
}).done(function (result) {
renderRecordingGroups(page, result.Items);
2013-12-28 16:09:24 -07:00
});
2013-11-27 12:04:19 -07:00
}
2015-06-18 21:23:55 -07:00
$(document).on('pagebeforeshowready', "#liveTvRecordingsPage", function () {
2013-11-27 12:04:19 -07:00
var page = this;
reload(page);
2013-12-28 14:37:01 -07:00
2013-11-27 12:04:19 -07:00
});
2014-10-15 20:26:39 -07:00
})(jQuery, document);