Spaces:
Running
Running
Download js/main.js from HelloSun/empire-web: direct link, hf CLI and curl.
- Browser
- Download file 471 Bytes
-
https://huggingface.co/spaces/HelloSun/empire-web/resolve/main/js/main.js
- Command line
-
hf download hf://spaces/HelloSun/empire-web/js/main.js
-
curl -L -o main.js https://huggingface.co/spaces/HelloSun/empire-web/resolve/main/js/main.js
471 Bytes
| import { Game } from './game.js'; | |
| import { UI } from './ui.js'; | |
| const game = new Game(); | |
| const ui = new UI(game); | |
| window.__empire = { game, ui }; | |
| ui.init(); | |
| // Auto-save when the tab is closed or backgrounded. | |
| window.addEventListener('beforeunload', () => { | |
| if (game.state && !game.state.isOver) game.save(); | |
| }); | |
| document.addEventListener('visibilitychange', () => { | |
| if (document.visibilityState === 'hidden' && game.state && !game.state.isOver) game.save(); | |
| }); | |