⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
www
/
work
/
public
/
js
/
chatify
/
Edit File: utils.js
/** * changes date string to time ago string. * @param dateString - The date string to convert to a time ago string. * @returns A string that tells the user how long ago the date was. */ function dateStringToTimeAgo(dateString) { const now = new Date(); const date = new Date(dateString); const seconds = Math.floor((now - date) / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); const weeks = Math.floor(days / 7); if (seconds < 60) { return "just now"; } else if (minutes < 60) { return `${minutes}m ago`; } else if (hours < 24) { return `${hours}h ago`; } else if (days < 7) { return `${days}d ago`; } else { return `${weeks}w ago`; } } /** * It returns a function that, when invoked, will wait for a specified amount of time before executing * the original function. * @param callback - The function to be executed after the delay. * @param delay - The amount of time to wait before calling the callback. * @returns A function that will call the callback function after a delay. */ function debounce(callback, delay) { let timerId; return function (...args) { clearTimeout(timerId); timerId = setTimeout(() => { callback.apply(this, args); }, delay); }; }
Simpan