Compare commits

...

2 commits

3 changed files with 62 additions and 41 deletions

View file

@ -8,6 +8,7 @@
description: Description
}
frequency_unit: kHz
frequency_fraction_digits: 0
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 Date: "2021-06-09"

View file

@ -66,7 +66,7 @@ div>label {
location.search.substr(1).split("&").forEach((param) => {
let p = param.split("=");
let key = p[0];
["base", "extension", "css"].forEach((id) => {
["base", "regulation", "css"].forEach((id) => {
if (key === id) {
document.getElementById(id + "_input").value = decodeURIComponent(p[1]);
}
@ -74,7 +74,7 @@ div>label {
});
update_inputs();
["base", "extension", "css"].forEach((id) => {
["base", "regulation", "css"].forEach((id) => {
// download buttons
create_element_link(document.getElementById("download_" + id), document.getElementById(id + "_input").value);
// enter on input fields
@ -88,7 +88,7 @@ div>label {
create_element_link(document.getElementById("create_link"), function() {
return window.location.href.split("?")[0] + "?"
+ "base=" + document.getElementById("base_input").value
+ "&extension=" + document.getElementById("extension_input").value
+ "&regulation=" + document.getElementById("regulation_input").value
+ "&css=" + document.getElementById("css_input").value;
});
});
@ -125,17 +125,29 @@ div>label {
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) => {
if (header.columns.includes(col)) {
if (typeof cols[col] === "object") {
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;
}
}
} else {
if ((col === "frequency") && (typeof cols[col] === "number")) {
row[col] = formatter.format(cols[col]);
} else {
row[col] = cols[col];
}
}
}
});
}
@ -149,11 +161,13 @@ div>label {
}
});
document.getElementById("comments_" + key).innerHTML = s;
} else {
document.getElementById("comments_" + key).innerHTML = "";
}
};
}
function update_table(bases, extensions) {
function update_table(bases, regulations) {
let tdata = [];
let header = {};
@ -169,53 +183,53 @@ div>label {
if ((typeof base.header === "undefined") || (base.header == false)) {
let row = {};
// first, fill ext_header
extensions.forEach((ext) => {
if ((typeof ext.header !== "undefined") && ext.header) {
header["extension"] = structuredClone(ext);
// first, fill reg_header
regulations.forEach((reg) => {
if ((typeof reg.header !== "undefined") && reg.header) {
header["regulation"] = structuredClone(reg);
}
});
fill_comments(header);
// then fill tdata
extensions.forEach((ext) => {
if ((typeof ext.header === "undefined") || (ext.header == false)) {
add_column(row, base, header["base"]);
regulations.forEach((reg) => {
if ((typeof reg.header === "undefined") || (reg.header == false)) {
add_column(row, base, header["base"], header["base"].frequency_fraction_digits);
let [ext_start, ext_end] = ext.frequency.split("-");
ext_start = Qty(Number(ext_start), header["extension"].frequency_unit).to(header["base"].frequency_unit).scalar;
ext_end = Qty(Number(ext_end), header["extension"].frequency_unit).to(header["base"].frequency_unit).scalar;
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_end = Qty(Number(reg_end), header["regulation"].frequency_unit).to(header["base"].frequency_unit).scalar;
if (typeof base.frequency === "number") {
// at single frequency
if (isInRange(base.frequency, ext_start, ext_end)) {
add_column(row, ext, header["extension"]);
if (isInRange(base.frequency, reg_start, reg_end)) {
add_column(row, reg, header["regulation"], header["base"].frequency_fraction_digits);
tdata.push(row);
}
} else {
// frequeny range
let [base_start, base_end] = base.frequency.split("-");
if (isInRange(base_start, ext_start, ext_end) && isInRange(base_end, ext_start, ext_end)) {
// base range is inside of ext range or the same
add_column(row, ext, header["extension"]);
if (isInRange(base_start, reg_start, reg_end) && isInRange(base_end, reg_start, reg_end)) {
// base range is inside of reg range or the same
add_column(row, reg, header["regulation"]);
tdata.push(row);
} else {
// base range is split by ext range
if ((base_end > ext_start) && isInRange(ext_start, base_start, base_end)) {
// base range starts below ext range
// base range is split by reg range
if ((base_end > reg_start) && isInRange(reg_start, base_start, base_end)) {
// base range starts below reg range
let r = structuredClone(row);
let start = ext_start;
let end = base_end < ext_end ? base_end : ext_end;
let start = reg_start;
let end = base_end < reg_end ? base_end : reg_end;
r["frequency"] = start + "-" + end;
add_column(r, ext, header["extension"]);
add_column(r, reg, header["regulation"]);
tdata.push(r);
} else if ((ext_end > base_start) && isInRange(ext_end, base_start, base_end)) {
// ext range starts below base range
} else if ((reg_end > base_start) && isInRange(reg_end, base_start, base_end)) {
// reg range starts below base range
let r = structuredClone(row);
let start = base_start;
let end = ext_end;
let end = reg_end;
r["frequency"] = start + "-" + end;
add_column(r, ext, header["extension"]);
add_column(r, reg, header["regulation"]);
tdata.push(r);
}
}
@ -293,8 +307,8 @@ div>label {
if (typeof header["base"].titles[column.field] !== "undefined") {
column.title = header["base"].titles[column.field];
}
if (typeof header["extension"].titles[column.field] !== "undefined") {
column.title = header["extension"].titles[column.field];
if (typeof header["regulation"].titles[column.field] !== "undefined") {
column.title = header["regulation"].titles[column.field];
}
// add css styles for formatting based on cell values
@ -366,7 +380,7 @@ div>label {
function update_inputs() {
Promise.all([
fetch(document.getElementById("base_input").value, { mode: "cors" }),
fetch(document.getElementById("extension_input").value, { mode: "cors" }),
fetch(document.getElementById("regulation_input").value, { mode: "cors" }),
]).then((res) => {
res.forEach((r) => {
if (!r.ok) {
@ -375,7 +389,11 @@ div>label {
});
Promise.all([res[0].text(), res[1].text()]).then((d) => {
try {
update_table(yaml.load(d[0]),yaml.load(d[1]));
let reg = d[1];
if (reg === "") {
reg = "- header: true\n columns: []\n titles: []\n frequency_unit: GHz\n- frequency: 0-" + 9007199254740991;
}
update_table(yaml.load(d[0]), yaml.load(reg));
} catch (e) {
display_error(e);
}
@ -407,7 +425,9 @@ div>label {
// eslint-disable-next-line no-unused-vars
function help() {
alert(
"Base plan, extension plan and css: use your own files for the band plan and css, URLs are possible, CORS needs to be allowed for the files, download standard files for examples\n"
"Base plan, regulation and css: use your own files for the band plan and css, URLs are possible, CORS needs to be allowed for the files, download standard files for examples\n"
+ "When Regulation is empty, all frequencies from base plan will be included\n"
+ "When CSS is empty or URL not available, colors, etc. will be gone\n"
+ "Filter rows with text in column headings, use filter starting with \"!\" as exclusion\n"
+ "Download list: saves .pdf of the current list (selection of rows apply)\n"
+ "Selection of rows with mouse possible\n"
@ -420,8 +440,8 @@ div>label {
<label>Base Plan:
<input id="base_input" type="text" value="band-plan-iaru_r1_hf.yml">
</label>
<label>Extension:
<input id="extension_input" type="text" value="band-plan-de.yml">
<label>Regulation:
<input id="regulation_input" type="text" value="regulations-de.yml">
</label>
<label>CSS:
<input id="css_input" type="text" value="standard.css">
@ -432,7 +452,7 @@ div>label {
<div>
<button id="download">Download list</button>
<button id="download_base">Download base plan</button>
<button id="download_extension">Download extension plan</button>
<button id="download_regulation">Download regulation</button>
<button id="download_css">Download css file</button>
<button id="create_link">Create link</button>
<button onclick="help()">Help</button>
@ -440,7 +460,7 @@ div>label {
<div id="data-table"></div>
<div id="error"></div>
<div id="comments_base"></div>
<div id="comments_extension"></div>
<div id="comments_regulation"></div>
<div>
<p>This information is supplied without liability.</p>
<p>Source is at <a href="https://src.dm5wk.de/dm5wk/band-plan-web/">https://src.dm5wk.de/dm5wk/band-plan-web/</a></p>