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

89 lines
2.1 KiB
JavaScript
Raw Normal View History

2013-11-20 14:08:12 -07:00
(function ($, document, apiClient) {
function getChannelHtml(channel) {
var html = '';
html += '<a class="squareTileItem tileItem" href="livetvchannel.html?id=' + channel.Id + '">';
2013-11-20 14:08:12 -07:00
2013-11-24 14:30:38 -07:00
var imgUrl;
var isDefault;
2013-11-29 11:44:51 -07:00
if (channel.ImageTags.Primary) {
2013-11-24 14:30:38 -07:00
imgUrl = apiClient.getUrl("LiveTV/Channels/" + channel.Id + "/Images/Primary", {
2013-11-29 11:44:51 -07:00
tag: channel.ImageTags.Primary,
2013-11-24 14:30:38 -07:00
height: 300
});
} else {
imgUrl = "css/images/items/list/collection.png";
isDefault = true;
}
2013-11-20 14:08:12 -07:00
var cssClass = isDefault ? "tileImage defaultTileImage" : "tileImage";
html += '<div class="' + cssClass + '" style="background-image: url(\'' + imgUrl + '\');"></div>';
html += '<div class="tileContent">';
html += '<div class="tileName">' + channel.Name + '</div>';
html += '<p class="itemMiscInfo">' + channel.Number + '</p>';
2013-12-14 18:17:57 -07:00
html += '<p class="userDataIcons">' + LibraryBrowser.getUserDataIconsHtml(channel) + '</p>';
2013-11-20 14:08:12 -07:00
html += '</div>';
html += "</a>";
return html;
}
function getChannelsHtml(channels) {
var html = [];
for (var i = 0, length = channels.length; i < length; i++) {
html.push(getChannelHtml(channels[i]));
}
return html.join('');
}
function renderChannels(page, channels) {
2013-11-21 13:48:26 -07:00
//var pagingHtml = LibraryBrowser.getPagingHtml({
2013-11-20 14:08:12 -07:00
2013-11-21 13:48:26 -07:00
// StartIndex: 0,
// Limit: channels.length
2013-11-20 14:08:12 -07:00
2013-11-21 13:48:26 -07:00
//}, channels.length, true);
2013-11-20 14:08:12 -07:00
2013-11-21 13:48:26 -07:00
//$('.listTopPaging', page).html(pagingHtml).trigger('create');
2013-11-20 14:08:12 -07:00
$('#items', page).html(getChannelsHtml(channels)).trigger('create');
}
$(document).on('pagebeforeshow', "#liveTvChannelsPage", function () {
var page = this;
2013-11-25 19:53:48 -07:00
apiClient.getLiveTvChannels({
userId: Dashboard.getCurrentUserId()
}).done(function (result) {
2013-11-20 14:08:12 -07:00
2013-11-25 13:39:23 -07:00
renderChannels(page, result.Items);
2013-11-20 14:08:12 -07:00
});
});
})(jQuery, document, ApiClient);