From a12764067f05f4bc2ff8ec56420980f3eb3d2b56 Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Sun, 24 Mar 2024 20:41:44 +0530 Subject: [PATCH] fixed the heading copy and added the checkmark --- frontend/javascript/code_snippets.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/javascript/code_snippets.js b/frontend/javascript/code_snippets.js index 0966f18..4ce8e5e 100644 --- a/frontend/javascript/code_snippets.js +++ b/frontend/javascript/code_snippets.js @@ -10,7 +10,7 @@ export function copyHeadingDirectLinks() { headings.forEach(function (heading) { const linkIcon = document.createElement('span'); - linkIcon.innerHTML = ''; + linkIcon.innerHTML = `` linkIcon.style.cursor = 'pointer'; linkIcon.style.position = 'relative'; linkIcon.style.left = '10px'; @@ -23,6 +23,15 @@ export function copyHeadingDirectLinks() { const id = heading.getAttribute('id'); const url = window.location.href.split('#')[0] + '#' + id; navigator.clipboard.writeText(url); + + // Replace the link icon with a checkmark icon + linkIcon.innerHTML = ` + ` + + // Automatically revert the checkmark to the link icon after 2 seconds + setTimeout(function () { + linkIcon.innerHTML = `` + }, 2000); }); heading.addEventListener('mouseover', function () {