1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
This commit is contained in:
Techywarrior 2013-04-12 18:12:21 -07:00
commit 4bf5405130
3 changed files with 114 additions and 11 deletions

View file

@ -1671,7 +1671,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
}; };
/** /**
* Updates a user's favorite status for an item and returns the updated UserItemData object. * Updates a user's favorite status for an item.
* @param {String} userId * @param {String} userId
* @param {String} itemId * @param {String} itemId
* @param {Boolean} isFavorite * @param {Boolean} isFavorite
@ -1723,6 +1723,87 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
}); });
}; };
/**
* Updates a user's favorite status for a person.
* @param {String} userId
* @param {String} name
* @param {Boolean} isFavorite
*/
self.updateFavoritePersonStatus = function (userId, name, isFavorite) {
if (!userId) {
throw new Error("null userId");
}
if (!name) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/FavoritePersons/" + name);
var method = isFavorite ? "POST" : "DELETE";
return self.ajax({
type: method,
url: url,
dataType: "json"
});
};
/**
* Updates a user's favorite status for a genre.
* @param {String} userId
* @param {String} name
* @param {Boolean} isFavorite
*/
self.updateFavoriteGenreStatus = function (userId, name, isFavorite) {
if (!userId) {
throw new Error("null userId");
}
if (!name) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/FavoriteGenre/" + name);
var method = isFavorite ? "POST" : "DELETE";
return self.ajax({
type: method,
url: url,
dataType: "json"
});
};
/**
* Updates a user's favorite status for a studio.
* @param {String} userId
* @param {String} name
* @param {Boolean} isFavorite
*/
self.updateFavoriteStudioStatus = function (userId, name, isFavorite) {
if (!userId) {
throw new Error("null userId");
}
if (!name) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/FavoriteStudios/" + name);
var method = isFavorite ? "POST" : "DELETE";
return self.ajax({
type: method,
url: url,
dataType: "json"
});
};
/** /**
* Clears a user's personal rating for an item * Clears a user's personal rating for an item
* @param {String} userId * @param {String} userId

View file

@ -564,6 +564,16 @@
var itemId = item.Id; var itemId = item.Id;
var type = item.Type; 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) { if (item.MediaType) {
if (userData.Played) { if (userData.Played) {
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;" />'; 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;" />';
@ -616,12 +626,24 @@
markFavorite: function (link) { markFavorite: function (link) {
var id = link.getAttribute('data-itemid'); var id = link.getAttribute('data-itemid');
var type = link.getAttribute('data-type');
var $link = $(link); var $link = $(link);
var markAsFavorite = $link.hasClass('imgFavoriteOff'); 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 == "Genre") {
ApiClient.updateFavoriteGenreStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
}
else {
ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite); ApiClient.updateFavoriteStatus(Dashboard.getCurrentUserId(), id, markAsFavorite);
}
if (markAsFavorite) { if (markAsFavorite) {
link.src = "css/images/userdata/heart_on.png"; link.src = "css/images/userdata/heart_on.png";
@ -697,21 +719,21 @@
if (item.Type == "Person") { if (item.Type == "Person") {
url = ApiClient.getPersonImageUrl(item.Name, { url = ApiClient.getPersonImageUrl(item.Name, {
width: 800, maxwidth: 800,
tag: imageTags.Primary, tag: imageTags.Primary,
type: "primary" type: "primary"
}); });
} }
else if (item.Type == "Genre") { else if (item.Type == "Genre") {
url = ApiClient.getGenreImageUrl(item.Name, { url = ApiClient.getGenreImageUrl(item.Name, {
width: 800, maxwidth: 800,
tag: imageTags.Primary, tag: imageTags.Primary,
type: "primary" type: "primary"
}); });
} }
else if (item.Type == "Studio") { else if (item.Type == "Studio") {
url = ApiClient.getStudioImageUrl(item.Name, { url = ApiClient.getStudioImageUrl(item.Name, {
width: 800, maxwidth: 800,
tag: imageTags.Primary, tag: imageTags.Primary,
type: "primary" type: "primary"
}); });
@ -719,7 +741,7 @@
else { else {
url = ApiClient.getImageUrl(item.Id, { url = ApiClient.getImageUrl(item.Id, {
type: "Primary", type: "Primary",
width: 800, maxwidth: 800,
tag: item.ImageTags.Primary tag: item.ImageTags.Primary
}); });
} }
@ -728,7 +750,7 @@
url = ApiClient.getImageUrl(item.Id, { url = ApiClient.getImageUrl(item.Id, {
type: "Backdrop", type: "Backdrop",
width: 800, maxwidth: 800,
tag: item.BackdropImageTags[0] tag: item.BackdropImageTags[0]
}); });
} }
@ -736,7 +758,7 @@
url = ApiClient.getImageUrl(item.Id, { url = ApiClient.getImageUrl(item.Id, {
type: "Thumb", type: "Thumb",
width: 800, maxwidth: 800,
tag: item.ImageTags.Thumb tag: item.ImageTags.Thumb
}); });
} }
@ -744,7 +766,7 @@
url = ApiClient.getImageUrl(item.Id, { url = ApiClient.getImageUrl(item.Id, {
type: "Disc", type: "Disc",
width: 800, maxwidth: 800,
tag: item.ImageTags.Disc tag: item.ImageTags.Disc
}); });
} }

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.73" targetFramework="net45" /> <package id="MediaBrowser.ApiClient.Javascript" version="3.0.74" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
</packages> </packages>