From 793dd69b63a8e1b73d43e4630041a0078545d610 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 22 Feb 2014 15:20:22 -0500 Subject: [PATCH] consolidate ibn api a bit --- dashboard-ui/scripts/edititemmetadata.js | 2 +- dashboard-ui/scripts/librarybrowser.js | 305 +++-------------------- dashboard-ui/useredit.html | 2 +- dashboard-ui/userimage.html | 2 +- dashboard-ui/userparentalcontrol.html | 2 +- dashboard-ui/userpassword.html | 2 +- dashboard-ui/usersettings.html | 2 +- 7 files changed, 34 insertions(+), 283 deletions(-) diff --git a/dashboard-ui/scripts/edititemmetadata.js b/dashboard-ui/scripts/edititemmetadata.js index 01a560be80..b7cdfc3fb2 100644 --- a/dashboard-ui/scripts/edititemmetadata.js +++ b/dashboard-ui/scripts/edititemmetadata.js @@ -62,7 +62,7 @@ item.Type != "GameGenre" && item.Type != "Person" && item.Type != "MusicArtist" && - item.Type != "UserRootFolder") { + item.Type != "CollectionFolder") { $('#fldDelete', page).show(); } else { $('#fldDelete', page).hide(); diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 8c86a877e1..78be7dc074 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -645,31 +645,6 @@ options.tag = item.ImageTags[type]; } - 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); - } - if (item.Type == "MusicGenre") { - - return ApiClient.getMusicGenreImageUrl(item.Name, options); - } - if (item.Type == "GameGenre") { - - return ApiClient.getGameGenreImageUrl(item.Name, options); - } - if (item.Type == "MusicArtist") { - - return ApiClient.getArtistImageUrl(item.Name, options); - } - // For search hints return ApiClient.getImageUrl(item.Id || item.ItemId, options); @@ -1501,25 +1476,6 @@ 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; - } - else if (type == "MusicGenre") { - itemId = item.Name; - } - else if (type == "GameGenre") { - itemId = item.Name; - } - else if (type == "MusicArtist") { - itemId = item.Name; - } - if ((item.MediaType || item.IsFolder) && item.Type != "Channel" && item.Type != "MusicArtist") { if (userData.Played) { html += 'Played'; @@ -1529,22 +1485,22 @@ } if (typeof userData.Likes == "undefined") { - html += 'Dislike'; - html += 'Like'; + html += 'Dislike'; + html += 'Like'; } else if (userData.Likes) { - html += 'Dislike'; - html += 'Like'; + html += 'Dislike'; + html += 'Like'; } else { - html += 'Dislike'; - html += 'Like'; + html += 'Dislike'; + html += 'Like'; } if (userData.IsFavorite) { - html += 'Favorite'; + html += 'Favorite'; } else { - html += 'Favorite'; + html += 'Favorite'; } return html; @@ -1576,33 +1532,12 @@ 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") { - ApiClient.updateFavoritePersonStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } - else if (type == "Studio") { - ApiClient.updateFavoriteStudioStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } - else if (type == "MusicArtist") { - ApiClient.updateFavoriteArtistStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } - else if (type == "Genre") { - ApiClient.updateFavoriteGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } - else if (type == "MusicGenre") { - ApiClient.updateFavoriteMusicGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } - else if (type == "GameGenre") { - ApiClient.updateFavoriteGameGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } - else { - ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); - } + ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); if (markAsFavorite) { link.src = "css/images/userdata/heart_on.png"; @@ -1616,20 +1551,19 @@ markLike: function (link) { var id = link.getAttribute('data-itemid'); - var type = link.getAttribute('data-type'); var $link = $(link); if ($link.hasClass('imgLikeOff')) { - LibraryBrowser.updateUserItemRating(type, id, true); + ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, true); link.src = "css/images/userdata/thumbs_up_on.png"; $link.addClass('imgLike').removeClass('imgLikeOff'); } else { - LibraryBrowser.clearUserItemRating(type, id); + ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id); link.src = "css/images/userdata/thumbs_up_off.png"; $link.addClass('imgLikeOff').removeClass('imgLike'); @@ -1643,20 +1577,19 @@ markDislike: function (link) { var id = link.getAttribute('data-itemid'); - var type = link.getAttribute('data-type'); var $link = $(link); if ($link.hasClass('imgDislikeOff')) { - LibraryBrowser.updateUserItemRating(type, id, false); + ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, false); link.src = "css/images/userdata/thumbs_down_on.png"; $link.addClass('imgDislike').removeClass('imgDislikeOff'); } else { - LibraryBrowser.clearUserItemRating(type, id); + ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id); link.src = "css/images/userdata/thumbs_down_off.png"; $link.addClass('imgDislikeOff').removeClass('imgDislike'); @@ -1667,56 +1600,6 @@ }); }, - updateUserItemRating: function (type, id, likes) { - - if (type == "Person") { - ApiClient.updatePersonRating(Dashboard.getCurrentUserId(), id, likes); - } - else if (type == "Studio") { - ApiClient.updateStudioRating(Dashboard.getCurrentUserId(), id, likes); - } - else if (type == "MusicArtist") { - ApiClient.updateArtistRating(Dashboard.getCurrentUserId(), id, likes); - } - else if (type == "Genre") { - ApiClient.updateGenreRating(Dashboard.getCurrentUserId(), id, likes); - } - else if (type == "MusicGenre") { - ApiClient.updateMusicGenreRating(Dashboard.getCurrentUserId(), id, likes); - } - else if (type == "GameGenre") { - ApiClient.updateGameGenreRating(Dashboard.getCurrentUserId(), id, likes); - } - else { - ApiClient.updateUserItemRating(Dashboard.getCurrentUserId(), id, likes); - } - }, - - clearUserItemRating: function (type, id) { - - if (type == "Person") { - ApiClient.clearPersonRating(Dashboard.getCurrentUserId(), id); - } - else if (type == "Studio") { - ApiClient.clearStudioRating(Dashboard.getCurrentUserId(), id); - } - else if (type == "MusicArtist") { - ApiClient.clearArtistRating(Dashboard.getCurrentUserId(), id); - } - else if (type == "Genre") { - ApiClient.clearGenreRating(Dashboard.getCurrentUserId(), id); - } - else if (type == "MusicGenre") { - ApiClient.clearMusicGenreRating(Dashboard.getCurrentUserId(), id); - } - else if (type == "GameGenre") { - ApiClient.clearGameGenreRating(Dashboard.getCurrentUserId(), id); - } - else { - ApiClient.clearUserItemRating(Dashboard.getCurrentUserId(), id); - } - }, - getDetailImageHtml: function (item, href) { var imageTags = item.ImageTags || {}; @@ -1733,159 +1616,27 @@ if (imageTags.Primary) { - if (item.Type == "Person") { - url = ApiClient.getPersonImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Primary, - type: "Primary" - }); - } - else if (item.Type == "Genre") { - url = ApiClient.getGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Primary, - type: "Primary" - }); - } - else if (item.Type == "MusicGenre") { - url = ApiClient.getMusicGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Primary, - type: "Primary" - }); - } - else if (item.Type == "GameGenre") { - url = ApiClient.getGameGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Primary, - type: "Primary" - }); - } - else if (item.Type == "Studio") { - url = ApiClient.getStudioImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Primary, - type: "Primary" - }); - } - else if (item.Type == "MusicArtist") { - url = ApiClient.getArtistImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Primary, - type: "Primary" - }); - } - else { - url = ApiClient.getImageUrl(item.Id, { - type: "Primary", - maxheight: imageHeight, - tag: item.ImageTags.Primary - }); - } + url = ApiClient.getImageUrl(item.Id, { + type: "Primary", + maxheight: imageHeight, + tag: item.ImageTags.Primary + }); } else if (item.BackdropImageTags && item.BackdropImageTags.length) { - if (item.Type == "Person") { - url = ApiClient.getPersonImageUrl(item.Name, { - maxheight: imageHeight, - tag: item.BackdropImageTags[0], - type: "Backdrop" - }); - } - else if (item.Type == "Genre") { - url = ApiClient.getGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: item.BackdropImageTags[0], - type: "Backdrop" - }); - } - else if (item.Type == "MusicGenre") { - url = ApiClient.getMusicGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: item.BackdropImageTags[0], - type: "Backdrop" - }); - } - else if (item.Type == "GameGenre") { - url = ApiClient.getGameGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: item.BackdropImageTags[0], - type: "Backdrop" - }); - } - else if (item.Type == "Studio") { - url = ApiClient.getStudioImageUrl(item.Name, { - maxheight: imageHeight, - tag: item.BackdropImageTags[0], - type: "Backdrop" - }); - } - else if (item.Type == "MusicArtist") { - url = ApiClient.getArtistImageUrl(item.Name, { - maxheight: imageHeight, - tag: item.BackdropImageTags[0], - type: "Backdrop" - }); - } - else { - url = ApiClient.getImageUrl(item.Id, { - type: "Backdrop", - maxheight: imageHeight, - tag: item.BackdropImageTags[0] - }); - } + url = ApiClient.getImageUrl(item.Id, { + type: "Backdrop", + maxheight: imageHeight, + tag: item.BackdropImageTags[0] + }); } else if (imageTags.Thumb) { - if (item.Type == "Person") { - url = ApiClient.getPersonImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Thumb, - type: "Thumb" - }); - } - else if (item.Type == "Genre") { - url = ApiClient.getGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Thumb, - type: "Thumb" - }); - } - else if (item.Type == "MusicGenre") { - url = ApiClient.getMusicGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Thumb, - type: "Thumb" - }); - } - else if (item.Type == "GameGenre") { - url = ApiClient.getGameGenreImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Thumb, - type: "Thumb" - }); - } - else if (item.Type == "Studio") { - url = ApiClient.getStudioImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Thumb, - type: "Thumb" - }); - } - else if (item.Type == "MusicArtist") { - url = ApiClient.getArtistImageUrl(item.Name, { - maxheight: imageHeight, - tag: imageTags.Thumb, - type: "Thumb" - }); - } - else { - url = ApiClient.getImageUrl(item.Id, { - type: "Thumb", - maxheight: imageHeight, - tag: item.ImageTags.Thumb - }); - } + url = ApiClient.getImageUrl(item.Id, { + type: "Thumb", + maxheight: imageHeight, + tag: item.ImageTags.Thumb + }); } else if (imageTags.Disc) { diff --git a/dashboard-ui/useredit.html b/dashboard-ui/useredit.html index 3e1f718c19..098bb68295 100644 --- a/dashboard-ui/useredit.html +++ b/dashboard-ui/useredit.html @@ -11,7 +11,7 @@ diff --git a/dashboard-ui/userimage.html b/dashboard-ui/userimage.html index 141c222a8d..41febd1392 100644 --- a/dashboard-ui/userimage.html +++ b/dashboard-ui/userimage.html @@ -11,7 +11,7 @@
Profile Image - + Password Preferences
diff --git a/dashboard-ui/userparentalcontrol.html b/dashboard-ui/userparentalcontrol.html index 26f2ca78e0..314704db14 100644 --- a/dashboard-ui/userparentalcontrol.html +++ b/dashboard-ui/userparentalcontrol.html @@ -11,7 +11,7 @@
Profile Image - Sharing + Library Access Password Preferences
diff --git a/dashboard-ui/userpassword.html b/dashboard-ui/userpassword.html index 7f4a78e2d5..504e2dc577 100644 --- a/dashboard-ui/userpassword.html +++ b/dashboard-ui/userpassword.html @@ -11,7 +11,7 @@
Profile Image - + Password Preferences
diff --git a/dashboard-ui/usersettings.html b/dashboard-ui/usersettings.html index a7b3c6e627..69b85a88d5 100644 --- a/dashboard-ui/usersettings.html +++ b/dashboard-ui/usersettings.html @@ -11,7 +11,7 @@
Profile Image - + Password Preferences