mycorrhiza/web/static/editor.js
Timur Ismagilov 4c31c8cc32 Move a lot of files into internal dir
Outside of it are web and stuff that needs further refactoring
2024-06-04 23:26:49 +03:00

20 lines
567 B
JavaScript

window.hyphaChanged = false;
let textarea = document.querySelector('.edit-form__textarea');
let form = document.querySelector('.edit-form');
let warnBeforeClosing = function (ev) {
if (!window.hyphaChanged) return;
ev.preventDefault();
return ev.returnValue = 'Are you sure you want to exit? You have unsaved changes.';
};
textarea.addEventListener('input', function () {
window.hyphaChanged = true;
});
form.addEventListener('submit', function () {
window.hyphaChanged = false;
});
window.addEventListener('beforeunload', warnBeforeClosing);