|
| 1 | +// Controlador para Editor de Mensajes |
| 2 | + |
| 3 | +// Generar URL del mensaje |
| 4 | +function generateMensajeURL() { |
| 5 | + const content = document.getElementById('mensaje-content').value; |
| 6 | + const font = document.getElementById('mensaje-font').value; |
| 7 | + const bgColor = document.getElementById('mensaje-bg-color').value; |
| 8 | + const bgImage = document.getElementById('mensaje-bg-image').value.trim(); |
| 9 | + const textColor = document.getElementById('mensaje-text-color').value; |
| 10 | + const flowMode = document.getElementById('mensaje-flow-mode').checked; |
| 11 | + const animation = document.getElementById('mensaje-animation').value; |
| 12 | + const animationSpeed = document.getElementById('mensaje-animation-speed').value; |
| 13 | + |
| 14 | + // Actualizar hex labels |
| 15 | + document.getElementById('mensaje-bg-color-hex').value = bgColor.toUpperCase(); |
| 16 | + document.getElementById('mensaje-text-color-hex').value = textColor.toUpperCase(); |
| 17 | + |
| 18 | + // Codificar contenido markdown en base64 para evitar problemas con caracteres especiales |
| 19 | + const encodedContent = btoa(unescape(encodeURIComponent(content))); |
| 20 | + |
| 21 | + let url = `../app/mensaje.html?content=${encodeURIComponent(encodedContent)}`; |
| 22 | + url += `&font=${encodeURIComponent(font)}`; |
| 23 | + url += `&bg=${encodeURIComponent(bgColor)}`; |
| 24 | + url += `&text=${encodeURIComponent(textColor)}`; |
| 25 | + |
| 26 | + if (bgImage) { |
| 27 | + url += `&bgImage=${encodeURIComponent(bgImage)}`; |
| 28 | + } |
| 29 | + |
| 30 | + if (flowMode) { |
| 31 | + url += `&flow=1`; |
| 32 | + url += `&anim=${encodeURIComponent(animation)}`; |
| 33 | + url += `&speed=${encodeURIComponent(animationSpeed)}`; |
| 34 | + } |
| 35 | + |
| 36 | + const baseURL = window.location.origin + window.location.pathname.replace('admin/mensaje.html', ''); |
| 37 | + const fullURL = baseURL + url.replace('../', ''); |
| 38 | + const embedCode = `<iframe src="${fullURL}" width="100%" height="800" frameborder="0" style="border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);"></iframe>`; |
| 39 | + |
| 40 | + document.getElementById('mensaje-url').value = fullURL; |
| 41 | + document.getElementById('mensaje-embed').value = embedCode; |
| 42 | + document.getElementById('preview-mensaje').src = url; |
| 43 | +} |
| 44 | + |
| 45 | +// Abrir mensaje en nueva pestaña |
| 46 | +function openMensaje() { |
| 47 | + window.open(document.getElementById('mensaje-url').value, '_blank'); |
| 48 | +} |
| 49 | + |
0 commit comments