move translate buttons up for better mobile usability (closes #16)
Some checks are pending
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Waiting to run
mozhi pipeline / Build and publish artifacts (push) Waiting to run

This commit is contained in:
Arya 2024-12-27 14:40:02 +05:30
parent 2f63e58e4d
commit 0f72048b11
Signed by: arya
GPG Key ID: 842D12BDA50DF120
2 changed files with 27 additions and 25 deletions

View File

@ -97,9 +97,11 @@ func HandleIndex(c *fiber.Ctx) error {
if engine != "" && originalText != "" && from != "" && to != "" {
if engine == "all" {
transmany = libmozhi.TranslateAll(to, from, originalText)
translationExists = true
} else if engine == "some" {
// The error doesn't really matter since it just checks if the engines are valid, which is already checked in the code at the beginning of the func
transmany, _ = libmozhi.TranslateSome(enginesSome.Engines, to, from, originalText)
translationExists = true
} else {
translation, tlerr = libmozhi.Translate(engine, to, from, originalText)
if tlerr != nil {

View File

@ -73,6 +73,22 @@
</select>
</div>
</div>
{{ if .TranslationExists }}
<div style="display:flex;
justify-content:space-around;
align-items:center">
<button class="wrap" type="button" onclick="copyToClipboard()">Copy the translation</button>
{{ if and .Engine .From .To .OriginalText }}
<p>
<a id="url"
class="button"
onclick="copyLinkToClipboard(event)"
href="/?engine={{.Engine}}&from={{.From}}&to={{.To}}&text={{.OriginalText}}">Copy translation link</a>
</p>
{{ end }}
<button class="wrap" type="submit">Translate!</button>
</div>
{{ end }}
<div class="center-area2 item-wrapper">
Source Text:
<textarea autofocus class="item" id="input" name="text" dir="auto" placeholder="Enter Text Here">
@ -128,31 +144,15 @@
<br>
{{ end }}
{{ end }}
<div style="display:flex;
justify-content:space-around;
align-items:center">
{{ if .TranslationExists }}
<button class="wrap" type="button" onclick="copyToClipboard()">Copy the translation</button>
{{ end }}
{{ if and .Engine .From .To .OriginalText }}
<p>
<a id="url"
class="button"
onclick="copyLinkToClipboard(event)"
href="/?engine={{.Engine}}&from={{.From}}&to={{.To}}&text={{.OriginalText}}">Copy translation link</a>
</p>
{{ end }}
{{ if .TranslationExists }}
<button class="wrap" type="submit">Translate!</button>
{{ else }}
<button class="wrap"
style="margin-left:auto;
position:relative;
left:-10%;
margin-top: 1%"
type="submit">Translate!</button>
{{ end }}
</div>
{{ if not .TranslationExists }}
<button class="wrap"
style="margin-left:auto;
position:relative;
left:-10%;
margin-top: 1%"
type="submit">Translate!</button>
{{ end }}
</div>
{{ if eq .Engine "yandex" }}
{{ template "yandex_extras" . }}