2013-04-10 12:33:19 -07:00
|
|
|
|
var LibraryBrowser = (function (window, $) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return {
|
2013-04-09 09:42:55 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getDetaultPageSize: function () {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (window.location.toString().toLowerCase().indexOf('localhost') != -1) {
|
|
|
|
|
return 100;
|
|
|
|
|
}
|
|
|
|
|
return 25;
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
getPosterDetailViewHtml: function (options) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var items = options.items;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
var html = '';
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var item = items[i];
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<a class="posterDetailViewItem" href="' + LibraryBrowser.getHref(item) + '">';
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (options.preferBackdrop && item.BackdropImageTags && item.BackdropImageTags.length) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<img class='posterDetailViewImage' src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
}) + "' />";
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
}
|
|
|
|
|
else if (options.preferBackdrop && item.ImageTags && item.ImageTags.Thumb) {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<img class='posterDetailViewImage' src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
2013-04-10 12:33:19 -07:00
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
2013-04-10 22:27:27 -07:00
|
|
|
|
tag: item.ImageTags.Thumb
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}) + "' />";
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.ImageTags && item.ImageTags.Primary) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-11 20:50:47 -07:00
|
|
|
|
html += "<img class='posterDetailViewImage' src='" + LibraryBrowser.getPrimaryImageUrl(item, {
|
2013-04-10 12:33:19 -07:00
|
|
|
|
height: height,
|
2013-04-11 20:50:47 -07:00
|
|
|
|
width: width
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}) + "' />";
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
html += "<img class='posterDetailViewImage' src='" + ApiClient.getImageUrl(item.Id, {
|
2013-04-10 12:33:19 -07:00
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}) + "' />";
|
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") {
|
2013-04-04 10:27:36 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<img class='posterDetailViewImage' style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/audio.png' />";
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<img class='posterDetailViewImage' style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/video.png' />";
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-11 20:50:47 -07:00
|
|
|
|
else if (item.Type == "Person") {
|
|
|
|
|
|
|
|
|
|
html += "<img class='posterDetailViewImage' style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/person.png' />";
|
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
else {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<img class='posterDetailViewImage' style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/collection.png' />";
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<div class="posterDetailViewContentContainer">';
|
|
|
|
|
|
|
|
|
|
if (item.SeriesName || item.Album) {
|
|
|
|
|
var seriesName = item.SeriesName || item.Album;
|
|
|
|
|
html += '<div class="posterDetailViewName">' + seriesName + '</div>';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
var name = item.Name;
|
|
|
|
|
|
|
|
|
|
if (item.IndexNumber != null) {
|
|
|
|
|
name = item.IndexNumber + " - " + name;
|
|
|
|
|
}
|
|
|
|
|
if (item.ParentIndexNumber != null) {
|
|
|
|
|
name = item.ParentIndexNumber + "." + name;
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<div class="posterDetailViewName">' + name + '</div>';
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (item.CommunityRating) {
|
|
|
|
|
html += '<p>' + LibraryBrowser.getFiveStarRatingHtml(item) + '</p>';
|
|
|
|
|
}
|
2013-04-11 12:36:50 -07:00
|
|
|
|
|
|
|
|
|
var childText;
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2013-04-11 08:43:57 -07:00
|
|
|
|
if (item.Type == "BoxSet") {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-11 12:36:50 -07:00
|
|
|
|
childText = item.ChildCount == 1 ? "1 Movie" : item.ChildCount + " Movies";
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2013-04-11 12:36:50 -07:00
|
|
|
|
html += '<p class="itemMiscInfo">' + childText + '</p>';
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Genre" || item.Type == "Studio" || item.Type == "Person") {
|
|
|
|
|
|
|
|
|
|
childText = item.ChildCount == 1 ? "1 " + options.countNameSingular : item.ChildCount + " " + options.countNamePlural;
|
|
|
|
|
|
|
|
|
|
html += '<p class="itemMiscInfo">' + childText + '</p>';
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-04-11 08:43:57 -07:00
|
|
|
|
html += '<p class="itemMiscInfo">' + LibraryBrowser.getMiscInfoHtml(item, false) + '</p>';
|
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
|
|
|
|
html += '<p class="userDataIcons">' + LibraryBrowser.getUserDataIconsHtml(item) + '</p>';
|
|
|
|
|
|
|
|
|
|
if (item.PlayedPercentage || (item.UserData && item.UserData.PlaybackPositionTicks)) {
|
|
|
|
|
html += '<p>' + LibraryBrowser.getProgressBarHtml(item) + '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
|
|
|
|
|
|
|
|
|
html += "</a>";
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
getHref: function (item) {
|
|
|
|
|
|
|
|
|
|
if (item.url) {
|
|
|
|
|
return item.url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Type == "Series") {
|
|
|
|
|
return "tvseries.html?id=" + item.Id;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "BoxSet") {
|
|
|
|
|
return "boxset.html?id=" + item.Id;
|
|
|
|
|
}
|
2013-04-11 15:09:08 -07:00
|
|
|
|
if (item.Type == "Genre") {
|
|
|
|
|
return "itembynamedetails.html?genre=" + item.Name;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Studio") {
|
|
|
|
|
return "itembynamedetails.html?studio=" + item.Name;
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Person") {
|
|
|
|
|
return "itembynamedetails.html?person=" + item.Name;
|
|
|
|
|
}
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
|
|
|
|
return item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id;
|
|
|
|
|
|
|
|
|
|
},
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2013-04-11 20:50:47 -07:00
|
|
|
|
getPrimaryImageUrl: function (item, options) {
|
|
|
|
|
|
|
|
|
|
options = options || {};
|
|
|
|
|
options.type = "Primary";
|
|
|
|
|
options.tag = item.ImageTags.Primary;
|
2013-04-12 07:13:47 -07:00
|
|
|
|
|
2013-04-11 20:50:47 -07:00
|
|
|
|
if (item.Type == "Studio") {
|
|
|
|
|
|
|
|
|
|
return ApiClient.getStudioImageUrl(item.Name, options);
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Person") {
|
|
|
|
|
|
|
|
|
|
return ApiClient.getPersonImageUrl(item.Name, options);
|
|
|
|
|
}
|
|
|
|
|
if (item.Type == "Genre") {
|
|
|
|
|
|
|
|
|
|
return ApiClient.getGenreImageUrl(item.Name, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ApiClient.getImageUrl(item.Id, options);
|
|
|
|
|
|
|
|
|
|
},
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
|
|
|
|
getPosterViewHtml: function (options) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var items = options.items;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = "";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
var item = items[i];
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
var showText = options.showTitle || !hasPrimaryImage;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
var cssClass = showText ? "posterViewItem" : "posterViewItem posterViewItemWithNoText";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<div class='" + cssClass + "'><a href='" + LibraryBrowser.getHref(item) + "'>";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (options.preferBackdrop && item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}) + "' />";
|
|
|
|
|
} else if (hasPrimaryImage) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}) + "' />";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}) + "' />";
|
2013-04-10 22:27:27 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") {
|
|
|
|
|
|
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/audio.png' />";
|
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") {
|
|
|
|
|
|
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/video.png' />";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/collection.png' />";
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
|
|
|
|
|
if (showText) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<div class='posterViewItemText'>";
|
|
|
|
|
html += item.Name;
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "</div>";
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
|
|
|
|
|
if (options.showNewIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "</a></div>";
|
2013-04-09 21:38:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
getEpisodePosterViewHtml: function (options) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var items = options.items;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = "";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
var item = items[i];
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer');
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var cssClass = showText ? "posterViewItem posterViewItemWithDualText" : "posterViewItem posterViewItemWithNoText";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<div class='" + cssClass + "'><a href='" + LibraryBrowser.getHref(item) + "'>";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (options.preferBackdrop && item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
|
}) + "' />";
|
|
|
|
|
} else if (hasPrimaryImage) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
|
}) + "' />";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
height: 198,
|
|
|
|
|
width: 352,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
|
}) + "' />";
|
|
|
|
|
} else {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/collection.png' />";
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (showText) {
|
|
|
|
|
html += "<div class='posterViewItemText posterViewItemPrimaryText'>";
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (item.SeriesName != null) {
|
|
|
|
|
html += item.SeriesName;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
html += "<div class='posterViewItemText'>";
|
|
|
|
|
}
|
|
|
|
|
if (item.ParentIndexNumber != null) {
|
|
|
|
|
html += item.ParentIndexNumber + ".";
|
|
|
|
|
}
|
|
|
|
|
if (item.IndexNumber != null) {
|
|
|
|
|
html += item.IndexNumber + " -";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += " " + item.Name;
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (options.showNewIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "</a></div>";
|
2013-04-08 22:06:13 -07:00
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getNewIndicatorHtml: function (item) {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.RecentlyAddedItemCount) {
|
|
|
|
|
return '<div class="posterRibbon">' + item.RecentlyAddedItemCount + ' New</div>';
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-11 15:33:49 -07:00
|
|
|
|
if (!item.IsFolder && item.Type !== "Genre" && item.Type !== "Studio" && item.Type !== "Person") {
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var date = item.DateCreated;
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (date && (new Date().getTime() - parseISO8601Date(date).getTime()) < 1209600000) {
|
|
|
|
|
return "<div class='posterRibbon'>New</div>";
|
|
|
|
|
}
|
2013-04-09 21:38:04 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return '';
|
|
|
|
|
},
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getProgressBarHtml: function (item) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = '';
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
var tooltip;
|
|
|
|
|
|
|
|
|
|
if (item.PlayedPercentage) {
|
|
|
|
|
|
|
|
|
|
tooltip = parseInt(item.PlayedPercentage) + '% watched';
|
|
|
|
|
html += '<progress class="itemProgress" min="0" max="100" value="' + item.PlayedPercentage + '" title="' + tooltip + '"></progress>';
|
|
|
|
|
}
|
|
|
|
|
else if (item.UserData && item.UserData.PlaybackPositionTicks && item.RunTimeTicks) {
|
|
|
|
|
|
|
|
|
|
tooltip = DashboardPage.getDisplayText(item.UserData.PlaybackPositionTicks) + " / " + DashboardPage.getDisplayText(item.RunTimeTicks);
|
|
|
|
|
|
|
|
|
|
html += '<progress class="itemProgress" min="0" max="100" value="' + (item.UserData.PlaybackPositionTicks / item.RunTimeTicks) + '" title="' + tooltip + '"></progress>';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getAveragePrimaryImageAspectRatio: function (items) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var values = [];
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var ratio = items[i].PrimaryImageAspectRatio || 0;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (!ratio) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
values[values.length] = ratio;
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (!values.length) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
// Use the median
|
|
|
|
|
values.sort(function (a, b) { return a - b; });
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var half = Math.floor(values.length / 2);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (values.length % 2)
|
|
|
|
|
return values[half];
|
|
|
|
|
else
|
|
|
|
|
return (values[half - 1] + values[half]) / 2.0;
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
metroColors: ["#6FBD45", "#4BB3DD", "#4164A5", "#E12026", "#800080", "#E1B222", "#008040", "#0094FF", "#FF00C7", "#FF870F", "#7F0037"],
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getRandomMetroColor: function () {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var index = Math.floor(Math.random() * (LibraryBrowser.metroColors.length - 1));
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getMetroColor: function (str) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (str) {
|
|
|
|
|
var char = String(str.substr(0, 1).charCodeAt());
|
|
|
|
|
var sum = 0;
|
|
|
|
|
for (var i = 0; i < char.length; i++) {
|
|
|
|
|
sum += parseInt(char.charAt(i));
|
|
|
|
|
}
|
|
|
|
|
var index = String(sum).substr(-1);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
} else {
|
|
|
|
|
return LibraryBrowser.getRandomMetroColor();
|
2013-04-08 22:06:13 -07:00
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
},
|
2013-04-05 11:35:37 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getLinksHtml: function (item) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = 'Links: ';
|
|
|
|
|
var links = [];
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-12 07:13:47 -07:00
|
|
|
|
if (item.HomePageUrl) {
|
|
|
|
|
links.push('<a class="ui-link" href="' + item.HomePageUrl + '" target="_blank">Website</a>');
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.ProviderIds.Imdb) {
|
|
|
|
|
if (item.Type == "Movie" || item.Type == "Episode")
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.imdb.com/title/' + item.ProviderIds.Imdb + '" target="_blank">IMDb</a>');
|
|
|
|
|
else if (item.Type == "Person")
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.imdb.com/name/' + item.ProviderIds.Imdb + '" target="_blank">IMDb</a>');
|
|
|
|
|
}
|
|
|
|
|
if (item.ProviderIds.Tmdb) {
|
|
|
|
|
if (item.Type == "Movie")
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.themoviedb.org/movie/' + item.ProviderIds.Tmdb + '" target="_blank">TMDB</a>');
|
|
|
|
|
else if (item.Type == "Person")
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.themoviedb.org/person/' + item.ProviderIds.Tmdb + '" target="_blank">TMDB</a>');
|
|
|
|
|
}
|
|
|
|
|
if (item.ProviderIds.Tvdb)
|
|
|
|
|
links.push('<a class="ui-link" href="http://thetvdb.com/index.php?tab=series&id=' + item.ProviderIds.Tvdb + '" target="_blank">TVDB</a>');
|
|
|
|
|
if (item.ProviderIds.Tvcom) {
|
|
|
|
|
if (item.Type == "Episode")
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.tv.com/shows/' + item.ProviderIds.Tvcom + '" target="_blank">TV.com</a>');
|
|
|
|
|
else if (item.Type == "Person")
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.tv.com/people/' + item.ProviderIds.Tvcom + '" target="_blank">TV.com</a>');
|
|
|
|
|
}
|
|
|
|
|
if (item.ProviderIds.Musicbrainz)
|
|
|
|
|
links.push('<a class="ui-link" href="http://musicbrainz.org/release/' + item.ProviderIds.Musicbrainz + '" target="_blank">MusicBrainz</a>');
|
|
|
|
|
if (item.ProviderIds.Gamesdb)
|
|
|
|
|
links.push('<a class="ui-link" href="http://www.games-db.com/Game/' + item.ProviderIds.Gamesdb + '" target="_blank">GamesDB</a>');
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += links.join(' / ');
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
renderLinks: function (item, page) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.ProviderIds) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
$('#itemLinks', page).html(LibraryBrowser.getLinksHtml(item));
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('#itemLinks', page).hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-11 05:23:02 -07:00
|
|
|
|
getPagingHtml: function (query, totalRecordCount, isTop) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = '';
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var pageCount = Math.ceil(totalRecordCount / query.Limit);
|
|
|
|
|
var pageNumber = (query.StartIndex / query.Limit) + 1;
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var dropdownHtml = '<select data-enhance="false" data-role="none">';
|
|
|
|
|
for (var i = 1; i <= pageCount; i++) {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (i == pageNumber) {
|
|
|
|
|
dropdownHtml += '<option value="' + i + '" selected="selected">' + i + '</option>';
|
|
|
|
|
} else {
|
|
|
|
|
dropdownHtml += '<option value="' + i + '">' + i + '</option>';
|
|
|
|
|
}
|
2013-04-08 22:06:13 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
dropdownHtml += '</select>';
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var recordsEnd = Math.min(query.StartIndex + query.Limit, totalRecordCount);
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-11 05:23:02 -07:00
|
|
|
|
html += isTop ? '<div class="listPaging topListPaging">' : '<div class="listPaging">';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += 'Results ' + (query.StartIndex + 1) + '-' + recordsEnd + ' of ' + totalRecordCount + ', page ' + dropdownHtml + ' of ' + pageCount;
|
|
|
|
|
html += '</div>';
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getStarRatingHtml: function (item) {
|
|
|
|
|
var rating = item.CommunityRating;
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = "";
|
|
|
|
|
for (var i = 1; i <= 10; i++) {
|
|
|
|
|
if (rating < i - 1) {
|
|
|
|
|
html += "<div class='starRating emptyStarRating'></div>";
|
|
|
|
|
}
|
|
|
|
|
else if (rating < i) {
|
|
|
|
|
html += "<div class='starRating halfStarRating'></div>";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += "<div class='starRating'></div>";
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
getFiveStarRatingHtml: function (item) {
|
|
|
|
|
|
|
|
|
|
var rating = item.CommunityRating / 2;
|
|
|
|
|
|
|
|
|
|
var html = "";
|
|
|
|
|
for (var i = 1; i <= 5; i++) {
|
|
|
|
|
if (rating < i - 1) {
|
|
|
|
|
html += "<div class='starRating emptyStarRating'></div>";
|
|
|
|
|
}
|
|
|
|
|
else if (rating < i) {
|
|
|
|
|
html += "<div class='starRating halfStarRating'></div>";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
html += "<div class='starRating'></div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getUserDataIconsHtml: function (item) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = '';
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var userData = item.UserData || {};
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var itemId = item.Id;
|
|
|
|
|
var type = item.Type;
|
2013-04-12 17:42:51 -07:00
|
|
|
|
|
|
|
|
|
if (type == "Person") {
|
|
|
|
|
itemId = item.Name;
|
|
|
|
|
}
|
|
|
|
|
else if (type == "Studio") {
|
|
|
|
|
itemId = item.Name;
|
|
|
|
|
}
|
|
|
|
|
else if (type == "Genre") {
|
|
|
|
|
itemId = item.Name;
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.MediaType) {
|
|
|
|
|
if (userData.Played) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgPlayed" src="css/images/userdata/played.png" alt="Played" title="Played" onclick="LibraryBrowser.markPlayed(this);return false;" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgPlayedOff" src="css/images/userdata/unplayed.png" alt="Played" title="Played" onclick="LibraryBrowser.markPlayed(this);return false;" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (typeof userData.Likes == "undefined") {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img onclick="LibraryBrowser.markDislike(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgDislikeOff" src="css/images/userdata/thumbs_down_off.png" alt="Dislike" title="Dislike" />';
|
|
|
|
|
html += '<img onclick="LibraryBrowser.markLike(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgLikeOff" src="css/images/userdata/thumbs_up_off.png" alt="Like" title="Like" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
else if (userData.Likes) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img onclick="LibraryBrowser.markDislike(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgDislikeOff" src="css/images/userdata/thumbs_down_off.png" alt="Dislike" title="Dislike" />';
|
|
|
|
|
html += '<img onclick="LibraryBrowser.markLike(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgLike" src="css/images/userdata/thumbs_up_on.png" alt="Like" title="Like" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img onclick="LibraryBrowser.markDislike(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgDislike" src="css/images/userdata/thumbs_down_on.png" alt="Dislike" title="Dislike" />';
|
|
|
|
|
html += '<img onclick="LibraryBrowser.markLike(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgLikeOff" src="css/images/userdata/thumbs_up_off.png" alt="Like" title="Like" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (userData.IsFavorite) {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img onclick="LibraryBrowser.markFavorite(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgFavorite" src="css/images/userdata/heart_on.png" alt="Favorite" title="Favorite" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-10 22:27:27 -07:00
|
|
|
|
html += '<img onclick="LibraryBrowser.markFavorite(this);return false;" data-type="' + type + '" data-itemid="' + itemId + '" class="imgUserItemRating imgFavoriteOff" src="css/images/userdata/heart_off.png" alt="Favorite" title="Favorite" />';
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markPlayed: function (link) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var markAsPlayed = $link.hasClass('imgPlayedOff');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
ApiClient.updatePlayedStatus(Dashboard.getCurrentUserId(), id, markAsPlayed);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (markAsPlayed) {
|
|
|
|
|
link.src = "css/images/userdata/played.png";
|
|
|
|
|
$link.addClass('imgPlayed').removeClass('imgPlayedOff');
|
|
|
|
|
} else {
|
|
|
|
|
link.src = "css/images/userdata/unplayed.png";
|
|
|
|
|
$link.addClass('imgPlayedOff').removeClass('imgPlayed');
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markFavorite: function (link) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-12 17:42:51 -07:00
|
|
|
|
var type = link.getAttribute('data-type');
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var markAsFavorite = $link.hasClass('imgFavoriteOff');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-12 17:42:51 -07:00
|
|
|
|
if (type == "Person") {
|
|
|
|
|
ApiClient.updateFavoritePersonStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
|
|
|
|
}
|
|
|
|
|
else if (type == "Studio") {
|
|
|
|
|
ApiClient.updateFavoriteStudioStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
|
|
|
|
}
|
|
|
|
|
else if (type == "Genre") {
|
|
|
|
|
ApiClient.updateFavoriteGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (markAsFavorite) {
|
|
|
|
|
link.src = "css/images/userdata/heart_on.png";
|
|
|
|
|
$link.addClass('imgFavorite').removeClass('imgFavoriteOff');
|
|
|
|
|
} else {
|
|
|
|
|
link.src = "css/images/userdata/heart_off.png";
|
|
|
|
|
$link.addClass('imgFavoriteOff').removeClass('imgFavorite');
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markLike: function (link) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if ($link.hasClass('imgLikeOff')) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
link.src = "css/images/userdata/thumbs_up_on.png";
|
|
|
|
|
$link.addClass('imgLike').removeClass('imgLikeOff');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
link.src = "css/images/userdata/thumbs_up_off.png";
|
|
|
|
|
$link.addClass('imgLikeOff').removeClass('imgLike');
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
$link.prev().removeClass('imgDislike').addClass('imgDislikeOff').each(function () {
|
|
|
|
|
this.src = "css/images/userdata/thumbs_down_off.png";
|
|
|
|
|
});
|
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
markDislike: function (link) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var id = link.getAttribute('data-itemid');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var $link = $(link);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if ($link.hasClass('imgDislikeOff')) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
link.src = "css/images/userdata/thumbs_down_on.png";
|
|
|
|
|
$link.addClass('imgDislike').removeClass('imgDislikeOff');
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
link.src = "css/images/userdata/thumbs_down_off.png";
|
|
|
|
|
$link.addClass('imgDislikeOff').removeClass('imgDislike');
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
$link.next().removeClass('imgLike').addClass('imgLikeOff').each(function () {
|
|
|
|
|
this.src = "css/images/userdata/thumbs_up_off.png";
|
|
|
|
|
});
|
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
getDetailImageHtml: function (item) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var imageTags = item.ImageTags || {};
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = '';
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var url;
|
|
|
|
|
var useBackgroundColor;
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (imageTags.Primary) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.Type == "Person") {
|
|
|
|
|
url = ApiClient.getPersonImageUrl(item.Name, {
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: imageTags.Primary,
|
|
|
|
|
type: "primary"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Genre") {
|
|
|
|
|
url = ApiClient.getGenreImageUrl(item.Name, {
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: imageTags.Primary,
|
|
|
|
|
type: "primary"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (item.Type == "Studio") {
|
|
|
|
|
url = ApiClient.getStudioImageUrl(item.Name, {
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: imageTags.Primary,
|
|
|
|
|
type: "primary"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-10 10:36:34 -07:00
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: item.BackdropImageTags[0]
|
2013-04-10 10:36:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
else if (imageTags.Thumb) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: item.ImageTags.Thumb
|
2013-04-10 10:36:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
else if (imageTags.Disc) {
|
|
|
|
|
|
2013-04-10 10:36:34 -07:00
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
2013-04-10 12:33:19 -07:00
|
|
|
|
type: "Disc",
|
2013-04-12 17:42:51 -07:00
|
|
|
|
maxwidth: 800,
|
2013-04-10 12:33:19 -07:00
|
|
|
|
tag: item.ImageTags.Disc
|
2013-04-10 10:36:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
else if (item.MediaType == "Audio") {
|
|
|
|
|
url = "css/images/items/detail/audio.png";
|
|
|
|
|
useBackgroundColor = true;
|
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Game") {
|
|
|
|
|
url = "css/images/items/detail/game.png";
|
|
|
|
|
useBackgroundColor = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
url = "css/images/items/detail/video.png";
|
|
|
|
|
useBackgroundColor = true;
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (url) {
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : "";
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += "<img class='itemDetailImage' src='" + url + "' style='" + style + "' />";
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
getMiscInfoHtml: function (item, includeMediaInfo) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var miscInfo = [];
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.ProductionYear) {
|
|
|
|
|
miscInfo.push(item.ProductionYear);
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.OfficialRating) {
|
|
|
|
|
miscInfo.push(item.OfficialRating);
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.RunTimeTicks) {
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var minutes = item.RunTimeTicks / 600000000;
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
minutes = minutes || 1;
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
miscInfo.push(parseInt(minutes) + "min");
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (includeMediaInfo !== false) {
|
|
|
|
|
if (item.DisplayMediaType) {
|
|
|
|
|
miscInfo.push(item.DisplayMediaType);
|
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
if (item.VideoFormat && item.VideoFormat !== 'Standard') {
|
|
|
|
|
miscInfo.push(item.VideoFormat);
|
|
|
|
|
}
|
2013-04-10 12:33:19 -07:00
|
|
|
|
}
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 22:27:27 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
return miscInfo.join(' ');
|
|
|
|
|
},
|
2013-04-10 10:11:23 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
renderStudios: function (elem, item) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.Studios && item.Studios.length) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
var html = 'Studios: ';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = item.Studios.length; i < length; i++) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (i > 0) {
|
|
|
|
|
html += ' / ';
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += '<a href="itembynamedetails.html?studio=' + item.Studios[i] + '">' + item.Studios[i] + '</a>';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
elem.show().html(html).trigger('create');
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
renderGenres: function (elem, item) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (item.Genres && item.Genres.length) {
|
|
|
|
|
var html = 'Genres: ';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
for (var i = 0, length = item.Genres.length; i < length; i++) {
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
if (i > 0) {
|
|
|
|
|
html += ' / ';
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
html += '<a href="itembynamedetails.html?genre=' + item.Genres[i] + '">' + item.Genres[i] + '</a>';
|
2013-04-10 12:25:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
elem.show().html(html).trigger('create');
|
2013-04-10 12:25:34 -07:00
|
|
|
|
|
|
|
|
|
|
2013-04-12 08:25:00 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-12 17:42:51 -07:00
|
|
|
|
|
2013-04-12 08:25:00 -07:00
|
|
|
|
renderBudget: function (elem, item) {
|
|
|
|
|
if (item.Budget) {
|
|
|
|
|
elem.show().html('Budget: $' + item.Budget);
|
2013-04-10 12:33:19 -07:00
|
|
|
|
} else {
|
|
|
|
|
elem.hide();
|
|
|
|
|
}
|
2013-04-10 12:25:34 -07:00
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-10 12:33:19 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})(window, jQuery);
|