feat: Share button = copy to clipboard if no sharenav

This commit is contained in:
ThatOneCalculator 2022-04-04 11:59:26 -07:00
parent fff67c1a43
commit 648b6aac4e
1 changed files with 10 additions and 7 deletions

View File

@ -167,16 +167,19 @@ function viewPaste(content: string, views: string, singleView: boolean) {
addMessage("This is a single-view paste!") addMessage("This is a single-view paste!")
} }
if (navigator.canShare) { show(shareButton)
show(shareButton) shareButton.addEventListener("click", function () {
const url = window.location.toString()
shareButton.addEventListener("click", function () { if (navigator.canShare) {
navigator.share({ navigator.share({
title: "zer0bin paste", title: "zer0bin paste",
url: window.location.toString(), url: url,
}) })
}) } else {
} navigator.clipboard.writeText(url)
addMessage("Copied URL to clipboard!")
}
})
disable(saveButton) disable(saveButton)
disable(markdownButton) disable(markdownButton)