Skip to content

Commit

Permalink
Remove browser dependent checks on write to clipboard.
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <steve.cassidy@mq.edu.au>
  • Loading branch information
stevecassidy committed Aug 30, 2024
1 parent 8125b7e commit 4211de4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
14 changes: 6 additions & 8 deletions api/views/home.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,12 @@

<script>
const copyTokenToClipboard = () => {
navigator.permissions.query({name: "clipboard-write"}).then((result) => {
if (result.state === "granted" || result.state === "prompt") {
navigator.clipboard.writeText("{{{token}}}").then(() => {
alert("Bearer token copied to clipboard.")
}, () => {
alert("Could not copy token.")
});
}
navigator.clipboard.writeText("{{{token}}}").then(() => {
alert("Bearer token copied to clipboard.")
}, () => {
alert("Could not copy token.")
});
}
</script>
14 changes: 4 additions & 10 deletions api/views/notebook-landing.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,12 @@
</div>
</div>



<script>
const copyToClipboard = (text) => {
navigator.permissions.query({name: "clipboard-write"}).then((result) => {
if (result.state === "granted" || result.state === "prompt") {
navigator.clipboard.writeText(text).then(() => {
alert("Copied to clipboard.")
}, () => {
alert("Could not copy text.")
});
}
navigator.clipboard.writeText(text).then(() => {
alert("URL copied to clipboard.")
}, () => {
alert("Could not copy URL to clipboard.")
});
}
Expand Down

0 comments on commit 4211de4

Please sign in to comment.