-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVisibility Change.js
34 lines (30 loc) · 961 Bytes
/
Visibility Change.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//Check Visibility Change
Qualtrics.SurveyEngine.addOnload(function () {
time_off = Number("${e://Field/time_off}");
time_fs = Number("${e://Field/time_fs}");
document.addEventListener("visibilitychange", function () {
if (document.visibilityState != "visible") {
Qualtrics.SurveyEngine.setEmbeddedData("tab_changed", "true");
off_screen = setInterval(() => {
time_off++;
}, 100);
}else{
clearInterval(off_screen);
}
});
document.addEventListener("fullscreenchange", function () {
if (document.fullscreenElement != null) {
full_screen = setInterval(() => {
time_fs++;
}, 100);
} else {
clearInterval(full_screen);
}
});
document.querySelector("#NextButton").onclick = function () {
clearInterval(off_screen);
clearInterval(full_screen);
Qualtrics.SurveyEngine.setEmbeddedData("time_off", time_off);
Qualtrics.SurveyEngine.setEmbeddedData("time_fs", time_fs);
};
});