ctrl+return to send, english default source

This commit is contained in:
Arya Kiran 2023-09-10 19:11:45 +05:30
parent a2ae02f6d7
commit 197296e91f
No known key found for this signature in database
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" .}}