X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/bfbbf72959faa385b97d250484be1d25e4fd22aa..93d87c13b5169a0a61e3906af13cf07ec8ae2a58:/lib/functions.js.php?ds=sidebyside 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() {