create link for bookmarking different plans

This commit is contained in:
Wolfgang 2024-05-26 16:53:34 +02:00
parent 3114b4ce30
commit e6779b3e77

View file

@ -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("=");
@ -55,6 +77,12 @@ div>label {
update_plan() 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;
});
}); });
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -291,6 +319,7 @@ 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="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>