Compare commits

...

4 commits

4 changed files with 116 additions and 81 deletions

View file

@ -1,6 +1,7 @@
{ {
"env": { "env": {
"browser": true "browser": true,
"es6": true
}, },
"extends": "eslint:recommended", "extends": "eslint:recommended",
"parserOptions": { "parserOptions": {

View file

@ -1,52 +1,52 @@
- header: true
columns: [power]
titles: {
power_a: Power A,
power_e: Power E,
power_n: Power N
}
- start: 135.7 - start: 135.7
end: 137.8 end: 137.8
power_a: 1 W ERP power: {a: 1 W ERP}
- start: 472 - start: 472
end: 479 end: 479
power_a: 1 W ERP power: {a: 1 W ERP}
- start: 1810 - start: 1810
end: 1850 end: 1850
power_a: 750 W PEP power: {a: 750 W PEP, e: 100 W PEP}
power_e: 100 W PEP
- start: 1850 - start: 1850
end: 1890 end: 1890
power_a: 75 W PEP power: {a: 75 W PEP, e: 75 W PEP}
power_e: 75 W PEP
- start: 1890 - start: 1890
end: 2000 end: 2000
power_a: 10 W PEP power: {a: 10 W PEP, e: 10 W PEP}
power_e: 10 W PEP
- start: 3500 - start: 3500
end: 3800 end: 3800
power_a: 750 W PEP power: {a: 750 W PEP, e: 100 W PEP}
power_e: 100 W PEP
- start: 5351.5 - start: 5351.5
end: 5366.5 end: 5366.5
power_a: 15 W EIRP power: {a: 15 W EIRP}
- start: 7000 - start: 7000
end: 7100 end: 7100
power_a: 750 W PEP power: {a: 750 W PEP}
- start: 7100 - start: 7100
end: 7200 end: 7200
power_a: 750 W PEP power: {a: 750 W PEP}
- start: 10100 - start: 10100
end: 10150 end: 10150
power_a: 150 W PEP power: {a: 150 W PEP}
- start: 14000 - start: 14000
end: 14350 end: 14350
power_a: 750 W PEP power: {a: 750 W PEP}
- start: 18068 - start: 18068
end: 18168 end: 18168
power_a: 750 W PEP power: {a: 750 W PEP}
- start: 21000 - start: 21000
end: 21450 end: 21450
power_a: 750 W PEP power: {a: 750 W PEP, e: 100 W PEP}
power_e: 100 W PEP
- start: 24890 - start: 24890
end: 24990 end: 24990
power_a: 750 W PEP power: {a: 750 W PEP}
- start: 28000 - start: 28000
end: 29700 end: 29700
power_a: 750 W PEP power: {a: 750 W PEP, e: 100 W PEP, n: 10 W ERP}
power_e: 100 W PEP
power_n: 10 W ERP

View file

@ -1,3 +1,13 @@
- 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 - band: 2.2 km
mode: CW mode: CW
bandwidth: 200 bandwidth: 200

View file

@ -77,74 +77,92 @@ div#togglebuttons>button {
} }
function add_power(add, p) { function add_power(add, p) {
if (typeof add.power_a !== "undefined") { for (const [key, value] of Object.entries(add.power)) {
p["power_a"] = add.power_a; p["power_" + key] = value;
}
if (typeof add.power_e !== "undefined") {
p["power_e"] = add.power_e;
}
if (typeof add.power_n !== "undefined") {
p["power_n"] = add.power_n;
} }
} }
function update_table(bands, additions) { function update_table(bands, additions) {
var tdata = []; var tdata = [];
var base_header = {};
var add_header = {};
// first, fill base_header
bands.forEach((band) => { bands.forEach((band) => {
band.parts.forEach((part) => { if ((typeof band.header !== "undefined") && band.header) {
let p = { base_header = structuredClone(band);
"band": band.band, }
"frequency": typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end, });
"mode": band.mode,
//"band_start": band.start, // then fill tdata
//"band_end": band.end, bands.forEach((band) => {
"bandwidth": band.bandwidth, if ((typeof band.header === "undefined") || (band.header == false)) {
"description": part.description, band.parts.forEach((part) => {
}; let p = {};
let parts_already_added = false; base_header.columns.forEach((col) => {
additions.forEach((add) => { if (base_header.part_columns.includes(col)) {
if (typeof part.at !== "undefined") { p[col] = part[col];
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);
} else { } else {
// part range is split by add range p[col] = band[col];
if (isInRange(add.start, part.start, part.end)) { }
// part range starts below add range });
let p_clone = structuredClone(p); p["frequency"] = typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end;
let start = add.start;
let end = part.end < add.end ? part.end : add.end; // first, fill add_header
p_clone["frequency"] = start + '\u2013' + end; additions.forEach((add) => {
add_power(add, p_clone); if ((typeof add.header !== "undefined") && add.header) {
tdata.push(p_clone); add_header = structuredClone(add);
parts_already_added = true; }
} else if (isInRange(add.end, part.start, part.end)) { });
// add range starts below part range
let p_clone = structuredClone(p); // then fill tdata
let start = part.start; let parts_already_added = false;
let end = add.end; additions.forEach((add) => {
p_clone["frequency"] = start + '\u2013' + end; if ((typeof add.header === "undefined") || (add.header == false)) {
add_power(add, p_clone); if (typeof part.at !== "undefined") {
tdata.push(p_clone); if (isInRange(part.at, add.start, add.end)) {
parts_already_added = true; // 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);
} 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 // require in tabular-tables
@ -162,7 +180,7 @@ div#togglebuttons>button {
autoColumnsDefinitions: function(definitions){ autoColumnsDefinitions: function(definitions){
definitions.forEach((column) => { definitions.forEach((column) => {
if (column.field == "band") { if (column.field == "band") {
column.sorter = function(a, b, aRow, bRow, column, dir, sorterParams) { column.sorter = function(a, b) {
return parseFloat(new Measures().from(a).to('m')) - parseFloat(new Measures().from(b).to('m')); return parseFloat(new Measures().from(a).to('m')) - parseFloat(new Measures().from(b).to('m'));
} }
} }
@ -173,6 +191,12 @@ div#togglebuttons>button {
column.headerFilter = "input"; column.headerFilter = "input";
column.headerFilterFunc = filter_with_not; 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; return definitions;