X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/41f33f9c1dac5381412bcab57c971fd08d1d8613..4823b32b6ce68f7a6a0949c225c808da4979506f:/lib/functions.js.php diff --git a/lib/functions.js.php b/lib/functions.js.php index 50aa2f0..58623e6 100644 --- a/lib/functions.js.php +++ b/lib/functions.js.php @@ -786,6 +786,21 @@ 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 = "";