Test Public Side
This commit is contained in:
71
Elecciones-Web/frontend/public/bootstrap.js
vendored
Normal file
71
Elecciones-Web/frontend/public/bootstrap.js
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// public/bootstrap.js
|
||||
(function() {
|
||||
// --- CONFIGURACIÓN ---
|
||||
// Cambie esto por el dominio final en producción
|
||||
const WIDGETS_HOST = 'https://elecciones2025.eldia.com';
|
||||
|
||||
// --- FUNCIONES AUXILIARES (sin cambios) ---
|
||||
function loadScript(src) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const script = document.createElement('script');
|
||||
script.type = 'module';
|
||||
script.src = src;
|
||||
script.onload = resolve;
|
||||
script.onerror = reject;
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
}
|
||||
|
||||
function loadCSS(href) {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = href;
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
// --- LÓGICA PRINCIPAL ---
|
||||
async function initWidgets() {
|
||||
try {
|
||||
// 1. Obtener el manifest.json
|
||||
const response = await fetch(`${WIDGETS_HOST}/manifest.json`);
|
||||
if (!response.ok) throw new Error('No se pudo cargar el manifest.');
|
||||
const manifest = await response.json();
|
||||
|
||||
// 2. Encontrar el punto de entrada principal (nuestro main.tsx)
|
||||
// En modo 'lib', la entrada es el propio archivo de entrada.
|
||||
const entryKey = 'src/main.tsx';
|
||||
const entry = manifest[entryKey];
|
||||
|
||||
if (!entry) throw new Error('No se encontró el punto de entrada en el manifest.');
|
||||
|
||||
const jsUrl = `${WIDGETS_HOST}/${entry.file}`;
|
||||
|
||||
// 3. Cargar el CSS asociado, si existe
|
||||
if (entry.css && entry.css.length > 0) {
|
||||
entry.css.forEach(cssFile => {
|
||||
const cssUrl = `${WIDGETS_HOST}/${cssFile}`;
|
||||
loadCSS(cssUrl);
|
||||
});
|
||||
}
|
||||
|
||||
// 4. Cargar el script principal de la librería
|
||||
await loadScript(jsUrl);
|
||||
|
||||
// 5. Esperar a que la página esté completamente cargada
|
||||
// y luego llamar a la función de renderizado.
|
||||
window.addEventListener('load', function () {
|
||||
if (window.EleccionesWidgets && typeof window.EleccionesWidgets.render === 'function') {
|
||||
console.log('Elecciones Widgets listos. Renderizando...');
|
||||
window.EleccionesWidgets.render();
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error al inicializar los widgets de Elecciones:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Iniciar el proceso
|
||||
initWidgets();
|
||||
|
||||
})();
|
||||
6
Elecciones-Web/frontend/public/eldia.svg
Normal file
6
Elecciones-Web/frontend/public/eldia.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="89" height="69">
|
||||
<path d="M0 0 C29.37 0 58.74 0 89 0 C89 22.77 89 45.54 89 69 C59.63 69 30.26 69 0 69 C0 46.23 0 23.46 0 0 Z " fill="#008FBD" transform="translate(0,0)"/>
|
||||
<path d="M0 0 C3.3 0 6.6 0 10 0 C13.04822999 3.04822999 12.29337257 6.08805307 12.32226562 10.25390625 C12.31904297 11.32511719 12.31582031 12.39632812 12.3125 13.5 C12.32861328 14.57121094 12.34472656 15.64242187 12.36132812 16.74609375 C12.36197266 17.76832031 12.36261719 18.79054688 12.36328125 19.84375 C12.36775269 21.25430664 12.36775269 21.25430664 12.37231445 22.69335938 C12.1880188 23.83514648 12.1880188 23.83514648 12 25 C9 27 9 27 0 27 C0 18.09 0 9.18 0 0 Z " fill="#000000" transform="translate(0,21)"/>
|
||||
<path d="M0 0 C5.61 0 11.22 0 17 0 C17 3.3 17 6.6 17 10 C25.58 10 34.16 10 43 10 C43 10.99 43 11.98 43 13 C34.42 13 25.84 13 17 13 C17 17.29 17 21.58 17 26 C11.39 26 5.78 26 0 26 C0 24.68 0 23.36 0 22 C4.62 22 9.24 22 14 22 C14 16.06 14 10.12 14 4 C9.38 4 4.76 4 0 4 C0 2.68 0 1.36 0 0 Z " fill="#000000" transform="translate(46,21)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
Reference in New Issue
Block a user