Skip to content

Commit e40d43e

Browse files
committed
Fix NaN error message when FTL is offline
Signed-off-by: RD WebDesign <[email protected]>
1 parent 4a9a0c2 commit e40d43e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

scripts/pi-hole/js/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ function updateSummaryData(runOnce) {
678678
updateTopLists();
679679
}
680680

681-
var formatter = new Intl.NumberFormat();
682681
//Element name might have a different name to the property of the API so we split it at |
683682
[
684683
"ads_blocked_today|queries_blocked_today",
@@ -691,9 +690,17 @@ function updateSummaryData(runOnce) {
691690
var apiName = apiElName[0];
692691
var elName = apiElName[1];
693692
var $todayElement = elName ? $("span#" + elName) : $("span#" + apiName);
694-
// Round to one decimal place and format locale-aware
695-
var text = formatter.format(Math.round(data[apiName] * 10) / 10);
696-
var textData = idx === 2 && data[apiName] !== "to" ? text + "%" : text;
693+
694+
var textData = data[apiName];
695+
if (!FTLoffline) {
696+
// Only format as number if FTL is online
697+
var formatter = new Intl.NumberFormat();
698+
699+
// Round to one decimal place and format locale-aware
700+
var text = formatter.format(Math.round(data[apiName] * 10) / 10);
701+
textData = idx === 2 && data[apiName] !== "to" ? text + "%" : text;
702+
}
703+
697704
if ($todayElement.text() !== textData && $todayElement.text() !== textData + "%") {
698705
$todayElement.addClass("glow");
699706
$todayElement.text(textData);

0 commit comments

Comments
 (0)