1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/livetvrecordings.js

121 lines
2.7 KiB
JavaScript
Raw Normal View History

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