moved js func to edit.ts to avoid console error on other pages

This commit is contained in:
BroodjeAap 2023-01-02 13:06:50 +00:00
parent 2bd8d03331
commit fe0102ac09
5 changed files with 46 additions and 46 deletions

View file

@ -989,3 +989,25 @@ function pageInit() {
saveButtonMain.onclick = saveWatch; saveButtonMain.onclick = saveWatch;
} }
document.addEventListener('DOMContentLoaded', pageInit, false); document.addEventListener('DOMContentLoaded', pageInit, false);
function clearCache() {
var confirmed = confirm("Do you want to clear the URL cache?");
if (!confirmed) {
return; // do nothing
}
var data = new URLSearchParams();
fetch("/cache/clear", {
method: "POST"
}).then(function (response) {
if (response.ok) {
window.location.reload();
}
else {
alert("Could not clear cache");
}
});
}
function clearCacheButtonInit() {
var clearCacheButton = document.getElementById("clearCacheButton");
clearCacheButton.onclick = clearCache;
}
document.addEventListener('DOMContentLoaded', clearCacheButtonInit, false);

View file

@ -975,4 +975,26 @@ function pageInit(){
saveButtonMain.onclick = saveWatch; saveButtonMain.onclick = saveWatch;
} }
document.addEventListener('DOMContentLoaded', pageInit, false); document.addEventListener('DOMContentLoaded', pageInit, false);
function clearCache(){
let confirmed = confirm("Do you want to clear the URL cache?");
if (!confirmed){
return // do nothing
}
let data = new URLSearchParams();
fetch("/cache/clear", {
method: "POST"
}).then((response) => {
if(response.ok){
window.location.reload()
} else {
alert("Could not clear cache");
}
});
}
function clearCacheButtonInit(){
let clearCacheButton = document.getElementById("clearCacheButton") as HTMLElement;
clearCacheButton.onclick = clearCache;
}
document.addEventListener('DOMContentLoaded', clearCacheButtonInit, false);

View file

@ -1,22 +0,0 @@
function clearCache() {
var confirmed = confirm("Do you want to clear the URL cache?");
if (!confirmed) {
return; // do nothing
}
var data = new URLSearchParams();
fetch("/cache/clear", {
method: "POST"
}).then(function (response) {
if (response.ok) {
window.location.reload();
}
else {
alert("Could not clear cache");
}
});
}
function clearCacheButtonInit() {
var clearCacheButton = document.getElementById("clearCacheButton");
clearCacheButton.onclick = clearCache;
}
document.addEventListener('DOMContentLoaded', clearCacheButtonInit, false);

View file

@ -1,21 +0,0 @@
function clearCache(){
let confirmed = confirm("Do you want to clear the URL cache?");
if (!confirmed){
return // do nothing
}
let data = new URLSearchParams();
fetch("/cache/clear", {
method: "POST"
}).then((response) => {
if(response.ok){
window.location.reload()
} else {
alert("Could not clear cache");
}
});
}
function clearCacheButtonInit(){
let clearCacheButton = document.getElementById("clearCacheButton") as HTMLElement;
clearCacheButton.onclick = clearCache;
}
document.addEventListener('DOMContentLoaded', clearCacheButtonInit, false);

View file

@ -8,5 +8,4 @@
- postgresql+apprise - postgresql+apprise
- postgresql+apprise+browserless - postgresql+apprise+browserless
- add kube yaml example? - add kube yaml example?
- organize docs? - organize docs?
- move clearCacheButton to edit.ts