Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lessen chance of elements being blocked by browser blockers #1296

Merged
merged 1 commit into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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