Skip to content

Commit

Permalink
Merge pull request #3 from RossSmyth/master
Browse files Browse the repository at this point in the history
Added a save warning pop up.
  • Loading branch information
gzuidhof authored May 21, 2021
2 parents a4cb64b + 7a62579 commit 238704e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions starboard/web/templates/editor.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@
if (dirty && !document.title.startsWith("* ")) {
document.title = "* " + document.title;
dirtyIndicator.innerText = " Unsaved changes";
window.addEventListener("beforeunload", saveWarning);
} else if (!dirty && document.title.startsWith("* ")) {
document.title = document.title.substr(2);
dirtyIndicator.innerText = "";
window.removeEventListener("beforeunload", saveWarning);
}
}

function saveWarning(e) {
e.preventDefault();
e.returnValue = '';
}

async function save(content) {
const r = await fetch(window.location.pathname, {
method: "PUT",
Expand Down

0 comments on commit 238704e

Please sign in to comment.