This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
forms.html
124 lines (116 loc) · 4.37 KB
/
forms.html
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
{% import "github.com/bakape/meguca/config" %}
{% import "github.com/bakape/meguca/lang" %}
OwnedBoard renders a form for selecting one of several boards owned by the
user
{% func OwnedBoard(boards config.BoardTitles, lang map[string]string) %}{% stripspace %}
{% if len(boards) != 0 %}
<select name="boards" required>
{% for _, b := range boards %}
<option value="{%s= b.ID %}">
{%= formatTitle(b.ID, b.Title) %}
</option>
{% endfor %}
</select>
<br>
<input type="submit" value="{%s= lang["submit"] %}">
{% else %}
{%s= lang["ownNoBoards"] %}
<br>
<br>
{% endif %}
<input type="button" name="cancel" value="{%s= lang["cancel"] %}">
<div class="form-response admin"></div>
{% endstripspace %}{% endfunc %}
{% func formatTitle(id, title string) %}{% stripspace %}
/{%s= id %}/ - {%s title %}
{% endstripspace %}{% endfunc %}
BoardNavigation renders a board selection and search form
{% func BoardNavigation(lang map[string]string) %}{% stripspace %}
<input type="text" class="full-width" name="search" placeholder="{%s= lang["search"] %}">
<br>
<form>
<input type="submit" value="{%s= lang["apply"] %}">
<input type="button" name="cancel" value="{%s= lang["cancel"] %}">
<br>
{% for _, b := range config.GetBoardTitles() %}
<label>
<input type="checkbox" name="{%s= b.ID %}">
<a href="/{%s= b.ID %}/" class="history">
{%= formatTitle(b.ID, b.Title) %}
</a>
<br>
</label>
{% endfor %}
</form>
{% endstripspace %}{% endfunc %}
CreateBoard renders a the form for creating new boards
{% func CreateBoard(ln lang.Pack) %}{% stripspace %}
{%s= renderTable(specs["createBoard"], ln) %}
<input type="submit" value="{%s= ln.UI["submit"] %}">
{%= captcha("create-board", ln.UI) %}
<input type="button" name="cancel" value="{%s= ln.UI["cancel"] %}">
<div class="form-response admin"></div>
{% endstripspace %}{% endfunc %}
{% func captcha(id string, lang map[string]string) %}{% stripspace %}
{% code conf := config.Get() %}
{% if !conf.Captcha %}
{% return %}
{% endif %}
<div class="captcha-container" id="captcha-{%s= id %}">
<div id="adcopy-outer-{%s= id %}">
<div id="adcopy-puzzle-image-{%s= id %}" class="captcha-image" title="{%s= lang["reloadCaptcha"] %}"></div>
<div id="adcopy-puzzle-audio-{%s= id %}" class="hidden"></div>
<div id="adcopy-pixel-image-{%s= id %}" class="hidden"></div>
<div>
<span id="adcopy-instr-{%s= id %}" class="hidden"></span>
</div>
<input id="adcopy_response-{%s= id %}" name="adcopy_response" class="full-width" type="text" placeholder="{%s= lang["focusForCaptcha"] %}" required>
<input type="hidden" name="adcopy_challenge" id="adcopy_challenge-{%s= id %}" hidden>
<a id="adcopy-link-refresh-{%s= id %}" class="hidden"></a>
<a id="adcopy-link-audio-{%s= id %}" class="hidden"></a>
<a id="adcopy-link-image-{%s= id %}" class="hidden"></a>
<a id="adcopy-link-info-{%s= id %}" class="hidden"></a>
<!-- Temporary, till better noscript support >
<noscript>
<iframe src="https://api-secure.solvemedia.com/papi/challenge.noscript?k={%s= conf.CaptchaPublicKey %}"
height="260" width="350" frameborder="0"></iframe>
<br>
<input name="adcopy_challenge" type="text" required>
</noscript>
<-->
</div>
</div>
{% endstripspace %}{% endfunc %}
Form for inputing key-value map-like data
{% func keyValueForm(k, v string) %}{% stripspace %}
<span>
<input type="text" class="map-field" value="{%s k %}">
<input type="text" class="map-field" value="{%s v %}">
<a class="map-remove">
[X]
</a>
<br>
</span>
{% endstripspace %}{% endfunc %}
Form fommatted as a table, with cancel and submit buttons
{% func tableForm(specs []inputSpec, needCaptcha bool, ln lang.Pack) %}{% stripspace %}
{%s= renderTable(specs, ln) %}
{% if needCaptcha %}
{%= captcha("ajax", ln.UI) %}
{% endif %}
<input type="submit" value="{%s= ln.UI["submit"] %}">
<input type="button" name="cancel" value="{%s= ln.UI["cancel"] %}">
<div class="form-response admin"></div>
{% endstripspace %}{% endfunc %}
Render a map form for inputting map-like data
{% func renderMap(spec inputSpec, ln lang.Pack) %}{% stripspace %}
<div class="map-form" name="{%s= spec.ID %}" title="{%s= ln.Forms[spec.ID][1] %}">
{% for k, v := range spec.Val.(map[string]string) %}
{%= keyValueForm(k, v) %}
{% endfor %}
<a class="map-add">
{%s= ln.UI["add"] %}
</a>
<br>
</div>
{% endstripspace %}{% endfunc %}