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

64 lines
1.9 KiB
JavaScript
Raw Normal View History

2013-06-07 09:06:32 -07:00
(function ($, document) {
2013-04-08 13:46:59 -07:00
2013-06-07 09:06:32 -07:00
function reloadPlaylist(page) {
var html = '';
2013-04-08 13:46:59 -07:00
2013-06-07 09:06:32 -07:00
html += '<table class="detailTable">';
2013-04-08 13:46:59 -07:00
2013-06-07 09:06:32 -07:00
html += '<tr>';
html += '<th></th>';
html += '<th>Name</th>';
html += '<th>Album</th>';
html += '<th>Time</th>';
html += '<th>Rating</th>';
html += '</tr>';
2013-04-08 13:46:59 -07:00
2013-06-07 09:06:32 -07:00
$.each(MediaPlayer.playlist, function (i, item) {
2013-06-07 09:06:32 -07:00
var name = LibraryBrowser.getPosterViewDisplayName(item);
2013-04-17 18:32:38 -07:00
2013-06-07 09:06:32 -07:00
var parentName = item.SeriesName || item.Album || item.ProductionYear || '';
2013-06-07 09:06:32 -07:00
html += '<tr>';
html += '<td><a href="#" data-index="' + i + '" class="lnkPlay"><img src="css/images/media/playCircle.png" style="height: 24px;" /></a></td>';
html += '<td>' + name + '</td>';
html += '<td>' + parentName + '</td>';
html += '<td>' + ticks_to_human(item.RunTimeTicks) + '</td>';
html += '<td>' + LibraryBrowser.getUserDataIconsHtml(item) + '</td>';
html += '<td><a href="#" data-index="' + i + '" class="lnkRemove"><img src="css/images/media/playCircle.png" style="height: 24px;" /></a></td>';
html += '</tr>';
});
2013-06-07 09:06:32 -07:00
html += '</table>';
2013-06-07 09:06:32 -07:00
$("#playlist", page).html(html).trigger('create');
}
$(document).on('pageinit', "#playlistPage", function () {
2013-06-07 09:06:32 -07:00
var page = this;
2013-06-07 09:06:32 -07:00
$(page).on('click', '.lnkPlay', function () {
2013-06-07 09:06:32 -07:00
var index = parseInt(this.getAttribute('data-index'));
2013-06-07 09:06:32 -07:00
MediaPlayer.currentPlaylistIndex(index);
2013-06-07 09:06:32 -07:00
}).on('click', '.lnkRemove', function () {
2013-06-07 09:06:32 -07:00
var index = parseInt(this.getAttribute('data-index'));
2013-06-07 09:06:32 -07:00
MediaPlayer.removeFromPlaylist(index);
reloadPlaylist(page);
});
2013-06-07 09:06:32 -07:00
}).on('pagebeforeshow', "#playlistPage", function () {
2013-06-07 09:06:32 -07:00
var page = this;
2013-06-07 09:06:32 -07:00
reloadPlaylist(page);
});
})(jQuery, document);