diff options
author | Aki <please@ignore.pl> | 2020-07-08 22:41:18 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2020-07-08 22:41:18 +0200 |
commit | 81311c9a72058fedf0b9add696db170349478ebe (patch) | |
tree | b7bdd49cd1ebc2bcfea6bb45eeb8ad50c908f35f | |
parent | 74a06dab4d6a4a05d7a4c0c384a826c0d2b1df92 (diff) | |
download | rudone-81311c9a72058fedf0b9add696db170349478ebe.zip rudone-81311c9a72058fedf0b9add696db170349478ebe.tar.gz rudone-81311c9a72058fedf0b9add696db170349478ebe.tar.bz2 |
Changed to short circuit non-null just in case
-rw-r--r-- | track.js | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -13,6 +13,7 @@ }, false) window.addEventListener("beforeunload", ()=>{ let xhr = new XMLHttpRequest() + startedAt = startedAt || new Date() xhr.open("POST", "https://stats.ignore.pl/entry") xhr.setRequestHeader("Content-Type", "application/json") xhr.send(JSON.stringify({ @@ -20,7 +21,7 @@ "referrer": document.referrer, "startedAt": startedAt, "timeSpent": Math.floor((new Date() - startedAt) / 1000), - "scrolledTo": scrolledTo / document.scrollingElement.scrollHeight + "scrolledTo": (scrolledTo || 0) / document.scrollingElement.scrollHeight })) }) })() |