From febf0f3523aad7e0d7a74baa0f7b07bd644e1f62 Mon Sep 17 00:00:00 2001 From: Midou36O Date: Fri, 13 Oct 2023 08:03:57 +0100 Subject: [PATCH 1/5] Add a "Copy" button. Closes #5 --- views/index.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/views/index.html b/views/index.html index 6808cd9..ada58d4 100644 --- a/views/index.html +++ b/views/index.html @@ -70,7 +70,7 @@ {{range $key, $value := .TranslateAll}}
Engine: {{.Engine}} - {{if .AutoDetect}} Detected Language: {{.AutoDetect}}{{end}} {{if $.TtsTo}} @@ -82,7 +82,7 @@ {{end}} {{ else }} {{if .TranslationExists}}
- {{if .Translation.AutoDetect}} Detected Language: {{.Translation.AutoDetect}}{{end}} {{if .TtsTo}} @@ -94,6 +94,9 @@ {{end}} + {{ if and .Engine .From .To .OriginalText }}

Copy translation link

{{end}} @@ -111,6 +114,13 @@ var options = { searchable: true }; NiceSelect.bind(document.getElementById("targetLanguage"), options); NiceSelect.bind(document.getElementById("sourceLanguage"), options); + // This function allows to copy the translated text to the clipboard + function copyToClipboard() { + var copyText = document.getElementById("output"); + copyText.select(); + copyText.setSelectionRange(0, 99999); // This is for mobile devices. + document.execCommand("copy"); + } {{ template "footer" .}} From 16ee289b30242df1ec01a1d00ade47f3f6e9783e Mon Sep 17 00:00:00 2001 From: Midou36O Date: Fri, 13 Oct 2023 13:24:55 +0100 Subject: [PATCH 2/5] Since Arya requested more than a simple button, more CSS jankiness! --- public/css/style.css | 30 +++++++++++++++++++++++++----- views/index.html | 28 ++++++++++++++++++---------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/public/css/style.css b/public/css/style.css index c029fb6..e66db79 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -31,7 +31,7 @@ footer p { } a { - color: #F57C00; + color: #f57c00; text-decoration: none; } a:hover { @@ -79,7 +79,7 @@ select { border-bottom: none; border-top: none; border-radius: 4px; - border-left: 2px solid #F57C00; + border-left: 2px solid #f57c00; /* Accent shadow */ box-shadow: 2px 2px 0px 0px rgba(245, 124, 0, 0.25); color: #b2b2b2; @@ -89,18 +89,36 @@ select { button { display: flex; + font-size: 17px; padding: 4px 8px; justify-content: flex-end; gap: 2px; border: none; border-radius: 4px; - background: #F57C00; + background: #f57c00; } button:hover { box-shadow: 5px 5px 0px 0px rgba(245, 124, 0, 0.25); cursor: pointer; } +/* While we're at it, fake button css style for the url.*/ + +.button { + display: flex; + font-size: 17px; + padding: 4px 8px; + justify-content: flex-end; + gap: 2px; + border: none; + border-radius: 4px; + background: #f57c00; +} +.button:hover { + box-shadow: 5px 5px 0px 0px rgba(245, 124, 0, 0.25); + cursor: pointer; +} + /* Spacing stuff */ .wrap { display: flex; @@ -168,11 +186,13 @@ button:hover { } /* Javascript searchable select used in source/target language */ -.nice-select, .nice-select-dropdown, .nice-select-search { +.nice-select, +.nice-select-dropdown, +.nice-select-search { border-right: none; border-bottom: none; border-top: none; border-radius: 4px; - border-left: 2px solid #F57C00; + border-left: 2px solid #f57c00; box-shadow: 2px 2px 0px 0px rgba(245, 124, 0, 0.25); } diff --git a/views/index.html b/views/index.html index ada58d4..f62e54c 100644 --- a/views/index.html +++ b/views/index.html @@ -18,7 +18,7 @@ -
+
@@ -68,7 +68,7 @@ {{ if .TranslateAll }} {{range $key, $value := .TranslateAll}} -
+
Engine: {{.Engine}} @@ -92,13 +92,21 @@ {{end}} {{end}} {{end}} - - - {{ if and .Engine .From .To .OriginalText }}

Copy translation link

{{end}} +
+ {{if .TranslationExists}} + + {{end}} + {{ if and .Engine .From .To .OriginalText }}

Copy translation link

{{end}} + {{if .TranslationExists}} + +