refactor variable names
This commit is contained in:
parent
e6779b3e77
commit
41227eb77e
|
@ -66,7 +66,7 @@ div>label {
|
|||
if (key === "base") {
|
||||
document.getElementById("base_plan").value = decodeURIComponent(p[1]);
|
||||
}
|
||||
if (key === "add") {
|
||||
if (key === "ext") {
|
||||
document.getElementById("extension_plan").value = decodeURIComponent(p[1]);
|
||||
}
|
||||
});
|
||||
|
@ -117,9 +117,9 @@ div>label {
|
|||
return number >= min && number <= max;
|
||||
}
|
||||
|
||||
function add_power(add, p) {
|
||||
for (const [key, value] of Object.entries(add.power)) {
|
||||
p["power_" + key] = value;
|
||||
function add_power(ext, row) {
|
||||
for (const [key, value] of Object.entries(ext.power)) {
|
||||
row["power_" + key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ div>label {
|
|||
// then fill tdata
|
||||
bases.forEach((base) => {
|
||||
if ((typeof base.header === "undefined") || (base.header == false)) {
|
||||
let p = {};
|
||||
let row = {};
|
||||
|
||||
// first, fill ext_header
|
||||
extensions.forEach((ext) => {
|
||||
|
@ -153,7 +153,7 @@ div>label {
|
|||
if ((typeof ext.header === "undefined") || (ext.header == false)) {
|
||||
base_header.columns.forEach((col) => {
|
||||
if (base_header.columns.includes(col)) {
|
||||
p[col] = base[col];
|
||||
row[col] = base[col];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -161,38 +161,35 @@ div>label {
|
|||
if (typeof base.frequency === "number") {
|
||||
// at single frequency
|
||||
if (isInRange(base.frequency, ext_start, ext_end)) {
|
||||
add_power(ext, p);
|
||||
add_power(ext, row);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// frequeny range
|
||||
let [base_start, base_end] = base.frequency.split('-');
|
||||
if ((ext_start == base_start) && (ext_end == base_end)) {
|
||||
// ranges are the same
|
||||
add_power(ext, p);
|
||||
} else if (isInRange(base_start, ext_start, ext_end) && isInRange(base_end, ext_start, ext_end)) {
|
||||
// base range is inside of ext range
|
||||
add_power(ext, p);
|
||||
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_power(ext, row);
|
||||
} else {
|
||||
// base range is split by ext range
|
||||
if (isInRange(ext_start, base_start, base_end)) {
|
||||
// base range starts below ext range
|
||||
let q = structuredClone(p);
|
||||
let r = structuredClone(row);
|
||||
let start = ext_start;
|
||||
let end = base_end < ext_end ? base_end : ext_end;
|
||||
q["frequency"] = start + '-' + end;
|
||||
add_power(ext, q);
|
||||
tdata.push(q);
|
||||
r["frequency"] = start + '-' + end;
|
||||
add_power(ext, r);
|
||||
tdata.push(r);
|
||||
already_added = true;
|
||||
} else if (isInRange(ext_end, base_start, base_end)) {
|
||||
// ext range starts below base range
|
||||
let q = structuredClone(p);
|
||||
let r = structuredClone(row);
|
||||
let start = base_start;
|
||||
let end = ext_end;
|
||||
q["frequency"] = start + '-' + end;
|
||||
add_power(ext, q);
|
||||
tdata.push(q);
|
||||
r["frequency"] = start + '-' + end;
|
||||
add_power(ext, r);
|
||||
tdata.push(r);
|
||||
already_added = true;
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +197,7 @@ div>label {
|
|||
}
|
||||
});
|
||||
if (!already_added) {
|
||||
tdata.push(p);
|
||||
tdata.push(row);
|
||||
}
|
||||
already_added = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue