From 542d6477f9a654f6b1f0528ad7eca4daf2e02a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 25 Sep 2020 19:02:40 +0200 Subject: [PATCH] chg: Add missing js --- website/web/static/generic.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 website/web/static/generic.js diff --git a/website/web/static/generic.js b/website/web/static/generic.js new file mode 100644 index 0000000..41af08b --- /dev/null +++ b/website/web/static/generic.js @@ -0,0 +1,19 @@ +"use strict"; + +// Copy to clipboard +// Source: https://codepen.io/nathanlong/pen/ZpAmjv +let copyToClipboard = (text, el) => { + const elOriginalText = el.attr('data-original-title'); + + const copyTextArea = document.createElement("textarea"); + copyTextArea.value = text; + document.body.appendChild(copyTextArea); + copyTextArea.select(); + + const successful = document.execCommand('copy'); + const msg = successful ? 'Copied!' : 'Whoops, not copied!'; + el.attr('data-original-title', msg).tooltip('show'); + + document.body.removeChild(copyTextArea); + el.attr('data-original-title', elOriginalText); +}