From 18cfd8dab10cdf29715a1e28a0cbae69a7bb1f23 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 17 Dec 2019 12:19:43 +0200 Subject: [PATCH] Reuse variable and make code clearer Signed-off-by: XhmikosR --- scripts/pi-hole/js/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index cd9ffa21..fb398637 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -655,10 +655,14 @@ function updateSummaryData(runOnce) { } ["ads_blocked_today", "dns_queries_today", "ads_percentage_today", "unique_clients"].forEach(function(today) { - var todayElement = $("span#" + today); - todayElement.text() !== data[today] && - todayElement.text() !== data[today] + "%" && - $("span#" + today).addClass("glow"); + var $todayElement = $("span#" + today); + + if ( + $todayElement.text() !== data[today] && + $todayElement.text() !== data[today] + "%" + ) { + $todayElement.addClass("glow"); + } }); if(Object.prototype.hasOwnProperty.call(data, "dns_queries_all_types"))