From 3e3a12ffdf285a48cd6cbbef65094750401caf2f Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 12 Feb 2018 12:47:37 +0100 Subject: zelfoverhoor: Onbeforeunload message in docent interface --- modules/zelfoverhoor/docent.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/zelfoverhoor/docent.js b/modules/zelfoverhoor/docent.js index 388c7f7..c14fb2e 100644 --- a/modules/zelfoverhoor/docent.js +++ b/modules/zelfoverhoor/docent.js @@ -5,8 +5,18 @@ window.addEventListener("error",function(err){ xhr.send(str); }); +window.onbeforeunload=function(ev){ + if(editorIsOpen){ + var text="Je bent momenteel een vragenset aan het bewerken; weet je zeker dat je het window wilt sluiten?"; + ev.returnValue=text; + return text; + } + return undefined; +}; + var questionsets=null; var currentlyEditing=null; +var editorIsOpen=false; function getQuestionSets(){ var xhr=new XMLHttpRequest(); @@ -107,6 +117,7 @@ function openBlankSetEditor(){ document.getElementById("newqsetform").classList.remove("invisible"); document.getElementById("newqsetvisible").classList.add("invisible"); currentlyEditing=null; + editorIsOpen=true; } function doNewQSet(){ @@ -157,6 +168,7 @@ function closeQSetForm(){ document.getElementById("newqsetform").classList.add("invisible"); document.getElementById("newqsetvisible").classList.remove("invisible"); currentlyEditing=null; + editorIsOpen=false; } function renumberQuestions(){ -- cgit v1.2.3