2013-04-01 22:14:37 -07:00
|
|
|
|
var LibraryBrowser = {
|
2013-04-08 22:06:13 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
getDetaultPageSize: function () {
|
2013-04-09 09:42:55 -07:00
|
|
|
|
|
|
|
|
|
if (window.location.toString().toLowerCase().indexOf('localhost') != -1) {
|
|
|
|
|
return 100;
|
|
|
|
|
}
|
|
|
|
|
return 25;
|
|
|
|
|
},
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
getPosterViewHtml: function (options) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var items = options.items;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var html = "";
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
var item = items[i];
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var href = item.url || (item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-06 10:16:46 -07:00
|
|
|
|
var showText = options.showTitle || !hasPrimaryImage;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var cssClass = showText ? "posterViewItem" : "posterViewItem posterViewItemWithNoText";
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "<div class='" + cssClass + "'><a href='" + href + "'>";
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -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-09 21:38:04 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}) + "' />";
|
|
|
|
|
} else if (hasPrimaryImage) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary
|
2013-04-09 21:38:04 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}) + "' />";
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -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-09 21:38:04 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
}) + "' />";
|
2013-04-04 10:27:36 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/audio.png' />";
|
2013-04-04 10:27:36 -07:00
|
|
|
|
}
|
2013-04-09 05:31:43 -07:00
|
|
|
|
else if (item.MediaType == "Video" || item.Type == "Season" || item.Type == "Series") {
|
2013-04-04 10:27:36 -07:00
|
|
|
|
|
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/video.png' />";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/collection.png' />";
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
if (showText) {
|
|
|
|
|
html += "<div class='posterViewItemText'>";
|
|
|
|
|
html += item.Name;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
if (options.showNewIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += LibraryBrowser.getProgressBarHtml(item);
|
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "</a></div>";
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
getEpisodePosterViewHtml: function (options) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var items = options.items;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var html = "";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -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-03 05:03:13 -07:00
|
|
|
|
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var href = item.url || (item.IsFolder ? (item.Id ? "itemList.html?parentId=" + item.Id : "#") : "itemdetails.html?id=" + item.Id);
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var showText = options.showTitle || !hasPrimaryImage || (item.Type !== 'Movie' && item.Type !== 'Series' && item.Type !== 'Season' && item.Type !== 'Trailer');
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var cssClass = showText ? "posterViewItem posterViewItemWithDualText" : "posterViewItem posterViewItemWithNoText";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "<div class='" + cssClass + "'><a href='" + href + "'>";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -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-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
|
}) + "' />";
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -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 {
|
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/collection.png' />";
|
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
if (showText) {
|
|
|
|
|
html += "<div class='posterViewItemText posterViewItemPrimaryText'>";
|
|
|
|
|
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 + " -";
|
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += " " + item.Name;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
if (options.showNewIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += LibraryBrowser.getProgressBarHtml(item);
|
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
html += "</a></div>";
|
|
|
|
|
}
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
getBoxsetPosterViewHtml: function (options) {
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
var items = options.items;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
var html = "";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -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-08 22:06:13 -07:00
|
|
|
|
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
var href = item.url || ("boxset.html?id=" + item.Id);
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -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-08 22:06:13 -07:00
|
|
|
|
var cssClass = showText ? "posterViewItem posterViewItemWithDualText" : "posterViewItem posterViewItemWithNoText";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
html += "<div class='" + cssClass + "'><a href='" + href + "'>";
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -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-08 22:06:13 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -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-08 22:06:13 -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 {
|
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/video.png' />";
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
if (showText) {
|
|
|
|
|
html += "<div class='posterViewItemText posterViewItemPrimaryText'>";
|
|
|
|
|
html += item.Name;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
html += "<div class='posterViewItemText'>";
|
|
|
|
|
html += item.ChildCount + " Movie";
|
|
|
|
|
if (item.ChildCount > 1) html += "s";
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
if (options.showNewIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
html += "</a></div>";
|
|
|
|
|
}
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-03 21:21:46 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
getSeriesPosterViewHtml: function (options) {
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var items = options.items;
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var html = "";
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
var item = items[i];
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var href = item.url || "tvseries.html?id=" + item.Id;
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var showText = options.showTitle || !hasPrimaryImage;
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var cssClass = showText ? "posterViewItem" : "posterViewItem posterViewItemWithNoText";
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += "<div class='" + cssClass + "'><a href='" + href + "'>";
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -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-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
}) + "' />";
|
|
|
|
|
} else if (hasPrimaryImage) {
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
var height = 300;
|
|
|
|
|
var width = primaryImageAspectRatio ? parseInt(height * primaryImageAspectRatio) : null;
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += "<img src='" + ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
height: height,
|
|
|
|
|
width: width,
|
|
|
|
|
tag: item.ImageTags.Primary
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
}) + "' />";
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -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-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
}) + "' />";
|
|
|
|
|
}
|
|
|
|
|
else if (item.MediaType == "Audio" || item.Type == "MusicAlbum" || item.Type == "MusicArtist") {
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
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") {
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/video.png' />";
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += "<img style='background:" + LibraryBrowser.getMetroColor(item.Id) + ";' src='css/images/items/list/collection.png' />";
|
|
|
|
|
}
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
if (showText) {
|
|
|
|
|
html += "<div class='posterViewItemText'>";
|
|
|
|
|
html += item.Name;
|
|
|
|
|
html += "</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.showNewIndicator !== false) {
|
|
|
|
|
html += LibraryBrowser.getNewIndicatorHtml(item);
|
|
|
|
|
}
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += LibraryBrowser.getProgressBarHtml(item);
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
html += "</a></div>";
|
|
|
|
|
}
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
2013-04-09 22:06:59 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
getNewIndicatorHtml: function (item) {
|
|
|
|
|
|
|
|
|
|
if (item.RecentlyAddedItemCount) {
|
|
|
|
|
return '<div class="posterRibbon">' + item.RecentlyAddedItemCount + ' New</div>';
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
if (!item.IsFolder) {
|
|
|
|
|
|
|
|
|
|
var date = item.DateCreated;
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
if (date && (new Date().getTime() - parseISO8601Date(date).getTime()) < 1209600000) {
|
|
|
|
|
return "<div class='posterRibbon'>New</div>";
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-09 21:38:04 -07:00
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
getProgressBarHtml: function (item) {
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
if (item.PlayedPercentage && item.PlayedPercentage < 100) {
|
|
|
|
|
html += '<progress class="itemProgress" min="0" max="100" value="' + item.PlayedPercentage + '"></progress>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
getAveragePrimaryImageAspectRatio: function (items) {
|
2013-04-02 15:53:31 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var values = [];
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var ratio = items[i].PrimaryImageAspectRatio || 0;
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
if (!ratio) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
values[values.length] = ratio;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
if (!values.length) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
// Use the median
|
|
|
|
|
values.sort(function (a, b) { return a - b; });
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var half = Math.floor(values.length / 2);
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -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-03 05:03:13 -07:00
|
|
|
|
metroColors: ["#6FBD45", "#4BB3DD", "#4164A5", "#E12026", "#800080", "#E1B222", "#008040", "#0094FF", "#FF00C7", "#FF870F", "#7F0037"],
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
getRandomMetroColor: function () {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
var index = Math.floor(Math.random() * (LibraryBrowser.metroColors.length - 1));
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
},
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
getMetroColor: function (str) {
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
if (str) {
|
2013-04-04 13:36:25 -07:00
|
|
|
|
var char = String(str.substr(0, 1).charCodeAt());
|
2013-04-08 22:06:13 -07:00
|
|
|
|
var sum = 0;
|
|
|
|
|
for (var i = 0; i < char.length; i++) {
|
|
|
|
|
sum += parseInt(char.charAt(i));
|
|
|
|
|
}
|
2013-04-04 13:36:25 -07:00
|
|
|
|
var index = String(sum).substr(-1);
|
2013-04-03 05:03:13 -07:00
|
|
|
|
|
|
|
|
|
return LibraryBrowser.metroColors[index];
|
|
|
|
|
} else {
|
|
|
|
|
return LibraryBrowser.getRandomMetroColor();
|
|
|
|
|
}
|
2013-04-01 22:14:37 -07:00
|
|
|
|
|
2013-04-05 11:35:37 -07:00
|
|
|
|
},
|
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
renderLinks: function (item) {
|
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
//console.log(item);
|
|
|
|
|
if (item.ProviderIds) {
|
|
|
|
|
|
|
|
|
|
var html = 'Links: ';
|
|
|
|
|
var links = [];
|
|
|
|
|
|
|
|
|
|
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>');
|
|
|
|
|
|
|
|
|
|
html += links.join(' / ');
|
|
|
|
|
|
|
|
|
|
$('#itemLinks', page).html(html);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$('#itemLinks', page).hide();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPagingHtml: function (query, totalRecordCount) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var pageCount = Math.ceil(totalRecordCount / query.Limit);
|
|
|
|
|
var pageNumber = (query.StartIndex / query.Limit) + 1;
|
|
|
|
|
|
|
|
|
|
var dropdownHtml = '<select data-enhance="false" data-role="none">';
|
|
|
|
|
for (var i = 1; i <= pageCount; i++) {
|
|
|
|
|
|
|
|
|
|
if (i == pageNumber) {
|
|
|
|
|
dropdownHtml += '<option value="' + i + '" selected="selected">' + i + '</option>';
|
|
|
|
|
} else {
|
|
|
|
|
dropdownHtml += '<option value="' + i + '">' + i + '</option>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dropdownHtml += '</select>';
|
|
|
|
|
|
|
|
|
|
var recordsEnd = Math.min(query.StartIndex + query.Limit, totalRecordCount);
|
|
|
|
|
|
|
|
|
|
html += '<div class="listPaging">';
|
|
|
|
|
html += 'Results ' + (query.StartIndex + 1) + '-' + recordsEnd + ' of ' + totalRecordCount + ', page ' + dropdownHtml + ' of ' + pageCount;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2013-04-10 06:53:44 -07:00
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getStarRatingHtml: function (item) {
|
|
|
|
|
var rating = item.CommunityRating;
|
|
|
|
|
|
|
|
|
|
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>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getUserRatingHtml: function (item) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var userData = item.UserData || {};
|
|
|
|
|
|
|
|
|
|
if (typeof userData.Likes == "undefined") {
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_down_off.png" alt="Dislike" title="Dislike" />';
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_up_off.png" alt="Like" title="Like" />';
|
|
|
|
|
} else if (userData.Likes) {
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_down_off.png" alt="Dislike" title="Dislike" />';
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_up_on.png" alt="Liked" title="Like" />';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_down_on.png" alt="Dislike" title="Dislike" />';
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/thumbs_up_off.png" alt="Like" title="Like" />';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userData.IsFavorite) {
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/heart_on.png" alt="Favorite" title="Favorite" />';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<img class="imgUserItemRating" src="css/images/userdata/heart_off.png" alt="Favorite" title="Favorite" />';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getDetailImageHtml: function(item) {
|
|
|
|
|
var imageTags = item.ImageTags || {};
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var url;
|
|
|
|
|
var useBackgroundColor;
|
|
|
|
|
|
|
|
|
|
if (imageTags.Primary) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Primary",
|
|
|
|
|
width: 800,
|
|
|
|
|
tag: item.ImageTags.Primary
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Backdrop",
|
|
|
|
|
width: 800,
|
|
|
|
|
tag: item.BackdropImageTags[0]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Thumb) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Thumb",
|
|
|
|
|
width: 800,
|
|
|
|
|
tag: item.ImageTags.Thumb
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (imageTags.Disc) {
|
|
|
|
|
|
|
|
|
|
url = ApiClient.getImageUrl(item.Id, {
|
|
|
|
|
type: "Disc",
|
|
|
|
|
width: 800,
|
|
|
|
|
tag: item.ImageTags.Disc
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
|
|
|
|
|
|
var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : "";
|
|
|
|
|
|
|
|
|
|
html += "<img class='itemDetailImage' src='" + url + "' style='" + style + "' />";
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 22:06:13 -07:00
|
|
|
|
return html;
|
|
|
|
|
}
|
2013-04-10 06:53:44 -07:00
|
|
|
|
|
2013-04-03 05:03:13 -07:00
|
|
|
|
};
|