links / script.js
minispace's picture
Optimize and sanitize public codebase: remove all comments, explanatory notes, backend training data, and verify security isolation
9b14626
Raw History Blame Contribute Delete
2.23 kB
'use strict';
document.addEventListener('DOMContentLoaded', () => {
setupCopyShortUrl();
setupSecurityLocks();
});
let toastTimeout = null;
function setupCopyShortUrl() {
const shortUrlCard = document.getElementById('shortUrlCard');
if (!shortUrlCard) return;
shortUrlCard.addEventListener('click', () => {
const urlToCopy = 'https://minispace-links.static.hf.space';
navigator.clipboard.writeText(urlToCopy).then(() => {
showToast('¡Enlace copiado al portapapeles!');
}).catch(() => {
showToast('minispace-links.static.hf.space');
});
});
}
function handleLinkClick(event, brandName) {
const routes = {
'BEAT': 'beat.html',
'Pi Juguetes': 'pi.html',
'Pi': 'pi.html',
'Mundo Stand': 'stand.html',
'Stand': 'stand.html',
'Interactive': 'interactive.html'
};
if (routes[brandName]) {
event.preventDefault();
window.location.href = routes[brandName];
}
}
function handleAppClick(event, appName) {
event.preventDefault();
showToast(`¡Aplicación "${appName}" en desarrollo!`);
}
function showToast(message) {
const toast = document.getElementById('toast');
const toastMessage = document.getElementById('toastMessage');
if (!toast || !toastMessage) return;
toastMessage.textContent = message;
toast.classList.remove('hidden');
if (toastTimeout) {
clearTimeout(toastTimeout);
}
toastTimeout = setTimeout(() => {
toast.classList.add('hidden');
}, 3000);
}
function setupSecurityLocks() {
document.addEventListener('contextmenu', (e) => e.preventDefault());
document.addEventListener('keydown', (e) => {
if (e.keyCode === 123 ||
(e.ctrlKey && e.shiftKey && (e.keyCode === 73 || e.keyCode === 74 || e.keyCode === 67)) ||
(e.ctrlKey && (e.keyCode === 85 || e.keyCode === 83)) ||
(e.metaKey && e.altKey && (e.keyCode === 73 || e.keyCode === 74)) ||
(e.metaKey && (e.keyCode === 85 || e.keyCode === 83))) {
e.preventDefault();
return false;
}
});
document.addEventListener('dragstart', (e) => e.preventDefault());
}