Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
edited index javascript to implement new backend software (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z authored Feb 29, 2024
1 parent c0ea957 commit a0a00fa
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@


async function doVisit(token){
async function doVisit(){
fetch((await getBackend())+"/admin/visit", {
method:"post",
body: JSON.stringify({
token: token,
time: Date.now()/1000
}),
headers: {
"Content-Type":"application/json"
}
method:"get"
}).then(response => {
switch(response.status){
case 200:
Expand Down Expand Up @@ -57,20 +50,14 @@ async function commit_history(){

async function getSessionToken(){
if(getCookie("session") == ""){
fetch((await getBackend())+"/admin/session?time="+Date.now()/1000, {
method:"get"
}).then(response => {
switch(response.status){
case 200:
response.text().then(text => {
document.cookie = "session=" + text + "; expires=" + (new Date(Date.now() + 604800000)).toUTCString()
doVisit(text)
})
break;
default:
console.log("WTF, exiting...")
}
})
fetch((await getBackend())+"/admin/session", {
method:"post"
}).then(response => response.text().then(token => {
var date = new Date()
var tomorrow = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
document.cookie = "session="+ token + "; expires = "+tomorrow.toUTCString()
doVisit()
}))
}
else{
doVisit(getCookie("session"))
Expand Down

0 comments on commit a0a00fa

Please sign in to comment.