diff --git a/dashboard-ui/scripts/Itemdetailpage.js b/dashboard-ui/scripts/Itemdetailpage.js index 2ce2a3c098..a18a8f5972 100644 --- a/dashboard-ui/scripts/Itemdetailpage.js +++ b/dashboard-ui/scripts/Itemdetailpage.js @@ -84,8 +84,8 @@ $('#itemName', page).html(name); if (item.SeriesName || item.Album) { - var series_name = item.SeriesName || item.Album; - $('#seriesName', page).html(series_name).show(); + var seriesName = item.SeriesName || item.Album; + $('#seriesName', page).html(seriesName).show(); } ItemDetailPage.renderFav(item); @@ -299,7 +299,7 @@ for (var i = 0, length = chapters.length; i < length; i++) { var chapter = chapters[i]; - var chapter_name = chapter.Name || "Chapter " + i; + var chapterName = chapter.Name || "Chapter " + i; html += '
'; html += ''; @@ -318,7 +318,7 @@ html += ''; } - html += '
' + chapter_name + '
'; + html += '
' + chapterName + '
'; html += '
'; html += ticks_to_human(chapter.StartPositionTicks); diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 6c095d5680..2aa5b31798 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -410,42 +410,46 @@ }, - renderLinks: function (item) { - var page = $.mobile.activePage; - //console.log(item); + getLinksHtml: function (item) { + + var html = 'Links:  '; + var links = []; + + if (item.ProviderIds.Imdb) { + if (item.Type == "Movie" || item.Type == "Episode") + links.push('IMDb'); + else if (item.Type == "Person") + links.push('IMDb'); + } + if (item.ProviderIds.Tmdb) { + if (item.Type == "Movie") + links.push('TMDB'); + else if (item.Type == "Person") + links.push('TMDB'); + } + if (item.ProviderIds.Tvdb) + links.push('TVDB'); + if (item.ProviderIds.Tvcom) { + if (item.Type == "Episode") + links.push('TV.com'); + else if (item.Type == "Person") + links.push('TV.com'); + } + if (item.ProviderIds.Musicbrainz) + links.push('MusicBrainz'); + if (item.ProviderIds.Gamesdb) + links.push('GamesDB'); + + html += links.join('  /  '); + + return html; + }, + + renderLinks: function (item, page) { + if (item.ProviderIds) { - var html = 'Links:  '; - var links = []; - - if (item.ProviderIds.Imdb) { - if (item.Type == "Movie" || item.Type == "Episode") - links.push('IMDb'); - else if (item.Type == "Person") - links.push('IMDb'); - } - if (item.ProviderIds.Tmdb) { - if (item.Type == "Movie") - links.push('TMDB'); - else if (item.Type == "Person") - links.push('TMDB'); - } - if (item.ProviderIds.Tvdb) - links.push('TVDB'); - if (item.ProviderIds.Tvcom) { - if (item.Type == "Episode") - links.push('TV.com'); - else if (item.Type == "Person") - links.push('TV.com'); - } - if (item.ProviderIds.Musicbrainz) - links.push('MusicBrainz'); - if (item.ProviderIds.Gamesdb) - links.push('GamesDB'); - - html += links.join('  /  '); - - $('#itemLinks', page).html(html); + $('#itemLinks', page).html(LibraryBrowser.getLinksHtml(item)); } else { $('#itemLinks', page).hide(); @@ -498,33 +502,136 @@ return html; }, - getUserRatingHtml: function (item) { - + getUserDataIconsHtml: function (item) { + var html = ''; var userData = item.UserData || {}; + var itemId = item.Id; + var type = item.Type; + + if (item.MediaType) { + if (userData.Played) { + html += 'Played'; + } else { + html += 'Played'; + } + } + if (typeof userData.Likes == "undefined") { - html += 'Dislike'; - html += 'Like'; - } else if (userData.Likes) { - html += 'Dislike'; - html += 'Liked'; - } else { - html += 'Dislike'; - html += 'Like'; + html += 'Dislike'; + html += 'Like'; + } + else if (userData.Likes) { + html += 'Dislike'; + html += 'Like'; + } + else { + html += 'Dislike'; + html += 'Like'; } if (userData.IsFavorite) { - html += 'Favorite'; + html += 'Favorite'; } else { - html += 'Favorite'; + html += 'Favorite'; } return html; }, - getDetailImageHtml: function(item) { + 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 $link = $(link); + + var markAsFavorite = $link.hasClass('imgFavoriteOff'); + + 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 $link = $(link); + + if ($link.hasClass('imgLikeOff')) { + + ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true); + + link.src = "css/images/userdata/thumbs_up_on.png"; + $link.addClass('imgLike').removeClass('imgLikeOff'); + + } 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 $link = $(link); + + if ($link.hasClass('imgDislikeOff')) { + + ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false); + + link.src = "css/images/userdata/thumbs_down_on.png"; + $link.addClass('imgDislike').removeClass('imgDislikeOff'); + + } 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 = ''; @@ -585,6 +692,38 @@ } return html; + }, + + getMiscInfoHtml: function (item) { + + 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 (item.DisplayMediaType) { + miscInfo.push(item.DisplayMediaType); + } + + if (item.VideoFormat && item.VideoFormat !== 'Standard') { + miscInfo.push(item.VideoFormat); + } + + return miscInfo.join('     '); } }; \ No newline at end of file diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index b4e6b06e73..b3c776caa1 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -1,5 +1,7 @@ var MediaPlayer = (function (document, clearTimeout, screen, localStorage, _V_, $, setInterval) { + var self = this; + var testableAudioElement = document.createElement('audio'); var testableVideoElement = document.createElement('video'); var currentMediaElement; diff --git a/dashboard-ui/scripts/movies.js b/dashboard-ui/scripts/movies.js index 90fb4cec2f..6aa6b44bd4 100644 --- a/dashboard-ui/scripts/movies.js +++ b/dashboard-ui/scripts/movies.js @@ -107,30 +107,7 @@ html += ''; - var userData = item.UserData || {}; - - if (userData.Played) { - html += 'Played'; - } else { - html += 'Played'; - } - - if (typeof userData.Likes == "undefined") { - html += 'Dislike'; - html += 'Like'; - } else if (userData.Likes) { - html += 'Dislike'; - html += 'Liked'; - } else { - html += 'Dislike'; - html += 'Like'; - } - - if (userData.IsFavorite) { - html += 'Favorite'; - } else { - html += 'Favorite'; - } + html += LibraryBrowser.getUserDataIconsHtml(item); html += ''; diff --git a/dashboard-ui/scripts/playlist.js b/dashboard-ui/scripts/playlist.js index 75622452e8..06dca09653 100644 --- a/dashboard-ui/scripts/playlist.js +++ b/dashboard-ui/scripts/playlist.js @@ -1,18 +1,25 @@ -var PlayList = { +var Playlist = (function() { - queue: Array(), + var self = this; - addItem: function (item) { - PlayList.queue.push(item); - }, + self.queue = []; - removeItem: function (index) { - PlayList.queue.splice(index, 1); - }, + self.add = function(item) { - playItem: function (index) { - MediaPlayer.play(PlayList.queue[index]); - PlayList.queue.shift(); - } + queue.push(item); + }; -}; \ No newline at end of file + self.remove = function (index) { + + queue.splice(index, 1); + }; + + self.play = function (index) { + + MediaPlayer.play(queue[index]); + queue.shift(); + }; + + return self; + +})(); \ No newline at end of file diff --git a/dashboard-ui/scripts/tvseries.js b/dashboard-ui/scripts/tvseries.js index b8f7538880..206a28182a 100644 --- a/dashboard-ui/scripts/tvseries.js +++ b/dashboard-ui/scripts/tvseries.js @@ -14,27 +14,20 @@ var name = item.Name; + $('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item)); + Dashboard.setPageTitle(name); - renderImage(page, item); - - renderDetails(page, item); - $('#itemName', page).html(name); - renderFavorites(page, item); - LibraryBrowser.renderLinks(item); + renderDetails(page, item); Dashboard.hideLoadingMsg(); }); } - function renderImage(page, item) { - - $('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item)); - } - function renderDetails(page, item) { + if (item.Taglines && item.Taglines.length) { $('#itemTagline', page).html(item.Taglines[0]).show(); } else { @@ -58,41 +51,28 @@ $('#itemCommunityRating', page).hide(); } - 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 (item.DisplayMediaType) { - miscInfo.push(item.DisplayMediaType); - } - - if (item.VideoFormat && item.VideoFormat !== 'Standard') { - miscInfo.push(item.VideoFormat); - } - - $('#itemMiscInfo', page).html(miscInfo.join('     ')); + $('#itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item)); renderGenres(page, item); renderStudios(page, item); + renderUserDataIcons(page, item); + renderLinks(page, item); + } + + function renderLinks(page, item) { + if (item.ProviderIds) { + + $('#itemLinks', page).html(LibraryBrowser.getLinksHtml(item)); + + } else { + $('#itemLinks', page).hide(); + } } function renderStudios(page, item) { + if (item.Studios && item.Studios.length) { + var elem = $('#itemStudios', page).show(); var html = 'Studios:  '; @@ -138,8 +118,8 @@ } } - function renderFavorites(page, item) { - $('#itemRatings', page).html(LibraryBrowser.getUserRatingHtml(item)); + function renderUserDataIcons(page, item) { + $('#itemRatings', page).html(LibraryBrowser.getUserDataIconsHtml(item)); } $(document).on('pageshow', "#tvSeriesPage", function () { @@ -152,72 +132,4 @@ }); -})(jQuery, document, LibraryBrowser); - -var tvSeriesPage = { - - setFavorite: function () { - var item = tvSeriesPage.item; - - item.UserData = item.UserData || {}; - - var setting = !item.UserData.IsFavorite; - item.UserData.IsFavorite = setting; - - ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), item.Id, setting); - - renderFavorites(page, item); - }, - - setLike: function () { - - var item = tvSeriesPage.item; - - item.UserData = item.UserData || {}; - - item.UserData.Likes = true; - - ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, true); - - renderFavorites(page, item); - }, - - clearLike: function () { - - var item = tvSeriesPage.item; - - item.UserData = item.UserData || {}; - - item.UserData.Likes = undefined; - - ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), item.Id); - - renderFavorites(page, item); - }, - - setDislike: function () { - var item = tvSeriesPage.item; - - item.UserData = item.UserData || {}; - - item.UserData.Likes = false; - - ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), item.Id, false); - - renderFavorites(page, item); - }, - - setPlayed: function () { - var item = tvSeriesPage.item; - - item.UserData = item.UserData || {}; - - var setting = !item.UserData.Played; - item.UserData.Played = setting; - - ApiClient.updatePlayedStatus(Dashboard.getCurrentUserId(), item.Id, setting); - - renderFavorites(page, item); - } - -}; \ No newline at end of file +})(jQuery, document, LibraryBrowser); \ No newline at end of file