mirror of
https://github.com/samber/awesome-prometheus-alerts.git
synced 2026-06-25 02:46:59 +08:00
Update site/src/components/CopyButton.astro
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e056652504
commit
96731e7ee2
1 changed files with 39 additions and 36 deletions
|
|
@ -43,8 +43,12 @@ const btnId = `copy-btn-${targetId}`;
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<script>
|
<script define:vars={{ btnId }}>
|
||||||
document.querySelectorAll<HTMLButtonElement>('.copy-btn').forEach((btn) => {
|
const btn = document.getElementById(btnId);
|
||||||
|
if (!(btn instanceof HTMLButtonElement)) return;
|
||||||
|
if (btn.dataset.copyBound === 'true') return;
|
||||||
|
|
||||||
|
btn.dataset.copyBound = 'true';
|
||||||
btn.addEventListener('click', async () => {
|
btn.addEventListener('click', async () => {
|
||||||
const targetId = btn.dataset.copyTarget;
|
const targetId = btn.dataset.copyTarget;
|
||||||
if (!targetId) return;
|
if (!targetId) return;
|
||||||
|
|
@ -83,5 +87,4 @@ const btnId = `copy-btn-${targetId}`;
|
||||||
copiedLabel?.classList.add('hidden');
|
copiedLabel?.classList.add('hidden');
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue