- Fonctionnement de la plateforme, CGV des Pass et Boosts et mentions légales deviennent les annexes 1 à 3 des CGU (contenu inchangé, ancres conservées). - Anciennes adresses (#fonctionnement, #cgv, #mentions, #confidentialite, #cookies) redirigées vers leur nouvelle place : les liens d'app.html fonctionnent toujours. - Sommaire : les dernières sections, trop courtes pour remonter en haut de l'écran, s'allument au clic et en bas de page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lignes
3.8 KiB
JavaScript
94 lignes
3.8 KiB
JavaScript
// Espace légal Jobrunner : trois onglets par ancre (#cgu, #rgpd, #vie-privee), sommaire généré, export PDF.
|
|
(function () {
|
|
'use strict';
|
|
var TABS = ['cgu', 'rgpd', 'vie-privee'];
|
|
var DEFAULT = 'cgu';
|
|
// Anciennes adresses (app.html, liens déjà partagés) : documents regroupés en trois onglets le 13/10
|
|
var ALIAS = {
|
|
fonctionnement: ['cgu', 'annexe-fonctionnement'],
|
|
cgv: ['cgu', 'annexe-cgv'],
|
|
mentions: ['cgu', 'annexe-mentions'],
|
|
confidentialite: ['rgpd'],
|
|
cookies: ['vie-privee']
|
|
};
|
|
|
|
function buildSidebar(panel) {
|
|
var list = panel.querySelector('.sidebar ul');
|
|
if (!list || list.children.length) return;
|
|
panel.querySelectorAll('section.part').forEach(function (part) {
|
|
var h2 = part.querySelector('h2');
|
|
if (!h2 || !part.id) return;
|
|
var li = document.createElement('li');
|
|
var a = document.createElement('a');
|
|
a.href = '#' + panel.dataset.tab + '/' + part.id;
|
|
a.textContent = h2.textContent.trim();
|
|
a.dataset.target = part.id;
|
|
// Les dernières sections, trop courtes pour remonter en haut de l'écran, doivent aussi s'allumer au clic
|
|
a.addEventListener('click', function () { surligner(part.id); verrouClic = Date.now(); });
|
|
li.appendChild(a);
|
|
list.appendChild(li);
|
|
});
|
|
}
|
|
|
|
function show(tab, anchor) {
|
|
if (ALIAS[tab]) { anchor = anchor || ALIAS[tab][1]; tab = ALIAS[tab][0]; }
|
|
if (TABS.indexOf(tab) === -1) tab = DEFAULT;
|
|
document.querySelectorAll('.legal-panel').forEach(function (p) {
|
|
p.classList.toggle('active', p.dataset.tab === tab);
|
|
});
|
|
document.querySelectorAll('.legal-tab').forEach(function (a) {
|
|
if (a.dataset.tab === tab) {
|
|
a.setAttribute('aria-current', 'page');
|
|
// garde l'onglet actif visible dans la barre défilante (mobile)
|
|
if (a.scrollIntoView) a.scrollIntoView({ block: 'nearest', inline: 'center' });
|
|
} else a.removeAttribute('aria-current');
|
|
});
|
|
var panel = document.querySelector('.legal-panel[data-tab="' + tab + '"]');
|
|
if (!panel) return;
|
|
buildSidebar(panel);
|
|
var title = panel.querySelector('h1');
|
|
if (title) document.title = title.textContent.trim() + ' — Jobrunner';
|
|
var target = anchor && document.getElementById(anchor);
|
|
if (target) { target.scrollIntoView(); var part = target.closest('section.part'); if (part) surligner(part.id); }
|
|
else window.scrollTo(0, 0);
|
|
}
|
|
|
|
function route() {
|
|
var hash = decodeURIComponent(location.hash.replace('#', ''));
|
|
var parts = hash.split('/');
|
|
show(parts[0], parts[1]);
|
|
}
|
|
|
|
// Surligne la section visible dans le sommaire
|
|
var verrouClic = 0;
|
|
function surligner(id) {
|
|
document.querySelectorAll('.sidebar a').forEach(function (a) {
|
|
a.classList.toggle('active', a.dataset.target === id);
|
|
});
|
|
}
|
|
// En bas de page, la dernière section est la section courante
|
|
window.addEventListener('scroll', function () {
|
|
if (Date.now() - verrouClic < 800) return;
|
|
if (window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 4) {
|
|
var panel = document.querySelector('.legal-panel.active');
|
|
var parts = panel ? panel.querySelectorAll('section.part') : [];
|
|
if (parts.length) surligner(parts[parts.length - 1].id);
|
|
}
|
|
}, { passive: true });
|
|
if ('IntersectionObserver' in window) {
|
|
var observer = new IntersectionObserver(function (entries) {
|
|
if (Date.now() - verrouClic < 800) return;
|
|
entries.forEach(function (e) {
|
|
if (e.isIntersecting) surligner(e.target.id);
|
|
});
|
|
}, { rootMargin: '-90px 0px -70% 0px' });
|
|
document.querySelectorAll('section.part').forEach(function (s) { observer.observe(s); });
|
|
}
|
|
|
|
var printBtn = document.getElementById('legal-print');
|
|
if (printBtn) printBtn.addEventListener('click', function () { window.print(); });
|
|
|
|
window.addEventListener('hashchange', route);
|
|
route();
|
|
})();
|