Compare commits
5 commits
3114b4ce30
...
2aa403d3c9
Author | SHA1 | Date | |
---|---|---|---|
Wolfgang | 2aa403d3c9 | ||
Wolfgang | 962051be59 | ||
Wolfgang | 762d5a5114 | ||
Wolfgang | 41227eb77e | ||
Wolfgang | e6779b3e77 |
|
@ -37,6 +37,28 @@ div>label {
|
|||
// eslint-disable-next-line no-undef
|
||||
const path = require('https://unpkg.com/path-browserify/index.js');
|
||||
|
||||
function create_element_link(element, href) {
|
||||
element.addEventListener("click", () => {
|
||||
var lnk = document.createElement('a');
|
||||
|
||||
if (typeof href === "function") {
|
||||
lnk.href = href();
|
||||
} else {
|
||||
lnk.href = href;
|
||||
}
|
||||
|
||||
if (document.createEvent) {
|
||||
let e = document.createEvent("MouseEvents");
|
||||
e.initMouseEvent("click", true, true, window,
|
||||
0, 0, 0, 0, 0, false, false, false,
|
||||
false, 0, null);
|
||||
lnk.dispatchEvent(e);
|
||||
} else if (lnk.fireEvent) {
|
||||
lnk.fireEvent("onclick");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
location.search.substr(1).split("&").forEach((param) => {
|
||||
let p = param.split("=");
|
||||
|
@ -44,16 +66,25 @@ 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]);
|
||||
}
|
||||
});
|
||||
update_plan();
|
||||
|
||||
document.getElementById("base_plan").addEventListener("keydown", (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
update_plan()
|
||||
}
|
||||
["base", "extension"].forEach((id) => {
|
||||
create_element_link(document.getElementById("download_" + id), document.getElementById(id + "_plan").value);
|
||||
document.getElementById("download_" + id).addEventListener("keydown", (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
update_plan()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
create_element_link(document.getElementById("create_link"), function() {
|
||||
return window.location.href.split('?')[0] + '?'
|
||||
+ "base=" + document.getElementById("base_plan").value
|
||||
+ "&ext=" + document.getElementById("extension_plan").value;
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -86,12 +117,12 @@ div>label {
|
|||
}
|
||||
|
||||
function isInRange(number, min, max) {
|
||||
return number >= min && number <= max;
|
||||
return Number(number) >= Number(min) && Number(number) <= 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +141,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) => {
|
||||
|
@ -125,7 +156,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];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -133,38 +164,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;
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +200,7 @@ div>label {
|
|||
}
|
||||
});
|
||||
if (!already_added) {
|
||||
tdata.push(p);
|
||||
tdata.push(row);
|
||||
}
|
||||
already_added = false;
|
||||
}
|
||||
|
@ -272,10 +300,12 @@ div>label {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
function help() {
|
||||
alert(
|
||||
'Plan: use your own yml file for a band plan, URLs are possible, CORS needs to be allowed for the file\n'
|
||||
'Base plan and Extension plan: use your own yml file for a band plan, URLs are possible, CORS needs to be allowed for the files, download standard files for examples\n'
|
||||
+ 'Filter rows with text in column headings, use filter starting with "!" as exclusion\n'
|
||||
+ 'Download list: saves .pdf of the current list\n'
|
||||
+ 'Selection of rows with mouse possible'
|
||||
+ 'Download list: saves .pdf of the current list (selection of rows apply)\n'
|
||||
+ 'Selection of rows with mouse possible\n'
|
||||
+ 'Download plans: get the yml plans\n'
|
||||
+ 'Create link: get link for currently selected plans for bookmarking\n'
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
@ -291,9 +321,16 @@ div>label {
|
|||
<div id="togglebuttons"></div>
|
||||
<div>
|
||||
<button id="download">Download list</button>
|
||||
<button id="download_base">Download base plan</button>
|
||||
<button id="download_extension">Download extension plan</button>
|
||||
<button id="create_link">Create link</button>
|
||||
<button onclick="help()">Help</button>
|
||||
</div>
|
||||
<div id="data-table"></div>
|
||||
<div id="error"></div>
|
||||
<div>
|
||||
<p>This information is supplied without liability.</p>
|
||||
<p>Source is at <a href="https://src.dm5wk.de/dm5wk/band-plan-web/">https://src.dm5wk.de/dm5wk/band-plan-web/</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue