X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/bfbbf72959faa385b97d250484be1d25e4fd22aa..6103246a73b77d4264afed927febf5eb4c38dad5:/lib/functions.js.php

diff --git a/lib/functions.js.php b/lib/functions.js.php
index 50aa2f0..3052bf0 100644
--- a/lib/functions.js.php
+++ b/lib/functions.js.php
@@ -786,18 +786,33 @@ function addCopyListener(button_id, link_id) {
     }
 }
 
+function copyTextToClipboard(text_id){
+    var copyText = document.getElementById(text_id);
+    copyText.select();
+    copyText.setSelectionRange(0, 99999); 
+    navigator.clipboard.writeText(copyText.value);
+}
+
+function addTextCopyListener(button_id, text_id) {
+    if(document.getElementById(button_id)){
+        document.getElementById(button_id)
+            .addEventListener("click", function() {
+                copyTextToClipboard(text_id);});
+    }
+}
+
 function set_dark_mode() {
     let steel_sheet = "<?php echo 'media/' . $cfg['dark_style'] . '/style.css.php'; ?>";
     let shortcut_icon = "<?php echo 'media/' . $cfg['dark_style'] . '/favicon.ico'; ?>";
     document.getElementById('stylesheet').href = steel_sheet;
-    document.getElementById('shortcut_icon').href = steel_sheet;
+    document.getElementById('shortcut_icon').href = shortcut_icon;
 }
 
 function set_light_mode() {
     let steel_sheet = "<?php echo 'media/' . $cfg['style'] . '/style.css.php'; ?>";
     let shortcut_icon = "<?php echo 'media/' . $cfg['style'] . '/favicon.ico'; ?>";
     document.getElementById('stylesheet').href = steel_sheet;
-    document.getElementById('shortcut_icon').href = steel_sheet;
+    document.getElementById('shortcut_icon').href = shortcut_icon;
 }
 
 function color_scheme_preferences() {