Spaces:
Running
Running
Download shared/js/share.js from Tonic/uas-eus-webhook: direct link, hf CLI and curl.
- Browser
- Download file 2.35 kB
-
https://huggingface.co/spaces/Tonic/uas-eus-webhook/resolve/main/shared/js/share.js
- Command line
-
hf download hf://spaces/Tonic/uas-eus-webhook/shared/js/share.js
-
curl -L -o share.js https://huggingface.co/spaces/Tonic/uas-eus-webhook/resolve/main/shared/js/share.js
2.35 kB
| /* Share buttons β zero external scripts, just share URLs + navigator.share + clipboard. | |
| Mount into any container: <div class="share" data-share></div> */ | |
| (function () { | |
| function enc(s) { return encodeURIComponent(s); } | |
| window.Share = { | |
| mountAll() { | |
| document.querySelectorAll('[data-share]').forEach(function (el) { | |
| var url = location.href, title = document.title; | |
| var text = (window.I18N && I18N.t('share.title')) || 'Share'; | |
| var items = []; | |
| if (navigator.share) items.push({ label: 'β ' + text, fn: function () { navigator.share({ title: title, url: url }).catch(function () {}); } }); | |
| items.push({ label: 'π', url: 'https://twitter.com/intent/tweet?url=' + enc(url) + '&text=' + enc(title) }); | |
| items.push({ label: 'in', url: 'https://www.linkedin.com/sharing/share-offsite/?url=' + enc(url) }); | |
| items.push({ label: 'β telegram', url: 'https://t.me/share/url?url=' + enc(url) + '&text=' + enc(title) }); | |
| items.push({ label: 'β whatsapp', url: 'https://wa.me/?text=' + enc(title + ' ' + url) }); | |
| items.push({ label: 'π mastodon', url: 'https://mastodon.social/share?text=' + enc(title + ' ' + url) }); | |
| items.push({ label: 'β email', url: 'mailto:?subject=' + enc(title) + '&body=' + enc(url) }); | |
| items.push({ label: 'π', fn: function () { | |
| (navigator.clipboard ? navigator.clipboard.writeText(url) : Promise.reject()).then(function () { | |
| el.querySelector('[data-copy]').textContent = 'β'; | |
| }).catch(function () { | |
| var t = document.createElement('input'); t.value = url; document.body.appendChild(t); | |
| t.select(); try { document.execCommand('copy'); } catch (e) {} t.remove(); | |
| }); | |
| }, copy: true }); | |
| el.innerHTML = ''; | |
| items.forEach(function (it) { | |
| var a = document.createElement(it.url ? 'a' : 'button'); | |
| a.textContent = it.label; | |
| a.className = 'share-btn'; | |
| if (it.copy) a.setAttribute('data-copy', ''); | |
| if (it.url) { a.href = it.url; a.target = '_blank'; a.rel = 'noopener nofollow'; } | |
| else a.addEventListener('click', it.fn); | |
| el.appendChild(a); | |
| }); | |
| }); | |
| } | |
| }; | |
| window.addEventListener('DOMContentLoaded', function () { Share.mountAll(); }); | |
| })(); | |