add header to base yml file for column selection

This commit is contained in:
Wolfgang 2024-05-24 19:23:31 +02:00
parent 87ce5c1a8e
commit 401b52b768
2 changed files with 62 additions and 48 deletions

View file

@ -1,3 +1,5 @@
- band: header
columns: [band, frequency, mode, bandwidth, description]
- band: 2.2 km
mode: CW
bandwidth: 200

View file

@ -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