aboutsummaryrefslogtreecommitdiff
path: root/src/scores.html
blob: f3b1050ed3168dbc2511e6f5a6ca5202b7c4c95e (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
<!doctype html>
<html lang="en">

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

<body>
    <script>
        window.onload = function () {
            var transactionData = new Vue({
                el: '#main',
                data: {
                    scores: [],
                },
                created() {
                    fetch(new Request(`/scores`)).then(response => response.json())
                        .then(response => this.scores = response);

                },
            });
        }
    </script>
    <div id="main">
        <h1>High Scores</h1>
        <div v-for="game in Object.keys(scores)">
            <h2>{{game}}</h2>
            <table class="table">
                <tr>
                    <th>Rank</th>
                    <th>Score</th>
                    <th>Username</th>
                    <th>Date</th>
                </tr>
                <tr v-for="(item, i) in scores[game]">
                    <td>{{i+1}}</td>
                    <td>{{item.score}}</td>
                    <td>{{item.username}}</td>
                    <td>{{item.createdAt.substring(0, 16).replace("T", " ")}}</td>
                </tr>
            </table>
        </div>
    </div>
</body>

</html>