Commit ad86f8ec authored by Janne Koschinski's avatar Janne Koschinski

Minor UI fix

parent 7303fe5a
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment