diff options
Diffstat (limited to 'static/js/globals.js')
| -rw-r--r-- | static/js/globals.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/static/js/globals.js b/static/js/globals.js index 9100251b..61b3fcce 100644 --- a/static/js/globals.js +++ b/static/js/globals.js @@ -14,6 +14,20 @@ function changeLang(lang) { } } +function copyToClipboard(text) { + $('body').append('<input type="text" value="' + text + '" id="copyToClipboard">'); + const copyText = $('#copyToClipboard'); + copyText.select(); + copyText[0].setSelectionRange(0, 99999); + navigator.clipboard.writeText(copyText.val()).then(function () { + alert("Copied to clipboard!"); + }, function (err) { + alert("Failed to copy to clipboard!"); + }); + copyText.remove(); +} + + // Smooth scroll to anchor $(document).ready(function () { $('a[href^="#"]').on("click", function (e) { |
