summaryrefslogtreecommitdiff
path: root/updater/index.html
blob: b97d287f8d7b3709d07b4559adced60520e30bfc (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
<!doctype html>
<html>
    <head>
        <title>Vainsocial backend status</title>
    </head>
    <body>
        <form id="update-form">
            <input type="text">
            <input type="submit" value="Update">
        </form>

        <ul id="updates"></ul>
        <script src="/socket.io/socket.io.js"></script>
        <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
        <script>
            var socket = io();
            $("#update-form").submit(function(e) {
                var name = $("input:first").val();
                $.get("/api/player/name/" + name).done(function() {
                    $("#updates").append(
                        $("<li>")
                        .text("(found)")
                        .css("color", "black")
                    );
                    /* subscribe to socket notifications */
                    socket.on(name, function(msg) {
                        if (msg == "grab_failed")  {
                            $("#updates").append(
                                $("<li>")
                                .text(name + ": no new data")
                                .css("color", "red")
                            );
                        }
                        if (msg == "process_finished")  {
                            $("#updates").append(
                                $("<li>")
                                .text(name + ": processed")
                                .css("color", "green")
                            );
                        }
                        if (msg == "compile_finished")  {
                            $("#updates").append(
                                $("<li>")
                                .text(name + ": compiled")
                                .css("color", "orange")
                            );
                        }
                    });
                }).fail(function() {
                    $("#updates").append(
                        $("<li>")
                        .text("(not found)")
                        .css("color", "red")
                    );
                });
                e.preventDefault();
            });
        </script>
    </body>
</html>