File size: 926 Bytes
c9a41bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
626604a
c9a41bc
 
 
626604a
 
 
c9a41bc
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Tab navigation and initialization controller.

document.addEventListener("DOMContentLoaded", () => {
  const tabs = document.querySelectorAll(".tab-btn");
  const panels = document.querySelectorAll(".tab-panel");

  tabs.forEach(btn => {
    btn.addEventListener("click", () => {
      const target = btn.dataset.tab;

      tabs.forEach(t => t.classList.remove("active"));
      panels.forEach(p => p.classList.remove("active"));

      btn.classList.add("active");
      document.getElementById("tab-" + target).classList.add("active");

      // Lazy-init on first access
      if (target === "browser" && typeof initViewer === "function") {
        initViewer();
      }
      if (target === "leaderboard" && typeof initLeaderboard === "function") {
        initLeaderboard();
      }
    });
  });

  // Initialize leaderboard on page load
  if (typeof initLeaderboard === "function") {
    initLeaderboard();
  }
});