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