fix frequency range comparison

This commit is contained in:
Wolfgang 2024-05-27 21:38:59 +02:00
parent ca1f23bf9c
commit 1b7d9efaac

View file

@ -174,7 +174,6 @@ div>label {
fill_comments(header);
// then fill tdata
let already_added = false;
extensions.forEach((ext) => {
if ((typeof ext.header === "undefined") || (ext.header == false)) {
add_column(row, base, header["base"]);
@ -184,8 +183,7 @@ div>label {
// at single frequency
if (isInRange(base.frequency, ext_start, ext_end)) {
add_column(row, ext, header["extension"]);
} else {
return;
tdata.push(row);
}
} else {
// frequeny range
@ -193,9 +191,10 @@ div>label {
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"]);
tdata.push(row);
} else {
// base range is split by ext range
if (isInRange(ext_start, base_start, base_end)) {
if ((base_end > ext_start) && isInRange(ext_start, base_start, base_end)) {
// base range starts below ext range
let r = structuredClone(row);
let start = ext_start;
@ -203,8 +202,7 @@ div>label {
r["frequency"] = start + "-" + end;
add_column(r, ext, header["extension"]);
tdata.push(r);
already_added = true;
} else if (isInRange(ext_end, base_start, base_end)) {
} else if ((ext_end > base_start) && isInRange(ext_end, base_start, base_end)) {
// ext range starts below base range
let r = structuredClone(row);
let start = base_start;
@ -212,16 +210,11 @@ div>label {
r["frequency"] = start + "-" + end;
add_column(r, ext, header["extension"]);
tdata.push(r);
already_added = true;
}
}
}
}
});
if (!already_added) {
tdata.push(row);
}
already_added = false;
}
});