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

Move store rating rendering function to dash

This commit is contained in:
Eric Reed 2013-11-08 10:37:22 -05:00
parent cf12832d35
commit b7f0979093
2 changed files with 35 additions and 32 deletions

View file

@ -47,28 +47,6 @@
Dashboard.hideLoadingMsg(); Dashboard.hideLoadingMsg();
} }
function getRatingHtml(rating, id, name) {
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);' >";
if (rating < i - 1 || rating == 0) {
html += "<div class='storeStarRating emptyStarRating' title='Rate " + i + " stars'></div>";
} else if (rating < i) {
html += "<div class='storeStarRating halfStarRating' title='Rate " + i + " stars'></div>";
} else {
html += "<div class='storeStarRating' title='Rate " + i + " stars'></div>";
}
html += "</a>";
}
html += "</div>";
return html;
}
function populateList(page, availablePlugins, installedPlugins) { function populateList(page, availablePlugins, installedPlugins) {
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
@ -135,7 +113,7 @@
html += "<div class='posterItemStoreText' >"; html += "<div class='posterItemStoreText' >";
html += plugin.price > 0 ? "$" + plugin.price.toFixed(2) : "Free"; html += plugin.price > 0 ? "$" + plugin.price.toFixed(2) : "Free";
html += getRatingHtml(plugin.avgRating, plugin.id, plugin.name); html += Dashboard.getStoreRatingHtml(plugin.avgRating, plugin.id, plugin.name);
html += "<span class='storeReviewCount'>"; html += "<span class='storeReviewCount'>";
html += " " + plugin.totalRatings + " Reviews"; html += " " + plugin.totalRatings + " Reviews";

View file

@ -1128,17 +1128,42 @@ var Dashboard = {
var rating = link.getAttribute('data-rating'); var rating = link.getAttribute('data-rating');
var dialog = new RatingDialog($.mobile.activePage); var dialog = new RatingDialog($.mobile.activePage);
dialog.show({ header: "Rate and review " + name, id: id, rating: rating, callback: function(review) { dialog.show({
header: "Rate and review " + name,
id: id,
rating: rating,
callback: function(review) {
console.log(review); console.log(review);
dialog.close(); dialog.close();
ApiClient.createPackageReview(review).done(function() { ApiClient.createPackageReview(review).done(function() {
Dashboard.alert("Thank you for your review"); Dashboard.alert("Thank you for your review");
}); });
} }); }
});
},
} getStoreRatingHtml: function(rating, id, name) {
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);' >";
if (rating < i - 1 || rating == 0) {
html += "<div class='storeStarRating emptyStarRating' title='Rate " + i + " stars'></div>";
} else if (rating < i) {
html += "<div class='storeStarRating halfStarRating' title='Rate " + i + " stars'></div>";
} else {
html += "<div class='storeStarRating' title='Rate " + i + " stars'></div>";
}
html += "</a>";
}
html += "</div>";
return html;
}
}; };
if (!window.WebSocket) { if (!window.WebSocket) {