/*
* EjacosMarket – optimisations pour Ecwid Instant Site
* À coller dans « Code JavaScript personnalisé ».
* Si le champ attend du HTML, entourez tout ce code de .
*
* Modules (chacun s'active ou se coupe dans CONFIG) :
* 1. Langue de la page en français (attribut lang)
* 2. Données structurées Google (boutique, adresse, réseaux, recherche)
* 3. Bandeau de Noël avec compte à rebours (disparaît après la date limite)
* 4. Bande de garanties (livraison, paiement, retours, service client)
* 5. Traduction des libellés restés en anglais
* 6. Nettoyage des codes parasites (& " ') dans les textes
* 7. Texte alternatif automatique pour les images qui n'en ont pas
*/
(function () {
'use strict';
var CONFIG = {
lang: true,
structuredData: true,
christmasBanner: true,
trustBar: true,
translate: true,
cleanEntities: true,
autoAlt: true,
// Date limite de commande pour Noël (livraison 6 à 8 jours)
christmasDeadline: '2026-12-15T23:59:59+01:00',
shop: {
name: 'EjacosMarket',
url: 'https://ejacosmarket.company.site/',
logo: 'https://d2j6dbq0eux0bg.cloudfront.net/images/72150502/logos/profile/5743685060.jpg',
email: 'ejacos.fr@gmail.com',
telephone: '+33939245859',
street: '11 Rue Georges Enesco',
postalCode: '78280',
city: 'Guyancourt',
region: 'Île-de-France',
country: 'FR',
sameAs: [
'https://instagram.com/ejacos',
'https://facebook.com/profile.php?id=61553923779415',
'https://x.com/Ejacos7',
'https://pinterest.com/EjacosEj7S',
'https://youtube.com/channel/UCZeJxqfwZouyxAaX9vg-LnQ',
'https://www.etsy.com/fr/shop/EjacosJPOH'
]
},
colors: { navy: '#131e3a', gold: '#d6ac60', text: '#ffffff' }
};
/* ---------- outils ---------- */
function onReady(fn) {
if (document.readyState !== 'loading') fn();
else document.addEventListener('DOMContentLoaded', fn);
}
function debounce(fn, ms) {
var t;
return function () { clearTimeout(t); t = setTimeout(fn, ms); };
}
function safeStorage(action, key, value) {
try {
if (action === 'get') return window.localStorage.getItem(key);
window.localStorage.setItem(key, value);
} catch (e) { return null; }
}
/* ---------- 1. langue ---------- */
if (CONFIG.lang) document.documentElement.setAttribute('lang', 'fr');
/* ---------- 2. données structurées ---------- */
function addStructuredData() {
if (document.getElementById('ejacos-jsonld')) return;
var s = CONFIG.shop;
var data = [
{
'@context': 'https://schema.org',
'@type': 'OnlineStore',
name: s.name,
url: s.url,
logo: s.logo,
email: s.email,
telephone: s.telephone,
address: {
'@type': 'PostalAddress',
streetAddress: s.street,
postalCode: s.postalCode,
addressLocality: s.city,
addressRegion: s.region,
addressCountry: s.country
},
sameAs: s.sameAs
},
{
'@context': 'https://schema.org',
'@type': 'WebSite',
name: s.name,
url: s.url,
inLanguage: 'fr-FR',
potentialAction: {
'@type': 'SearchAction',
target: s.url + 'search?keyword={search_term_string}',
'query-input': 'required name=search_term_string'
}
}
];
var tag = document.createElement('script');
tag.type = 'application/ld+json';
tag.id = 'ejacos-jsonld';
tag.textContent = JSON.stringify(data);
document.head.appendChild(tag);
}
/* ---------- styles communs ---------- */
function addStyles() {
if (document.getElementById('ejacos-styles')) return;
var c = CONFIG.colors;
var css =
'.ejacos-banner{position:relative;background:' + c.navy + ';color:' + c.text + ';text-align:center;' +
'font:600 15px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;padding:10px 44px;z-index:50}' +
'.ejacos-banner strong{color:' + c.gold + '}' +
'.ejacos-banner button{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:0;' +
'color:' + c.text + ';font-size:20px;cursor:pointer;line-height:1;padding:4px 8px}' +
'.ejacos-trust{display:flex;flex-wrap:wrap;justify-content:center;gap:8px 28px;background:#fff;' +
'border-bottom:1px solid #e5e7eb;padding:10px 16px;font:500 14px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;color:#111827}' +
'.ejacos-trust span{white-space:nowrap}' +
'@media (max-width:600px){.ejacos-banner{font-size:13px;padding:8px 40px}.ejacos-trust{gap:6px 16px;font-size:12px}}';
var st = document.createElement('style');
st.id = 'ejacos-styles';
st.textContent = css;
document.head.appendChild(st);
}
/* ---------- 3. bandeau de Noël ---------- */
function addChristmasBanner() {
var deadline = new Date(CONFIG.christmasDeadline);
var now = new Date();
if (now > deadline) return;
if (document.querySelector('.ejacos-banner')) return;
if (safeStorage('get', 'ejacos-banner-closed') === CONFIG.christmasDeadline) return;
var days = Math.ceil((deadline - now) / 86400000);
var bar = document.createElement('div');
bar.className = 'ejacos-banner';
bar.setAttribute('role', 'regio