about summary refs log tree commit diff
path: root/templates/battleSingle.html
blob: 267a0df540da00c38087ec62b2437fc6aedb7c5b (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
{{ define "battleSingle" }}

{{ template "head" . }}
<body>
  {{ template "nav" . }}

  <span id="battle"></span>
  <h1><a href="#battle">{{ .battle.Name }}</a></h1>

  <pre>
<a href="#settings">Settings</a>
<a href="#registered-bots">Registered Bots</a>
<a href="#output">Output</a>
<a href="#debug">Debug</a>
  </pre>

  <span id="settings"></span>
  <h2><a href="#settings">Settings</a></h2>

  <table>
    <tbody>
      <form id="battle" method="POST" action="/battle/{{ .battle.ID }}">
        <tr>
          <td><label for="name">Name:</label></td>
          <td><input class="border" type="text" id="name" name="name" value="{{ .battle.Name }}"></td>
        </tr>

        <!--
        <tr>
          <td><label for="latestBotSubmission">Latest Bot Submission</label></td>
          <td><input
                class="border"
                type="datetime-local"
                id="latestBotSubmission"
                name="latestBotSubmission"
                value="2024-11-08T12:00"
                ></td>
        </tr>

        <tr>
          <td><label for="battleStart">Battle Start</label></td>
          <td><input
                class="border"
                type="datetime-local"
                id="battleStart"
                name="battleStart"
                value="2024-11-08T16:00"
                ></td>
        </tr>

        <tr>
          <td><label for="owners">Owners:</label></td>
          <td>
            {{ range $idx, $usr := .battle.Owners }}{{if $idx}},{{end}}<a href="/user/{{ $usr.ID }}">{{ $usr.Name }}</a>{{ end }}
          </td>
        </tr>
        -->

        <tr>
          <td><label for="bots">Bots submitted:</label></td>
          <td>
            {{ range $idx, $bot := .battle.Bots }}{{if $idx}},{{end}}<a href="/bot/{{ $bot.ID }}">{{ $bot.Name }}</a>{{ end }}
          </td>
        </tr>

        <!--
        <tr>
          <td><label for="public">Public?</label></td>
          <td><input type="checkbox" id="public" name="public" {{ if .battle.Public }}checked{{end}}/></td>
        </tr>
        -->

        <tr>
          <td>Archs</td>
          <td>
            {{ range $idx, $arch := .archs }}{{if $idx}},{{end}}
              <input
                type="checkbox"
                class="check-with-label"
                name="arch-{{$arch.ID}}"
                id="arch-{{$arch.ID}}"
                {{if $arch.Enabled}}checked{{end}}/>
              <label class="label-for-check" for="arch-{{$arch.ID}}">{{$arch.Name}}</label>
            {{- end }}
          </td>
        </td>

        <tr>
          <td>Bits</td>
          <td>{{ range $idx, $bit := .bits }}{{if $idx}},{{end}}
            <input
              type="checkbox"
              class="check-with-label"
              id="bit-{{$bit.ID}}"
              name="bit-{{$bit.ID}}"
              {{if $bit.Enabled}}checked{{end}}/>
            <label class="label-for-check" for="bit-{{$bit.ID}}">{{$bit.Name}}</label>
            {{- end }}
          </td>
        </tr>

        <tr>
          <td></td>
          <td>
            <table>
              <tr>
                <td style="width: 33%;"><input class="border" type="submit" value="Save"></td>
                <td style="width: 33%;"></td>
                <td style="width: 33%; ">
                  <!--<input type="submit" value="Delete this battle" form="delete" style="border: 1px solid red; ">-->
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </form>


    {{ if .res }}
    <tr>
      <td></td>
      <td><div style="border: 1px solid blue; padding: 1ex">{{ .res }}</div></td>
    </tr>
    {{ end }}

    <tr>
      <td><br><hr><br></td>
      <td><br><hr><br></td>
    </tr>

    {{ if .myBots }}

    <form method="POST" action="/battle/{{ .battle.ID }}/submit">
      <tr>
        <td><label for="name">My Bots</label></td>
        <td style="width: 100%;">
          <table style="width: 100%;">
              {{ range $bot := .myBots  }}
              <tr class="trhover">
                <td style="text-align: center; vertical-align: middle; width: 2ex;">
                  <input
                    type="checkbox"
                    id="bot-{{$bot.ID}}"
                    name="bot-{{$bot.ID}}"
                    value="{{$bot.ID}}"
                    {{ range $bbot := $.battle.Bots }}
                    {{ if eq $bot.ID $bbot.ID }}checked{{ end }}
                    {{ end }}
                    />
                  <label for="bot-{{$bot.ID}}">
                    <a href="/bot/{{$bot.ID}}">{{$bot.Name}}</a>
                  </label>
                </td>
                <td style="vertical-align: middle">
                </td>
              </tr>
              {{ end }}
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="5"><input class="border" type="submit" value="Submit bots"></td>
      </tr>
    </form>

    {{ else }}

    <tr>
      <td></td>
      <td><a href='/bot/new'>Upload a bot</a> to get started!</td>
    </tr>

    {{ end }}

    </tbody>
  <table>

  <br>

  <form method="POST" action="/battle/{{ .battle.ID }}/run">
    <input class="border" type="submit" value="Run the Battle">
  </form>

  <br><br>

  <form id="delete" method="POST" action="/battle/{{ .battle.ID }}/delete">
    <input type="submit" value="Delete this battle" form="delete" style="border: 1px solid red; ">
  </form>

  <span id="registered bots"></span>
  <h2><a href="#registered-bots">Registered Bots</a></h2>

  {{ range $idx, $bot := .battle.Bots}}{{if $idx}}, {{end}}<a href="/bot/{{ $bot.ID }}">{{ $bot.Name }}</a>{{ end -}}

  <span id="output"></span>
  <h2><a href="#output">Output</a></h2>

  <pre>{{ .battle.RawOutput }}</pre>

  <span id="debug"></span>
  <h2><a href="#debug">Debug</a></h2>

  <pre>{{ .battle }}</pre>
</body>
{{ template "footer" . }}
{{ end }}