mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-03-13 10:10:27 +08:00
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
function setGithubClipboard() {
|
|
var clipboard = 'ESP Easy | Information |\n -----|-----|\n';
|
|
const max_loop = 100;
|
|
for (var i = 1; i < max_loop; i++) {
|
|
var cur_id = 'copyText_' + i;
|
|
var test = document.getElementById(cur_id);
|
|
if (!test) {
|
|
i = max_loop + 1;
|
|
} else {
|
|
var separatorSymbol = '|';
|
|
if (i % 2 == 0) {
|
|
separatorSymbol += '\n'
|
|
}
|
|
// collect only visible log entry divs
|
|
const visibleLines = Array.from(test.children)
|
|
.filter(div => div.offsetParent !== null) // visible only
|
|
.map(div => div.innerHTML);
|
|
|
|
if (visibleLines.length > 0) {
|
|
clipboard +=
|
|
visibleLines.join('\n').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!');
|
|
}
|