101 lines
No EOL
4.3 KiB
HTML
101 lines
No EOL
4.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
|
<script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
|
|
<script src="js/index.js"></script>
|
|
<script src="js/localState.js"></script>
|
|
<script src="js/remoteState.js"></script>
|
|
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css" />
|
|
<link rel="stylesheet" href="index.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<main class="container">
|
|
<div x-data>
|
|
<div x-show="$store.remoteState.connected && $store.localState.room">
|
|
<hgroup>
|
|
<h1
|
|
x-text="'Currently playing: ' + ($store.remoteState.isMyTurn ? 'YOU!':$store.remoteState.players[$store.remoteState.currentPlayer])">
|
|
</h1>
|
|
<h2 x-text="'You are ' + $store.localState.name"></h2>
|
|
</hgroup>
|
|
|
|
<div x-data="Timer">
|
|
<p :class="'timer' + ($store.remoteState.isMyTurn ? ' my-turn':'') + (time < 0 ? ' over':'')"
|
|
x-text="time + 's'"></p>
|
|
</div>
|
|
|
|
<button @click="$store.remoteState.giveTurnToNextPlayer()"
|
|
x-bind:disabled="$store.remoteState.currentPlayer !== $store.localState.id">
|
|
I'm done!
|
|
</button>
|
|
|
|
<details class="first-details">
|
|
<summary>Options</summary>
|
|
|
|
|
|
<fieldset>
|
|
<label for="nextPlayer_select">Player after me:
|
|
<b x-text="$store.remoteState.players[$store.localState.nextPlayer]"></b>
|
|
</label>
|
|
<select x-model="$store.localState.nextPlayer" id="nextPlayer_select">
|
|
<template
|
|
x-for="playerId in Object.keys($store.remoteState.players).filter(id => id != $store.localState.id)"
|
|
:key="playerId">
|
|
<option x-bind:value="playerId" x-text="$store.remoteState.players[playerId]"></option>
|
|
</template>
|
|
</select>
|
|
|
|
<label for="sound_enabled">
|
|
<input x-model="$store.audio.isEnabled" @click="$store.audio.testPermission()"
|
|
type="checkbox" id="sound_enabled" name="sound_enabled" role="switch" />
|
|
Enable sound
|
|
</label>
|
|
</fieldset>
|
|
|
|
<button class="invalid outline" @click="$store.localState.leave()" type="submit">
|
|
Leave room
|
|
</button>
|
|
</details>
|
|
|
|
<details>
|
|
<summary>This room</summary>
|
|
|
|
<label for="roomForm_interval">Interval (seconds):</label>
|
|
<input id="roomForm_interval" type="number" x-model.throttle.1000ms="$store.remoteState.interval" placeholder="Interval" />
|
|
|
|
<p>
|
|
Other players:
|
|
<ul>
|
|
<template x-for="playerId in Object.keys($store.remoteState.players)" :key="playerId">
|
|
<li x-text="$store.remoteState.players[playerId]"></li>
|
|
</template>
|
|
</ul>
|
|
</p>
|
|
|
|
<button class="secondary outline" @click="$store.remoteState.clear()">
|
|
Clear player list
|
|
</button>
|
|
</details>
|
|
</div>
|
|
|
|
<div x-show="!$store.remoteState.connected && $store.localState.room">
|
|
<h1 class="timer loading" aria-busy="true">Connecting...</h1>
|
|
</div>
|
|
|
|
<div x-show="!$store.localState.room">
|
|
<form x-data="JoinForm()" @submit.prevent="submitForm">
|
|
<input type="text" x-model="formData.name" placeholder="Name" />
|
|
<input type="text" x-model="formData.room" placeholder="Room" />
|
|
<button type="submit">Join</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</body>
|
|
|
|
</html> |