aboutsummaryrefslogtreecommitdiff
path: root/resource/session.html
blob: 6adb83a66df4097d442a69a1f58fef5d2e1a53de (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<html>

<head>
    <title>hive mind draft</title>
    <meta charset="utf-8">
    <style>
        * {
          box-sizing: border-box;
        }
        
        .img-container {
          float: left;
          width: 384px;
          height: 534px;
          padding: 20px;
        }

        div.img-container img {
            z-index: -1;
        }
        
        .clearfix::after {
          content: "";
          clear: both;
          display: table;
        }

        div.zhsdesc {
            visibility: hidden;
            position: relative;
            top: -110px;
            left: 7px;
            width: 170px; 
            border: 2px black; 
            font-size: 10px; 
            margin: 7px;
            padding: 7px;
            z-index: 9999;
        }
        div.img-container:hover :nth-child(3) {
            background-color: #ffffff; 
            visibility: visible;
            display: block;
        }
    </style>
</head>

<body>
    <p>当前游戏状态: {{state}}</p>

    <table border="1">
        {{#players}}
        <tr>
            <td>{{nick}}</td>
            <td>{{packnum}}</td>
        </tr>
        {{/players}}
    </table>

    {{#download}}
        <a href="/download/{{sessionid}}">下载牌组列表</a>
    {{/download}}

    {{#start}}
        <br><br>
        <form action="/start-session/{{sessionid}}" method="POST">
            <input type="submit" value="开始">
        </form>
    {{/start}}

    {{#join}}
        <br><br>
        <form action="/join/{{sessionid}}" method="POST">
            <label for="nickname">名字:</label><br>
            <input type="text" id="nickname" name="nickname" value=""><br>
            <input type="submit" value="加入"> 
        </form>
    {{/join}}


    <h1>可选牌</h1>
    <div class="clearfix">
        {{#cardstopick}}
        <div class="img-container">
            <div><form action="/select/{{sessionid}}/{{nameurl}}" method="POST">
                <input type="submit" value="{{name}}">
            </form></div>
            <img class="cardimg" src="{{imgurl}}" alt="{{name}}" style="width:100%">
            <!-- {{{stab}}}
            <div class="zhsdesc">
                <p>{{{zhstext}}}</p>
            </div> -->
        </div>
        {{/cardstopick}}
    </div>

    <h1>已选牌</h1>

    <div class="clearfix">
        {{#cardspicked}}
        <div class="img-container">
            <div></div>
            <img class="cardimg" src="{{imgurl}}" alt="{{name}}" style="width:100%">
            <!-- {{{stab}}}
            <div class="zhsdesc">
                <p>{{{zhstext}}}</p>
            </div> -->
        </div>
        {{/cardspicked}}
    </div>


<script>

window.lastUpdate = 0;

function reqListener () {
    if (this.readyState != 4 || this.status != 200) {
        return;
    }
    console.log(this.responseText);
    let timestamp = parseInt(this.responseText);
    if (window.lastUpdate == 0) {
        window.lastUpdate = timestamp;
        return;
    }
    if (window.lastUpdate < timestamp) {
        window.lastUpdate = timestamp;
        location.reload(); 
    }
}

function checkTimestamp() {
    var oReq = new XMLHttpRequest();
    oReq.onreadystatechange = reqListener;
    var url = window.location.href;
    oReq.open("GET", url.replace("/session/", "/timestamp/"), true);
    oReq.send();
}
checkTimestamp();
setInterval(checkTimestamp, 5000);

</script>

</body>

</html>