mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-31 07:33:00 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			588 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			588 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| (function () {
 | |
| 	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);
 | |
| })();
 | 
