about summary refs log tree commit diff
path: root/templates/battleNew.html
blob: 1992e1d5f4482af35c901cba203256fcf4605aa5 (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
{{ define "battleNew" }}

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

  <span id="newbattle"></span>
  <h1><a href="#newbattle">New battle</a></h1>
  
  <p>A battle is a <b>collection</b> of fights intended to be fought with multiple bots. In case you just want to try out two bots, create a <a href="/battle/quick">quick</a> battle!</p>
  <br>
  <p>Select the values you find appropriate. Bots can be added to the battle later.</p>

  <br>

  <table>
    <form id="battle" method="POST" action="/battle/new">
      <tr>
        <td><label for="name">Name:</label></td>
        <td><input class="border" type="text" id="name" name="name" autofocus></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}}"
            form="battle"
            {{if eq $arch.Name "x86-64"}}checked{{end}}
            {{if eq $arch.Name "ARM"}}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"
            name="bit-{{$bit.ID}}"
            id="bit-{{$bit.ID}}"
            {{if eq $bit.Name "32"}}checked{{end}}
            {{if eq $bit.Name "64"}}checked{{end}}/>
          <label class="label-for-check" for="bit-{{$bit.ID}}">{{$bit.Name}}</label>
          {{- end }}
        </td>
      </tr>

      <tr>
        <td>Arena size:</td>
        <td>
          <input class="border" type="number" name="arena-size" id="arena-size" value="4096"/>
        </td>
      </tr>

      <tr>
        <td>Max Rounds:</td>
        <td>
          <input class="border" type="number" name="max-rounds" id="max-rounds" value="100"/>
        </td>
      </tr>

      <tr>
        <td>Public:</td>
        <td>
          <input
            type="checkbox"
            name="public"
            id="public"/>
        </td>
      </td>

      <tr>
        <td>Owners</td>
        <td>
          {{ $viewerID := .user.ID }}
          {{ range $idx, $u := .users}}{{if $idx}},{{- end}}
            <input
              type="checkbox"
              class="check-with-label"
              name="owner-{{ $u.ID }}"
              id="owner-{{ $u.ID }}"
              {{if eq $u.ID $viewerID}}checked{{end}}
              />
            <label class="label-for-check" for="owner-{{ $u.ID }}">{{$u.Name}}</label>
          {{- end }}
        </td>
      </tr>

      <tr>
        <td></td>
        <td><input class="border" type="submit" value="Create"></td>
      </tr>

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

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

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