Files
hitstar/public/js/main.js
Elmar Kresse 35b88c0b29
All checks were successful
Build and Push Docker Image / docker (push) Successful in 9s
refactor: Modularize JavaScript Code into Separate Files
2025-09-05 14:41:55 +02:00

24 lines
645 B
JavaScript

import { state } from './state.js';
import { connectWS } from './ws.js';
import { onMessage } from './handlers.js';
import { wireUi } from './ui.js';
import { $nameLobby } from './dom.js';
// Initialize UI and open WebSocket connection
wireUi();
connectWS(onMessage);
// Restore name/id immediately for initial render smoothness
(() => {
try {
const savedPid = localStorage.getItem('playerId');
if (savedPid && !state.playerId) {
state.playerId = savedPid;
}
} catch {}
const saved = localStorage.getItem('playerName');
if (saved && $nameLobby && $nameLobby.value !== saved) {
$nameLobby.value = saved;
}
})();