Files
database_editor/src/javascript/error.js
T
admin e21ba3e213 Added recovery feature
If the database get corrupted, the admin can restore it through the website.
2025-05-15 13:58:50 +03:00

45 lines
1.3 KiB
JavaScript

const upload = document.getElementById("upload");
const download = document.getElementById("download");
const logout = document.getElementById("logout");
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(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) => {
location.reload();
});
}
const onSelectFile = () => upload(input.files[0]);
input.addEventListener('change', onSelectFile, false);
input.click();
});
setEventListeners(download, () => {
window.location.href = "/app/download";
});
setEventListeners(logout, () => {
window.location.href = `${window.location.protocol}//logout@${window.location.host}/`;
});