ctrl+return to send, english default source
All checks were successful
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 2m57s
mozhi pipeline / Build and publish artifacts (push) Successful in 12m55s

This commit is contained in:
Arya 2023-09-10 19:11:45 +05:30
parent a2ae02f6d7
commit 197296e91f
Signed by: arya
GPG Key ID: 842D12BDA50DF120
2 changed files with 21 additions and 3 deletions

View File

@ -62,5 +62,6 @@ func HandleIndex(c *fiber.Ctx) error {
"To": to,
"TtsFrom": ttsFrom,
"TtsTo": ttsTo,
"defaultLang": "en",
})
}

View File

@ -5,7 +5,9 @@
Translate with: <a href="#" class="selected-option">{{.Engine}}</a>
<ul class="options">
{{range .enginesNames}}
<a href="/?engine={{.}}"><li>{{.}}</li></a>
<a href="/?engine={{.}}">
<li>{{.}}</li>
</a>
{{end}}
</ul>
</div>
@ -18,11 +20,15 @@
<div class="wrap languages">
<div class="language">
<select name="from" aria-label="Source language">
{{range $key, $value := .SourceLanguages}}
{{range $key, $value := .SourceLanguages}} {{if $.From}}
<option value="{{ .Id }}" {{if eq $.From .Id}}selected{{end}}>
{{ .Name }}
</option>
{{end}}
{{else}}
<option value="{{ .Id }}" {{if eq .Id $.defaultLang}}selected{{end}}>
{{ .Name }}
</option>
{{end}} {{end}}
</select>
</div>
@ -91,5 +97,16 @@
<button type="submit">Translate with {{ .Engine }}!</button>
</div>
</form>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
// this code submits the translation form when pressing Ctrl/Meta+Enter while focussed on the input text field
document
.getElementById("input")
.addEventListener("keydown", function (event) {
if (event.keyCode === 13 && (event.metaKey || event.ctrlKey)) {
document.getElementById("translation-form").submit();
}
});
</script>
</main>
{{ template "footer" .}}