Spaces:
Sleeping
Sleeping
File size: 2,111 Bytes
4ee7c6a | 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 36 37 38 39 40 41 42 43 44 45 46 | // Executed inside Gradio's load hook. No cookies, IDs, dataset names or card content
// leave the page. Clipboard text is used locally and never sent as telemetry.
if (!window.kalanosUsage) {
const enabled = location.origin === 'https://kalanosdev-lerobot-grader.hf.space';
const emit = (event) => {
if (!enabled) return;
fetch('https://hub.kalanos.ai/api/events/hf-space', {
method: 'POST', credentials: 'omit', referrerPolicy: 'no-referrer',
headers: {'Content-Type': 'text/plain'}, body: JSON.stringify({event}), keepalive: true
}).catch(() => {});
};
const copy = async (text, button, status) => {
if (!text) return;
try {
await navigator.clipboard.writeText(text);
emit('hf_card_copied');
if (status) status.textContent = 'Copied';
if (button) { button.title = 'Copied'; button.setAttribute('aria-label', 'Copied'); }
} catch {
if (status) status.textContent = 'Clipboard unavailable. Select the Markdown and copy manually.';
if (button) { button.title = 'Copy unavailable — select the Markdown and copy manually'; button.setAttribute('aria-label', button.title); }
}
};
window.kalanosUsage = {emit, copy};
emit('hf_space_viewed');
document.addEventListener('toggle', (e) => {
if (e.target.matches?.('details.k-hf-card') && e.target.open) emit('hf_card_previewed');
}, true);
document.addEventListener('click', (e) => {
const button = e.target.closest?.('.k-copy-card');
if (button) {
const panel = button.closest('.k-hf-card');
copy(panel.querySelector('textarea').value, button, panel.querySelector('.k-copy-status'));
}
const link = e.target.closest?.('.k-card a[href]');
if (link) {
const url = new URL(link.href);
if (url.origin === 'https://hub.kalanos.ai' && url.pathname.startsWith('/d/')) emit('hf_report_opened');
}
});
document.addEventListener('copy', (e) => {
const input = e.target.closest?.('.k-hf-card textarea');
if (input && input.selectionStart !== input.selectionEnd && !e.defaultPrevented) emit('hf_card_copied');
});
}
|