Stop using tables for forms
This commit is contained in:
@@ -320,14 +320,36 @@ p {
|
|||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Forms*/
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
text-align: left;
|
text-align: initial;
|
||||||
max-width: 30em;
|
max-width: 500px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form>* {
|
||||||
|
display: block;
|
||||||
|
margin-left: 3px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form>label {
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form>input[type="submit"],
|
||||||
|
.form>button[type="submit"] {
|
||||||
|
align-self: end;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tables */
|
||||||
|
|
||||||
table:not(.form) {
|
table:not(.form) {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -344,7 +366,7 @@ table:not(.form) {
|
|||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr:not(.form) {
|
tr {
|
||||||
border-bottom: 1px var(--separator) solid;
|
border-bottom: 1px var(--separator) solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,16 +375,6 @@ tr>th {
|
|||||||
padding: 0.2em 0.5em;
|
padding: 0.2em 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: 30em) {
|
|
||||||
|
|
||||||
/* Forms will be stacked on small screens */
|
|
||||||
tr.form>td {
|
|
||||||
float: left;
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-bottom: 1px var(--separator) solid;
|
border-bottom: 1px var(--separator) solid;
|
||||||
@@ -416,12 +428,6 @@ details.request_patch {
|
|||||||
background-color: rgba(128, 0, 255, 0.1);
|
background-color: rgba(128, 0, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form fields */
|
|
||||||
|
|
||||||
.form_input {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* BUTTONS */
|
/* BUTTONS */
|
||||||
button,
|
button,
|
||||||
.button,
|
.button,
|
||||||
@@ -583,7 +589,7 @@ input[type="date"] {
|
|||||||
border: none;
|
border: none;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: var(--input_background);
|
background: var(--input_background);
|
||||||
box-shadow: inset 1px 1px 2px -1px var(--shadow_color);
|
/* box-shadow: inset 1px 1px 2px -1px var(--shadow_color); */
|
||||||
padding: 3px 5px;
|
padding: 3px 5px;
|
||||||
color: var(--input_text);
|
color: var(--input_text);
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
|
@@ -21,80 +21,59 @@
|
|||||||
<!-- The invisible username field is so browsers know which user the form was for -->
|
<!-- The invisible username field is so browsers know which user the form was for -->
|
||||||
<input type="text" autocomplete="username" value="{{.Username}}" style="display: none;" readonly="readonly"/>
|
<input type="text" autocomplete="username" value="{{.Username}}" style="display: none;" readonly="readonly"/>
|
||||||
{{end}}
|
{{end}}
|
||||||
<table class="form">
|
<div class="form">
|
||||||
{{range $field := .Fields}}
|
{{range $field := .Fields}}
|
||||||
<tr class="form">
|
<label for="input_{{$field.Name}}">
|
||||||
{{if eq $field.Type "textarea"}}
|
{{$field.Label}}
|
||||||
<td colspan="2">
|
</label>
|
||||||
{{$field.Label}}<br/>
|
{{if eq $field.Type "text"}}
|
||||||
<textarea id="input_{{$field.Name}}" name="{{$field.Name}}" class="form_input" style="width: 100%; height: 10em; resize: vertical;">{{$field.DefaultValue}}</textarea>
|
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" class="form_input"/>
|
||||||
</td>
|
{{else if eq $field.Type "number"}}
|
||||||
{{else}}
|
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="number" class="form_input"/>
|
||||||
<td>{{$field.Label}}</td>
|
{{else if eq $field.Type "username"}}
|
||||||
<td>
|
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" autocomplete="username" class="form_input"/>
|
||||||
{{if eq $field.Type "text"}}
|
{{else if eq $field.Type "email"}}
|
||||||
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" class="form_input"/>
|
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="email" autocomplete="email" class="form_input"/>
|
||||||
{{else if eq $field.Type "number"}}
|
{{else if eq $field.Type "current-password"}}
|
||||||
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="number" class="form_input"/>
|
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="current-password" class="form_input"/>
|
||||||
{{else if eq $field.Type "username"}}
|
{{else if eq $field.Type "new-password"}}
|
||||||
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" autocomplete="username" class="form_input"/>
|
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="new-password" class="form_input"/>
|
||||||
{{else if eq $field.Type "email"}}
|
{{else if eq $field.Type "textarea"}}
|
||||||
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="email" autocomplete="email" class="form_input"/>
|
<textarea id="input_{{$field.Name}}" name="{{$field.Name}}" class="form_input" style="width: 100%; height: 10em; resize: vertical;">{{$field.DefaultValue}}</textarea>
|
||||||
{{else if eq $field.Type "current-password"}}
|
{{else if eq $field.Type "captcha"}}
|
||||||
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="current-password" class="form_input"/>
|
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||||
{{else if eq $field.Type "new-password"}}
|
<div class="g-recaptcha" data-theme="dark" data-sitekey="{{$field.CaptchaSiteKey}}"></div>
|
||||||
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="new-password" class="form_input"/>
|
{{else if eq $field.Type "radio"}}
|
||||||
{{else if eq $field.Type "captcha"}}
|
{{ range $val := $field.RadioValues}}
|
||||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
<input
|
||||||
<div class="g-recaptcha" data-theme="dark" data-sitekey="{{$field.CaptchaSiteKey}}"></div>
|
id="input_{{$field.Name}}_choice_{{$val}}"
|
||||||
{{else if eq $field.Type "radio"}}
|
name="{{$field.Name}}"
|
||||||
{{ range $val := $field.RadioValues}}
|
value="{{$val}}"
|
||||||
<input
|
type="radio"
|
||||||
id="input_{{$field.Name}}_choice_{{$val}}"
|
{{if eq $val $field.DefaultValue}}checked="checked"{{end}}/>
|
||||||
name="{{$field.Name}}"
|
<label for="input_{{$field.Name}}_choice_{{$val}}">{{$val}}</label><br/>
|
||||||
value="{{$val}}"
|
{{ end }}
|
||||||
type="radio"
|
{{else if eq $field.Type "description"}}
|
||||||
{{if eq $val $field.DefaultValue}}checked="checked"{{end}}/>
|
{{$field.DefaultValue}}
|
||||||
<label for="input_{{$field.Name}}_choice_{{$val}}">{{$val}}</label><br/>
|
{{end}}
|
||||||
{{ end }}
|
{{if ne $field.Description ""}}
|
||||||
{{else if eq $field.Type "description"}}
|
<div>
|
||||||
{{$field.DefaultValue}}
|
{{$field.Description}}
|
||||||
{{end}}
|
</div>
|
||||||
</td>
|
|
||||||
{{end}}
|
|
||||||
</tr>
|
|
||||||
{{if or (ne $field.Description "") (eq $field.Separator true)}}
|
|
||||||
<tr class="form">
|
|
||||||
<td colspan="2">
|
|
||||||
{{$field.Description}}
|
|
||||||
{{if eq $field.Separator true}}
|
|
||||||
<hr/>
|
|
||||||
{{end}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<tr class="form">
|
{{if eq .SubmitRed true}}
|
||||||
{{if eq .BackLink ""}}
|
<button type="submit" class="button_red">
|
||||||
<td colspan="2" style="text-align: right;">
|
<i class="icon">send</i>
|
||||||
{{if eq .SubmitRed true}}
|
{{.SubmitLabel}}
|
||||||
<input type="submit" value="{{.SubmitLabel}}" class="button_red" style="float: right;"/>
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<input type="submit" value="{{.SubmitLabel}}" class="button_highlight" style="float: right;"/>
|
<button type="submit" class="button_highlight">
|
||||||
{{end}}
|
<i class="icon">send</i>
|
||||||
</td>
|
{{.SubmitLabel}}
|
||||||
{{else}}
|
</button>
|
||||||
<td colspan="2" style="text-align: left;">
|
{{end}}
|
||||||
<a href="{{.BackLink}}" class="button button_red" style="float: left;"/>Back</a>
|
</div>
|
||||||
{{if eq .SubmitRed true}}
|
|
||||||
<input type="submit" value="{{.SubmitLabel}}" class="button_red" style="float: right;"/>
|
|
||||||
{{else}}
|
|
||||||
<input type="submit" value="{{.SubmitLabel}}" class="button_highlight" style="float: right"/>
|
|
||||||
{{end}}
|
|
||||||
</td>
|
|
||||||
{{end}}
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
</form>
|
||||||
{{.PostFormHTML}}
|
{{.PostFormHTML}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@@ -129,37 +129,25 @@ onMount(get_reporters);
|
|||||||
{#if creating}
|
{#if creating}
|
||||||
<div class="highlight_shaded">
|
<div class="highlight_shaded">
|
||||||
<form on:submit|preventDefault={create_reporter}>
|
<form on:submit|preventDefault={create_reporter}>
|
||||||
<table class="form">
|
<div class="form">
|
||||||
<tr>
|
<label for="field_from_address">E-mail address</label>
|
||||||
<td>E-mail address</td>
|
<input id="field_from_address" type="text" bind:this={new_reporter_from_address}/>
|
||||||
<td><input type="text" bind:this={new_reporter_from_address}/></td>
|
<label for="field_mailserver">Mail server</label>
|
||||||
</tr>
|
<input id="field_mailserver" type="text" bind:this={new_reporter_mail_server}/>
|
||||||
<tr>
|
<label for="field_name">Name</label>
|
||||||
<td>Mail server</td>
|
<input id="field_name" type="text" bind:this={new_reporter_name} value="Anonymous tip"/>
|
||||||
<td><input type="text" bind:this={new_reporter_mail_server}/></td>
|
<label for="reporter_status">Status</label>
|
||||||
</tr>
|
<div>
|
||||||
<tr>
|
<input id="reporter_status_1" name="reporter_status" type="radio" bind:group={new_reporter_status} value="trusted" />
|
||||||
<td>Name</td>
|
<label for="reporter_status_1">Trusted</label>
|
||||||
<td><input type="text" bind:this={new_reporter_name} value="Anonymous tip"/></td>
|
<br/>
|
||||||
</tr>
|
<input id="reporter_status_2" name="reporter_status" type="radio" bind:group={new_reporter_status} value="rejected" />
|
||||||
<tr>
|
<label for="reporter_status_2">Rejected</label>
|
||||||
<td>Status</td>
|
</div>
|
||||||
<td>
|
<button class="button_highlight" type="submit">
|
||||||
<input id="reporter_status_1" name="reporter_status" type="radio" bind:group={new_reporter_status} value="trusted" />
|
<i class="icon">save</i> Save
|
||||||
<label for="reporter_status_1">Trusted</label>
|
</button>
|
||||||
<br/>
|
</div>
|
||||||
<input id="reporter_status_2" name="reporter_status" type="radio" bind:group={new_reporter_status} value="rejected" />
|
|
||||||
<label for="reporter_status_2">Rejected</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<button class="button_highlight" type="submit" style="float: right;">
|
|
||||||
<i class="icon">save</i> Save
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
@@ -98,41 +98,33 @@ onMount(get_bans);
|
|||||||
{#if creating}
|
{#if creating}
|
||||||
<div class="highlight_shaded">
|
<div class="highlight_shaded">
|
||||||
<form on:submit|preventDefault={create_ban}>
|
<form on:submit|preventDefault={create_ban}>
|
||||||
<table class="form">
|
<div class="form">
|
||||||
<tr>
|
<label for="field_address">IP address</label>
|
||||||
<td>IP address</td>
|
<input id="field_address" type="text" bind:this={new_ban_address}/>
|
||||||
<td><input type="text" bind:this={new_ban_address}/></td>
|
<label for="field_reason">Reason</label>
|
||||||
</tr>
|
<div id="field_reason">
|
||||||
<tr>
|
<input id="reason_unknown" name="reporter_type" type="radio" bind:group={new_ban_reason} value="unknown" />
|
||||||
<td>Reason</td>
|
<label for="reason_unknown">unknown</label>
|
||||||
<td>
|
<br/>
|
||||||
<input id="reason_unknown" name="reporter_type" type="radio" bind:group={new_ban_reason} value="unknown" />
|
<input id="reason_copyright" name="reporter_type" type="radio" bind:group={new_ban_reason} value="copyright" />
|
||||||
<label for="reason_unknown">unknown</label>
|
<label for="reason_copyright">copyright</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="reason_copyright" name="reporter_type" type="radio" bind:group={new_ban_reason} value="copyright" />
|
<input id="reason_child_abuse" name="reporter_type" type="radio" bind:group={new_ban_reason} value="child_abuse" />
|
||||||
<label for="reason_copyright">copyright</label>
|
<label for="reason_child_abuse">child_abuse</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="reason_child_abuse" name="reporter_type" type="radio" bind:group={new_ban_reason} value="child_abuse" />
|
<input id="reason_terrorism" name="reporter_type" type="radio" bind:group={new_ban_reason} value="terorrism" />
|
||||||
<label for="reason_child_abuse">child_abuse</label>
|
<label for="reason_terrorism">terrorism</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="reason_terrorism" name="reporter_type" type="radio" bind:group={new_ban_reason} value="terorrism" />
|
<input id="reason_gore" name="reporter_type" type="radio" bind:group={new_ban_reason} value="gore" />
|
||||||
<label for="reason_terrorism">terrorism</label>
|
<label for="reason_gore">gore</label>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="reason_gore" name="reporter_type" type="radio" bind:group={new_ban_reason} value="gore" />
|
<input id="reason_malware" name="reporter_type" type="radio" bind:group={new_ban_reason} value="malware" />
|
||||||
<label for="reason_gore">gore</label>
|
<label for="reason_malware">malware</label>
|
||||||
<br/>
|
</div>
|
||||||
<input id="reason_malware" name="reporter_type" type="radio" bind:group={new_ban_reason} value="malware" />
|
<button class="button_highlight" type="submit" style="float: right;">
|
||||||
<label for="reason_malware">malware</label>
|
<i class="icon">save</i> Save
|
||||||
</td>
|
</button>
|
||||||
</tr>
|
</div>
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<button class="button_highlight" type="submit" style="float: right;">
|
|
||||||
<i class="icon">save</i> Save
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
@@ -51,7 +51,7 @@ let email_change = {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "new_email",
|
name: "new_email",
|
||||||
label: "New e-mail address",
|
label: "E-mail address",
|
||||||
type: "email",
|
type: "email",
|
||||||
default_value: window.user.email,
|
default_value: window.user.email,
|
||||||
description: `we will send an e-mail to the new address to
|
description: `we will send an e-mail to the new address to
|
||||||
@@ -83,7 +83,7 @@ let name_change = {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "new_username",
|
name: "new_username",
|
||||||
label: "New name",
|
label: "Name",
|
||||||
type: "username",
|
type: "username",
|
||||||
default_value: window.user.username,
|
default_value: window.user.username,
|
||||||
description: `changing your username also changes the name used to
|
description: `changing your username also changes the name used to
|
||||||
@@ -143,15 +143,27 @@ let delete_account = {
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Account settings</h2>
|
<h2>Account settings</h2>
|
||||||
<h3>Change password</h3>
|
<div class="highlight_shaded">
|
||||||
<Form config={password_change}></Form>
|
<h3>Change password</h3>
|
||||||
|
<Form config={password_change}></Form>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<h3>Change e-mail address</h3>
|
<div class="highlight_shaded">
|
||||||
<Form config={email_change}></Form>
|
<h3>Change e-mail address</h3>
|
||||||
|
<Form config={email_change}></Form>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<h3>Change name</h3>
|
<div class="highlight_shaded">
|
||||||
<Form config={name_change}></Form>
|
<h3>Change name</h3>
|
||||||
|
<Form config={name_change}></Form>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<h3>Delete account</h3>
|
<div class="highlight_shaded">
|
||||||
<Form config={delete_account}></Form>
|
<h3>Delete account</h3>
|
||||||
|
<Form config={delete_account}></Form>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
</section>
|
</section>
|
||||||
|
@@ -131,121 +131,107 @@ let handle_errors = (response) => {
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
<table class="form">
|
<div class="form">
|
||||||
{#each config.fields as field}
|
{#each config.fields as field}
|
||||||
<tr class="form">
|
{#if field.type !== "description"}
|
||||||
{#if field.type === "text_area"}
|
<label for="input_{field.name}">
|
||||||
<td colspan="2">
|
{field.label}
|
||||||
{field.label}
|
</label>
|
||||||
<br/>
|
{#if field.type === "text"}
|
||||||
<textarea bind:this={field.binding}
|
<input bind:this={field.binding}
|
||||||
id="input_{field.name}"
|
id="input_{field.name}"
|
||||||
name="{field.name}"
|
name="{field.name}"
|
||||||
class="form_input"
|
value="{field.default_value}"
|
||||||
style="width: 100%; height: 10em; resize: vertical;"
|
type="text"
|
||||||
>{field.default_value}</textarea>
|
class="form_input"/>
|
||||||
</td>
|
{:else if field.type === "text_area"}
|
||||||
{:else if field.type !== "description"}
|
<textarea bind:this={field.binding}
|
||||||
<td>{field.label}</td>
|
id="input_{field.name}"
|
||||||
<td>
|
name="{field.name}"
|
||||||
{#if field.type === "text"}
|
class="form_input"
|
||||||
<input bind:this={field.binding}
|
style="width: 100%; height: 10em; resize: vertical;"
|
||||||
id="input_{field.name}"
|
>{field.default_value}</textarea>
|
||||||
|
{:else if field.type === "number"}
|
||||||
|
<input bind:this={field.binding}
|
||||||
|
id="input_{field.name}"
|
||||||
|
name="{field.name}"
|
||||||
|
value="{field.default_value}"
|
||||||
|
type="number"
|
||||||
|
class="form_input"/>
|
||||||
|
{:else if field.type === "decimal"}
|
||||||
|
<input bind:this={field.binding}
|
||||||
|
id="input_{field.name}"
|
||||||
|
name="{field.name}"
|
||||||
|
value="{field.default_value}"
|
||||||
|
type="number"
|
||||||
|
step="0.1"
|
||||||
|
class="form_input"/>
|
||||||
|
{:else if field.type === "username"}
|
||||||
|
<input bind:this={field.binding}
|
||||||
|
id="input_{field.name}"
|
||||||
|
name="{field.name}"
|
||||||
|
value="{field.default_value}"
|
||||||
|
type="text"
|
||||||
|
autocomplete="username"
|
||||||
|
class="form_input"/>
|
||||||
|
{:else if field.type === "email"}
|
||||||
|
<input bind:this={field.binding}
|
||||||
|
id="input_{field.name}"
|
||||||
|
name="{field.name}"
|
||||||
|
value="{field.default_value}"
|
||||||
|
type="email"
|
||||||
|
autocomplete="email"
|
||||||
|
class="form_input"/>
|
||||||
|
{:else if field.type === "current_password"}
|
||||||
|
<input bind:this={field.binding}
|
||||||
|
id="input_{field.name}"
|
||||||
|
name="{field.name}"
|
||||||
|
value="{field.default_value}"
|
||||||
|
type="password"
|
||||||
|
autocomplete="current-password"
|
||||||
|
class="form_input"/>
|
||||||
|
{:else if field.type === "new_password"}
|
||||||
|
<input bind:this={field.binding}
|
||||||
|
id="input_{field.name}"
|
||||||
|
name="{field.name}"
|
||||||
|
value="{field.default_value}"
|
||||||
|
type="password"
|
||||||
|
autocomplete="new-password"
|
||||||
|
class="form_input"/>
|
||||||
|
{:else if field.type === "captcha"}
|
||||||
|
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
||||||
|
<div class="g-recaptcha" data-theme="dark" data-sitekey="{field.captcha_site_key}"></div>
|
||||||
|
{:else if field.type === "radio"}
|
||||||
|
<div>
|
||||||
|
{#each field.radio_values as val}
|
||||||
|
<input bind:group={field.binding}
|
||||||
|
id="input_{field.name}_choice_{val}"
|
||||||
name="{field.name}"
|
name="{field.name}"
|
||||||
value="{field.default_value}"
|
value={val}
|
||||||
type="text"
|
type="radio"
|
||||||
class="form_input"/>
|
checked={val === field.default_value}/>
|
||||||
{:else if field.type === "number"}
|
<label for="input_{field.name}_choice_{val}">{val}</label><br/>
|
||||||
<input bind:this={field.binding}
|
{/each}
|
||||||
id="input_{field.name}"
|
</div>
|
||||||
name="{field.name}"
|
|
||||||
value="{field.default_value}"
|
|
||||||
type="number"
|
|
||||||
class="form_input"/>
|
|
||||||
{:else if field.type === "decimal"}
|
|
||||||
<input bind:this={field.binding}
|
|
||||||
id="input_{field.name}"
|
|
||||||
name="{field.name}"
|
|
||||||
value="{field.default_value}"
|
|
||||||
type="number"
|
|
||||||
step="0.1"
|
|
||||||
class="form_input"/>
|
|
||||||
{:else if field.type === "username"}
|
|
||||||
<input bind:this={field.binding}
|
|
||||||
id="input_{field.name}"
|
|
||||||
name="{field.name}"
|
|
||||||
value="{field.default_value}"
|
|
||||||
type="text"
|
|
||||||
autocomplete="username"
|
|
||||||
class="form_input"/>
|
|
||||||
{:else if field.type === "email"}
|
|
||||||
<input bind:this={field.binding}
|
|
||||||
id="input_{field.name}"
|
|
||||||
name="{field.name}"
|
|
||||||
value="{field.default_value}"
|
|
||||||
type="email"
|
|
||||||
autocomplete="email"
|
|
||||||
class="form_input"/>
|
|
||||||
{:else if field.type === "current_password"}
|
|
||||||
<input bind:this={field.binding}
|
|
||||||
id="input_{field.name}"
|
|
||||||
name="{field.name}"
|
|
||||||
value="{field.default_value}"
|
|
||||||
type="password"
|
|
||||||
autocomplete="current-password"
|
|
||||||
class="form_input"/>
|
|
||||||
{:else if field.type === "new_password"}
|
|
||||||
<input bind:this={field.binding}
|
|
||||||
id="input_{field.name}"
|
|
||||||
name="{field.name}"
|
|
||||||
value="{field.default_value}"
|
|
||||||
type="password"
|
|
||||||
autocomplete="new-password"
|
|
||||||
class="form_input"/>
|
|
||||||
{:else if field.type === "captcha"}
|
|
||||||
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
|
||||||
<div class="g-recaptcha" data-theme="dark" data-sitekey="{field.captcha_site_key}"></div>
|
|
||||||
{:else if field.type === "radio"}
|
|
||||||
{#each field.radio_values as val}
|
|
||||||
<input bind:group={field.binding}
|
|
||||||
id="input_{field.name}_choice_{val}"
|
|
||||||
name="{field.name}"
|
|
||||||
value={val}
|
|
||||||
type="radio"
|
|
||||||
checked={val === field.default_value}/>
|
|
||||||
<label for="input_{field.name}_choice_{val}">{val}</label><br/>
|
|
||||||
{/each}
|
|
||||||
{/if}
|
|
||||||
</td>
|
|
||||||
{/if}
|
{/if}
|
||||||
</tr>
|
{/if}
|
||||||
{#if field.description}
|
{#if field.description}
|
||||||
<tr class="form">
|
<div>
|
||||||
<td colspan="2">
|
{@html field.description}
|
||||||
{@html field.description}
|
</div>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if field.separator}
|
{#if field.separator}
|
||||||
<tr class="form">
|
<hr/>
|
||||||
<td colspan="2">
|
|
||||||
<hr/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
<!-- Submit button -->
|
<!-- Submit button -->
|
||||||
<tr class="form">
|
{#if config.submit_red}
|
||||||
<td colspan="2" style="text-align: right;">
|
<button type="submit" class="button_red">{@html config.submit_label}</button>
|
||||||
{#if config.submit_red}
|
{:else}
|
||||||
<button type="submit" class="button_red" style="float: right;">{@html config.submit_label}</button>
|
<button type="submit" class="button_highlight">{@html config.submit_label}</button>
|
||||||
{:else}
|
{/if}
|
||||||
<button type="submit" class="button_highlight" style="float: right;">{@html config.submit_label}</button>
|
</div>
|
||||||
{/if}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@@ -18,7 +18,6 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f
|
|||||||
Name: "admin_globals",
|
Name: "admin_globals",
|
||||||
Title: "Pixeldrain global configuration",
|
Title: "Pixeldrain global configuration",
|
||||||
PreFormHTML: template.HTML("<p>Careful! The slightest typing error could bring the whole website down</p>"),
|
PreFormHTML: template.HTML("<p>Careful! The slightest typing error could bring the whole website down</p>"),
|
||||||
BackLink: "/admin",
|
|
||||||
SubmitLabel: "Submit",
|
SubmitLabel: "Submit",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ type Form struct {
|
|||||||
|
|
||||||
Fields []Field
|
Fields []Field
|
||||||
|
|
||||||
BackLink string // Empty for no back link
|
|
||||||
SubmitLabel string // Label for the submit button
|
SubmitLabel string // Label for the submit button
|
||||||
SubmitRed bool // If the submit button should be red or green
|
SubmitRed bool // If the submit button should be red or green
|
||||||
|
|
||||||
@@ -53,9 +52,6 @@ type Field struct {
|
|||||||
// Text below the input field
|
// Text below the input field
|
||||||
Description template.HTML
|
Description template.HTML
|
||||||
|
|
||||||
// Separates fields with a horizontal rule
|
|
||||||
Separator bool
|
|
||||||
|
|
||||||
Type FieldType
|
Type FieldType
|
||||||
|
|
||||||
// Only used when Type == FieldTypeCaptcha
|
// Only used when Type == FieldTypeCaptcha
|
||||||
|
@@ -99,7 +99,6 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
|||||||
Name: "username",
|
Name: "username",
|
||||||
Label: "Username",
|
Label: "Username",
|
||||||
Description: "used for logging into your account",
|
Description: "used for logging into your account",
|
||||||
Separator: true,
|
|
||||||
Type: FieldTypeUsername,
|
Type: FieldTypeUsername,
|
||||||
}, {
|
}, {
|
||||||
Name: "email",
|
Name: "email",
|
||||||
@@ -107,8 +106,7 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
|||||||
Description: `not required. your e-mail address will only be
|
Description: `not required. your e-mail address will only be
|
||||||
used for password resets and important account
|
used for password resets and important account
|
||||||
notifications`,
|
notifications`,
|
||||||
Separator: true,
|
Type: FieldTypeEmail,
|
||||||
Type: FieldTypeEmail,
|
|
||||||
}, {
|
}, {
|
||||||
Name: "password",
|
Name: "password",
|
||||||
Label: "Password",
|
Label: "Password",
|
||||||
@@ -119,8 +117,7 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
|||||||
Description: "you need to enter your password twice so we " +
|
Description: "you need to enter your password twice so we " +
|
||||||
"can verify that no typing errors were made, which would " +
|
"can verify that no typing errors were made, which would " +
|
||||||
"prevent you from logging into your new account",
|
"prevent you from logging into your new account",
|
||||||
Separator: true,
|
Type: FieldTypeNewPassword,
|
||||||
Type: FieldTypeNewPassword,
|
|
||||||
}, {
|
}, {
|
||||||
Name: "recaptcha_response",
|
Name: "recaptcha_response",
|
||||||
Label: "reCaptcha",
|
Label: "reCaptcha",
|
||||||
@@ -128,12 +125,10 @@ func (wc *WebController) registerForm(td *TemplateData, r *http.Request) (f Form
|
|||||||
"are not an evil robot that is trying to flood the " +
|
"are not an evil robot that is trying to flood the " +
|
||||||
"website with fake accounts. Please click the white box " +
|
"website with fake accounts. Please click the white box " +
|
||||||
"to prove that you're not a robot",
|
"to prove that you're not a robot",
|
||||||
Separator: true,
|
|
||||||
Type: FieldTypeCaptcha,
|
Type: FieldTypeCaptcha,
|
||||||
CaptchaSiteKey: wc.captchaKey(),
|
CaptchaSiteKey: wc.captchaKey(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
BackLink: "/",
|
|
||||||
SubmitLabel: "Register",
|
SubmitLabel: "Register",
|
||||||
PostFormHTML: template.HTML("<p>Welcome to the club!</p>"),
|
PostFormHTML: template.HTML("<p>Welcome to the club!</p>"),
|
||||||
}
|
}
|
||||||
@@ -181,7 +176,6 @@ func (wc *WebController) loginForm(td *TemplateData, r *http.Request) (f Form) {
|
|||||||
Type: FieldTypeCurrentPassword,
|
Type: FieldTypeCurrentPassword,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
BackLink: "/",
|
|
||||||
SubmitLabel: "Login",
|
SubmitLabel: "Login",
|
||||||
PostFormHTML: template.HTML(
|
PostFormHTML: template.HTML(
|
||||||
`<p>If you don't have a pixeldrain account yet, you can ` +
|
`<p>If you don't have a pixeldrain account yet, you can ` +
|
||||||
@@ -240,19 +234,16 @@ func (wc *WebController) passwordResetForm(td *TemplateData, r *http.Request) (f
|
|||||||
Label: "E-mail address",
|
Label: "E-mail address",
|
||||||
Description: `we will send a password reset link to this e-mail
|
Description: `we will send a password reset link to this e-mail
|
||||||
address`,
|
address`,
|
||||||
Separator: true,
|
Type: FieldTypeEmail,
|
||||||
Type: FieldTypeEmail,
|
|
||||||
}, {
|
}, {
|
||||||
Name: "recaptcha_response",
|
Name: "recaptcha_response",
|
||||||
Label: "Turing test (click the white box)",
|
Label: "Turing test (click the white box)",
|
||||||
Description: "the reCaptcha turing test verifies that you " +
|
Description: "the reCaptcha turing test verifies that you " +
|
||||||
"are not an evil robot that is trying hijack accounts",
|
"are not an evil robot that is trying hijack accounts",
|
||||||
Separator: true,
|
|
||||||
Type: FieldTypeCaptcha,
|
Type: FieldTypeCaptcha,
|
||||||
CaptchaSiteKey: wc.captchaKey(),
|
CaptchaSiteKey: wc.captchaKey(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
BackLink: "/login",
|
|
||||||
SubmitLabel: "Submit",
|
SubmitLabel: "Submit",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,8 +278,7 @@ func (wc *WebController) passwordResetConfirmForm(td *TemplateData, r *http.Requ
|
|||||||
Description: "you need to enter your password twice so we " +
|
Description: "you need to enter your password twice so we " +
|
||||||
"can verify that no typing errors were made, which would " +
|
"can verify that no typing errors were made, which would " +
|
||||||
"prevent you from logging into your new account",
|
"prevent you from logging into your new account",
|
||||||
Separator: true,
|
Type: FieldTypeNewPassword,
|
||||||
Type: FieldTypeNewPassword,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
SubmitLabel: "Submit",
|
SubmitLabel: "Submit",
|
||||||
|
Reference in New Issue
Block a user