Blasta/script/regulator.js

21 lines
710 B
JavaScript
Raw Permalink Normal View History

document.addEventListener('DOMContentLoaded', () => {
window.addEventListener('pywebviewready', () => {
// Attach event listeners to all anchor elements
document.querySelectorAll('a').forEach(element => {
element.addEventListener('click', regulator);
});
});
});
// This function will be called when an anchor is clicked
function regulator(event) {
event.preventDefault(); // Prevent the default link behavior
const url = this.href; // Get the URL from the clicked link
// Call the exposed Python function
window.pywebview.api.regulator(url)
.catch(error => {
console.error("Error calling regulator:", error);
});
}