Bug fixes
This commit is contained in:
+45
-12
@@ -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}/`;
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user