'use strict'; console.log(window.location); const isTest = false; // Set to true for testing with mock data const roomsDiv = document.getElementById('rooms'); const searchInput = document.getElementById('searchInput'); const searchBtn = document.getElementById('search-btn'); const refreshBtn = document.getElementById('refresh-btn'); let allRooms = []; searchBtn.addEventListener('click', handleSearch); refreshBtn.addEventListener('click', fetchRooms); function setRoomsContent(html) { roomsDiv.innerHTML = html; } function getRoomsData(res) { return !isTest ? res.data.activeRooms || [] : mockRooms(); } function mockRooms(roomCount = 1000) { return Array.from({ length: roomCount }, () => { const id = getUUID(); return { id, peers: Math.floor(Math.random() * 10) + 1, join: `${window.location.origin}/${id}`, }; }); } function getUUID() { return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) ); } async function fetchRooms() { setRoomsContent('