(function () { 'use strict'; const { Store, esc, chips } = App; const nameInput = document.getElementById('name'); const nameError = document.getElementById('name-error'); const listEl = document.getElementById('list'); const countEl = document.getElementById('count'); nameInput.value = Store.name; nameInput.addEventListener('input', () => { Store.name = nameInput.value.trim(); nameInput.classList.remove('invalid'); nameError.textContent = ''; }); function requireName() { if (Store.name) return true; nameInput.classList.add('invalid'); nameError.textContent = '先に名前を入力してください。'; nameInput.focus(); return false; } // 管理者だけにハンドレンジ学習へのリンクを出す(ページ自体もサーバ側で管理者以外は 404) App.api('GET', '/api/me') .then((me) => { document.getElementById('range-link').hidden = !me.admin; }) .catch(() => {}); document.getElementById('create').addEventListener('click', () => { if (requireName()) location.href = '/create'; }); listEl.addEventListener('click', (e) => { const btn = e.target.closest('[data-join]'); if (btn && requireName()) location.href = '/table/' + encodeURIComponent(btn.dataset.join); }); const MODE_LABEL = { chips: '💰 キャッシュオンリー', friends: '🃏 友人戦', cpu: '🤖 CPU戦' }; function phaseBadge(t) { if (t.paused) return 'PAUSED'; if (t.phase === 'WAITING') return 'WAITING'; return 'PLAYING'; } function render(tables) { countEl.textContent = tables.length ? `${tables.length} テーブル` : ''; if (!tables.length) { listEl.innerHTML = '