Skip to content

Commit

Permalink
Added Visibility Change
Browse files Browse the repository at this point in the history
  • Loading branch information
tafakkur committed Dec 24, 2020
1 parent cdcc21d commit 4faf893
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions JavaScript Files/Visibility Change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//Check Visibility Change

Qualtrics.SurveyEngine.addOnReady(function () {
time_off = 0;
time_fs = 0;
document.addEventListener("visibilitychange", function () {
if (document.visibilityState != "visible") {
Qualtrics.SurveyEngine.setEmbeddedData("tab_changed", "true");
off_screen = setInterval(() => {
time_off++;
console.log(time_off);
}, 100);
}else{
clearInterval(off_screen);
console.log(time_off);
}
});
document.addEventListener("fullscreenchange", function () {
if (document.fullscreenElement !== null) {
full_screen = setInterval(() => {
time_fs++;
console.log(time_fs);
}, 100);
} else {
clearInterval(full_screen);
console.log(time_fs);
console.log("fs disabled");
}
});
document.querySelector("#NextButton").onclick = function () {
clearInterval(off_screen);
clearInterval(full_screen);
Qualtrics.SurveyEngine.setEmbeddedData("gone_for", time_off);
Qualtrics.SurveyEngine.setEmbeddedData("full_screen", time_fs);
console.log(time_fs);
console.log(time_off);

};
});

0 comments on commit 4faf893

Please sign in to comment.