Skip to content
Snippets Groups Projects
Commit ad86f8ec authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Minor UI fix

parent 7303fe5a
Branches
No related tags found
No related merge requests found
......@@ -19,13 +19,19 @@ const save = document.querySelector("#save");
const updateForm = document.querySelector(".update-form");
let lastTimeOut = null;
let lastSaved = null;
const doSave = () => {
const currentState = () => {
const data = new FormData(document.forms.namedItem("upload"));
data.append("from_js", "true");
};
const doSave = () => {
const data = currentState();
save.value = "Saving…";
postData(location.href, data).then((json) => {
save.value = "Saved";
lastSaved = data;
})
};
......@@ -71,4 +77,11 @@ save.addEventListener("click", (e) => {
e.preventDefault();
doSave();
});
\ No newline at end of file
});
window.onbeforeunload = (e) => {
const state = currentState();
if (lastSaved !== null && lastSaved !== state) {
return "Your changes have not been saved. Are you sure you want to leave?"
}
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment