[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb] 10/66: Use a "Copy All" button instead of "Select All"



This is an automated email from the git hooks/post-receive script.

meskio pushed a commit to branch main
in repository bridgedb.

commit a8eb365783375739c56ae1c5e55817766651431e
Author: kez <kez@xxxxxxxxxxxxxx>
AuthorDate: Wed May 25 17:38:51 2022 -0700

    Use a "Copy All" button instead of "Select All"
    
    Closes: #40050
---
 frontend/assets/static/js/bridges.js      | 14 ++++++++++++--
 frontend/templates/hero-bridge-lines.html |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/frontend/assets/static/js/bridges.js b/frontend/assets/static/js/bridges.js
index 2686e24..bf54cec 100644
--- a/frontend/assets/static/js/bridges.js
+++ b/frontend/assets/static/js/bridges.js
@@ -22,6 +22,16 @@ function selectText(element) {
   }
 }
 
+function copyText(element) {
+  'use strict';
+  try {
+    let text = document.getElementById(element).innerText;
+    navigator.clipboard.writeText(text);
+  } catch (e) {
+    console.log(e);
+  }
+}
+
 function displayOrHide(element) {
   try {
     e = document.getElementById(element);
@@ -43,10 +53,10 @@ function displayOrHide(element) {
 
 window.onload = function() {
   var selectBtn = document.getElementById('bridgedb-selectbtn');
-  if (selectBtn) {
+  if (selectBtn && navigator.clipboard) {
     selectBtn.addEventListener('click',
       function() {
-        selectText('bridgelines');
+        copyText('bridgelines');
       }, false);
     // Make the 'Select All' button clickable:
     selectBtn.classList.remove('disabled');
diff --git a/frontend/templates/hero-bridge-lines.html b/frontend/templates/hero-bridge-lines.html
index 4e43e24..cffc6b1 100644
--- a/frontend/templates/hero-bridge-lines.html
+++ b/frontend/templates/hero-bridge-lines.html
@@ -28,7 +28,7 @@
         {{ 0/0 }}
         {% endif %}
     </div>
-    <button class="btn btn-primary disabled" id="bridgedb-selectbtn" aria-disabled="true"><span class="fa fa-copy pr-3"></span>Select All</button>
+    <button class="btn btn-primary disabled" id="bridgedb-selectbtn" aria-disabled="true"><span class="fa fa-copy pr-3"></span>Copy All</button>
     {% if envvars('ENV') == 'dev' %}
     <a id="bridgedb-qrcodebtn" class="btn btn-primary" type="button" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAABmJLR0QA/wD/AP+gvaeTAAADUklEQVR4nO3dQU4DQRAEQUD8/8vwBaAtN+mOuCOvB6fmVNq3NwAAAAAAAAAAAAAAAADgxb0P//7rIU9xw+Sst865+MxFfz7nj0c+BfBcAoYwAUOYgCFMwBAmYAgTMIQJGMIEDGEChjABQ5iAIUzAECZgCPtc/OzplHFDcSJXPOfiM6/8NtzAECZgCBMwhAkYwgQMYQKGMAFDmIAhTMAQJmAIEzCECRjCBAxhAoawzTnhxGS6VZyqTVw7q1Pf1w0MYQKGMAFDmIAhTMAQJmAIEzCECRjCBAxhAoYwAUOYgCFMwBAmYAirzglzs6+hyfctvlF [...]
     {% elif envvars('ENV') == 'prod' %}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits