Skip to content

Commit

Permalink
Rearrange the code and use better texts in case of error
Browse files Browse the repository at this point in the history
- show an error message including the error code;
- change the title (tooltip) text

Signed-off-by: RD WebDesign <[email protected]>
  • Loading branch information
rdwebdesign committed Oct 27, 2024
1 parent 8511681 commit 40c5fb8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,6 @@ function updateSummaryData(runOnce = false) {
$("span#percent_blocked").text(formattedPercentage);
updateQueryFrequency(intl, data.queries.frequency);

const gravityCount = parseInt(data.gravity.domains_being_blocked, 10);
$("span#gravity_size").text(intl.format(gravityCount > 0 ? gravityCount : 0));
const lastupdate = parseInt(data.gravity.last_update, 10);
var updatetxt = "Lists were never updated";
if (lastupdate > 0) {
Expand All @@ -429,6 +427,15 @@ function updateSummaryData(runOnce = false) {
")";
}

const gravityCount = parseInt(data.gravity.domains_being_blocked, 10);
if (gravityCount < 0) {
// Error. Change the title text and show the error code in parentheses
updatetxt = "Error! Update gravity to reset this value."
$("span#gravity_size").text("Error (" + gravityCount + ")");
} else {
$("span#gravity_size").text(intl.format(gravityCount));
}

$(".small-box:has(#gravity_size)").attr("title", updatetxt);

if (2 * previousCount < newCount && newCount > 100 && !firstSummaryUpdate) {
Expand Down

0 comments on commit 40c5fb8

Please sign in to comment.