1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Latest reviews in plug-in detail page

This commit is contained in:
Eric Reed 2013-11-08 15:53:09 -05:00
parent a6c7c8de0d
commit 7341aadbb9
4 changed files with 375 additions and 299 deletions

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,12 @@
</div>
<div data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;">
<h3>Rating and Reviews</h3>
<div id="ratingLine"></div>
<div id="latestReviews"></div>
</div>
<div data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;">
<h3>Developer Info</h3>
<p id="developer"></p>

View file

@ -63,6 +63,86 @@
}
}
function populateReviews(id, page) {
// Get the latest positive and negative reviews
var promise1 = ApiClient.getPackageReviews(id, 4, null, 3, true);
var promise2 = ApiClient.getPackageReviews(id, null, 2, 3, true);
$.when(promise1, promise2).done(function (response1, response2) {
//positive
var html = '<div data-role="collapsible" data-content-theme="c" data-collapsed="true" style="margin-top: 2em;" >';
html += '<h3>Latest Outstanding Reviews</h3>';
var positive = response1[0];
var hasReviews = false;
if (positive && positive.length > 0) {
for (var i = 0; i < positive.length; i++) {
var review = positive[i];
if (review.title) {
hasReviews = true;
html += "<div>";
html += "<span class='storeItemReviewText'>";
html += new Date(review.timestamp).toDateString();
html += " " + Dashboard.getStoreRatingHtml(review.rating, review.id, review.name, true);
html += " " + review.title;
html += "</span>";
if (review.review) {
html += "<p class='storeItemReviewText'>";
html += review.review;
html += "</p>";
}
html += "</div>";
html += "<hr/>";
}
}
}
if (!hasReviews) {
html += "<p>No Outstanding Reviews with additional information</p>";
}
html += "</div>";
//negative
html += '<div data-role="collapsible" data-content-theme="c" data-collapsed="true" style="margin-top: 2em;" >';
html += '<h3>Latest Negative Reviews</h3>';
var negative = response2[0];
hasReviews = false;
if (negative && negative.length > 0) {
for (var i = 0; i < negative.length; i++) {
review = negative[i];
if (review.title) {
hasReviews = true;
html += "<div>";
html += "<span class='storeItemReviewText'>";
html += new Date(review.timestamp).toDateString();
html += " " + Dashboard.getStoreRatingHtml(review.rating, review.id, review.name, true);
html += " " + review.title;
html += "</span>";
if (review.review) {
html += "<p class='storeItemReviewText'>";
html += review.review;
html += "</p>";
}
html += "</div>";
html += "<hr/>";
}
}
}
if (!hasReviews) {
html += "<p>No Negative Reviews with additional information</p>";
}
html += "</div>";
$('#latestReviews', page).html(html).trigger('create');
});
}
function renderPackage(pkg, installedPlugins, pluginSecurityInfo, page) {
var installedPlugin = installedPlugins.filter(function (ip) {
@ -71,6 +151,7 @@
populateVersions(pkg, page, installedPlugin);
populateHistory(pkg, page);
if (pkg.totalRatings > 0) populateReviews(pkg.id, page);
Dashboard.setPageTitle(pkg.name);
@ -159,6 +240,14 @@
$('.premiumPackage', page).hide();
}
//Ratings and Reviews
var ratingHtml = "<strong>Overall </strong>" + Dashboard.getStoreRatingHtml(pkg.avgRating, pkg.id, pkg.name);
ratingHtml += "<span class='storeReviewCount'>";
ratingHtml += " " + pkg.totalRatings + " Reviews";
ratingHtml += "</span>";
$('#ratingLine', page).html(ratingHtml);
if (pkg.richDescUrl) {
$('#pViewWebsite', page).show();
$('#pViewWebsite a', page)[0].href = pkg.richDescUrl;

View file

@ -1143,21 +1143,23 @@ var Dashboard = {
});
},
getStoreRatingHtml: function(rating, id, name) {
getStoreRatingHtml: function(rating, id, name, noLinks) {
var html = "<div style='margin-left: 5px; margin-right: 5px; display: inline-block'>";
if (!rating) rating = 0;
for (var i = 1; i <= 5; i++) {
html += "<a href='#' data-id=" + id + " data-name='" + name + "' data-rating=" + i + " onclick='Dashboard.ratePackage(this);' >";
var title = noLinks ? rating + " stars" : "Rate " + i + (i > 1 ? " stars" : " star");
html += noLinks ? "" : "<a href='#' data-id=" + id + " data-name='" + name + "' data-rating=" + i + " onclick='Dashboard.ratePackage(this);' >";
if (rating < i - 1 || rating == 0) {
html += "<div class='storeStarRating emptyStarRating' title='Rate " + i + " stars'></div>";
html += "<div class='storeStarRating emptyStarRating' title='" + title + "'></div>";
} else if (rating < i) {
html += "<div class='storeStarRating halfStarRating' title='Rate " + i + " stars'></div>";
html += "<div class='storeStarRating halfStarRating' title='" + title + "'></div>";
} else {
html += "<div class='storeStarRating' title='Rate " + i + " stars'></div>";
html += "<div class='storeStarRating' title='" + title + "'></div>";
}
html += "</a>";
html += noLinks ? "" : "</a>";
}
html += "</div>";