add digits after comma for showing e. g. 145.500 MHz
This commit is contained in:
parent
2395abe47d
commit
64d4f68eb3
|
@ -8,6 +8,7 @@
|
||||||
description: Description
|
description: Description
|
||||||
}
|
}
|
||||||
frequency_unit: kHz
|
frequency_unit: kHz
|
||||||
|
frequency_fraction_digits: 0
|
||||||
comments:
|
comments:
|
||||||
- Source Base: '<a href="https://www.iaru-r1.org/wp-content/uploads/2021/06/hf_r1_bandplan.pdf">https://www.iaru-r1.org/wp-content/uploads/2021/06/hf_r1_bandplan.pdf</a>'
|
- Source Base: '<a href="https://www.iaru-r1.org/wp-content/uploads/2021/06/hf_r1_bandplan.pdf">https://www.iaru-r1.org/wp-content/uploads/2021/06/hf_r1_bandplan.pdf</a>'
|
||||||
- Source Base Date: "2021-06-09"
|
- Source Base Date: "2021-06-09"
|
||||||
|
|
|
@ -125,17 +125,29 @@ div>label {
|
||||||
return Number(number) >= Number(min) && Number(number) <= Number(max);
|
return Number(number) >= Number(min) && Number(number) <= Number(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_column(row, cols, header) {
|
function add_column(row, cols, header, minimum_fraction_digits = 0) {
|
||||||
|
const formatter = new Intl.NumberFormat("en-US", {
|
||||||
|
minimumFractionDigits: minimum_fraction_digits,
|
||||||
|
maximumFractionDigits: 100,
|
||||||
|
});
|
||||||
header.columns.forEach((col) => {
|
header.columns.forEach((col) => {
|
||||||
if (header.columns.includes(col)) {
|
if (header.columns.includes(col)) {
|
||||||
if (typeof cols[col] === "object") {
|
if (typeof cols[col] === "object") {
|
||||||
for (const [key, value] of Object.entries(cols[col])) {
|
for (const [key, value] of Object.entries(cols[col])) {
|
||||||
|
if ((key === "frequency") && (typeof value === "number")) {
|
||||||
|
row[col + "_" + key] = formatter.format(value);
|
||||||
|
} else {
|
||||||
row[col + "_" + key] = value;
|
row[col + "_" + key] = value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((col === "frequency") && (typeof cols[col] === "number")) {
|
||||||
|
row[col] = formatter.format(cols[col]);
|
||||||
} else {
|
} else {
|
||||||
row[col] = cols[col];
|
row[col] = cols[col];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +195,7 @@ div>label {
|
||||||
// then fill tdata
|
// then fill tdata
|
||||||
regulations.forEach((reg) => {
|
regulations.forEach((reg) => {
|
||||||
if ((typeof reg.header === "undefined") || (reg.header == false)) {
|
if ((typeof reg.header === "undefined") || (reg.header == false)) {
|
||||||
add_column(row, base, header["base"]);
|
add_column(row, base, header["base"], header["base"].frequency_fraction_digits);
|
||||||
|
|
||||||
let [reg_start, reg_end] = reg.frequency.split("-");
|
let [reg_start, reg_end] = reg.frequency.split("-");
|
||||||
reg_start = Qty(Number(reg_start), header["regulation"].frequency_unit).to(header["base"].frequency_unit).scalar;
|
reg_start = Qty(Number(reg_start), header["regulation"].frequency_unit).to(header["base"].frequency_unit).scalar;
|
||||||
|
@ -191,7 +203,7 @@ div>label {
|
||||||
if (typeof base.frequency === "number") {
|
if (typeof base.frequency === "number") {
|
||||||
// at single frequency
|
// at single frequency
|
||||||
if (isInRange(base.frequency, reg_start, reg_end)) {
|
if (isInRange(base.frequency, reg_start, reg_end)) {
|
||||||
add_column(row, reg, header["regulation"]);
|
add_column(row, reg, header["regulation"], header["base"].frequency_fraction_digits);
|
||||||
tdata.push(row);
|
tdata.push(row);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue