chg: Add missing js

pull/92/head
Raphaël Vinot 2020-09-25 19:02:40 +02:00
parent ef6eb1c253
commit 542d6477f9
1 changed files with 19 additions and 0 deletions

View File

@ -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);
}