diff --git a/band-plan.html b/band-plan.html index ca35c2b..9d4dc5e 100644 --- a/band-plan.html +++ b/band-plan.html @@ -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 + + "®ulation=" + document.getElementById("regulation_input").value + "&css=" + document.getElementById("css_input").value; }); }); @@ -149,11 +149,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 +171,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)) { + regulations.forEach((reg) => { + if ((typeof reg.header === "undefined") || (reg.header == false)) { add_column(row, base, header["base"]); - 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"]); 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 +295,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 +368,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 +377,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 +413,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 +428,8 @@ div>label { -