From 9233a95ff0da1958d3e1f2660affb95db028f773 Mon Sep 17 00:00:00 2001 From: Rezza Priatna <58212770+rezzaapr@users.noreply.github.com> Date: Sat, 13 Aug 2022 13:34:02 +0700 Subject: [PATCH] Update visitor.js --- visitor.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/visitor.js b/visitor.js index 625d83c..337c78b 100644 --- a/visitor.js +++ b/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; \ No newline at end of file +xhr.send();