382 lines
15 KiB
JavaScript
382 lines
15 KiB
JavaScript
/* WEVAL fixes v5 - safe */
|
||
|
||
/* 1. FAQ French accent fixes */
|
||
(function(){
|
||
var t=0,iv=setInterval(function(){
|
||
var els=document.querySelectorAll('p,div,span');
|
||
var fixed=0;
|
||
els.forEach(function(el){
|
||
if(!el.dataset.faqfix && el.textContent && el.textContent.length>20){
|
||
var html=el.innerHTML;
|
||
var orig=html;
|
||
html=html.replace(/360\?\?/g,'360°');
|
||
html=html.replace(/acceleree/g,'accélérée');
|
||
html=html.replace(/Durabilite/g,'Durabilité');
|
||
html=html.replace(/certifie et conforme/g,'certifié et conforme');
|
||
html=html.replace(/securite les plus/g,'sécurité les plus');
|
||
html=html.replace(/proprietaire/g,'propriétaire');
|
||
if(html!==orig){el.innerHTML=html;el.dataset.faqfix='1';fixed++}
|
||
}
|
||
});
|
||
if(fixed>0||++t>30)clearInterval(iv);
|
||
},500);
|
||
})();
|
||
|
||
/* 2. References nav link - <a> tag, FR/EN via localStorage */
|
||
(function(){
|
||
function getLang(){
|
||
try{return localStorage.getItem('weval-lang')||'fr'}catch(e){return 'fr'}
|
||
}
|
||
function updateText(el){
|
||
if(!el)return;
|
||
el.textContent=getLang()==='en'?'References':'Références';
|
||
}
|
||
var t=0,iv=setInterval(function(){
|
||
var nav=document.querySelector('.main-navigation');
|
||
if(nav && !document.getElementById('nav-references')){
|
||
var prodLink=document.getElementById('nav-products');
|
||
if(!prodLink){
|
||
nav.querySelectorAll('button,a').forEach(function(el){
|
||
if((el.textContent||'').trim()==='Products') prodLink=el;
|
||
});
|
||
}
|
||
if(prodLink){
|
||
var a=document.createElement('a');
|
||
a.id='nav-references';
|
||
a.className='nav-link';
|
||
a.href='/blog/use-cases.html';
|
||
a.style.cssText='background:none;border:none;color:#374151;font-size:13.5px;font-weight:500;cursor:pointer;padding:.6rem .45rem;text-decoration:none;white-space:nowrap';
|
||
updateText(a);
|
||
if(prodLink.nextSibling){
|
||
nav.insertBefore(a,prodLink.nextSibling);
|
||
} else {
|
||
nav.appendChild(a);
|
||
}
|
||
}
|
||
}
|
||
/* Mobile nav */
|
||
var mobileNav=document.querySelector('.mobile-nav-links');
|
||
if(mobileNav && !document.getElementById('nav-references-mobile')){
|
||
var mLinks=mobileNav.querySelectorAll('button,a');
|
||
var pm=null;
|
||
mLinks.forEach(function(el){
|
||
if((el.textContent||'').trim()==='Products') pm=el;
|
||
});
|
||
if(pm){
|
||
var ma=document.createElement('a');
|
||
ma.id='nav-references-mobile';
|
||
ma.className=pm.className||'mobile-nav-link';
|
||
ma.href='/blog/use-cases.html';
|
||
ma.style.textDecoration='none';
|
||
updateText(ma);
|
||
if(pm.nextSibling){
|
||
pm.parentNode.insertBefore(ma,pm.nextSibling);
|
||
} else {
|
||
pm.parentNode.appendChild(ma);
|
||
}
|
||
}
|
||
}
|
||
if(++t>40)clearInterval(iv);
|
||
},500);
|
||
|
||
/* Watch for language changes */
|
||
var origSet=localStorage.setItem.bind(localStorage);
|
||
try{
|
||
localStorage.setItem=function(k,v){
|
||
origSet(k,v);
|
||
if(k==='weval-lang'){
|
||
updateText(document.getElementById('nav-references'));
|
||
updateText(document.getElementById('nav-references-mobile'));
|
||
}
|
||
};
|
||
}catch(e){}
|
||
})();
|
||
|
||
|
||
/* 3. Fix footer links - accented URLs to actual file paths */
|
||
(function(){
|
||
var t=0,iv=setInterval(function(){
|
||
var links=document.querySelectorAll('a[href]');
|
||
links.forEach(function(a){
|
||
var h=a.getAttribute('href');
|
||
if(h==='/méthodologie.html') a.setAttribute('href','/methodologie.html');
|
||
});
|
||
if(++t>40)clearInterval(iv);
|
||
},800);
|
||
})();
|
||
|
||
/* 4. Remove duplicate Products in nav */
|
||
(function(){
|
||
var t=0,iv=setInterval(function(){
|
||
var nav=document.querySelector('.main-navigation');
|
||
if(nav){
|
||
var prods=[];
|
||
nav.querySelectorAll('button,a').forEach(function(el){
|
||
if((el.textContent||'').trim()==='Products') prods.push(el);
|
||
});
|
||
if(prods.length>1){
|
||
prods[1].remove();
|
||
clearInterval(iv);
|
||
}
|
||
}
|
||
if(++t>40)clearInterval(iv);
|
||
},600);
|
||
})();
|
||
|
||
/* 5. WhatsApp button in sticky CTA bar next to Prendre RDV */
|
||
(function(){
|
||
var t=0,iv=setInterval(function(){
|
||
var btns=document.querySelectorAll('button,a');
|
||
var rdvBtn=null;
|
||
btns.forEach(function(b){
|
||
var txt=(b.textContent||'').trim();
|
||
if(txt==='Prendre RDV'||txt==='Book a meeting') rdvBtn=b;
|
||
});
|
||
if(rdvBtn && !document.getElementById('wv-wa-cta')){
|
||
var wa=document.createElement('a');
|
||
wa.id='wv-wa-cta';
|
||
wa.href='https://wa.me/33647087627?text=Bonjour%20WEVAL%2C%20je%20souhaite%20en%20savoir%20plus';
|
||
wa.target='_blank';
|
||
wa.rel='noopener';
|
||
wa.style.cssText='display:inline-flex;align-items:center;gap:6px;background:#25D366;color:#fff;border:none;padding:8px 18px;border-radius:25px;font-size:13px;font-weight:600;text-decoration:none;white-space:nowrap;cursor:pointer;box-shadow:0 2px 8px rgba(37,211,102,0.4);transition:all .2s';
|
||
wa.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="white"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>WhatsApp';
|
||
wa.onmouseover=function(){this.style.transform='translateY(-2px)';this.style.boxShadow='0 4px 12px rgba(37,211,102,0.5)'};
|
||
wa.onmouseout=function(){this.style.transform='';this.style.boxShadow='0 2px 8px rgba(37,211,102,0.4)'};
|
||
rdvBtn.parentNode.insertBefore(wa,rdvBtn.nextSibling);
|
||
clearInterval(iv);
|
||
}
|
||
if(++t>50)clearInterval(iv);
|
||
},600);
|
||
})();
|
||
|
||
/* 6. Hide floating WhatsApp bubble (now in CTA bar) */
|
||
(function(){
|
||
var s=document.createElement('style');
|
||
s.textContent='#weval-whatsapp{display:none!important}';
|
||
document.head.appendChild(s);
|
||
})();
|
||
|
||
/* 7. Force client logos slider with animation */
|
||
(function(){
|
||
var t=0,iv=setInterval(function(){
|
||
var el=document.querySelector('.logos-slider');
|
||
if(el && !el.dataset.wvSlider){
|
||
el.dataset.wvSlider='1';
|
||
var logos=[
|
||
["Abbott-BBqN71LY.png","Abbott"],["AbbVie-DrAnGwE6.png","AbbVie"],
|
||
["LOreal-Dyr2mSS8.png","L'Oréal"],["carrefour-BExziI9J.png","Carrefour"],
|
||
["intermarche-CclDwFVk.png","Intermarché"],["Michelin-C394e1Ut.png","Michelin"],
|
||
["Point-p-FB9NU5Ha.png","Point P"],["geodis-D3847iTr.png","Geodis"],
|
||
["saham-bank-xjtdeNfo.png","Société Générale"],["Ocp-group-Djer-YwL.png","OCP"],
|
||
["ratp-D6fh_40B.png","RATP"],["Safran-CZsHqZN5.png","Safran"],
|
||
["Faiveley-DofO1lx4.png","Faiveley"],["Givaudan-BwJ_2RJS.png","Givaudan"],
|
||
["SNTL-yETbLVxR.png","SNTL"],["lesaffre-BVekOo93.png","AB Lesaffre"],
|
||
["REUNICAA-B8cSoEBJ.png","Réunica"]
|
||
];
|
||
el.innerHTML='';
|
||
for(var r=0;r<2;r++) logos.forEach(function(c){
|
||
var i=document.createElement('img');
|
||
i.src='/assets/'+c[0]; i.alt=c[1]; i.loading='lazy';
|
||
i.style.cssText='height:70px;width:auto;max-width:220px;object-fit:contain;opacity:.85;transition:all .3s;flex-shrink:0';
|
||
i.onmouseenter=function(){this.style.opacity='1';this.style.transform='scale(1.05)'};
|
||
i.onmouseleave=function(){this.style.opacity='.85';this.style.transform='scale(1)'};
|
||
el.appendChild(i);
|
||
});
|
||
/* Force animation restart */
|
||
el.style.animation='none';
|
||
el.offsetHeight;
|
||
el.style.animation='slide 50s linear infinite';
|
||
clearInterval(iv);
|
||
}
|
||
if(++t>80)clearInterval(iv);
|
||
},400);
|
||
})();
|
||
|
||
/* 7. Partners slider - show section */
|
||
(function(){
|
||
var s=document.createElement("style");
|
||
s.textContent=".partners-section{display:block!important;padding:3rem 0;background:#f8fafc}";
|
||
document.head.appendChild(s);
|
||
})();
|
||
|
||
/* Fix CSS leak in L99/Brain pages */
|
||
(function hideCSSLeak(){
|
||
var b=document.body;
|
||
if(!b)return;
|
||
var nodes=b.childNodes;
|
||
for(var i=0;i<nodes.length;i++){
|
||
var n=nodes[i];
|
||
if(n.nodeType===3 && n.textContent && n.textContent.indexOf("data-theme")>-1){
|
||
n.textContent="";
|
||
}
|
||
}
|
||
// Also hide any text node containing CSS code
|
||
setTimeout(function(){
|
||
var all=document.querySelectorAll("body > *");
|
||
for(var j=0;j<all.length;j++){
|
||
var el=all[j];
|
||
if(el.tagName!=="STYLE" && el.tagName!=="SCRIPT" && el.textContent &&
|
||
el.textContent.indexOf("weval-theme-btn")>-1 && el.textContent.indexOf("{")>-1) {
|
||
el.style.display="none";
|
||
}
|
||
}
|
||
},500);
|
||
})();
|
||
|
||
|
||
/* === MOBILE MENU FIX (3avr26) === */
|
||
(function(){
|
||
var btn = document.querySelector('.mobile-toggle');
|
||
var nav = document.querySelector('.mobile-navigation');
|
||
if(btn && nav){
|
||
btn.addEventListener('click', function(e){
|
||
e.stopPropagation();
|
||
nav.classList.toggle('active');
|
||
/* Force z-index */
|
||
nav.style.zIndex = '9999';
|
||
nav.style.pointerEvents = 'auto';
|
||
});
|
||
/* Close on outside click */
|
||
document.addEventListener('click', function(e){
|
||
if(nav.classList.contains('active') && !nav.contains(e.target) && !btn.contains(e.target)){
|
||
nav.classList.remove('active');
|
||
}
|
||
});
|
||
/* Close on link click */
|
||
nav.querySelectorAll('button,a').forEach(function(link){
|
||
link.addEventListener('click', function(){
|
||
nav.classList.remove('active');
|
||
});
|
||
});
|
||
}
|
||
})();
|
||
|
||
/* === MOBILE MENU FIX v2 (3avr26) — ROBUST OVERRIDE === */
|
||
(function(){
|
||
function initMobileMenu(){
|
||
var btn = document.querySelector('.mobile-toggle');
|
||
var nav = document.querySelector('.mobile-navigation');
|
||
if(!btn || !nav) return setTimeout(initMobileMenu, 500);
|
||
|
||
var isOpen = false;
|
||
|
||
/* Clone button to remove React handlers */
|
||
var newBtn = btn.cloneNode(true);
|
||
btn.parentNode.replaceChild(newBtn, btn);
|
||
|
||
newBtn.addEventListener('click', function(e){
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
isOpen = !isOpen;
|
||
if(isOpen){
|
||
nav.style.cssText = 'transform:translateX(0) !important;opacity:1 !important;visibility:visible !important;pointer-events:auto !important;z-index:9999 !important;';
|
||
} else {
|
||
nav.style.cssText = '';
|
||
nav.classList.remove('active');
|
||
}
|
||
});
|
||
|
||
/* Override nav link clicks with direct navigation */
|
||
var links = nav.querySelectorAll('button, a');
|
||
links.forEach(function(link){
|
||
var clone = link.cloneNode(true);
|
||
link.parentNode.replaceChild(clone, link);
|
||
clone.addEventListener('click', function(e){
|
||
var text = this.textContent.trim().toLowerCase();
|
||
var pathMap = {
|
||
'accueil':'/','home':'/',
|
||
'services':'/#our-services',
|
||
'solutions':'/nos-solutions',
|
||
'marketplace':'/marketplace',
|
||
'blog':'/blog',
|
||
'produits':'/products/','products':'/products/',
|
||
'wevia':'/wevia','ia':'/wevia',
|
||
'contact':'/contact','contactez-nous':'/contact',
|
||
'actualites':'/actualites','news':'/actualites',
|
||
'references':'/#references',
|
||
'booking':'/booking.html'
|
||
};
|
||
var href = null;
|
||
for(var key in pathMap){
|
||
if(text.indexOf(key) !== -1){ href = pathMap[key]; break; }
|
||
}
|
||
if(href){
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
nav.style.cssText = '';
|
||
isOpen = false;
|
||
window.location.href = href;
|
||
}
|
||
});
|
||
});
|
||
|
||
/* Close on outside click */
|
||
document.addEventListener('click', function(e){
|
||
if(isOpen && !nav.contains(e.target) && !newBtn.contains(e.target)){
|
||
nav.style.cssText = '';
|
||
isOpen = false;
|
||
}
|
||
});
|
||
}
|
||
|
||
/* Wait for React to render */
|
||
if(document.readyState === 'loading'){
|
||
document.addEventListener('DOMContentLoaded', function(){ setTimeout(initMobileMenu, 300); });
|
||
} else {
|
||
setTimeout(initMobileMenu, 300);
|
||
}
|
||
})();
|
||
|
||
/* FIX 8: Partner logos slider gap */
|
||
(function(){
|
||
var s=document.querySelector('[style*="gap:2rem"]')||document.querySelector('.logos-slider,.partners-slider,.logo-slider,.clients');
|
||
if(s){s.style.gap='0';s.style.justifyContent='center';s.style.alignItems='center';}
|
||
// Fix logos-slider gap
|
||
var ls=document.querySelector('.logos-slider');
|
||
if(ls){ls.style.gap='2rem';ls.style.setProperty('gap','2rem','important');}
|
||
// Also fix any marquee/scroll gaps
|
||
document.querySelectorAll('[class*=marquee],[class*=scroll],[class*=slider]').forEach(function(e){
|
||
e.style.gap='0px';
|
||
});
|
||
})();
|
||
|
||
// Fix 9: REMOVED — was causing homepage redirect to command center
|
||
|
||
/* FIX 10: Mobile slider */
|
||
(function(){var s=document.createElement('style');s.textContent='.logos-slider{display:flex!important;overflow:hidden!important;width:100%!important}.logos-slider img{flex-shrink:0!important}@keyframes slide{0%{transform:translateX(0)}100%{transform:translateX(-50%)}}@media(max-width:768px){.logos-slider img{height:35px!important;max-width:100px!important;margin:0 .8rem!important}}@media(max-width:480px){.logos-slider img{height:28px!important;max-width:80px!important;margin:0 .5rem!important}}';document.head.appendChild(s)})();
|
||
|
||
|
||
|
||
|
||
/* FIX 11v4: hamburger event delegation (survives SPA re-render) */
|
||
(function(){
|
||
var navStyled=false;
|
||
document.addEventListener("click",function(e){
|
||
var btn=e.target.closest(".mobile-toggle");
|
||
if(!btn)return;
|
||
e.preventDefault();e.stopPropagation();
|
||
var nav=document.querySelector(".mobile-navigation");
|
||
if(!nav)return;
|
||
if(!navStyled){
|
||
navStyled=true;
|
||
nav.style.position="fixed";nav.style.top="0";nav.style.left="-100%";
|
||
nav.style.width="85%";nav.style.maxWidth="320px";nav.style.height="100vh";
|
||
nav.style.background="#1a1a2e";nav.style.zIndex="10000";
|
||
nav.style.transition="left .3s";nav.style.padding="70px 0 20px";
|
||
nav.style.overflowY="auto";nav.style.display="flex";
|
||
nav.style.flexDirection="column";nav.style.boxShadow="2px 0 20px rgba(0,0,0,.5)";
|
||
nav.querySelectorAll("button,a").forEach(function(l){
|
||
l.style.cssText="display:block;width:100%;padding:14px 24px;color:white;background:none;border:none;border-bottom:1px solid rgba(255,255,255,.08);font-size:1rem;text-align:left;cursor:pointer";
|
||
});
|
||
var cl=document.createElement("div");cl.innerHTML="×";
|
||
cl.style.cssText="position:absolute;top:15px;right:18px;font-size:32px;color:white;cursor:pointer;z-index:10001";
|
||
cl.addEventListener("click",function(){nav.style.left="-100%"});
|
||
nav.insertBefore(cl,nav.firstChild);
|
||
nav.querySelectorAll("button,a").forEach(function(l){
|
||
l.addEventListener("click",function(){nav.style.left="-100%"});
|
||
});
|
||
}
|
||
var open=nav.style.left==="0px";
|
||
nav.style.left=open?"-100%":"0px";
|
||
},true);
|
||
})(); |