Skip to content

Commit

Permalink
added copyToClipboard, cozyResultArea
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamreet committed Jun 29, 2024
1 parent 3f773f4 commit d6fa86d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,16 @@ function findUnfollowed(followers, followings) {
const followerSet = new Set(followers.split(',').map(item => item.trim()));
return followings.split(',').map(item => item.trim()).filter(item => !followerSet.has(item));
}

function copyCode() {
const codeSnippet = document.getElementById('code-snippet');
const range = document.createRange();
range.selectNode(codeSnippet);
window.getSelection().removeAllRanges(); // Clear any current selection
window.getSelection().addRange(range); // Select the code
document.execCommand('copy'); // Copy the selected text to clipboard
window.getSelection().removeAllRanges(); // Deselect the text

// Optionally, show a message or change button text to indicate success
alert("Code copied to clipboard!");
}

0 comments on commit d6fa86d

Please sign in to comment.