Delete unnecessary js file

This commit is contained in:
Pl4gue
2017-12-23 17:34:12 +01:00
parent 5e78f55020
commit a536f2a67d

View File

@ -1,20 +0,0 @@
var pres = document.querySelectorAll("pre");
pres.forEach(element => {
const button = document.createElement("button");
button.innerHTML = "Copy to clipboard";
element.parentElement.appendChild(button);
button.addEventListener ("click", function() {
//The following regex removes all the comments from the snippet
const text = element.textContent.replace(/\/\*(.|[\r\n])*?\*\//g, '').replace(/\/\/.*/gm, '');
// Apparently you can copy variable to clipboard so you need to create text input element,
// give it a value, copy it and then remove it
const textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("Copy");
document.body.removeChild(textArea);
console.log(`copied: ${text}`);
});
});