feat: splitted js in different modules
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Guardar/cargar el patrón completo (secciones + personalización de
|
||||
// página) en localStorage. Para integrarlo con Django, bastaría con
|
||||
// sustituir estos dos listeners por una llamada a la API (POST del JSON de
|
||||
// serializeSections()+serializePageSettings() / GET para restaurarlo con
|
||||
// buildSectionsFrom()+applyPageSettings()).
|
||||
|
||||
import { serializeSections, buildSectionsFrom } from './section-types.js';
|
||||
import { serializePageSettings, applyPageSettings } from './page-settings.js';
|
||||
import { renderOutput } from './render.js';
|
||||
|
||||
const SECTIONS_STORAGE_KEY = 'sections-data';
|
||||
|
||||
document.getElementById('save-pattern').addEventListener('click', () => {
|
||||
const data = { sections: serializeSections(), pageSettings: serializePageSettings() };
|
||||
localStorage.setItem(SECTIONS_STORAGE_KEY, JSON.stringify(data));
|
||||
});
|
||||
|
||||
document.getElementById('load-pattern').addEventListener('click', () => {
|
||||
const raw = localStorage.getItem(SECTIONS_STORAGE_KEY);
|
||||
if (!raw) return;
|
||||
const data = JSON.parse(raw);
|
||||
buildSectionsFrom(data.sections || []);
|
||||
applyPageSettings(data.pageSettings);
|
||||
renderOutput();
|
||||
});
|
||||
Reference in New Issue
Block a user