-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (23 loc) · 883 Bytes
/
script.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
if (sessionStorage.getItem("reload")) {
sessionStorage.removeItem("reload");
location.reload();
}
function markPageReload() {
sessionStorage.setItem("reload", "true");
}
function submitScore(score) {
const xhr = new XMLHttpRequest();
xhr.open("POST", "process.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
document.querySelector(".nps-buttons").style.display = "none";
document.getElementById("thankYouMessage").style.display = "block";
markPageReload();
setTimeout(function() {
window.location.href = "index.php";
}, 1009);
}
};
xhr.send("score=" + score);
}