Skip to content

Commit f931dc3

Browse files
committed
added the count to ui
1 parent 886af40 commit f931dc3

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

client/index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,6 @@ async function weather(city) {
127127
return response
128128
}
129129

130-
// Visits
131-
let visitCount = localStorage.getItem("visits")
132-
if (!visitCount) {
133-
document.querySelector('.visits').textContent = `This is your first time on this page`;
134-
localStorage.setItem("visits", 1)
135-
} else {
136-
visitCount = parseInt(visitCount) + 1;
137-
localStorage.setItem("visits", visitCount)
138-
document.querySelector('.visits').textContent = `You have visited this page ${visitCount} times`;
139-
}
140-
141130
// PLay with cookies
142131
nowFetch().then(response => {
143132
const data = {
@@ -158,8 +147,11 @@ nowFetch().then(response => {
158147

159148
const encodedDynamic = btoa(JSON.stringify(dynamicData))
160149
const HASH = sha1(encodedDynamic)
150+
document.querySelector('.visits').textContent = `LOADING.......`
161151
addSHA(HASH).then(shaRESPONSE => {
162-
console.log(shaRESPONSE)
152+
const visits = shaRESPONSE.visits
153+
document.querySelector('.visits').textContent = `According to the unique hash, you have visited the site ${visits} time(s).`
154+
console.log(visits)
163155
}).catch(e => {
164156
console.log(e)
165157
})

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var app = express();
44
const atob = require('atob');
55
const KEY = require('./key');
66
const Base64 = require('base-64');
7-
const compareHash = require('./funcs/compareHashes')
87

98
app.use(cors())
109

@@ -85,7 +84,7 @@ app.get('/add-sha/:sha', (req, res) => {
8584
}, {
8685
headers: { 'Authorization': "token " + KEY }
8786
}).then(result => {
88-
res.json({ message: "created" })
87+
res.json({ visits: 1 })
8988
}).catch(e => {
9089
Axios.get("https://api.github.com/repos/ujjwal-kr-data/ip-data/contents/" + req.params.sha, {
9190
headers: { 'Authorization': "token " + KEY }

0 commit comments

Comments
 (0)