Fix NaN error message when FTL is offline (#2548)

This commit is contained in:
RD WebDesign
2023-03-22 17:32:00 -03:00
committed by GitHub
+11 -4
View File
@@ -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);