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
Tags 1.7.1
No related merge requests found
...@@ -19,13 +19,19 @@ const save = document.querySelector("#save"); ...@@ -19,13 +19,19 @@ const save = document.querySelector("#save");
const updateForm = document.querySelector(".update-form"); const updateForm = document.querySelector(".update-form");
let lastTimeOut = null; let lastTimeOut = null;
let lastSaved = null;
const doSave = () => { const currentState = () => {
const data = new FormData(document.forms.namedItem("upload")); const data = new FormData(document.forms.namedItem("upload"));
data.append("from_js", "true"); data.append("from_js", "true");
};
const doSave = () => {
const data = currentState();
save.value = "Saving…"; save.value = "Saving…";
postData(location.href, data).then((json) => { postData(location.href, data).then((json) => {
save.value = "Saved"; save.value = "Saved";
lastSaved = data;
}) })
}; };
...@@ -72,3 +78,10 @@ save.addEventListener("click", (e) => { ...@@ -72,3 +78,10 @@ save.addEventListener("click", (e) => {
doSave(); doSave();
}); });
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