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

72 lines
2.2 KiB
JavaScript
Raw Normal View History

(function ($, document, apiClient) {
2013-02-20 18:33:05 -07:00
2013-04-04 10:27:36 -07:00
function getViewHtml(view) {
var html = '';
2013-04-25 17:52:55 -07:00
html += '<a class="posterItem backdropPosterItem" href="' + view.url + '">';
html += '<div class="posterItemImage" style="background-color: ' + view.background + ';background-image:url(\'' + view.img + '\');"></div><div class="posterItemText posterItemTextCentered">' + view.name + '</div>';
2013-04-04 10:27:36 -07:00
html += '</a>';
return html;
}
$(document).on('pagebeforeshow', "#indexPage", function () {
2013-02-20 18:33:05 -07:00
2013-04-01 08:59:56 -07:00
var page = this;
2013-02-20 18:33:05 -07:00
2013-04-01 08:59:56 -07:00
var userId = Dashboard.getCurrentUserId();
2013-02-20 18:33:05 -07:00
if (!userId) {
return;
}
var options = {
sortBy: "SortName"
};
apiClient.getItems(userId, options).done(function (result) {
2013-02-20 18:33:05 -07:00
2013-04-01 22:14:37 -07:00
$('#divCollections', page).html(LibraryBrowser.getPosterViewHtml({
2013-02-20 18:33:05 -07:00
items: result.Items,
2013-04-25 17:52:55 -07:00
showTitle: true,
shape: "backdrop",
centerText: true
2013-02-20 18:33:05 -07:00
}));
});
2013-04-04 10:27:36 -07:00
// Kick this off now. Just see if there are any games in the library
var gamesPromise = ApiClient.getItems(userId, { Recursive: true, limit: 0, MediaTypes: "Game" });
var views = [
2013-04-04 10:27:36 -07:00
{ name: "Movies", url: "moviesrecommended.html", img: "css/images/items/list/chapter.png", background: "#0094FF" },
{ name: "TV Shows", url: "tvrecommended.html", img: "css/images/items/list/collection.png", background: "#FF870F" },
2013-04-04 10:27:36 -07:00
{ name: "Music", url: "musicrecommended.html", img: "css/images/items/list/audiocollection.png", background: "#6FBD45" }
];
var html = '';
for (var i = 0, length = views.length; i < length; i++) {
2013-04-04 10:27:36 -07:00
html += getViewHtml(views[i]);
}
$('#views', page).html(html);
2013-04-04 10:27:36 -07:00
gamesPromise.done(function (result) {
if (result.TotalRecordCount) {
2013-04-14 20:37:07 -07:00
var view = { name: "Games", url: "gamesrecommended.html", img: "css/images/items/list/gamecollection.png", background: "#E12026" };
2013-04-04 10:27:36 -07:00
$('#views', page).append(getViewHtml(view));
}
});
2013-04-01 08:59:56 -07:00
});
2013-02-20 18:33:05 -07:00
})(jQuery, document, ApiClient);