⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
erp.dev-unit.com
/
public
/
js
/
chatify
/
View File Name :
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); }; }