X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/bfbbf72959faa385b97d250484be1d25e4fd22aa..72d4080a3eafca5f496bad8604233d67411e9dc0:/lib/functions.js.php?ds=inline 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 = ""; let shortcut_icon = ""; 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 = ""; let shortcut_icon = ""; document.getElementById('stylesheet').href = steel_sheet; - document.getElementById('shortcut_icon').href = steel_sheet; + document.getElementById('shortcut_icon').href = shortcut_icon; } function color_scheme_preferences() {