diff --git a/src/front/static/ts/main.ts b/src/front/static/ts/main.ts index 731a972..032984e 100644 --- a/src/front/static/ts/main.ts +++ b/src/front/static/ts/main.ts @@ -75,8 +75,6 @@ window.addEventListener("popstate", router); document.addEventListener("DOMContentLoaded", () => { isLogged(); - - document.body.addEventListener("click", e => { if (!e.target.closest("#taskbar-menu") && !e.target.matches("#profile-button")) { profile_view.open = false; @@ -121,9 +119,18 @@ function updateClock() clock.innerHTML = `${days[now.getDay()]} ${now.getDate()} ${months[now.getMonth()]} ` + hours + ":" + minutes; } -friends_view.run(); +async function pingClock() { + if (await isLogged()) { + fetch(`http://localhost:3002/ping`, { + method: "POST", + credentials: "include" + }); + } +} setInterval(updateClock, 5000); updateClock(); +setInterval(pingClock, 30000); + oneko(); diff --git a/src/front/static/ts/views/Profile.ts b/src/front/static/ts/views/Profile.ts index e233f52..fe4f4c2 100644 --- a/src/front/static/ts/views/Profile.ts +++ b/src/front/static/ts/views/Profile.ts @@ -49,15 +49,14 @@ export default class extends Aview { uuid = document.cookie.match(new RegExp('(^| )' + "uuid" + '=([^;]+)'))[2]; const userdata_req = await fetch(`http://localhost:3002/users/${uuid}`, { - method: "GET", - credentials: "include", - }); - if (userdata_req.status == 404) - { - console.error("invalid user"); - return ; - } - let userdata = await userdata_req.json(); + method: "GET", + credentials: "include", + }); + if (userdata_req.status == 404) { + console.error("invalid user"); + return; + } + let userdata = await userdata_req.json(); const matchCount_req = await fetch(`http://localhost:3002/users/${uuid}/matchHistory/count`, { method: "GET", @@ -75,39 +74,40 @@ export default class extends Aview { if (!main) return console.error("what"); - console.log(matches); - if (matches.matchHistory) - { - for (let match of matches.matchHistory) - { + if (matches.matchHistory) { + for (let match of matches.matchHistory) { const newEntry = document.createElement("li"); newEntry.classList.add("m-2", "default-button", "bg-neutral-200", "dark:bg-neutral-800", "text-neutral-900", "dark:text-white"); newEntry.innerHTML = match.score.p1Score > match.score.p2Score ? `${match.score.p1} - winner` : `${match.score.p2} - winner`; main.insertBefore(newEntry, main.firstChild); + // ########################################################################################################################################### + // + // ADD TX LINK : https://testnet.snowscan.xyz/tx/${match.tx} + // + // ########################################################################################################################################### console.log(match.tx); } } - const profile = document.getElementById("profile-profile"); + const profile = document.getElementById("profile-profile"); if (!profile) return; - const picture = profile.appendChild(document.createElement("img")); - picture.src = "https://api.kanel.ovh/pp"; - picture.classList.add("text-neutral-900", "dark:text-white", "center", "h-18", "w-18", "mx-3"); + const picture = profile.appendChild(document.createElement("img")); + picture.src = "https://api.kanel.ovh/pp"; + picture.classList.add("text-neutral-900", "dark:text-white", "center", "h-18", "w-18", "mx-3"); - const nametag = profile.appendChild(document.createElement("div")); - nametag.innerHTML = ` + const nametag = profile.appendChild(document.createElement("div")); + nametag.innerHTML = `
welcome ! please register.
- - + +