From c142be9e4aa652d3dd886d92b8c655d41645bf6c Mon Sep 17 00:00:00 2001 From: dm5wk Date: Fri, 24 May 2024 19:55:54 +0200 Subject: [PATCH] header in both plans, add title mapping to columns --- band-plan-de.yml | 7 +++ band-plan-iaru_r1_hf.yml | 10 +++- band-plan.html | 98 ++++++++++++++++++++++++---------------- 3 files changed, 74 insertions(+), 41 deletions(-) diff --git a/band-plan-de.yml b/band-plan-de.yml index c8a451b..ad60dc7 100644 --- a/band-plan-de.yml +++ b/band-plan-de.yml @@ -1,3 +1,10 @@ +- header: true + columns: [power] + titles: { + power_a: Power A, + power_e: Power E, + power_n: Power N + } - start: 135.7 end: 137.8 power: {a: 1 W ERP} diff --git a/band-plan-iaru_r1_hf.yml b/band-plan-iaru_r1_hf.yml index 7513fd8..4798c2d 100644 --- a/band-plan-iaru_r1_hf.yml +++ b/band-plan-iaru_r1_hf.yml @@ -1,5 +1,13 @@ -- band: header +- header: true columns: [band, frequency, mode, bandwidth, description] + part_columns: [description] + titles: { + band: Band, + frequency: Frequency / kHz, + mode: Mode, + bandwidth: Bandwidth / Hz, + description: Description + } - band: 2.2 km mode: CW bandwidth: 200 diff --git a/band-plan.html b/band-plan.html index dba5f91..16b472e 100644 --- a/band-plan.html +++ b/band-plan.html @@ -84,63 +84,75 @@ div#togglebuttons>button { function update_table(bands, additions) { var tdata = []; - var header = {}; + var base_header = {}; + var add_header = {}; - // first, fill header + // first, fill base_header bands.forEach((band) => { - if (band.band === "header") { - header = structuredClone(band); + if ((typeof band.header !== "undefined") && band.header) { + base_header = structuredClone(band); } }); // then fill tdata bands.forEach((band) => { - if (band.band !== "header") { + if ((typeof band.header === "undefined") || (band.header == false)) { band.parts.forEach((part) => { let p = {}; - header.columns.forEach((col) => { - p[col] = band[col]; - if (col == "description") { + base_header.columns.forEach((col) => { + if (base_header.part_columns.includes(col)) { p[col] = part[col]; + } else { + p[col] = band[col]; } }); p["frequency"] = typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end; + // first, fill add_header + additions.forEach((add) => { + if ((typeof add.header !== "undefined") && add.header) { + add_header = structuredClone(add); + } + }); + + // then fill tdata 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 { - // 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); + if ((typeof add.header === "undefined") || (add.header == false)) { + 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; + } } } } @@ -179,6 +191,12 @@ div#togglebuttons>button { column.headerFilter = "input"; column.headerFilterFunc = filter_with_not; + if (typeof base_header.titles[column.field] !== "undefined") { + column.title = base_header.titles[column.field]; + } + if (typeof add_header.titles[column.field] !== "undefined") { + column.title = add_header.titles[column.field]; + } }); return definitions;