Add copy-to-clipboard feature

Change-Id: If531e8bb3b45b8659d02156e4b4eb76c253492b1
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 98dc54a..d246a8c 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -437,6 +437,13 @@
       KorAP.Panel['query'] = queryPanel;
     }
 
+
+    /**
+     * Initialize password toggle.
+     */
+    initCopyToClipboard(d);
+
+      
     /**
      * Initialize password toggle.
      */
diff --git a/dev/js/src/util.js b/dev/js/src/util.js
index 14480bc..86e6214 100644
--- a/dev/js/src/util.js
+++ b/dev/js/src/util.js
@@ -110,6 +110,25 @@
 };
 
 
+/**
+ * Add option to copy to clipboard.
+ */
+function initCopyToClipboard (element) {
+    const el = element.querySelectorAll("input.copy-to-clipboard");
+    for (let x = 0; x < el.length; x++) {     
+        const text = el[x];
+        const a = document.createElement('a');
+        a.classList.add('copy-to-clipboard');         
+        a.addEventListener('click', function () {
+            text.select();
+            text.setSelectionRange(0, 99999);
+            document.execCommand("copy");
+        });
+        text.parentNode.insertBefore(a, text.nextSibling);
+    };
+};
+
+
 define(function () {
   // Todo: That's double now!
   KorAP.API = KorAP.API || {};