PageSourceSearch

https://choicervoicer.studio/leaderboard.js

js choicervoicer.studio collected 2026-10-05 20:39:26 UTC 2,355 bytes, 38 lines download raw bytes

1(() => {
2  'use strict';
3  const status = document.querySelector('[data-leaderboard-status]');
4  const list = document.querySelector('[data-leaderboard-list]');
5  const buttons = Array.from(document.querySelectorAll('[data-period]'));
6  const packSelect = document.querySelector('[data-leaderboard-pack]');
7  let period = 'week';
8  const prettyPack = slug => String(slug || '').split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
9  const render = rows => {
10    if (!rows.length) {
11      list.innerHTML = '';
12      status.textContent = 'No completed dubs in this period yet. Be the first to set a score.';
13      return;
14    }
15    status.textContent = `${rows.length} player${rows.length === 1 ? '' : 's'} ranked by their best completed-dub average.`;
16    list.innerHTML = rows.map((row, index) => `<li><span class="leaderboard-rank num">#${index + 1}</span><span class="leaderboard-player">${escapeHtml(row.display_name)}</span><span class="leaderboard-sessions num">${row.sessions} session${row.sessions === 1 ? '' : 's'}</span><strong class="num">${row.best_score}<small>/100</small></strong></li>`).join('');
17  };
18  const escapeHtml = value => String(value || 'Player').replace(/[&<>'"]/g, char => ({'&':'&amp;','<':'&lt;','>':'&gt;',"'":'&#39;','"':'&quot;'}[char]));
19  const load = async () => {
20    if (!window.CVCloud || !window.CVCloud.enabled) { status.textContent = 'Leaderboard is being connected.'; return; }
21    status.textContent = 'Loading scores…';
22    try {
23      const packs = await window.CVCloud.leaderboardPacks(period);
24      const previous = packSelect.value;
25      packSelect.innerHTML = '<option value="">Most played pack</option>' + packs.map(pack => `<option value="${pack.pack_slug}">${prettyPack(pack.pack_slug)} · ${pack.sessions}</option>`).join('');
26      if (packs.some(pack => pack.pack_slug === previous)) packSelect.value = previous;
27      render(await window.CVCloud.leaderboard(period, packSelect.value || null));
28    }
29    catch (_) { status.textContent = 'Scores could not load right now. Please try again.'; }
30  };
31  buttons.forEach(button => button.addEventListener('click', () => {
32    period = button.dataset.period;
33    buttons.forEach(item => item.classList.toggle('is-active', item === button));
34    load();
35  }));
36  packSelect.addEventListener('change', load);
37  load();
38})();

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.