2023-06-03 21:22:03 +03:00
|
|
|
export default class extends HTMLElement {
|
|
|
|
|
connectedCallback () {
|
2023-06-30 23:22:57 +03:00
|
|
|
this.clearChecked()
|
|
|
|
|
|
2023-06-29 02:04:17 +03:00
|
|
|
this.addEventListener('click', (e) => {
|
2023-07-01 17:30:41 +03:00
|
|
|
const text = this.dataset.text || this.innerText.trim()
|
|
|
|
|
|
|
|
|
|
if (navigator.clipboard) {
|
|
|
|
|
navigator.clipboard.writeText(text)
|
|
|
|
|
} else {
|
|
|
|
|
if (e.target.tagName !== 'INPUT') {
|
|
|
|
|
alert(`Clipboard not available. Make sure you're using https://\nCopy text: ${text}`)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-29 02:04:17 +03:00
|
|
|
})
|
2023-06-03 21:22:03 +03:00
|
|
|
}
|
|
|
|
|
|
2023-06-30 23:22:57 +03:00
|
|
|
clearChecked () {
|
2023-06-29 02:04:17 +03:00
|
|
|
this.querySelectorAll('input').forEach((e) => {
|
|
|
|
|
e.checked = false
|
|
|
|
|
})
|
2023-06-11 18:42:00 +03:00
|
|
|
}
|
2023-06-03 21:22:03 +03:00
|
|
|
}
|