51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import { collectIdentite, renderIdentite } from './sections/identite.js';
|
|
import { collectCompetences, renderCompetences } from './sections/competences.js';
|
|
import { collectFormation, renderFormation } from './sections/formation.js';
|
|
import { collectExperience, renderExperience } from './sections/experience.js';
|
|
import { collectHobbies, renderHobbies } from './sections/hobbies.js';
|
|
import { initI18n, t, changeLanguage, getLang } from './i18n.js';
|
|
|
|
function generateCV() {
|
|
const identite = collectIdentite();
|
|
|
|
if (!identite.nom || !identite.prenom || !identite.email || !identite.titre) return;
|
|
|
|
renderIdentite(identite);
|
|
renderCompetences(collectCompetences());
|
|
renderFormation(collectFormation());
|
|
renderExperience(collectExperience());
|
|
renderHobbies(collectHobbies());
|
|
|
|
localStorage.setItem('cvData', JSON.stringify(identite));
|
|
|
|
const success = document.getElementById('success');
|
|
if (success) {
|
|
success.textContent = t('success', { prenom: identite.prenom, nom: identite.nom });
|
|
success.style.display = 'block';
|
|
}
|
|
}
|
|
|
|
function updateActiveLangButton() {
|
|
const lang = getLang();
|
|
document.querySelectorAll('.lang-btn').forEach(btn => {
|
|
btn.classList.toggle('active', btn.dataset.lang === lang);
|
|
});
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
await initI18n();
|
|
updateActiveLangButton();
|
|
|
|
document.querySelectorAll('.lang-btn').forEach(btn => {
|
|
btn.addEventListener('click', async () => {
|
|
await changeLanguage(btn.dataset.lang);
|
|
updateActiveLangButton();
|
|
});
|
|
});
|
|
|
|
document.getElementById('cv-form')?.addEventListener('submit', (e) => {
|
|
e.preventDefault();
|
|
generateCV();
|
|
});
|
|
});
|