From 69aeb7889ac136a8e4fbe7de1330298e30345479 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Wed, 22 Oct 2025 13:59:12 +0400 Subject: feat/frontend: switch to vite, update node to v22 (#281) --- frontend/src/utils/Jwt.ts | 20 ++++++++++---------- frontend/src/utils/Time.ts | 30 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'frontend/src/utils') diff --git a/frontend/src/utils/Jwt.ts b/frontend/src/utils/Jwt.ts index ce351fb..a6d1866 100644 --- a/frontend/src/utils/Jwt.ts +++ b/frontend/src/utils/Jwt.ts @@ -3,20 +3,20 @@ export function get_user_id_from_token(token: string | undefined): string | unde if (!token) { return undefined; } - const parts = token.split('.'); + const parts = token.split("."); if (parts.length !== 3) { return undefined; } const base64Url = parts[1]; - const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); + const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/"); const jsonPayload = decodeURIComponent( atob(base64) - .split('') + .split("") .map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2); }) - .join('') + .join("") ); return JSON.parse(jsonPayload).sub; }; @@ -25,20 +25,20 @@ export function get_user_mod_from_token(token: string | undefined): boolean | un if (!token) { return undefined; } - const parts = token.split('.'); + const parts = token.split("."); if (parts.length !== 3) { return undefined; } const base64Url = parts[1]; - const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); + const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/"); const jsonPayload = decodeURIComponent( atob(base64) - .split('') + .split("") .map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2); }) - .join('') + .join("") ); return JSON.parse(jsonPayload).mod; }; diff --git a/frontend/src/utils/Time.ts b/frontend/src/utils/Time.ts index b83a7ed..9cbe793 100644 --- a/frontend/src/utils/Time.ts +++ b/frontend/src/utils/Time.ts @@ -5,38 +5,38 @@ export function time_ago(date: any) { const seconds = Math.floor((now - localDate.getTime()) / 1000); let interval = Math.floor(seconds / 31536000); - if (interval === 1) {return interval + ' year ago';} - if (interval > 1) {return interval + ' years ago';} + if (interval === 1) {return interval + " year ago";} + if (interval > 1) {return interval + " years ago";} interval = Math.floor(seconds / 2592000); - if (interval === 1) {return interval + ' month ago';} - if (interval > 1) {return interval + ' months ago';} + if (interval === 1) {return interval + " month ago";} + if (interval > 1) {return interval + " months ago";} interval = Math.floor(seconds / 86400); - if (interval === 1) {return interval + ' day ago';} - if (interval > 1) {return interval + ' days ago';} + if (interval === 1) {return interval + " day ago";} + if (interval > 1) {return interval + " days ago";} interval = Math.floor(seconds / 3600); - if (interval === 1) {return interval + ' hour ago';} - if (interval > 1) {return interval + ' hours ago';} + if (interval === 1) {return interval + " hour ago";} + if (interval > 1) {return interval + " hours ago";} interval = Math.floor(seconds / 60); - if (interval === 1) {return interval + ' minute ago';} - if (interval > 1) {return interval + ' minutes ago';} + if (interval === 1) {return interval + " minute ago";} + if (interval > 1) {return interval + " minutes ago";} - if(seconds < 10) return 'just now'; + if(seconds < 10) return "just now"; - return Math.floor(seconds) + ' seconds ago'; + return Math.floor(seconds) + " seconds ago"; }; export function ticks_to_time(ticks: number) { let seconds = Math.floor(ticks / 60) let minutes = Math.floor(seconds / 60) - let hours = Math.floor(minutes / 60) + const hours = Math.floor(minutes / 60) - let milliseconds = Math.floor((ticks % 60) * 1000 / 60) + const milliseconds = Math.floor((ticks % 60) * 1000 / 60) seconds = seconds % 60; minutes = minutes % 60; - return `${hours === 0 ? "" : hours + ":"}${minutes === 0 ? "" : hours > 0 ? minutes.toString().padStart(2, '0') + ":" : (minutes + ":")}${minutes > 0 ? seconds.toString().padStart(2, '0') : seconds}.${milliseconds.toString().padStart(3, '0')}`; + return `${hours === 0 ? "" : hours + ":"}${minutes === 0 ? "" : hours > 0 ? minutes.toString().padStart(2, "0") + ":" : (minutes + ":")}${minutes > 0 ? seconds.toString().padStart(2, "0") : seconds}.${milliseconds.toString().padStart(3, "0")}`; }; \ No newline at end of file -- cgit v1.2.3