From d28906d74f1385519b2a14be7acc48ab8486cdfd Mon Sep 17 00:00:00 2001 From: Al Azhar Date: Wed, 29 Apr 2026 11:54:00 +0700 Subject: [PATCH] add copy button --- index.html | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index b61fad8..ee9f32e 100644 --- a/index.html +++ b/index.html @@ -942,7 +942,7 @@ } if (!isNaN(time)) { - + // Collect continuation lines (stack traces etc.) let exception = ''; let j = i + 1; @@ -1273,17 +1273,28 @@ expandedRows.add(idx); const detailTr = document.createElement('tr'); detailTr.className = 'row-detail'; + + const section = (label, content, color = 'var(--text2)') => ` +
+
+
${label}
+ +
+
${esc(content)}
+
`; + let sections = ''; - if (log.fullmessage) { - sections += `
Full Message
${esc(log.fullmessage)}
`; - } - if (log.exception) { - sections += `
Exception / Stack Trace
${esc(log.exception)}
`; - } - if (log.props) { - sections += `
Properties
${esc(JSON.stringify(log.props, null, 2))}
`; - } + if (log.fullmessage) sections += section('Full Message', log.fullmessage); + if (log.exception) sections += section('Exception / Stack Trace', log.exception, 'var(--error)'); + if (log.props) sections += section('Properties', JSON.stringify(log.props, null, 2)); if (!sections) return; + detailTr.innerHTML = `
${sections}
`; tr.after(detailTr); } @@ -1485,6 +1496,20 @@ if (file) loadFile(file); }); + window.copySection = function (btn, text) { + navigator.clipboard.writeText(text).then(() => { + const orig = btn.textContent; + btn.textContent = 'copied ✓'; + btn.style.color = 'var(--info)'; + btn.style.borderColor = 'var(--info)'; + setTimeout(() => { + btn.textContent = orig; + btn.style.color = 'var(--text3)'; + btn.style.borderColor = 'var(--border2)'; + }, 1500); + }); + }; + // Load demo on start //loadDemo();