Skip to content

Commit

Permalink
fix stats
Browse files Browse the repository at this point in the history
  • Loading branch information
silvereengames committed Aug 28, 2024
1 parent d7eb6b5 commit 92c1aae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
6 changes: 3 additions & 3 deletions public/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
};

function countTime() {
localStorage.setItem('moonlight.timeplayed', parseInt(localStorage.getItem('moonlight.timeplayed')) + 1)
localStorage.setItem('timeplayed', parseInt(localStorage.getItem('timeplayed')) + 1)
console.log(localStorage.getItem('timeplayed'))
}

if (localStorage.getItem('moonlight.timeplayed')) {
if (localStorage.getItem('timeplayed') !== null) {
setInterval(countTime, 1000)
} else {
localStorage.setItem('moonlight.timeplayed', 0);
localStorage.setItem('timeplayed', 0);
setInterval(countTime, 1000)
}
</script>
Expand Down
8 changes: 4 additions & 4 deletions public/load.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@
});

function countTime() {
localStorage.setItem('moonlight.timesearched', parseInt(localStorage.getItem('moonlight.timesearched')) + 1)
console.log(localStorage.getItem('moonlight.timesearched'))
localStorage.setItem('timesearched', parseInt(localStorage.getItem('timesearched')) + 1)
console.log(localStorage.getItem('timesearched'))
}

if (localStorage.getItem('moonlight.timesearched')) {
if (localStorage.getItem('timesearched')) {
setInterval(countTime, 1000)
} else {
localStorage.setItem('moonlight.timesearched', 0);
localStorage.setItem('timesearched', 0);
setInterval(countTime, 1000)
}
</script>
Expand Down
35 changes: 25 additions & 10 deletions public/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ <h2 class="center">Proxy settings</h2>
<h2 class="center">Stats</h2>
<h4 class="center">Time Played: <span id="timeplayed"></span></h4>
<h4 class="center">Time using proxy: <span id="timesearched"></span></h4>
<h4 class="center">Total time: <span id="totaltime"></span></h4>
</div>

<div class="settings-container">
Expand Down Expand Up @@ -392,21 +393,35 @@ <h3 class="sticky">Code Stuff</h3>
}

const hours = document.getElementById('timeplayed');
if (localStorage.getItem('moonlight.timeplayed') > 3600000) {
hours.innerHTML = Math.round(localStorage.getItem('moonlight.timeplayed') / 60 / 60) + " Hours"
} else if (localStorage.getItem('timeplayed') < 60000) {
hours.innerHTML = Math.round(localStorage.getItem('moonlight.timeplayed') / 60) + " Minutes"
const timeplayedSeconds = parseInt(localStorage.getItem('timeplayed'));

if (timeplayedSeconds >= 3600) {
hours.innerHTML = Math.round(timeplayedSeconds / 60 / 60) + " Hours";
} else if (timeplayedSeconds >= 60) {
hours.innerHTML = Math.round(timeplayedSeconds / 60) + " Minutes";
} else {
hours.innerHTML = Math.round(localStorage.getItem('moonlight.timeplayed')) + " Seconds"
hours.innerHTML = Math.round(timeplayedSeconds) + " Seconds";
}

const timesearched = document.getElementById('timesearched');
if (localStorage.getItem('moonlight.timesearched') > 3600000) {
timesearched.innerHTML = Math.round(localStorage.getItem('moonlight.timesearched') / 60 / 60) + " Hours"
} else if (localStorage.getItem('timesearched') < 60000) {
timesearched.innerHTML = Math.round(localStorage.getItem('moonlight.timesearched') / 60) + " Minutes"
const timesearchedSeconds = parseInt(localStorage.getItem('timesearched'));

if (timesearchedSeconds >= 3600) {
timesearched.innerHTML = Math.round(timesearchedSeconds / 60 / 60) + " Hours";
} else if (timesearchedSeconds >= 60) {
timesearched.innerHTML = Math.round(timesearchedSeconds / 60) + " Minutes";
} else {
timesearched.innerHTML = Math.round(timesearchedSeconds) + " Seconds";
}

const totaltime = document.getElementById('totaltime');
const totalTimeSeconds = timeplayedSeconds + timesearchedSeconds;
if (totalTimeSeconds >= 3600) {
totaltime.innerHTML = Math.round(totalTimeSeconds / 60 / 60) + " Hours";
} else if (totalTimeSeconds >= 60) {
totaltime.innerHTML = Math.round(totalTimeSeconds / 60) + " Minutes";
} else {
timesearched.innerHTML = Math.round(localStorage.getItem('moonlight.timesearched')) + " Seconds"
totaltime.innerHTML = Math.round(totalTimeSeconds) + " Seconds";
}


Expand Down

0 comments on commit 92c1aae

Please sign in to comment.