' : '
';
html += '';
html += (query.StartIndex + 1) + '-' + recordsEnd + ' of ' + totalRecordCount + ', page ' + dropdownHtml + ' of ' + pageCount;
html += ' ';
html += 'Previous Page ';
html += ' totalRecordCount ? 'disabled' : '') + '>Next Page ';
html += '
';
return html;
},
getStarRatingHtml: function (item) {
var rating = item.CommunityRating;
var html = "";
for (var i = 1; i <= 10; i++) {
if (rating < i - 1) {
html += "
";
}
else if (rating < i) {
html += "
";
}
else {
html += "
";
}
}
return html;
},
getFiveStarRatingHtml: function (item) {
var rating = item.CommunityRating / 2;
var html = "";
for (var i = 1; i <= 5; i++) {
if (rating < i - 1) {
html += "
";
}
else if (rating < i) {
html += "
";
}
else {
html += "
";
}
}
return html;
},
getUserDataIconsHtml: function (item) {
var html = '';
var tooltip;
var pct;
if (item.PlayedPercentage) {
tooltip = '';
pct = item.PlayedPercentage;
}
else if (item.UserData && item.UserData.PlaybackPositionTicks && item.RunTimeTicks) {
tooltip = DashboardPage.getDisplayText(item.UserData.PlaybackPositionTicks) + " / " + DashboardPage.getDisplayText(item.RunTimeTicks);
pct = (item.UserData.PlaybackPositionTicks / item.RunTimeTicks) * 100;
}
if (pct) {
pct = parseInt(pct);
html += '
' + pct + '% ';
}
var userData = item.UserData || {};
var itemId = item.Id;
var type = item.Type;
if (type == "Person") {
itemId = item.Name;
}
else if (type == "Studio") {
itemId = item.Name;
}
else if (type == "Genre") {
itemId = item.Name;
}
if (item.MediaType || item.IsFolder) {
if (userData.Played) {
html += '
';
} else {
html += '
';
}
}
if (typeof userData.Likes == "undefined") {
html += '
';
html += '
';
}
else if (userData.Likes) {
html += '
';
html += '
';
}
else {
html += '
';
html += '
';
}
if (userData.IsFavorite) {
html += '
';
} else {
html += '
';
}
return html;
},
markPlayed: function (link) {
var id = link.getAttribute('data-itemid');
var $link = $(link);
var markAsPlayed = $link.hasClass('imgPlayedOff');
ApiClient.updatePlayedStatus(Dashboard.getCurrentUserId(), id, markAsPlayed);
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');
}
},
markFavorite: function (link) {
var id = link.getAttribute('data-itemid');
var type = link.getAttribute('data-type');
var $link = $(link);
var markAsFavorite = $link.hasClass('imgFavoriteOff');
if (type == "Person" || type == "Studio" || type == "Genre") {
ApiClient.updateItemByNameFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
}
else {
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
}
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');
}
},
markLike: function (link) {
var id = link.getAttribute('data-itemid');
var type = link.getAttribute('data-type');
var $link = $(link);
if ($link.hasClass('imgLikeOff')) {
if (type == "Person" || type == "Studio" || type == "Genre") {
ApiClient.updateItemByNameRating(Dashboard.getCurrentUserId(), id, true);
}
else {
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true);
}
link.src = "css/images/userdata/thumbs_up_on.png";
$link.addClass('imgLike').removeClass('imgLikeOff');
} else {
if (type == "Person" || type == "Studio" || type == "Genre") {
ApiClient.clearItemByNameRating(Dashboard.getCurrentUserId(), id);
}
else {
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
}
link.src = "css/images/userdata/thumbs_up_off.png";
$link.addClass('imgLikeOff').removeClass('imgLike');
}
$link.prev().removeClass('imgDislike').addClass('imgDislikeOff').each(function () {
this.src = "css/images/userdata/thumbs_down_off.png";
});
},
markDislike: function (link) {
var id = link.getAttribute('data-itemid');
var type = link.getAttribute('data-type');
var $link = $(link);
if ($link.hasClass('imgDislikeOff')) {
if (type == "Person" || type == "Studio" || type == "Genre") {
ApiClient.updateItemByNameRating(Dashboard.getCurrentUserId(), id, false);
}
else {
ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false);
}
link.src = "css/images/userdata/thumbs_down_on.png";
$link.addClass('imgDislike').removeClass('imgDislikeOff');
} else {
if (type == "Person" || type == "Studio" || type == "Genre") {
ApiClient.clearItemByNameRating(Dashboard.getCurrentUserId(), id);
}
else {
ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id);
}
link.src = "css/images/userdata/thumbs_down_off.png";
$link.addClass('imgDislikeOff').removeClass('imgDislike');
}
$link.next().removeClass('imgLike').addClass('imgLikeOff').each(function () {
this.src = "css/images/userdata/thumbs_up_off.png";
});
},
getDetailImageHtml: function (item) {
var imageTags = item.ImageTags || {};
var html = '';
var url;
var useBackgroundColor;
var maxwidth;
if (imageTags.Primary) {
if (item.Type == "Person") {
url = ApiClient.getPersonImageUrl(item.Name, {
maxwidth: 800,
tag: imageTags.Primary,
type: "primary"
});
}
else if (item.Type == "Genre") {
url = ApiClient.getGenreImageUrl(item.Name, {
maxwidth: 800,
tag: imageTags.Primary,
type: "primary"
});
}
else if (item.Type == "Studio") {
url = ApiClient.getStudioImageUrl(item.Name, {
maxwidth: 800,
tag: imageTags.Primary,
type: "primary"
});
}
else {
url = ApiClient.getImageUrl(item.Id, {
type: "Primary",
maxwidth: 800,
tag: item.ImageTags.Primary
});
}
}
else if (item.BackdropImageTags && item.BackdropImageTags.length) {
url = ApiClient.getImageUrl(item.Id, {
type: "Backdrop",
maxwidth: 800,
tag: item.BackdropImageTags[0]
});
}
else if (imageTags.Thumb) {
url = ApiClient.getImageUrl(item.Id, {
type: "Thumb",
maxwidth: 800,
tag: item.ImageTags.Thumb
});
}
else if (imageTags.Disc) {
url = ApiClient.getImageUrl(item.Id, {
type: "Disc",
maxwidth: 800,
tag: item.ImageTags.Disc
});
}
else if (item.MediaType == "Audio") {
url = "css/images/items/detail/audio.png";
useBackgroundColor = true;
maxwidth = 150;
}
else if (item.MediaType == "Game") {
url = "css/images/items/detail/game.png";
useBackgroundColor = true;
maxwidth = 150;
}
else if (item.Type == "Person") {
url = "css/images/items/detail/person.png";
useBackgroundColor = true;
maxwidth = 125;
}
else if (item.Type == "Genre" || item.Type == "Studio") {
url = "css/images/items/detail/video.png";
useBackgroundColor = true;
maxwidth = 125;
}
else {
url = "css/images/items/detail/video.png";
useBackgroundColor = true;
maxwidth = 150;
}
if (url) {
var style = useBackgroundColor ? "background-color:" + LibraryBrowser.getMetroColor(item.Id) + ";" : "";
if (maxwidth) {
style += "max-width:" + maxwidth + "px;";
}
html += "
";
}
return html;
},
getMiscInfoHtml: function (item, includeMediaInfo) {
var miscInfo = [];
if (item.ProductionYear) {
miscInfo.push(item.ProductionYear);
}
if (item.OfficialRating) {
miscInfo.push(item.OfficialRating);
}
if (item.RunTimeTicks) {
var minutes = item.RunTimeTicks / 600000000;
minutes = minutes || 1;
miscInfo.push(parseInt(minutes) + "min");
}
if (includeMediaInfo !== false) {
if (item.DisplayMediaType) {
miscInfo.push(item.DisplayMediaType);
}
if (item.VideoFormat && item.VideoFormat !== 'Standard') {
miscInfo.push(item.VideoFormat);
}
}
return miscInfo.join(' ');
},
renderStudios: function (elem, item) {
if (item.Studios && item.Studios.length) {
var html = 'Studios: ';
for (var i = 0, length = item.Studios.length; i < length; i++) {
if (i > 0) {
html += ' / ';
}
html += '
' + item.Studios[i] + ' ';
}
elem.show().html(html).trigger('create');
} else {
elem.hide();
}
},
renderGenres: function (elem, item) {
if (item.Genres && item.Genres.length) {
var html = 'Genres: ';
for (var i = 0, length = item.Genres.length; i < length; i++) {
if (i > 0) {
html += ' / ';
}
html += '
' + item.Genres[i] + ' ';
}
elem.show().html(html).trigger('create');
} else {
elem.hide();
}
},
renderPremiereDate: function (elem, item) {
if (item.PremiereDate) {
elem.show().html('Premiered ' + parseISO8601Date(item.PremiereDate, { toLocal: true }).toDateString());
} else {
elem.hide();
}
},
renderBudget: function (elem, item) {
if (item.Budget) {
elem.show().html('Budget: $' + item.Budget);
} else {
elem.hide();
}
},
renderRevenue: function (elem, item) {
if (item.Revenue) {
elem.show().html('Revenue: $' + item.Revenue);
} else {
elem.hide();
}
},
getGamePosterViewHtml: function (options) {
var items = options.items;
var primaryImageAspectRatio = options.useAverageAspectRatio ? LibraryBrowser.getAveragePrimaryImageAspectRatio(items) : null;
var html = "";
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
var hasPrimaryImage = item.ImageTags && item.ImageTags.Primary;
var showText = options.showTitle || !hasPrimaryImage;
var cssClass = showText ? "posterViewItem" : "posterViewItem posterViewItemWithNoText";
html += "
";
}
return html;
},
shouldDisplayGallery: function (item) {
var imageTags = item.ImageTags || {};
if (imageTags.Banner) {
return true;
}
if (imageTags.Logo) {
return true;
}
if (imageTags.Thumb) {
return true;
}
if (imageTags.Art) {
return true;
}
if (imageTags.Menu) {
return true;
}
if (imageTags.Disc) {
return true;
}
if (imageTags.Box) {
return true;
}
if (item.BackdropImageTags && item.BackdropImageTags.length) {
return true;
}
if (item.ScreenshotImageTags && item.ScreenshotImageTags.length) {
return true;
}
return false;
},
getGalleryHtml: function (item) {
var html = '';
var i, length;
var imageTags = item.ImageTags || {};
if (imageTags.Banner) {
html += LibraryBrowser.createGalleryImage(item.Id, "Banner", imageTags.Banner);
}
if (imageTags.Logo) {
html += LibraryBrowser.createGalleryImage(item.Id, "Logo", imageTags.Logo);
}
if (imageTags.Thumb) {
html += LibraryBrowser.createGalleryImage(item.Id, "Thumb", imageTags.Thumb);
}
if (imageTags.Art) {
html += LibraryBrowser.createGalleryImage(item.Id, "Art", imageTags.Art);
}
if (imageTags.Menu) {
html += LibraryBrowser.createGalleryImage(item.Id, "Menu", imageTags.Menu);
}
if (imageTags.Disc) {
html += LibraryBrowser.createGalleryImage(item.Id, "Disc", imageTags.Disc);
}
if (imageTags.Box) {
html += LibraryBrowser.createGalleryImage(item.Id, "Box", imageTags.Box);
}
if (item.BackdropImageTags) {
for (i = 0, length = item.BackdropImageTags.length; i < length; i++) {
html += LibraryBrowser.createGalleryImage(item.Id, "Backdrop", item.BackdropImageTags[i], i);
}
}
if (item.ScreenshotImageTags) {
for (i = 0, length = item.ScreenshotImageTags.length; i < length; i++) {
html += LibraryBrowser.createGalleryImage(item.Id, "Screenshot", item.ScreenshotImageTags[i], i);
}
}
return html;
},
createGalleryImage: function (itemId, type, tag, index) {
var downloadWidth = 400;
var lightboxWidth = 800;
var html = '';
if (typeof (index) == "undefined") index = 0;
html += '
';
html += '';
return html;
},
createCastImage: function (cast) {
var html = '';
var role = cast.Role || cast.Type;
html += '
';
html += '';
if (cast.PrimaryImageTag) {
var imgUrl = ApiClient.getPersonImageUrl(cast.Name, {
width: 185,
tag: cast.PrimaryImageTag,
type: "primary"
});
html += '
';
} else {
var style = "background-color:" + LibraryBrowser.getMetroColor(cast.Name) + ";";
html += '
';
}
html += '
' + cast.Name + '
';
html += '
' + role + '
';
html += '
';
return html;
}
};
})(window, jQuery);