Skip to content

Commit

Permalink
Change the names of the info elements without changing the property n…
Browse files Browse the repository at this point in the history
…ames of the API

Signed-off-by: Adam Warner <[email protected]>
  • Loading branch information
PromoFaux committed May 15, 2020
1 parent 6634fb6 commit b351f45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function getinterval()
<div class="small-box bg-aqua">
<div class="inner">
<p>Queries Blocked</p>
<h3 class="statistic"><span id="ads_blocked_today">---</span></h3>
<h3 class="statistic"><span id="queries_blocked_today">---</span></h3>
</div>
<div class="icon">
<i class="fas fa-hand-paper"></i>
Expand All @@ -60,7 +60,7 @@ function getinterval()
<div class="small-box bg-yellow">
<div class="inner">
<p>Percent Blocked</p>
<h3 class="statistic"><span id="ads_percentage_today">---</span></h3>
<h3 class="statistic"><span id="percentage_blocked_today">---</span></h3>
</div>
<div class="icon">
<i class="fas fa-chart-pie"></i>
Expand Down
35 changes: 17 additions & 18 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,24 @@ function updateSummaryData(runOnce) {
updateTopLists();
}

["ads_blocked_today", "dns_queries_today", "ads_percentage_today", "unique_clients"].forEach(
function (today) {
var $todayElement = $("span#" + today);

if ($todayElement.text() !== data[today] && $todayElement.text() !== data[today] + "%") {
$todayElement.addClass("glow");
}
//Element name might have a different name to the property of the API so we split it at |
[
"ads_blocked_today|queries_blocked_today",
"dns_queries_today",
"ads_percentage_today|percentage_blocked_today",
"unique_clients",
"domains_being_blocked"
].forEach(function (arrayItem, idx) {
var apiElName = arrayItem.split("|");
var apiName = apiElName[0];
var elName = apiElName[1];
var $todayElement = elName === null ? $("span#" + apiName) : $("span#" + elName);
var textData = idx === 2 && data[apiName] !== "to" ? data[apiName] + "%" : data[apiName];
if ($todayElement.text() !== textData && $todayElement.text() !== textData + "%") {
$todayElement.addClass("glow");
$todayElement.text(textData);
}
);
});

if (Object.prototype.hasOwnProperty.call(data, "dns_queries_all_types")) {
$("#total_queries").prop(
Expand All @@ -795,16 +804,6 @@ function updateSummaryData(runOnce) {
}

window.setTimeout(function () {
[
"ads_blocked_today",
"dns_queries_today",
"domains_being_blocked",
"ads_percentage_today",
"unique_clients"
].forEach(function (header, idx) {
var textData = idx === 3 && data[header] !== "to" ? data[header] + "%" : data[header];
$("span#" + header).text(textData);
});
$("span.glow").removeClass("glow");
}, 500);
})
Expand Down

0 comments on commit b351f45

Please sign in to comment.