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
|
// eslint-disable-next-line no-undef
|
||||||
const path = require('https://unpkg.com/path-browserify/index.js');
|
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', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
location.search.substr(1).split("&").forEach((param) => {
|
location.search.substr(1).split("&").forEach((param) => {
|
||||||
let p = param.split("=");
|
let p = param.split("=");
|
||||||
|
@ -44,16 +66,25 @@ 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]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
update_plan();
|
update_plan();
|
||||||
|
|
||||||
document.getElementById("base_plan").addEventListener("keydown", (event) => {
|
["base", "extension"].forEach((id) => {
|
||||||
if (event.key === 'Enter') {
|
create_element_link(document.getElementById("download_" + id), document.getElementById(id + "_plan").value);
|
||||||
update_plan()
|
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) {
|
function isInRange(number, min, max) {
|
||||||
return number >= min && number <= max;
|
return Number(number) >= Number(min) && Number(number) <= 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +141,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) => {
|
||||||
|
@ -125,7 +156,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];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -133,38 +164,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +200,7 @@ div>label {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!already_added) {
|
if (!already_added) {
|
||||||
tdata.push(p);
|
tdata.push(row);
|
||||||
}
|
}
|
||||||
already_added = false;
|
already_added = false;
|
||||||
}
|
}
|
||||||
|
@ -272,10 +300,12 @@ div>label {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function help() {
|
function help() {
|
||||||
alert(
|
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'
|
+ 'Filter rows with text in column headings, use filter starting with "!" as exclusion\n'
|
||||||
+ 'Download list: saves .pdf of the current list\n'
|
+ 'Download list: saves .pdf of the current list (selection of rows apply)\n'
|
||||||
+ 'Selection of rows with mouse possible'
|
+ '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>
|
</script>
|
||||||
|
@ -291,9 +321,16 @@ div>label {
|
||||||
<div id="togglebuttons"></div>
|
<div id="togglebuttons"></div>
|
||||||
<div>
|
<div>
|
||||||
<button id="download">Download list</button>
|
<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>
|
<button onclick="help()">Help</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="data-table"></div>
|
<div id="data-table"></div>
|
||||||
<div id="error"></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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue