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