Download this file
| 1 | (() => { |
| 2 | 'use strict'; |
| 3 | const link = document.getElementById('invitation-link'); |
| 4 | const actions = document.getElementById('share-actions'); |
| 5 | const status = document.getElementById('share-status'); |
| 6 | if (!link || !actions || !status) return; |
| 7 | actions.hidden = false; |
| 8 | document.getElementById('copy-invitation').addEventListener('click', async () => { |
| 9 | try { |
| 10 | await navigator.clipboard.writeText(link.href); |
| 11 | status.textContent = 'Link copied.'; |
| 12 | } catch { |
| 13 | status.textContent = 'Select the invitation above and copy it.'; |
| 14 | } |
| 15 | }); |
| 16 | if (navigator.share) { |
| 17 | const share = document.getElementById('share-invitation'); |
| 18 | share.hidden = false; |
| 19 | share.addEventListener('click', async () => { |
| 20 | try { await navigator.share({ url: link.href }); } |
| 21 | catch (error) { |
| 22 | if (error.name !== 'AbortError') status.textContent = 'Could not share. You can copy the link instead.'; |
| 23 | } |
| 24 | }); |
| 25 | } |
| 26 | })(); |
| 27 | |