From 3c544d1f2e5888b983a65b8f6441e46136ecaefb Mon Sep 17 00:00:00 2001 From: BaselAkasha Date: Sat, 30 Nov 2019 15:17:33 +0000 Subject: [PATCH] Add copy button to the translator --- style.css | 9 ++++++++- translator/index.html | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/style.css b/style.css index 1217ee2..edbd27d 100644 --- a/style.css +++ b/style.css @@ -163,6 +163,9 @@ button:active, button.pressed, .button:active, .button.pressed { line-height: 1em; } +#tools{ + max-width: 40em; +} #editor, #in-editor, #out-editor { position: relative; @@ -177,9 +180,14 @@ button:active, button.pressed, .button:active, .button.pressed { #out-editor { width: 100%; padding: 4px; + margin-top: 4px; overflow: auto; } +#copy-btn{ + float:right; + margin: 0px; +} .CodeMirror, #out-editor { letter-spacing: +0.5px; @@ -500,4 +508,3 @@ img .hidden { position: absolute; opacity: 0; } - diff --git a/translator/index.html b/translator/index.html index d2218ca..8d06861 100644 --- a/translator/index.html +++ b/translator/index.html @@ -25,13 +25,14 @@

-
+
+
@@ -51,6 +52,7 @@

var editor = document.getElementById('in-editor'); var swapBtn = document.getElementById('swap-btn'); +var copyBtn = document.getElementById('copy-btn'); var obj = {}; extractHash(); @@ -285,6 +287,11 @@

updatedFromHash(); +copyBtn.onclick = function(){ + outEditor.select(); + document.execCommand('copy'); +}; + -