aboutsummaryrefslogtreecommitdiff
path: root/src/edit.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/edit.js')
-rw-r--r--src/edit.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/edit.js b/src/edit.js
index 062a0de..e45f5f5 100644
--- a/src/edit.js
+++ b/src/edit.js
@@ -27,6 +27,7 @@ window.addEventListener('load', () => {
submitHandler(this);
});
+ // disable CodeMirror's default ctrl+D shortcut (delete line)
delete CodeMirror.keyMap['default']['Ctrl-D'];
editors = [
@@ -127,7 +128,7 @@ function changeHandler(e) {
) {
return;
}
- unsavedChanges = true;
+ changed();
}
/**
@@ -157,8 +158,7 @@ function submitHandler(form) {
var fd = new FormData(form);
xhr.addEventListener('load', function(event) {
- unsavedChanges = false;
- // Add "last update" timestamp here
+ saved();
});
xhr.addEventListener('error', function(event) {
alert('Error while trying to update.');
@@ -176,3 +176,13 @@ function confirmExit(e) {
return 'You have unsaved changes, do you really want to leave this page?';
}
}
+
+function changed() {
+ unsavedChanges = true;
+ document.title = '✏ *' + pageid;
+}
+
+function saved() {
+ unsavedChanges = false;
+ document.title = '✏ ' + pageid;
+}