const assetsPath = "../assets/"; const api = new APIClient(); const toastContainer = $('.toast-container'); const onlineUsers = new Set(); let renderTableCell = (function () { function renderTitle(title) { return title .replace('_', ' ') .split(" ") .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(" "); } function renderSwitch(data, disable=false) { let enabled = data == true; let active = enabled ? ' active' : ''; let disabled = disable ? 'disabled' : ''; return ' '; } function renderName(full) { var $name = full['name'], $lastSeen = full['lastHandshake'].replace('T', ' ') $userId = full['id']; // Avatar badge var stateNum = Math.floor(Math.random() * 6); var states = ['success', 'danger', 'warning', 'info', 'dark', 'primary', 'secondary']; var $state = states[stateNum], $name = full['name'], $initials = ($name || '').match(/\b\w/g)?.join('').toUpperCase() || ''; let online = 'offline'; // online check if ($lastSeen.length == 8) { const time = new Date(`2000-01-01T${$lastSeen}`); const comparison = new Date(`2000-01-01T00:03:00`); if (time < comparison) { online = 'online'; onlineUsers.add($userId); }; } // end online check let $output = '