mirror of
https://github.com/pi-hole/web.git
synced 2025-12-20 02:38:28 +00:00
Dynamically determine number of QPS fraction digits based on the value itself
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -243,10 +243,21 @@ function updateQueryFrequency(intl, frequency) {
|
||||
title = "Queries per minute";
|
||||
}
|
||||
|
||||
// Determine number of fraction digits based on the frequency
|
||||
// - 0 fraction digits for frequencies > 10
|
||||
// - 1 fraction digit for frequencies between 1 and 10
|
||||
// - 2 fraction digits for frequencies < 1
|
||||
const fractionDigits = freq > 10 ? 0 : freq < 1 ? 2 : 1;
|
||||
const userLocale = navigator.language || "en-US";
|
||||
const freqFormatted = new Intl.NumberFormat(userLocale, {
|
||||
minimumFractionDigits: fractionDigits,
|
||||
maximumFractionDigits: fractionDigits,
|
||||
}).format(freq);
|
||||
|
||||
$("#query_frequency")
|
||||
.html(
|
||||
'<i class="fa fa-fw fa-gauge-high text-green-light"></i> ' +
|
||||
intl.format(freq) +
|
||||
freqFormatted +
|
||||
" " +
|
||||
unit
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user