1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-20 01:09:35 +05:30

(feat): implemented code snippet copy feature and disabled page scrolling when share window is open

This commit is contained in:
2023-11-28 21:48:06 +05:30
parent 574c84fd4e
commit 1871e73532
2 changed files with 6 additions and 2 deletions

View File

@@ -321,7 +321,7 @@ function activate_share() {
shareBtn.classList.add("hidden");
shareCloseBtn.classList.remove("hidden");
shareWin.classList.add("floatingshare-window-show");
document.body.classList.add("overflow-hidden");
}
// function to close the share window
@@ -331,6 +331,7 @@ function close_share() {
shareCloseBtn.classList.add("hidden");
shareBtn.classList.remove("hidden");
shareWin.classList.remove("floatingshare-window-show");
document.body.classList.remove("overflow-hidden");
}
shareBtn.addEventListener("click", function () {
@@ -364,6 +365,9 @@ function call_webshare_api() {
// function to copy text based content to device clipboard
function copy_to_clipboard(textContent, copyContext) {
if(copyContext === 'Code Snippet') {
textContent = textContent.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
}
if(navigator.clipboard) {
navigator.clipboard.writeText(textContent).then(function() {
window.alert(copyContext + " Copied to Clipboard");