aboutsummaryrefslogtreecommitdiff
path: root/src/quiz-bunny/index.html
blob: 9b0a6db980b50475cb8132010c375037022393f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!doctype html>
<html lang="en">

<head>
    <title>Quiz Bunny</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="shortcut icon" href="/favicon.ico">
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="/quiz-bunny/main.js"></script>
    <link rel="stylesheet" type="text/css" href="/quiz-bunny/styles.css">
</head>

<body>
    <div id="data">
        <div v-if="!game" class="center">
            <h1>
                Quiz Bunny
            </h1>
            <div>
                <div>
                    <input style="width: 390px;" type="text" placeholder="username" v-model="username">
                </div>
                <div>
                    <input style="width: 100%;" type="button" value="Host game" v-on:click="hostGame"
                        :disabled="username.length == 0">
                </div>
                <div>
                    <input type="text" placeholder="game code" v-model="gameCode" style="width: 300px;"
                        v-on:keyup.enter="joinGame">
                    <input type="button" value="Join game" v-on:click="joinGame"
                        :disabled="username.length == 0 || gameCode.length == 0">
                </div>
            </div>
        </div>
        <div v-if="game" class="center">
            <div v-if="!game.gameStarted">
                <h1>Game Code:</h1>
                <h2>{{game.gameCode}}</h2>
                <h1>Players</h1>
                <ul v-for="player in game.players">
                    <li>{{player.name}}</li>
                </ul>
                <div v-if="game.host">
                    <input type="button" value="Start game" v-on:click="startGame">
                </div>
            </div>
            <div v-else>
                <h1>{{game.round+1}}/{{game.maxRound}}</h1>
                <div v-if="game.state == STATES.TYPING" class="typing">
                    <h1>Answer:</h1>
                    <h2>{{game.prompt}}</h2>
                    <input type="text" placeholder="answer" v-model="submitText" :disabled="game.submitted"
                        v-on:keyup.enter="submitAnswer">
                    <input type="button" value="Submit" v-on:click="submitAnswer" :disabled="submitText.length == 0"
                        v-if="!game.submitted">
                    <div class="readyList">
                        <h4>Waiting:</h4>
                        <ul>
                            <li v-for="player in nonReady(game.players)">
                                {{player.name}}
                            </li>
                        </ul>
                    </div>
                </div>
                <div v-if="game.state == STATES.VOTING" class="voting">
                    <h1>Vote:</h1>
                    <h2>{{game.prompt}}</h2>
                    <div v-for="(answer, i) in game.answers">
                        <input style="width: 100%" type="button" :value="answer" v-on:click="submitVote(i)"
                            :disabled="game.voted">
                    </div>
                    <div class="readyList">
                        <h4>Waiting:</h4>
                        <ul>
                            <li v-for="player in nonReady(game.players)">
                                {{player.name}}
                            </li>
                        </ul>
                    </div>
                </div>
                <div v-if="game.state == STATES.WAITING" class="waiting">
                    <h1>Results:</h1>
                    <h2>{{game.prompt}}</h2>
                    <table>
                        <tr>
                            <th>Answer</th>
                            <th>Author</th>
                            <th>Votes</th>
                            <th>Endorsements</th>
                        </tr>
                        <tr v-for="(answer, i) in game.answers">
                            <td>{{answer.text}}</td>
                            <td>{{answer.name}}</td>
                            <td>{{answer.voteCount}}</td>
                            <td><p v-for="name in answer.voteNames">{{name}}</p></td>
                        </tr>
                    </table>
                    <input type="button" value="Ready" v-on:click="ready" :disabled="game.ready">
                    <div class="readyList">
                        <h4>Waiting:</h4>
                        <ul>
                            <li v-for="player in nonReady(game.players)">
                                {{player.name}}
                            </li>
                        </ul>
                    </div>
                </div>
                <div v-if="game.state == STATES.OVER">
                    <h1>Scores:</h1>
                    <ol>
                        <li v-for="(score, i) in game.scores"><span>{{score.name}}</span><span>{{score.score}}</span>
                        </li>
                    </ol>
                    <input type="button" value="Leave" v-on:click="leave">
                </div>
            </div>
        </div>
    </div>
</body>

</html>