Skip to content

Commit

Permalink
refactor: Update share button copy function to use navigator.clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ngeorger committed Jun 28, 2024
1 parent 4d1736c commit 48fc704
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assets/built/source.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/built/source.js.map

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions assets/js/copy.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Customized SREDevOps
function copyToClipboard() {
function loreaLoQuePuse() {
var url = window.location.href;

if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard
.writeText(url)
.then(function () {
alert("Link copied to clipboard!");
})
.catch(function (error) {
console.error("Failed to copy text: ", error);
});
navigator.clipboard
.writeText(url)
.then(function () {
alert("Link copied to clipboard!");
})
.catch(function (error) {
console.error("Failed to copy text: ", error);
});
} else {
console.error("Clipboard writeText is not supported.");
}
Expand Down
2 changes: 1 addition & 1 deletion partials/share-block.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="gh-article-meta">
<span>Upscale this post: </span>
<span>
<a id="copyButton" onclick="copyToClipboard()" href="javascript:void(0)" alt="Copy to clipboard" title="Copy to clipboard">
<a id="copyButton" onclick="loreaLoQuePuse()" href="javascript:void(0)" alt="Copy to clipboard" title="Copy to clipboard">
{{> icons/copy}}
</a>
</span>
Expand Down

0 comments on commit 48fc704

Please sign in to comment.