Update visitor.js

This commit is contained in:
Rezza Priatna 2022-08-13 13:34:02 +07:00 committed by GitHub
parent 3c9536d63d
commit 9233a95ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,13 +1,7 @@
var counterContainer = document.querySelector(".footer-title"); var xhr = new XMLHttpRequest();
var resetButton = document.querySelector("#reset"); xhr.open("GET", "https://api.countapi.xyz/hit/rezzaapr.my.id/visits");
var visitCount = localStorage.getItem("page_view"); xhr.responseType = "json";
xhr.onload = function() {
// Check if page_view entry is present document.querySelector('.footer-title').innerHTML = 'Total Visitor : ' + this.response.value;
if (visitCount) {
visitCount = Number(visitCount) + 1;
localStorage.setItem("page_view", visitCount);
} else {
visitCount = 1;
localStorage.setItem("page_view", 1);
} }
counterContainer.innerHTML = 'Visitor This Website : '+visitCount; xhr.send();