mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
itembynamedetailpage.js
This commit is contained in:
parent
af8d421a8c
commit
40e4f6a27a
1 changed files with 221 additions and 88 deletions
|
@ -3,38 +3,88 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
|
||||
function renderItems(page, item) {
|
||||
var sections = [];
|
||||
item.ArtistCount && sections.push({
|
||||
|
||||
if (item.ArtistCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabArtists"),
|
||||
type: "MusicArtist"
|
||||
}), item.ProgramCount && "Person" == item.Type && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.ProgramCount && "Person" == item.Type) {
|
||||
sections.push({
|
||||
name: Globalize.translate("HeaderUpcomingOnTV"),
|
||||
type: "Program"
|
||||
}), item.MovieCount && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.MovieCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabMovies"),
|
||||
type: "Movie"
|
||||
}), item.SeriesCount && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.SeriesCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabShows"),
|
||||
type: "Series"
|
||||
}), item.EpisodeCount && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.EpisodeCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabEpisodes"),
|
||||
type: "Episode"
|
||||
}), item.TrailerCount && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.TrailerCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabTrailers"),
|
||||
type: "Trailer"
|
||||
}), item.AlbumCount && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.AlbumCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabAlbums"),
|
||||
type: "MusicAlbum"
|
||||
}), item.MusicVideoCount && sections.push({
|
||||
});
|
||||
}
|
||||
|
||||
if (item.MusicVideoCount) {
|
||||
sections.push({
|
||||
name: Globalize.translate("TabMusicVideos"),
|
||||
type: "MusicVideo"
|
||||
});
|
||||
}
|
||||
|
||||
var elem = page.querySelector("#childrenContent");
|
||||
elem.innerHTML = sections.map(function (section) {
|
||||
var html = "",
|
||||
sectionClass = "verticalSection";
|
||||
return "Audio" === section.type && (sectionClass += " verticalSection-extrabottompadding"), html += '<div class="' + sectionClass + '" data-type="' + section.type + '">', html += '<div class="sectionTitleContainer sectionTitleContainer-cards">', html += '<h2 class="sectionTitle sectionTitle-cards padded-left">', html += section.name, html += "</h2>", html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + Globalize.translate("ButtonMore") + "</button></a>", html += "</div>", html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right">', html += "</div>", html += "</div>"
|
||||
var html = "";
|
||||
var sectionClass = "verticalSection";
|
||||
|
||||
if ("Audio" === section.type) {
|
||||
sectionClass += " verticalSection-extrabottompadding";
|
||||
}
|
||||
|
||||
html += '<div class="' + sectionClass + '" data-type="' + section.type + '">';
|
||||
html += '<div class="sectionTitleContainer sectionTitleContainer-cards">';
|
||||
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">';
|
||||
html += section.name;
|
||||
html += "</h2>";
|
||||
html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + Globalize.translate("ButtonMore") + "</button></a>";
|
||||
html += "</div>";
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right">';
|
||||
html += "</div>";
|
||||
return html += "</div>";
|
||||
}).join("");
|
||||
for (var sectionElems = elem.querySelectorAll(".verticalSection"), i = 0, length = sectionElems.length; i < length; i++) renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute("data-type"))
|
||||
var sectionElems = elem.querySelectorAll(".verticalSection");
|
||||
|
||||
for (var i = 0, length = sectionElems.length; i < length; i++) {
|
||||
renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute("data-type"));
|
||||
}
|
||||
}
|
||||
|
||||
function renderSection(page, item, element, type) {
|
||||
|
@ -50,16 +100,17 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "StartDate"
|
||||
}, {
|
||||
shape: "backdrop",
|
||||
showTitle: !0,
|
||||
centerText: !0,
|
||||
overlayMoreButton: !0,
|
||||
preferThumb: !0,
|
||||
overlayText: !1,
|
||||
showAirTime: !0,
|
||||
showAirDateTime: !0,
|
||||
showChannelName: !0
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true,
|
||||
preferThumb: true,
|
||||
overlayText: false,
|
||||
showAirTime: true,
|
||||
showAirDateTime: true,
|
||||
showChannelName: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "Movie":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -71,13 +122,14 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "SortName"
|
||||
}, {
|
||||
shape: "portrait",
|
||||
showTitle: !0,
|
||||
centerText: !0,
|
||||
overlayMoreButton: !0,
|
||||
overlayText: !1,
|
||||
showYear: !0
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true,
|
||||
overlayText: false,
|
||||
showYear: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "MusicVideo":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -89,11 +141,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "SortName"
|
||||
}, {
|
||||
shape: "portrait",
|
||||
showTitle: !0,
|
||||
centerText: !0,
|
||||
overlayPlayButton: !0
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "Trailer":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -105,11 +158,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "SortName"
|
||||
}, {
|
||||
shape: "portrait",
|
||||
showTitle: !0,
|
||||
centerText: !0,
|
||||
overlayPlayButton: !0
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "Series":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -121,11 +175,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "SortName"
|
||||
}, {
|
||||
shape: "portrait",
|
||||
showTitle: !0,
|
||||
centerText: !0,
|
||||
overlayMoreButton: !0
|
||||
showTitle: true,
|
||||
centerText: true,
|
||||
overlayMoreButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "MusicAlbum":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -137,14 +192,15 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "ProductionYear,Sortname"
|
||||
}, {
|
||||
shape: "square",
|
||||
playFromHere: !0,
|
||||
showTitle: !0,
|
||||
showYear: !0,
|
||||
coverImage: !0,
|
||||
centerText: !0,
|
||||
overlayPlayButton: !0
|
||||
playFromHere: true,
|
||||
showTitle: true,
|
||||
showYear: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "MusicArtist":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -156,14 +212,15 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "SortName"
|
||||
}, {
|
||||
shape: "square",
|
||||
playFromHere: !0,
|
||||
showTitle: !0,
|
||||
showParentTitle: !0,
|
||||
coverImage: !0,
|
||||
centerText: !0,
|
||||
overlayPlayButton: !0
|
||||
playFromHere: true,
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
coverImage: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "Episode":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -175,12 +232,13 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
SortBy: "SortName"
|
||||
}, {
|
||||
shape: "backdrop",
|
||||
showTitle: !0,
|
||||
showParentTitle: !0,
|
||||
centerText: !0,
|
||||
overlayPlayButton: !0
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
centerText: true,
|
||||
overlayPlayButton: true
|
||||
});
|
||||
break;
|
||||
|
||||
case "Audio":
|
||||
loadItems(element, item, type, {
|
||||
MediaTypes: "",
|
||||
|
@ -190,57 +248,132 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
|
|||
AlbumArtistIds: "",
|
||||
SortBy: "AlbumArtist,Album,SortName"
|
||||
}, {
|
||||
playFromHere: !0,
|
||||
playFromHere: true,
|
||||
action: "playallfromhere",
|
||||
smallIcon: !0,
|
||||
artist: !0
|
||||
})
|
||||
smallIcon: true,
|
||||
artist: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadItems(element, item, type, query, listOptions) {
|
||||
query = getQuery(query, item), getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function(result) {
|
||||
query = getQuery(query, item);
|
||||
getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function (result) {
|
||||
var html = "";
|
||||
|
||||
if (query.Limit && result.TotalRecordCount > query.Limit) {
|
||||
var link = element.querySelector("a");
|
||||
link.classList.remove("hide"), link.setAttribute("href", getMoreItemsHref(item, type))
|
||||
} else element.querySelector("a").classList.add("hide");
|
||||
link.classList.remove("hide");
|
||||
link.setAttribute("href", getMoreItemsHref(item, type));
|
||||
} else {
|
||||
element.querySelector("a").classList.add("hide");
|
||||
}
|
||||
|
||||
listOptions.items = result.Items;
|
||||
var itemsContainer = element.querySelector(".itemsContainer");
|
||||
"Audio" == type ? (html = listView.getListViewHtml(listOptions), itemsContainer.classList.remove("vertical-wrap"), itemsContainer.classList.add("vertical-list")) : (html = cardBuilder.getCardsHtml(listOptions), itemsContainer.classList.add("vertical-wrap"), itemsContainer.classList.remove("vertical-list")), itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer)
|
||||
})
|
||||
|
||||
if ("Audio" == type) {
|
||||
html = listView.getListViewHtml(listOptions);
|
||||
itemsContainer.classList.remove("vertical-wrap");
|
||||
itemsContainer.classList.add("vertical-list");
|
||||
} else {
|
||||
html = cardBuilder.getCardsHtml(listOptions);
|
||||
itemsContainer.classList.add("vertical-wrap");
|
||||
itemsContainer.classList.remove("vertical-list");
|
||||
}
|
||||
|
||||
itemsContainer.innerHTML = html;
|
||||
imageLoader.lazyChildren(itemsContainer);
|
||||
});
|
||||
}
|
||||
|
||||
function getMoreItemsHref(item, type) {
|
||||
return "Genre" == item.Type ? "list.html?type=" + type + "&genreId=" + item.Id + "&serverId=" + item.ServerId : "MusicGenre" == item.Type ? "list.html?type=" + type + "&musicGenreId=" + item.Id + "&serverId=" + item.ServerId : "Studio" == item.Type ? "list.html?type=" + type + "&studioId=" + item.Id + "&serverId=" + item.ServerId : "MusicArtist" == item.Type ? "list.html?type=" + type + "&artistId=" + item.Id + "&serverId=" + item.ServerId : "Person" == item.Type ? "list.html?type=" + type + "&personId=" + item.Id + "&serverId=" + item.ServerId : "list.html?type=" + type + "&parentId=" + item.Id + "&serverId=" + item.ServerId
|
||||
if ("Genre" == item.Type) {
|
||||
return "list.html?type=" + type + "&genreId=" + item.Id + "&serverId=" + item.ServerId;
|
||||
}
|
||||
|
||||
if ("MusicGenre" == item.Type) {
|
||||
return "list.html?type=" + type + "&musicGenreId=" + item.Id + "&serverId=" + item.ServerId;
|
||||
}
|
||||
|
||||
if ("Studio" == item.Type) {
|
||||
return "list.html?type=" + type + "&studioId=" + item.Id + "&serverId=" + item.ServerId;
|
||||
}
|
||||
|
||||
if ("MusicArtist" == item.Type) {
|
||||
return "list.html?type=" + type + "&artistId=" + item.Id + "&serverId=" + item.ServerId;
|
||||
}
|
||||
|
||||
if ("Person" == item.Type) {
|
||||
return "list.html?type=" + type + "&personId=" + item.Id + "&serverId=" + item.ServerId;
|
||||
}
|
||||
|
||||
return "list.html?type=" + type + "&parentId=" + item.Id + "&serverId=" + item.ServerId;
|
||||
}
|
||||
|
||||
function addCurrentItemToQuery(query, item) {
|
||||
"Person" == item.Type ? query.PersonIds = item.Id : "Genre" == item.Type ? query.GenreIds = item.Id : "MusicGenre" == item.Type ? query.GenreIds = item.Id : "Studio" == item.Type ? query.StudioIds = item.Id : "MusicArtist" == item.Type && (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18") ? query.AlbumArtistIds = item.Id : query.ArtistIds = item.Id)
|
||||
if ("Person" == item.Type) {
|
||||
query.PersonIds = item.Id;
|
||||
} else {
|
||||
if ("Genre" == item.Type) {
|
||||
query.GenreIds = item.Id;
|
||||
} else {
|
||||
if ("MusicGenre" == item.Type) {
|
||||
query.GenreIds = item.Id;
|
||||
} else {
|
||||
if ("Studio" == item.Type) {
|
||||
query.StudioIds = item.Id;
|
||||
} else {
|
||||
if ("MusicArtist" == item.Type) {
|
||||
if (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18")) {
|
||||
query.AlbumArtistIds = item.Id;
|
||||
} else {
|
||||
query.ArtistIds = item.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getQuery(options, item) {
|
||||
var query = {
|
||||
SortOrder: "Ascending",
|
||||
IncludeItemTypes: "",
|
||||
Recursive: !0,
|
||||
Recursive: true,
|
||||
Fields: "AudioInfo,SeriesInfo,ParentId,PrimaryImageAspectRatio,BasicSyncInfo",
|
||||
Limit: 100,
|
||||
StartIndex: 0,
|
||||
CollapseBoxSetItems: !1
|
||||
CollapseBoxSetItems: false
|
||||
};
|
||||
return query = Object.assign(query, options || {}), addCurrentItemToQuery(query, item), query
|
||||
query = Object.assign(query, options || {});
|
||||
addCurrentItemToQuery(query, item);
|
||||
return query;
|
||||
}
|
||||
|
||||
function getItemsFunction(options, item) {
|
||||
var query = getQuery(options, item);
|
||||
return function (index, limit, fields) {
|
||||
query.StartIndex = index, query.Limit = limit, fields && (query.Fields += "," + fields);
|
||||
query.StartIndex = index;
|
||||
query.Limit = limit;
|
||||
|
||||
if (fields) {
|
||||
query.Fields += "," + fields;
|
||||
}
|
||||
|
||||
var apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
return "MusicArtist" === query.IncludeItemTypes ? (query.IncludeItemTypes = null, apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query)) : apiClient.getItems(apiClient.getCurrentUserId(), query)
|
||||
|
||||
if ("MusicArtist" === query.IncludeItemTypes) {
|
||||
query.IncludeItemTypes = null;
|
||||
return apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query);
|
||||
}
|
||||
|
||||
return apiClient.getItems(apiClient.getCurrentUserId(), query);
|
||||
};
|
||||
}
|
||||
|
||||
window.ItemsByName = {
|
||||
renderItems: renderItems
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue