Navigation Menu

Skip to content

Commit

Permalink
Hide reviews, users and rating if they are unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
JustOff committed Jan 29, 2019
1 parent 6d0fd5f commit 5b48924
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
18 changes: 12 additions & 6 deletions content/addon.js
Expand Up @@ -45,9 +45,17 @@ let Addon = {
} catch (e) { } catch (e) {
return null; return null;
} }
data.reviews = new Intl.NumberFormat("en-US").format(dbQuery.row.reviews); if (dbQuery.row.reviews >= 0) {
data.reviews = '<span itemprop="ratingCount">' + new Intl.NumberFormat("en-US").format(dbQuery.row.reviews) + '</span> user reviews';
} else {
data.reviews = '';
}
data.rating = Math.round(dbQuery.row.rating); data.rating = Math.round(dbQuery.row.rating);
data.users = new Intl.NumberFormat("en-US").format(dbQuery.row.users); if (dbQuery.row.users >= 0) {
data.users = '<div id="daily-users">' + new Intl.NumberFormat("en-US").format(dbQuery.row.users) + ' users</div>';
} else {
data.users = '';
}
if (dbQuery.row.icon) { if (dbQuery.row.icon) {
data.icon_url = "chrome://ca-archive/skin/icons/" + dbQuery.row.icon + ".png"; data.icon_url = "chrome://ca-archive/skin/icons/" + dbQuery.row.icon + ".png";
} else { } else {
Expand Down Expand Up @@ -266,16 +274,14 @@ let Addon = {
<div> <div>
<a id="reviews-link" target="_blank" title="Open Reviews on Wayback Machine" href=%WBM%reviews/> <a id="reviews-link" target="_blank" title="Open Reviews on Wayback Machine" href=%WBM%reviews/>
<span itemprop="ratingCount">%REVIEWS%</span> user reviews %REVIEWS%
</a> </a>
</div> </div>
</div> </div>
%GRATING% %GRATING%
<div id="daily-users"> %USERS%
%USERS% users
</div>
</aside> </aside>
Expand Down
18 changes: 14 additions & 4 deletions content/list.js
Expand Up @@ -154,9 +154,19 @@ let List = {
} else { } else {
item = item.replace("%ICON%", "chrome://ca-archive/skin/icons/" + Math.trunc(dbQuery.row.addon_id/1000) + "/" + dbQuery.row.addon_id + ".png"); item = item.replace("%ICON%", "chrome://ca-archive/skin/icons/" + Math.trunc(dbQuery.row.addon_id/1000) + "/" + dbQuery.row.addon_id + ".png");
} }
let users = new Intl.NumberFormat("en-US").format(dbQuery.row.users); let users;
if (dbQuery.row.users >= 0) {
users = '<div class="adu">' + new Intl.NumberFormat("en-US").format(dbQuery.row.users) + ' users</div>';
} else {
users = '';
}
item = item.replace("%USERS%", users); item = item.replace("%USERS%", users);
let reviews = new Intl.NumberFormat("en-US").format(dbQuery.row.reviews); let reviews;
if (dbQuery.row.reviews >= 0) {
reviews = '(' + new Intl.NumberFormat("en-US").format(dbQuery.row.reviews) + ')';
} else {
reviews = '';
}
item = item.replace("%REVIEWS%", reviews); item = item.replace("%REVIEWS%", reviews);
let restart = ""; let restart = "";
if (dbQuery.row.is_restart_required == false) { if (dbQuery.row.is_restart_required == false) {
Expand Down Expand Up @@ -302,9 +312,9 @@ let List = {
<div class="vitals c"> <div class="vitals c">
<span class="rating"> <span class="rating">
<span class="stars stars-%RATING%" title="Rated %RATING% out of 5 stars">Rated %RATING% out of 5 stars</span> <span class="stars stars-%RATING%" title="Rated %RATING% out of 5 stars">Rated %RATING% out of 5 stars</span>
<a href="caa:addon/%SLUG%">(%REVIEWS%)</a> <a href="caa:addon/%SLUG%">%REVIEWS%</a>
</span> </span>
<div class="adu">%USERS% users</div> %USERS%
</div> </div>
</div> </div>
<div class="action"> <div class="action">
Expand Down
4 changes: 4 additions & 0 deletions skin/ca-archive.css
Expand Up @@ -1252,6 +1252,10 @@ button.search-button {
background-position: -65px 0 background-position: -65px 0
} }


.stars.stars--1 {
display: none !important
}

.stars.large { .stars.large {
display: block; display: block;
background: url(stars-16.png) no-repeat left top; background: url(stars-16.png) no-repeat left top;
Expand Down

0 comments on commit 5b48924

Please sign in to comment.