refactor: factoriser le code en plusieurs fichiers
- Extrait le CSS inline vers css/base.css, css/form.css, css/button.css - Extrait le JS inline vers js/main.js, js/form/formHandler.js, js/storage/cvStorage.js - index.html devient un shell qui charge les fichiers externes - Ajoute les dossiers placeholder pour les futures sections : education, experience, hobbies
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { saveCvData } from '../storage/cvStorage.js';
|
||||
|
||||
export function initForm() {
|
||||
document.getElementById('cv-form').addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const nom = document.getElementById('nom').value.trim();
|
||||
const prenom = document.getElementById('prenom').value.trim();
|
||||
const email = document.getElementById('email').value.trim();
|
||||
const titre = document.getElementById('titre').value.trim();
|
||||
|
||||
if (!nom || !prenom || !email || !titre) return;
|
||||
|
||||
const formData = { nom, prenom, email, titre };
|
||||
saveCvData(formData);
|
||||
|
||||
const success = document.getElementById('success');
|
||||
success.textContent = `CV prêt à être généré pour ${prenom} ${nom} !`;
|
||||
success.style.display = 'block';
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { initForm } from './form/formHandler.js';
|
||||
|
||||
initForm();
|
||||
@@ -0,0 +1,8 @@
|
||||
export function saveCvData(data) {
|
||||
localStorage.setItem('cvData', JSON.stringify(data));
|
||||
}
|
||||
|
||||
export function loadCvData() {
|
||||
const raw = localStorage.getItem('cvData');
|
||||
return raw ? JSON.parse(raw) : null;
|
||||
}
|
||||
Reference in New Issue
Block a user