Skip to content

Commit e4036ce

Browse files
committed
visits
1 parent 834b336 commit e4036ce

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

client/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ <h1>EPIC_Tracker</h1>
3333
<span class="pin"></span><br>
3434
<span class="weather"></span><br>
3535
<span class="temperature"></span><br>
36+
<span class="visits"></span><br>
3637
<span class="VPN"></span><br>
3738
<strong class="rotation-rate"></strong><br>
3839
<strong class="acceleration"></strong>

client/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ if (deviceWidth < 990) {
5858
}, 1000);
5959
})
6060
}
61+
} else {
62+
document.querySelector('.rotation-rate').textContent = `Open this website on your mobile device to see device motion tracker information`;
6163
}
6264
function guessIfTheDeviceIsOnTable(x,y,z) {
6365
if (x === 0 && y === 0 && z === 0) {
@@ -98,6 +100,16 @@ async function weather(city) {
98100
})
99101
return response.json()
100102
}
103+
// Visits
104+
let visitCount = localStorage.getItem("visits")
105+
if (!visitCount) {
106+
document.querySelector('.visits').textContent = `This is your first time on this page`;
107+
localStorage.setItem("visits", 1)
108+
} else {
109+
visitCount = parseInt(visitCount) + 1;
110+
localStorage.setItem("visits", visitCount)
111+
document.querySelector('.visits').textContent = `You have visited this page ${visitCount} times`;
112+
}
101113
// PLay with cookies
102114
nowFetch().then(response => {
103115
const data = {

0 commit comments

Comments
 (0)