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 resetButton = document.querySelector("#reset");
|
||||
var visitCount = localStorage.getItem("page_view");
|
||||
|
||||
// Check if page_view entry is present
|
||||
if (visitCount) {
|
||||
visitCount = Number(visitCount) + 1;
|
||||
localStorage.setItem("page_view", visitCount);
|
||||
} else {
|
||||
visitCount = 1;
|
||||
localStorage.setItem("page_view", 1);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "https://api.countapi.xyz/hit/rezzaapr.my.id/visits");
|
||||
xhr.responseType = "json";
|
||||
xhr.onload = function() {
|
||||
document.querySelector('.footer-title').innerHTML = 'Total Visitor : ' + this.response.value;
|
||||
}
|
||||
counterContainer.innerHTML = 'Visitor This Website : '+visitCount;
|
||||
xhr.send();
|
||||
|
Loading…
Reference in New Issue
Block a user