Files
ESPEasy/static/github_clipboard.js
T
TD-er 9eb2ebe210 [Cleanup] Minify JavaScript and CSS to reduce sketch size
Sketch size is reduced by 5 - 6 kB
Files are extracted from original source and moved to `static` directory.
2018-10-31 16:25:42 +01:00

28 lines
1.0 KiB
JavaScript

function setGithubClipboard() {
var clipboard = 'ESP Easy | Information |\n -----|-----|\n';
max_loop = 100;
for (var i = 1; i < max_loop; i++) {
var cur_id = 'copyText_' + i;
var test = document.getElementById(cur_id);
if (test == null) {
i = max_loop + 1;
} else {
var separatorSymbol = '|';
if (i % 2 == 0) {
separatorSymbol += '\n'
}
clipboard += test.innerHTML.replace(/<[Bb][Rr]\s*\/?>/gim, '\n') + separatorSymbol;
}
}
clipboard = clipboard.replace(/<\/[Dd][Ii][Vv]\s*\/?>/gim, '\n');
clipboard = clipboard.replace(/<[^>]*>/gim, '');
var tempInput = document.createElement('textarea');
tempInput.style = 'position: absolute;left: -1000px; top: -1000px';
tempInput.innerHTML = clipboard;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
alert('Copied: "' + clipboard + '" to clipboard!')
}