Feature/#12 search input with hotkey #15

Merged
Serraniel merged 10 commits from feature/#12-search-input-with-hotkey into develop 2020-07-29 14:01:12 +02:00
Showing only changes of commit 1b66379515 - Show all commits

View file

@ -1,4 +1,5 @@
let __scripts = [];
let __afterLoadScripts = [];
function registerScript(func, pattern = '.*') {
__scripts.push({ "function": func, "pattern": pattern });
@ -25,3 +26,29 @@ observer.observe(document.documentElement || document.body, {
subtree: true,
attributes: true
});
function runAfterLoad(func, pattern = '.*') {
__afterLoadScripts.push({ "function": func, "pattern": pattern });
}
document.addEventListener("DOMContentLoaded", event => awaitPageLoaded(), false);
function awaitPageLoaded() {
let preLoader = document.getElementById('preloader');
if (typeof preLoader === 'undefined') {
return;
}
let loop = setInterval(() => {
if (preLoader.style.display === "none") {
clearInterval(loop);
__afterLoadScripts.forEach(script => {
if (window.location.pathname.match(script.pattern)) {
script.function();
}
})
}
}, 100);
}