Bug fixes

This commit is contained in:
2025-05-31 10:10:18 +02:00
parent f1cfd0c77e
commit 05a8baed4f
6 changed files with 246 additions and 204 deletions
+45 -12
View File
@@ -1,15 +1,48 @@
const upload = document.getElementById("upload");
const logout = document.getElementById("logout");
logout.onmouseenter = async function () {
this.style.backgroundColor = "blue";
};
logout.onmouseleave = async function () {
this.style.backgroundColor = "";
};
logout.onmousedown = async function () {
this.style.backgroundColor = "red";
};
logout.ondblclick = async function () {
this.style.backgroundColor = "blue";
function setEventListeners(element, cb) {
element.onmouseenter = async function () {
this.style.backgroundColor = "blue";
};
element.onmouseleave = async function () {
this.style.backgroundColor = "";
};
element.onmousedown = async function () {
this.style.backgroundColor = "red";
};
element.ondblclick = async function () {
this.style.backgroundColor = "blue";
cb();
};
}
setEventListeners(add, () => {
window.location.href = "/app/add";
});
setEventListeners(upload, async () => {
const input = document.getElementById("file_input");
const upload = (file) => {
const formData = new FormData();
formData.append('file', file);
fetch('/app/upload', {
method: 'POST',
body: formData
}).then((response) => {
if (!response.ok) {
alert(`Upload unsuccessful. ${response.status}`);
} else {
location.reload();
}
});
}
const onSelectFile = () => upload(input.files[0]);
input.addEventListener('change', onSelectFile, false);
input.click();
});
setEventListeners(logout, () => {
window.location.href = `${window.location.protocol}//logout@${window.location.host}/`;
};
});