Files
ESPEasy/static/github_clipboard.js
chromoxdor 6c5ce7e8f8 [LOG] refining the filter
- Added highlight filter phrases
- Added ordered AND operator (&)
- Added exclusion (!)
2026-01-24 12:33:30 +01:00

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!');
}