Update visitor.js
This commit is contained in:
parent
3c9536d63d
commit
9233a95ff0
18
visitor.js
18
visitor.js
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user