Commit 8dd9b52e authored by Samarth Joshi's avatar Samarth Joshi

BugFix: Quiz doesnot notify event if user Alt+Tabs in fullscreen

parent 118a5df6
...@@ -20,6 +20,16 @@ ...@@ -20,6 +20,16 @@
return false; return false;
} }
document.addEventListener('contextmenu', event => event.preventDefault()); document.addEventListener('contextmenu', event => event.preventDefault());
var isTabActive;
window.onfocus = function () {
isTabActive = true;
};
window.onblur = function () {
isTabActive = false;
};
</script> </script>
</head> </head>
<body> <body>
...@@ -148,7 +158,26 @@ ...@@ -148,7 +158,26 @@
return false; return false;
} }
} }
var vis = (function(){
var stateKey, eventKey, keys = {
hidden: "visibilitychange",
webkitHidden: "webkitvisibilitychange",
mozHidden: "mozvisibilitychange",
msHidden: "msvisibilitychange"
};
for (stateKey in keys) {
if (stateKey in document) {
eventKey = keys[stateKey];
break;
}
}
return function(c) {
if (c) document.addEventListener(eventKey, c);
return !document[stateKey];
}
})();
var heartbeat = setInterval(function() { var heartbeat = setInterval(function() {
var currfs = get_fs(); var currfs = get_fs();
var flag = false; var flag = false;
if (currfs != prevfs) { if (currfs != prevfs) {
...@@ -161,8 +190,8 @@ ...@@ -161,8 +190,8 @@
{ {
question: selected_questions, question: selected_questions,
quiz: quizId, quiz: quizId,
fullscreen: currfs, fullscreen: (currfs && isTabActive),
log:flag log:flag,
}, },
function(data, status){ function(data, status){
console.log("Heartbeat sent!"); console.log("Heartbeat sent!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment