-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (27 loc) · 920 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const shareButtons = document.querySelectorAll('.tile-share-button')
// console.log(shareButtons)
async function copyText(e) {
//prevent button going to the site
e.preventDefault()
const link = this.getAttribute('link')
// console.log(link)
try {
await navigator.clipboard.writeText(link)
alert("Copied the text: " + link)
} catch (err) {
console.error(err)
}
}
shareButtons.forEach(shareButtons => shareButtons.addEventListener('click', copyText) )
const topShareButton = document.querySelector('.share-button')
async function copyTopText() {
const link = this.getAttribute('link')
// console.log(link)
try {
await navigator.clipboard.writeText(link)
alert("Copied the text: " + link)
} catch (err) {
console.error(err)
}
}
topShareButton.addEventListener('click', copyTopText)