diff --git a/band-plan-iaru_r1_hf.yml b/band-plan-iaru_r1_hf.yml index c36754e..7513fd8 100644 --- a/band-plan-iaru_r1_hf.yml +++ b/band-plan-iaru_r1_hf.yml @@ -1,3 +1,5 @@ +- band: header + columns: [band, frequency, mode, bandwidth, description] - band: 2.2 km mode: CW bandwidth: 200 diff --git a/band-plan.html b/band-plan.html index 42d5162..34479b1 100644 --- a/band-plan.html +++ b/band-plan.html @@ -90,61 +90,73 @@ div#togglebuttons>button { function update_table(bands, additions) { var tdata = []; + var header = {}; + + // first, fill header bands.forEach((band) => { - band.parts.forEach((part) => { - let p = { - "band": band.band, - "frequency": typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end, - "mode": band.mode, - //"band_start": band.start, - //"band_end": band.end, - "bandwidth": band.bandwidth, - "description": part.description, - }; - let parts_already_added = false; - additions.forEach((add) => { - if (typeof part.at !== "undefined") { - if (isInRange(part.at, add.start, add.end)) { - // at single frequency - add_power(add, p); + if (band.band === "header") { + header = structuredClone(band); + } + }); + + // then fill tdata + bands.forEach((band) => { + if (band.band !== "header") { + band.parts.forEach((part) => { + let p = {}; + header.columns.forEach((col) => { + p[col] = band[col]; + if (col == "description") { + p[col] = part[col]; } - } else { - // frequeny range - if ((add.start == part.start) && (add.end == part.end)) { - // ranges are the same - add_power(add, p); - } else if (isInRange(part.start, add.start, add.end) && isInRange(part.end, add.start, add.end)) { - // range of part is inside of range of add - add_power(add, p); + }); + p["frequency"] = typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end; + + let parts_already_added = false; + additions.forEach((add) => { + if (typeof part.at !== "undefined") { + if (isInRange(part.at, add.start, add.end)) { + // at single frequency + add_power(add, p); + } } else { - // part range is split by add range - if (isInRange(add.start, part.start, part.end)) { - // part range starts below add range - let p_clone = structuredClone(p); - let start = add.start; - let end = part.end < add.end ? part.end : add.end; - p_clone["frequency"] = start + '\u2013' + end; - add_power(add, p_clone); - tdata.push(p_clone); - parts_already_added = true; - } else if (isInRange(add.end, part.start, part.end)) { - // add range starts below part range - let p_clone = structuredClone(p); - let start = part.start; - let end = add.end; - p_clone["frequency"] = start + '\u2013' + end; - add_power(add, p_clone); - tdata.push(p_clone); - parts_already_added = true; + // frequeny range + if ((add.start == part.start) && (add.end == part.end)) { + // ranges are the same + add_power(add, p); + } else if (isInRange(part.start, add.start, add.end) && isInRange(part.end, add.start, add.end)) { + // range of part is inside of range of add + add_power(add, p); + } else { + // part range is split by add range + if (isInRange(add.start, part.start, part.end)) { + // part range starts below add range + let p_clone = structuredClone(p); + let start = add.start; + let end = part.end < add.end ? part.end : add.end; + p_clone["frequency"] = start + '\u2013' + end; + add_power(add, p_clone); + tdata.push(p_clone); + parts_already_added = true; + } else if (isInRange(add.end, part.start, part.end)) { + // add range starts below part range + let p_clone = structuredClone(p); + let start = part.start; + let end = add.end; + p_clone["frequency"] = start + '\u2013' + end; + add_power(add, p_clone); + tdata.push(p_clone); + parts_already_added = true; + } } } + }); + if (!parts_already_added) { + tdata.push(p); } + parts_already_added = false; }); - if (!parts_already_added) { - tdata.push(p); - } - parts_already_added = false; - }); + } }); // require in tabular-tables