mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Fix NaN error message when FTL is offline (#2548)
This commit is contained in:
@@ -678,7 +678,6 @@ function updateSummaryData(runOnce) {
|
||||
updateTopLists();
|
||||
}
|
||||
|
||||
var formatter = new Intl.NumberFormat();
|
||||
//Element name might have a different name to the property of the API so we split it at |
|
||||
[
|
||||
"ads_blocked_today|queries_blocked_today",
|
||||
@@ -691,9 +690,17 @@ function updateSummaryData(runOnce) {
|
||||
var apiName = apiElName[0];
|
||||
var elName = apiElName[1];
|
||||
var $todayElement = elName ? $("span#" + elName) : $("span#" + apiName);
|
||||
// Round to one decimal place and format locale-aware
|
||||
var text = formatter.format(Math.round(data[apiName] * 10) / 10);
|
||||
var textData = idx === 2 && data[apiName] !== "to" ? text + "%" : text;
|
||||
|
||||
var textData = data[apiName];
|
||||
if (!FTLoffline) {
|
||||
// Only format as number if FTL is online
|
||||
var formatter = new Intl.NumberFormat();
|
||||
|
||||
// Round to one decimal place and format locale-aware
|
||||
var text = formatter.format(Math.round(data[apiName] * 10) / 10);
|
||||
textData = idx === 2 && data[apiName] !== "to" ? text + "%" : text;
|
||||
}
|
||||
|
||||
if ($todayElement.text() !== textData && $todayElement.text() !== textData + "%") {
|
||||
$todayElement.addClass("glow");
|
||||
$todayElement.text(textData);
|
||||
|
||||
Reference in New Issue
Block a user