PageSourceSearch

https://callrec.net/js/notification-count.js?v=N0isfDbIzqRn0jwAo7uolsjEVlbecNRDABV4N00NaV8

js callrec.net collected 2026-09-24 15:06:32 UTC 1,541 bytes, 29 lines download raw bytes

1// One counter per CRM page, shared by navigation and the center. No requests while hidden.
2const query = new URLSearchParams(location.search);
3const companies = query.getAll('profileId');
4const companyId = companies[0] || null;
5const badges = [...document.querySelectorAll('[data-notification-count]')];
6document.querySelectorAll('a[href^="/app/notifications"]').forEach(link => {
7    const badge = document.createElement('span');
8    badge.className = 'badge rounded-pill badge-primary bg-primary ms-2';
9    badge.hidden = true;
10    badge.dataset.notificationCount = '';
11    link.append(badge);
12    badges.push(badge);
13});
14let busy = false;
15async function refresh() {
16    if (document.hidden || busy || !badges.length || companies.length > 1 || companies.length && !companyId) return;
17    busy = true;
18    try {
19        const response = await fetch('/api/notifications/unread-count' + (companyId ? '?companyId=' + encodeURIComponent(companyId) : ''), { cache: 'no-store' });
20        if (!response.ok) { badges.forEach(badge => { badge.hidden = true; }); return; }
21        const { count } = await response.json();
22        badges.forEach(badge => { badge.textContent = String(count); badge.hidden = count === 0; badge.setAttribute('aria-label', `Непрочитанных: ${count}`); });
23    } catch { badges.forEach(badge => { badge.hidden = true; }); }
24    finally { busy = false; }
25}
26setInterval(refresh, 30000);
27document.addEventListener('visibilitychange', refresh);
28window.addEventListener('notifications:read', refresh);
29refresh();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.