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

Minor UI fix

parent d5ebe054
Branches
No related tags found
No related merge requests found
......@@ -28,12 +28,20 @@ const currentState = () => {
return data;
};
const formDataToJson = (data) => {
const result = {};
for (let key of data.keys()) {
result[key] = data.getAll(key);
}
return data;
};
const doSave = () => {
const data = currentState();
save.value = "Saving…";
postData(location.href, data).then((json) => {
save.value = "Saved";
lastSaved = data;
lastSaved = formDataToJson(data);
})
};
......@@ -84,7 +92,7 @@ save.addEventListener("click", (e) => {
});
window.addEventListener("beforeunload", (e) => {
const state = currentState();
const state = formDataToJson(currentState());
if (hasChangedEver && lastSaved !== state) {
const message = "Your changes have not been saved. Are you sure you want to leave?";
e.preventDefault();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment