1$(function(){$(document).on("click keydown",".maxreadReadMore",function(e){if(e.type==="keydown"&&e.keyCode!==13&&e.keyCode!==32)return;e.preventDefault();var w=$(this).closest(".maxread-wrapper");var btn=$(this);w.toggleClass("maxread-expanded");btn.text(w.hasClass("maxread-expanded")?btn.data("text-less"):btn.data("text-more"));});$(".fromA").on("click",function(event){event.preventDefault();var formulaire=$("<form>").attr({action:$(this).attr("href"),method:"post"});formulaire.append('<input type="hidden" name="fromA" value="1">');$("body").append(formulaire);formulaire.submit();});});function changeLangue(lang){document.location="/?lang="+lang;} 2function changeCurrency(monnaie){var urlBase=window.location.origin+window.location.pathname;document.location=urlBase+"?devise="+monnaie;} 3function changePrice(valeur,changeval){return valeur*changeval;} 4function stickyHeader(){var scrollDir=$(window).scrollTop();if(scrollDir>position&&scrollDir>200){$('.primaryHeader').addClass('sticky');} 5else{$('.primaryHeader').removeClass('sticky');} 6position=scrollDir;} 7function stickySpots(){var scrollDir=$(window).scrollTop();var scrollBottom=$(window).scrollTop()+$(window).height();var footerHeight=$('.primaryFooter').height();var footerShowLimit=$(document).height()-footerHeight;if(scrollDir>200&&scrollBottom<footerShowLimit){$('.footerSpotPrices').addClass('stickySpots');} 8else{$('.footerSpotPrices').removeClass('stickySpots');}} 9function controlBodyScroll(){$('body').css('overflow',($('.headerNavigationController').is(':checked'))?'hidden':'visible');} 10function uncheckOtherCheckboxes(others,changed){(others).not(changed).prop('checked',false);} 11function uncheckRadios(radios){(radios).prop('checked',false);} 12function scrollToElement(frame,element,changed){var checkBoxId=changed.attr("id");if(changed.is(':checked')&&checkBoxId=="id_1"){(frame).animate({scrollTop:40},300);} 13else{if(changed.is(':checked')&&checkBoxId=="id_2"){(frame).animate({scrollTop:110},300);} 14else{if(changed.is(':checked')&&checkBoxId=="id_3"){(frame).animate({scrollTop:180},300);} 15else{(frame).animate({scrollTop:0},300);}}}} 16function makeTabRoom(){var tabHeight=$('.lvl_2NavController:checked + .lvl_2 .lvl3Container').innerHeight();var openedTab=$('.lvl_2NavController:checked + .lvl_2');var otherTabs=$('.lvl_2NavController + .lvl_2').not($('.lvl_2NavController:checked + .lvl_2'));openedTab.innerHeight(tabHeight+25);otherTabs.innerHeight(40);} 17function setMenuMaxHeight(){var windowHeight=$(window).height();var docScroll=$(document).scrollTop();var menuPosistion=($('.lvl1Scroller').offset().top)-docScroll;var menuMaxHeight=windowHeight-menuPosistion-31;if(windowHeight<600){$('.lvl1Scroller').each(function(){$(this).css("max-height",menuMaxHeight);});};} 18function alignCategNav(){var containerWidth=$('.categorieProducts').width();var howManyFit=Math.floor(containerWidth/360);var categNavPosition=(containerWidth/2)-(howManyFit*180);$('.categorieNav').css("right",categNavPosition);} 19function whatIsScrollBarWidth(){var scrollDiv=document.createElement("div");scrollDiv.className="scrollbar-measure";document.body.appendChild(scrollDiv);var scrollbarWidth=scrollDiv.offsetWidth-scrollDiv.clientWidth;$(".scrollbar-measure").remove();return scrollbarWidth;} 20function compensateScrollBarWidth(){var theCss='@media (min-width: 768px) {\ 21 .jaiUnPadding {padding-right: '+whatIsScrollBarWidth()+'px;}\ 22 .jaiUnPadding .stickySpots {right: '+whatIsScrollBarWidth()+'px;}\ 23 .jaiUnPadding .primaryHeader {right: '+whatIsScrollBarWidth()+'px;}\ 24 .jaiUnPadding .navigationWrapper {right: '+(30+whatIsScrollBarWidth())+'px;}\ 25 .jaiUnPadding .sticky .navigationWrapper {right: 3rem;}\ 26 .jaiUnPadding .searchDropdown {right: '+(290+whatIsScrollBarWidth())+'px;}\ 27 .jaiUnPadding .sticky .searchDropdown {left: 25rem; right: 29rem;}\ 28 }\ 29 @media (min-width: 1240px) {.jaiUnPadding .searchDropdown {left: calc(50% - '+(whatIsScrollBarWidth()/2)+'px);}}\ 30 @media (min-width: 768px) {.jaiUnPadding .sticky .searchDropdown {left: 25rem; right: 29rem;}}\ 31 @media (min-width: 992px) {.jaiUnPadding .sticky .searchDropdown {left: 33rem;}}\ 32 @media (min-width: 1240px) {.jaiUnPadding .sticky .searchDropdown {left: 50%;}}\ 33 ';var theHead=document.head||document.getElementsByTagName('head')[0];var theStyle=document.createElement('style');var theAttribute=document.createAttribute('ajouted');theStyle.type='text/css';theStyle.setAttributeNode(theAttribute) 34theStyle.appendChild(document.createTextNode(theCss));theHead.appendChild(theStyle);} 35function deCompensateScrollBarWidth(){$("style[ajouted]").remove();} 36function displayPopinAfterLoad(popinName){getRequiredLabels();formListen();if(typeof passkeySyncCsrfFromPopin==="function")passkeySyncCsrfFromPopin();if(popinName=="loginOtp"||$(".loginOtpForm").length){initLoginOtpResend();initLoginOtpInput();}if(popinName=="login"||$(".passkeyLoginBlock").length){if(typeof initPasskeyLoginBlock==="function")initPasskeyLoginBlock();}if(popinName=="passkeyEnroll"||$(".popinPasskeyEnroll").length||$("#passkeyEnrollBtn").length){if(typeof initPasskeyEnrollBlock==="function")initPasskeyEnrollBlock();}if(popinName=="coursCPR"){if($("#popin").length){var runGoChart=function(){if(typeof goChart==="function"){goChart();}};$("#popin").off("shown.bs.modal.coursCPR");if($("#popin").hasClass("show")){setTimeout(runGoChart,0);}else{$("#popin").one("shown.bs.modal.coursCPR",runGoChart);}}else{goChart();}}} 37function cleanupBootstrapModalOrphans(){var $popin=$("#popin");if(!$popin.length||!$popin.hasClass("show")){$(".modal-backdrop").remove();$("body").removeClass("modal-open").css("padding-right","");}} 38function displayPopin(popin){resPop=popin.split("-");var popinName=resPop[0];if($("#popin").length){$(".popinOverlay").removeClass("popinOverlayOpen");$("body").removeClass("bodyNotScrollable");$.post("/popinModal",{popin:resPop[0],typ:resPop[1],lid:resPop[2]}
38,function(data){if(!$.trim(data||"")){if($("#popin").hasClass("show")){$("#popin").modal("hide");}cleanupBootstrapModalOrphans();return;}var $dlg=$("#popin .modal-dialog");$dlg.removeClass("modal-lg modal-xl modal-sm modal-otp");if(popinName=="loginOtp"){$dlg.addClass("modal-otp");}if(popinName=="detailsCommande"||popinName=="detailsVente"||popinName=="detailsRachat"||popinName=="coursCPR"){$dlg.addClass("modal-lg");}$("#popin .modal-content").html(data);displayPopinAfterLoad(popinName);$("#popin").off("shown.bs.modal.loginOtp").on("shown.bs.modal.loginOtp",function(){if($(".loginOtpForm").length)initLoginOtpInput();});$("#popin").modal("show");});return;}$.post("/popin",{popin:resPop[0],typ:resPop[1],lid:resPop[2]},function(data){$(".popinOverlay").html(data);$(".popinWrapper").addClass($(".laClass").val());$(".popinOverlay").addClass("popinOverlayOpen");$("body").addClass("bodyNotScrollable");displayPopinAfterLoad(popinName);});} 39function hidePopin(){if($("#popin").length&&$("#popin").hasClass("show")){$("#popin").modal("hide");}cleanupBootstrapModalOrphans();if($(".laClass").val()=="popinCheckout"){$(".panierChoixPaiementCTA").removeAttr("disabled");} 40$(".popinOverlay").removeClass("popinOverlayOpen");$("body").removeClass("bodyNotScrollable");getBasket();} 41function hideMenuFromOutsideClick(e){e=e||window.event;if(!$(e.target).closest('.lvl_0').length){if(!$(e.target).closest('.popinOverlay').length){$('.lvl_0NavController').prop('checked',false);$("html, body").removeClass("bodyNotScrollable");if((whatIsScrollBarWidth()>0)&&($(document).height()>$(window).height())){$('html').removeClass("jaiUnPadding");};}}} 42function dealWithColRight(){var fpNbe=$(".fauxProduit").length+1;var fpHeight=$(".mepCategController:checked ~ .categorieProducts .categorieProduct.fauxProduit").outerHeight(true);var ftHeight=$(".filtresTri").outerHeight(true);var colLeftPadTop=parseInt($(".categorieProducts").css("padding-top"),10);var colRightHeight=fpNbe*fpHeight+ftHeight+colLeftPadTop;if($(".mepCategController").is(':checked')){$(".categorieProducts").css("min-height",colRightHeight);} 43else{$(".categorieProducts").css("min-height","");};} 44function setVuCookie(){localStorage.setItem('cookieAlert',1);$(".cookies").hide();} 45function getRequiredLabels(){$("[required]").prev("label").addClass("requiredLabel");} 46function number_format(number,decimals,dec_point,thousands_sep){number=(number+'').replace(/[^0-9+\-Ee.]/g,'');var n=!isFinite(+number)?0:+number,prec=!isFinite(+decimals)?0:Math.abs(decimals),sep=(typeof thousands_sep==='undefined')?',':thousands_sep,dec=(typeof dec_point==='undefined')?'.':dec_point,s='',toFixedFix=function(n,prec){var k=Math.pow(10,prec);return''+(Math.round(n*k)/k).toFixed(prec);};s=(prec?toFixedFix(n,prec):''+Math.round(n)).split('.');if(s[0].length>3){s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,sep);} 47if((s[1]||'').length<prec){s[1]=s[1]||'';s[1]+=new Array(prec-s[1].length+1).join('0');} 48return s.join(dec);} 49function parsePanierMontant(t){var s=String(t==null?"":t).replace(/â¬/g,"").replace(/\s/g,"");if(s.indexOf(".")<0&&/,/.test(s))s=s.replace(",",".");var n=parseFloat(s);return isNaN(n)?0:n;} 50function createNoty(message,type,duration){switch(type){case"warning":var classAlert="warning";break;case"success":var classAlert="success";break;case"info":var classAlert="info";break;case"danger":var classAlert="error";break;} 51$("#noty-content").html(message);$("#noty-holder").removeClass("d-none alert-success").addClass("displayed alert-"+classAlert);if(duration>0){setTimeout(function(){$("#noty-holder").removeClass("displayed alert-"+classAlert).addClass("d-none alert-success");$("#noty-content").empty();},duration);}};function vide(){} 52function addQrs(quest){$("#qrs").html('<label for="recoveryQuestion-1">'+quest+'</label><input id="recoveryQuestion-1" name="qrs" type="text" required>');} 53function errorQrs(texte){$("#recov").replaceWith('<div class="formIndication">'+texte+'</div>');} 54function parseAjaxJson(data){return(typeof data==="string")?$.parseJSON(data):data;} 55function clearLoginOtpError(){$("#loginOtpError").addClass("d-none is-hidden").empty();} 56function showLoginOtpError(message){var msg=(message&&String(message).length)?String(message):"";var $el=$("#loginOtpError");
56if($el.length){if(msg){$el.removeClass("d-none is-hidden").html(msg);}else{$el.addClass("d-none is-hidden").empty();}}else if(msg){createNoty(msg,"danger",5000);}} 57function formListen(){$("form").off("submit").on("submit",function(e){e.preventDefault();if(typeof this.checkValidity==='function'&&!this.checkValidity()){this.reportValidity();return;}var $form=$(this);var isLoginOtp=$form.hasClass("loginOtpForm");if(isLoginOtp)clearLoginOtpError();var sData=$form.serialize();var laction=""+$form.attr("action");if(laction.length>2){$(".panierValideVenteCTA,.JQActionBtn").attr("disabled","disabled");if(isLoginOtp)$form.find("[type=submit]").prop("disabled",true);$.post(laction,{datas:sData},function(returnResult){var result;try{result=parseAjaxJson(returnResult);}catch(err){if(isLoginOtp){showLoginOtpError("");$form.find("[type=submit]").prop("disabled",false);}return;}if(result['result']){var passkeyContinueLogin=function(){if(result['success_msg']&&result['success_msg'].length>1){createNoty(result['success_msg'],'success',3000);} 58if(result['redirect']!==undefined&&result['redirect'].length>1){setTimeout('document.location="'+result['redirect']+'"',3000);} 59else if(result['redraw']!==undefined&&result['redraw'].length>1){$("#"+result['redraw']).DataTable().draw();$(".modal").modal('hide');} 60else if(result['reload']==1){document.location.reload();} 61else if(result['doPopin']==1){displayPopin(result['doWhat']);$("#noty-holder").removeClass("displayed");} 62else if(result['fonction']==1){eval(result['action']+"()");} 63else if(result['addBack']==1){$("#moreContent").html(result['theContent']);} 64if(isLoginOtp&&!result['reload'])$form.find("[type=submit]").prop("disabled",false);}; 65if(result['passkey_offer_enroll']==1&&typeof passkeyMaybeOfferEnrollAfterLogin==="function"){passkeyMaybeOfferEnrollAfterLogin(result,passkeyContinueLogin);}else{passkeyContinueLogin();}} 66else{if(isLoginOtp){showLoginOtpError(result['error_msg']);$form.find("[type=submit]").prop("disabled",false);resetLoginOtpDigits();}else{createNoty(result['error_msg'],'danger',5000);}if(result['black']==1){document.location.reload();}}}).fail(function(){if(isLoginOtp){showLoginOtpError("");$form.find("[type=submit]").prop("disabled",false);}});}});} 67function addFavorite(what){$.post("/gestFav",{'fav':what,'add':1},function(data){var result=$.parseJSON(data);if(result['result']){$(".JQfav"+parseInt(what)).attr("disabled","disabled").removeAttr("onclick").prop("onclick",null).attr("title",messages[1]);$(".JQfav"+parseInt(what)).find("span").text(messages[1]);$(".JQfav"+parseInt(what)).find("i").removeClass('far').addClass('fas text-or');} 68else{createNoty(result['error_msg'],'warning',3000);}})} 69function removeFavorite(what,act){if(act!=1){displayPopin("popinConfirmation-fav-"+what);} 70else{$.post("/gestFav",{'fav':what,'add':0},function(data){var result=$.parseJSON(data);if(result['result']){document.location.reload();} 71else{createNoty(result['error_msg'],'warning',3000);}})}} 72function isFavorite(){$.post("/gestFav",{"get":1},function(fav){if(fav.result){for(i in fav){$(".JQfav"+fav[i]).attr("disabled","disabled").removeAttr("onclick").prop("onclick",null).attr("title",messages[1]);$(".JQfav"+fav[i]).find("span").text(messages[1]);$(".JQfav"+fav[i]).find("i").removeClass('far').addClass('fas text-or');}}},"json");} 73function delDiv(e){e.parent().remove();} 74function addAlerte(e){$.post("/addAlerte",function(data){$(data).insertBefore(e);checkNumberInput();});} 75function delAlerte(e,act){if(act!=1){var lid=e.parent().attr("id").replace("alerteId","");displayPopin("popinConfirmation-alert-"+lid);} 76else{hidePopin();$("#alerteId"+e).remove();createNoty(messages[0],"warning",3000);}} 77function getAlerte(){$.post("/getAlerte",function(data){$(".alerte").remove();$(data).insertBefore(".secondaryCTA.addAlertCTA");checkNumberInput();$("#alertes .alerte").each(function(){var $s=$(this).find("select[id^='alerteProduit-']");if($s.length)toggleAlerteVariableLine($s[0]);});})} 78function isAlerteSpecialProduct(val){var parsed=parseInt(val,10);return parsed===1||parsed===2||parsed===3||parsed===4;} 79function getAlerteClassIndex(value){var parsed=parseInt(value,10);if(parsed===1||parsed===2||parsed===3||parsed===4){return parsed;}return 4;} 80function setAlerteVariableOptions($alerte,isSpecial){var $varSelect=$alerte.find("select[id^='alerteVariable-']");$varSelect.find("option[data-alert-special='1']").toggle(isSpecial);$varSelect.find("option[data-alert-standard='1']").each(function(){var shouldShow=!isSpecial||this.value==="4";$(this).toggle(shouldShow);});if(isSpecial){var currentVal=$varSelect.val();if(currentVal!=="4"&¤tVal!=="900"){$varSelect.val("4");}}else if($varSelect.val()==="900"){$varSelect.val("4");}} 81function toggleAlerteSpecialFields($alerte){var idAlerte=$alerte.attr("id").replace("alerteId","");var varVal=$("#alerteVariable-"+idAlerte).val();var isPercentMode=varVal==="900";$alerte.find(".alerteMontantLabel,.alerteMontantInput").toggleClass("d-none",isPercentMode);$alerte.find(".alertePercentLabel,.alertePercentSelect").toggleClass("d-none",!isPercentMode);} 82function chgClassAlerte(e){lesClass=["","plus","moins","londres","cotFr"];lesObjets=["alerteProduit","alerteCondition","alerteMontant","alertePercent"];work=$(e).attr('id').split("-");var valSel=getAlerteClassIndex($(e).val());$(e).removeClass("plus moins londres cotFr");$(e).prev().removeClass("plus moins londres cotFr");$(e).addClass(lesClass[valSel]);$(e).prev().addClass(lesClass[valSel]);
82lesObjets.forEach(function(lobj){$("#"+lobj+"-"+work[1]).prev().removeClass("plus moins londres cotFr");$("#"+lobj+"-"+work[1]).removeClass("plus moins londres cotFr");$("#"+lobj+"-"+work[1]).prev().addClass(lesClass[valSel]);$("#"+lobj+"-"+work[1]).addClass(lesClass[valSel]);});var $alerte=$(e).closest(".alerte");if($alerte.length){$alerte.find(".alerteMontantLabel,.alertePercentLabel").removeClass("plus moins londres cotFr").addClass(lesClass[valSel]);toggleAlerteSpecialFields($alerte);}} 83function getInfosAlerte(e){work=$(e).attr('id').split("-");var valProd=$(e).val();$.post("/getInfosAlerte",{lidA:valProd},function(data){var vals=$.parseJSON(data);$(".JQplus."+work[1]).text(vals['resultat'].prixA);$(".JQmoins."+work[1]).text(vals['resultat'].prixV);$(".JQlondres."+work[1]).text(vals['resultat'].coursLondres);$(".JQcotFr."+work[1]).text(vals['resultat'].cours);});toggleAlerteVariableLine(e);} 84function toggleAlerteVariableLine(produitSelectEl){var $sel=produitSelectEl&&produitSelectEl.jquery?produitSelectEl:$(produitSelectEl);var idAlerte=$sel.attr('id').split("-")[1];var valProd=$sel.val();var $alerte=$("#alerteId"+idAlerte);var isSpecial=isAlerteSpecialProduct(valProd);setAlerteVariableOptions($alerte,isSpecial);$alerte.find(".alerteVariableLine").removeClass("d-none");toggleAlerteSpecialFields($alerte);chgClassAlerte($("#alerteVariable-"+idAlerte));} 85function getCategBackProdRaw(){try{return JSON.parse(sessionStorage.getItem("categBackProd")||"null");}catch(e){return null;}} 86function getCategCurrentIdCat(){return String($("#backProd").attr("data-cat")||$(".JQList").first().attr("data-cat")||"");} 87function categBackProdMatches(s){if(!s){return false;}var idCat=getCategCurrentIdCat();if(s.idCat&&idCat&&String(s.idCat)!==idCat){return false;}if(s.path&&categPathNorm(s.path)!==categPathNorm(location.pathname)){return false;}if(s.path&&categPathNorm(s.path)===categPathNorm(location.pathname)){return true;}if(s.idCat&&idCat&&String(s.idCat)===idCat){return true;}return false;} 88function getCategRestoreTargetId(){var s=getCategBackProdRaw();if(s&&s.id&&categBackProdMatches(s)){return parseInt(s.id,10)||0;}var v=parseInt(($("#backProd").val()||""),10)||0;return v>0?v:0;} 89function getCategRestoreSnapshot(){var s=getCategBackProdRaw();if(!s||!s.filters||!categBackProdMatches(s)){return null;}return s.filters;} 90function getCategViewSnapshot(){var s=getCategBackProdRaw();if(!s||!categBackProdMatches(s)){return null;}if(!s.html||s.html.indexOf("JQprodL")<0){return null;}return s;} 91function clearCategViewSnapshot(){try{var s=getCategBackProdRaw();if(!s){sessionStorage.removeItem("categBackProd");return;}delete s.html;delete s.theNext;delete s.deja;delete s.scrollY;sessionStorage.setItem("categBackProd",JSON.stringify(s));}catch(e){try{sessionStorage.removeItem("categBackProd");}catch(e2){}}} 92// Persistance filtres/tri par catégorie (session navigateur) â indépendante du retour produit 93function getCategFiltersStoreAll(){try{return JSON.parse(sessionStorage.getItem("categFiltersByCat")||"{}")||{};}catch(e){return {};}} 94function getCategFiltersStore(idCat){idCat=String(idCat||"");if(!idCat){return null;}var all=getCategFiltersStoreAll();return all[idCat]||null;} 95function saveCategFiltersStore(idCat,snap){idCat=String(idCat||"");if(!idCat||!snap){return;}try{var all=getCategFiltersStoreAll();snap.idCat=idCat;all[idCat]=snap;sessionStorage.setItem("categFiltersByCat",JSON.stringify(all));}catch(e){}} 96function clearCategFiltersStore(idCat){idCat=String(idCat||"");if(!idCat){return;}try{var all=getCategFiltersStoreAll();delete all[idCat];sessionStorage.setItem("categFiltersByCat",JSON.stringify(all));}catch(e){}} 97function optsFromCategFilterSnap(snap){var opts={start:0,replace:1};if(!snap){return opts;}if(snap.sort&&snap.sort!=="JQrazS"){opts.sort=snap.sort;}if(snap.cherche!=null&&snap.cherche!==""){opts.cherche=snap.cherche;}if(snap.sortOnce&&snap.sortOnce!=="triOnce0"&&String(snap.sortOnce)!=="0"){opts.sortOnce=snap.sortOnce;}if(snap.sortPays&&snap.sortPays.length){opts.sortPays=snap.sortPays;}
97if(snap.sortPeriode&&snap.sortPeriode.length){opts.sortPeriode=snap.sortPeriode;}if(snap.sortValFac&&snap.sortValFac.length){opts.sortValFac=snap.sortValFac;}if(snap.sortAutoPol&&snap.sortAutoPol.length){opts.sortAutoPol=snap.sortAutoPol;}if(snap.sortTypeMetal&&snap.sortTypeMetal.length){opts.sortTypeMetal=snap.sortTypeMetal;}if(snap.sortPrices&&snap.sortPrices.length>=2){opts.sortPrices=snap.sortPrices;}if(snap.sortYears&&snap.sortYears.length>=2){opts.sortYears=snap.sortYears;}return opts;} 98function persistCategFiltersStoreFromUi(idCat,cleared){idCat=String(idCat||getCategCurrentIdCat()||"");if(!idCat){return;}if(cleared){clearCategFiltersStore(idCat);return;}if(typeof collectCategFilterSnapshot!=="function"){return;}var snap=collectCategFilterSnapshot(idCat);if(categSnapshotHasFilters(snap)){saveCategFiltersStore(idCat,snap);}else{clearCategFiltersStore(idCat);}} 99function saveCategViewSnapshot(id,idCat,filters){ 100 var $box=$("#contentCategVitrine"); 101 if(!$box.length){return;} 102 var html=($box.html()||"").replace(/<img[^>]*\bid=["']waitLoader["'][^>]*>/gi,""); 103 if(html.indexOf("JQprodL")<0){return;} 104 var scrollY=parseInt(window.scrollY||window.pageYOffset||0,10)||0; 105 try{ 106 var $prod=$("#prod"+id); 107 if($prod.length){ 108 var top=(($prod.offset()||{}).top||0)-120; 109 if(top>0){scrollY=Math.max(0,Math.floor(top));} 110 } 111 }catch(e){} 112 var payload={ 113 id:String(id||""), 114 idCat:String(idCat||""), 115 path:location.pathname, 116 filters:filters||null, 117 html:html, 118 theNext:parseInt(window.theNext!=null?window.theNext:$("#inputLastTurn").val(),10)||0, 119 deja:parseInt(window.deja!=null?window.deja:$("#howMany").val(),10)||0, 120 scrollY:scrollY, 121 historyLen:parseInt(window.history&&window.history.length,10)||0, 122 ts:Date.now() 123 }; 124 try{sessionStorage.setItem("categBackProd",JSON.stringify(payload));} 125 catch(e){ 126 try{delete payload.html;sessionStorage.setItem("categBackProd",JSON.stringify(payload));}catch(e2){} 127 } 128} 129function categSnapshotHasFilters(snap){if(!snap){return false;}if(snap.sort&&snap.sort!=="JQrazS"){return true;}if(snap.cherche){return true;}if(snap.sortOnce&&snap.sortOnce!=="triOnce0"&&String(snap.sortOnce)!=="0"){return true;}if(snap.sortPays&&snap.sortPays.length){return true;}if(snap.sortPeriode&&snap.sortPeriode.length){return true;}if(snap.sortValFac&&snap.sortValFac.length){return true;}if(snap.sortAutoPol&&snap.sortAutoPol.length){return true;}if(snap.sortTypeMetal&&snap.sortTypeMetal.length){return true;}try{if(snap.sortPrices&&snap.sortPrices.length>=2&&$("#slidePrix").length){var mn=$("#slidePrix").data("slider-min"),mx=$("#slidePrix").data("slider-max");if(!(String(snap.sortPrices[0])===String(mn)&&String(snap.sortPrices[1])===String(mx))){return true;}}}catch(e){}try{if(snap.sortYears&&snap.sortYears.length>=2&&$("#slideAnnee").length){var yn=$("#slideAnnee").data("slider-min"),yx=$("#slideAnnee").data("slider-max");if(!(String(snap.sortYears[0])===String(yn)&&String(snap.sortYears[1])===String(yx))){return true;}}}catch(e){}return false;} 130function mergeCategRestoreOpts(opts,idCat){var snap=getCategRestoreSnapshot();if(!snap){return opts;}if(!snap.idCat||String(snap.idCat)!==String(idCat)){return opts;}if(snap.sort&&opts.sort==null&&snap.sort!=="JQrazS"){opts.sort=snap.sort;}if(snap.cherche!=null&&snap.cherche!==""&&opts.cherche==null){opts.cherche=snap.cherche;}if(snap.sortOnce&&opts.sortOnce==null&&snap.sortOnce!=="triOnce0"){opts.sortOnce=snap.sortOnce;}if(snap.sortPays&&snap.sortPays.length&&opts.sortPays==null){opts.sortPays=snap.sortPays;}if(snap.sortPeriode&&snap.sortPeriode.length&&opts.sortPeriode==null){opts.sortPeriode=snap.sortPeriode;}if(snap.sortValFac&&snap.sortValFac.length&&opts.sortValFac==null){opts.sortValFac=snap.sortValFac;}if(snap.sortAutoPol&&snap.sortAutoPol.length&&opts.sortAutoPol==null){opts.sortAutoPol=snap.sortAutoPol;}if(snap.sortTypeMetal&&snap.sortTypeMetal.length&&opts.sortTypeMetal==null){opts.sortTypeMetal=snap.sortTypeMetal;}if(snap.sortPrices&&snap.sortPrices.length>=2&&opts.sortPrices==null){opts.sortPrices=snap.sortPrices;}if(snap.sortYears&&snap.sortYears.length>=2&&opts.sortYears==null){opts.sortYears=snap.sortYears;}return opts;} 131function buildCategProductHtml(infos){ 132 var $box=$("#contentCategVitrine"); 133 var tplP=$box.data("tpl"); 134 if(!tplP||!infos){return "";} 135 var tplPA=$box.data("tplprice"); 136 var tplPV=$box.data("tplpricevol"); 137 var tplPNum=$box.data("tplpricenum"); 138 var tplPVente=$box.data("tplpricev"); 139 var tplPVenteEmpty=$box.data("tplpricevempty"); 140 var templ=tplP; 141 var hasVolumes=0; 142 for(var j in infos){ 143 if(!infos.hasOwnProperty(j)){continue;} 144 if(j==="hasVolumes"){hasVolumes=parseInt(infos[j],10)||0;} 145 if(j==="volumeTooltip"||j==="intrinsequeHtml"){continue;} 146 templ=templ.replace(new RegExp("__"+j+"__","g"),infos[j]==null?"":infos[j]); 147 } 148 templ=templ.replace(/__intrinsequeHtml__/g,infos.intrinsequeHtml||""); 149 var priceA=""; 150 if(parseInt(infos.isNumis,10)===1){priceA=(tplPNum||"").replace(/__prixAchat__/g,infos.prixAchat||infos.prixV||"");} 151 else if(hasVolumes===1){priceA=(tplPV||"").replace(/__prixApartir__/g,infos.prixApartir||"").replace(/__volumeTooltip__/g,(infos.volumeTooltip||"").replace(/"/g,"""));} 152 else if(infos.prixAchat||infos.prixV){priceA=(tplPA||"").replace(/__prixAffBF__/g,infos.prixAffBF||"").replace(/__prixAchat__/g,infos.prixAchat||infos.prixV||"");} 153 templ=templ.replace(/__priceProductA__/g,priceA); 154 var priceV=""; 155 if(infos.prixVente||infos.prixA){priceV=(tplPVente||"").replace(/__prixVente__/g,infos.prixVente||infos.prixA||"");} 156 else{priceV=tplPVenteEmpty||"";} 157 templ=templ.replace(/__priceProductV__/g,priceV); 158 return templ; 159} 160function patchCategListingFromApi(retour){ 161 if(!retour||!retour.success||!retour.vitrine){return;} 162 var list=retour.vitrine; 163 for(var i in list){ 164 if(!list.hasOwnProperty(i)){continue;} 165 var infos=list[i]; 166 var id=infos&&infos.id; 167 if(!id){continue;} 168 var $el=$("#prod"+id); 169 if(!$el.length){continue;} 170 var html=buildCategProductHtml(infos); 171 if(html){$el.replaceWith(html);} 172 } 173 if(window.lazySizes&&lazySizes.autoSizer){lazySizes.autoSizer.checkElems();} 174 isFavorite(); 175 $(".BStooltip").tooltip(); 176} 177function refreshCategViewFromApi(idCat,view){ 178 view=view||{}; 179 var pageSize=25; 180 var loadedEnd=Math.max(pageSize,parseInt(view.theNext,10)||pageSize); 181 var starts=[]; 182 for(var s=0;s<loadedEnd&&starts.length<10;s+=pageSize){starts.push(s);} 183 var idx=0; 184 function next(){ 185 if(idx>=starts.length){return;} 186 var start=starts[idx++]; 187 var opts=mergeCategRestoreOpts({start:start},idCat); 188 var payload={methode:"getProductsCategoryListing",idCat:idCat,start:start}; 189 if(opts.sort!=null){payload.sort=opts.sort;}
190 if(opts.cherche!=null){payload.cherche=opts.cherche;} 191 if(opts.sortOnce!=null){payload.sortOnce=opts.sortOnce;} 192 if(opts.sortPays!=null){payload.sortPays=opts.sortPays;} 193 if(opts.sortPeriode!=null){payload.sortPeriode=opts.sortPeriode;} 194 if(opts.sortValFac!=null){payload.sortValFac=opts.sortValFac;} 195 if(opts.sortAutoPol!=null){payload.sortAutoPol=opts.sortAutoPol;} 196 if(opts.sortTypeMetal!=null){payload.sortTypeMetal=opts.sortTypeMetal;} 197 if(opts.sortPrices!=null){payload.sortPrices=opts.sortPrices;} 198 if(opts.sortYears!=null){payload.sortYears=opts.sortYears;} 199 $.post("/workerApi",payload,function(raw){ 200 var retour=null; 201 try{retour=(typeof raw==="string")?JSON.parse(raw):raw;}catch(e){retour=null;} 202 if(retour&&retour.success){patchCategListingFromApi(retour);} 203 next(); 204 }).fail(function(){next();}); 205 } 206 next(); 207} 208function restoreCategViewSnapshot(view,idCat){ 209 if(!view||!view.html){return false;} 210 window.categRestoring=true; 211 try{if(history&&history.scrollRestoration){history.scrollRestoration="manual";}}catch(e){} 212 var $box=$("#contentCategVitrine"); 213 $box.html(view.html); 214 window.theNext=parseInt(view.theNext,10)||0; 215 window.deja=parseInt(view.deja,10)||0; 216 window.posDep=0; 217 encours=0; 218 $("#inputLastTurn").val(window.theNext); 219 $("#howMany").val(window.deja); 220 if(window.lazySizes&&lazySizes.autoSizer){lazySizes.autoSizer.checkElems();} 221 isFavorite(); 222 $(".BStooltip").tooltip(); 223 if(view.scrollY!=null){window.scrollTo(0,parseInt(view.scrollY,10)||0);} 224 var until=parseInt(view.id,10)||0; 225 if(until>0&&$("#prod"+until).length){ 226 if(typeof positionCateg==="function"){positionCateg({sticky:1});} 227 }else{ 228 window.categRestoring=false; 229 try{sessionStorage.removeItem("categBackProd");}catch(e){} 230 $("#backProd").val(""); 231 } 232 return true; 233} 234function getCategNumisPageSize(){return parseInt(window._categNumisPageSize,10)||30;} 235function getCategNumisUrlBase(){ 236 if(window._categNumisUrlBase){return String(window._categNumisUrlBase);} 237 return String(location.pathname||"").replace(/\/p\d+\/?$/,""); 238} 239function getCategNumisPageFromPath(){ 240 var m=String(location.pathname||"").match(/\/p(\d+)\/?$/); 241 return m?Math.max(1,parseInt(m[1],10)||1):1; 242} 243function getCategNumisStart(){ 244 return (getCategNumisPageFromPath()-1)*getCategNumisPageSize(); 245} 246function categNumisPageUrl(page){ 247 page=parseInt(page,10)||1; 248 var base=getCategNumisUrlBase(); 249 return page>1?(base+"/p"+page):base; 250} 251function categNumisStripPageFromUrl(){ 252 var base=getCategNumisUrlBase(); 253 if(categPathNorm(base)===categPathNorm(location.pathname)){return;} 254 try{history.replaceState(null,"",base+(location.search||"")+(location.hash||""));}catch(e){} 255 window._categNumisPage=1; 256} 257function updateCategNumisPagination(retour){ 258 var total=parseInt(retour&&retour.nb,10)||0; 259 var pageSize=parseInt(retour&&retour.pageSize,10)||getCategNumisPageSize(); 260 var threshold=parseInt(window._categNumisThreshold,10)||75; 261 var $nav=$("#categNumisPagination"); 262 if(total<=threshold){ 263 $nav.addClass("d-none").find("ul").empty(); 264 window._categNumisNbPages=1; 265 window._categNumisPage=1; 266 if(window._categNumisPaginate){ 267 window._categNumisPaginate=0; 268 var got=(retour.vitrine&&retour.vitrine.length)||0; 269 if(got<total&&window._categListingIdCat&&!window._categNumisLazySwitch){ 270 window._categNumisLazySwitch=1; 271 loadCategListing(window._categListingIdCat,{start:0,replace:1,resetPage:1,onDone:function(){window._categNumisLazySwitch=0;}}); 272 } 273 } 274 return; 275 } 276 window._categNumisPaginate=1; 277 var nbPages=Math.max(1,Math.ceil(total/pageSize)); 278 var cur=getCategNumisPageFromPath(); 279 if(retour&&retour.start!=null){ 280 cur=Math.floor((parseInt(retour.start,10)||0)/pageSize)+1; 281 }else if(parseInt(window._categNumisPage,10)>0){ 282 cur=parseInt(window._categNumisPage,10); 283 } 284 cur=Math.max(1,Math.min(cur,nbPages)); 285 window._categNumisPageSize=pageSize; 286 window._categNumisNbPages=nbPages; 287 window._categNumisPage=cur; 288 var prevDis=(cur<=1)?"disabled":""; 289 var html='<li class="page-item '+prevDis+'"><a class="page-link" href="'+categNumisPageUrl(Math.max(1,cur-1))+'" aria-label="Previous"><i class="fas fa-chevron-left" style="font-size:1.7rem;"></i></a></li>'; 290 for(var ip=1;ip<=nbPages;ip++){ 291 if(ip===cur){html+='<li class="page-item active"><span class="page-link">'+ip+'</span></li>';} 292 else{html+='<li class="page-item"><a class="page-link" href="'+categNumisPageUrl(ip)+'">'+ip+'</a></li>';} 293 } 294 var nextDis=(cur>=nbPages)?"disabled":""; 295 html+='<li class="page-item '+nextDis+'"><a class="page-link" href="'+categNumisPageUrl(Math.min(nbPages,cur+1))+'" aria-label="Next"><i class="fas fa-chevron-right" style="font-size:1.7rem;"></i></a></li>'; 296 if(!$nav.length){ 297 $nav=$('<nav id="categNumisPagination" class="mt-3 mb-2" aria-label="Pagination"><ul class="pagination justify-content-center flex-wrap"></ul></nav>'); 298 $("#contentCategVitrine").after($nav); 299 } 300 $nav.removeClass("d-none").find("ul").html(html); 301} 302function initCategListing(idCat){encours=0; 303idCat=String(idCat||getCategCurrentIdCat()||""); 304var untilFromInput=parseInt(($("#backProd").val()||""),10)||0; 305// Snapshot retour produit : uniquement si backProd serveur. 306try{ 307 if(!(untilFromInput>0)){ 308 sessionStorage.removeItem("categBackProd"); 309 }else{ 310 var raw=sessionStorage.getItem("categBackProd"); 311 if(raw){ 312 var st=JSON.parse(raw); 313 if(st){ 314 var catMismatch=!!(st.idCat&&idCat&&String(st.idCat)!==String(idCat)); 315 var savedPath=st.path?categPathNorm(st.path):""; 316 var curPath=categPathNorm(location.pathname); 317 var baseMismatch=!!(savedPath&&categPathBase(savedPath)!==categPathBase(curPath)); 318 if(catMismatch||baseMismatch){ 319 sessionStorage.removeItem("categBackProd"); 320 }else if(savedPath&&savedPath!==curPath){ 321 // Même cat, mauvaise page (/pN) : aller direct sur la page listing sauvée 322 location.replace(savedPath+(location.search||"")+(location.hash||"")); 323 return; 324 } 325 } 326 } 327 } 328}catch(e){}
329var view=getCategViewSnapshot(); 330var until=getCategRestoreTargetId(); 331if(!(untilFromInput>0)){until=0;} 332var snap=getCategRestoreSnapshot(); 333if(snap&&snap.idCat&&idCat&&String(snap.idCat)!==String(idCat)){snap=null;} 334if(until>0||view){try{if(history&&history.scrollRestoration){history.scrollRestoration="manual";}}catch(e){}} 335if(snap&&until>0&&typeof applyCategFilterUiFromSnapshot==="function"){applyCategFilterUiFromSnapshot(snap);} 336if(view&&until>0&&restoreCategViewSnapshot(view,idCat)){return;} 337var needFilterReload=(until>0)&&categSnapshotHasFilters(snap); 338var boot=null;try{var el=document.getElementById("categListingBootstrap");if(el&&el.textContent){var rawBoot=el.textContent;try{boot=JSON.parse(rawBoot);}catch(e1){var ta=document.createElement("textarea");ta.innerHTML=rawBoot;boot=JSON.parse(ta.value);}}}catch(e){boot=null;} 339if(needFilterReload){window.categRestoring=true;var opts=mergeCategRestoreOpts({start:window._categNumisPaginate?getCategNumisStart():0,replace:1},idCat);loadCategListing(idCat,$.extend({},opts,{onDone:function(){restoreCategListingToProduct(idCat,until);}}));return;} 340// Continuité filtres par cat : store client (survit aux allers-retours même si session PHP a été raz) 341if(!(until>0)){ 342 var stored=getCategFiltersStore(idCat); 343 if(stored&&categSnapshotHasFilters(stored)){ 344 if(typeof applyCategFilterUiFromSnapshot==="function"){applyCategFilterUiFromSnapshot(stored);} 345 var storeOpts=optsFromCategFilterSnap(stored); 346 if(window._categNumisPaginate){storeOpts.start=getCategNumisStart();storeOpts.replace=1;} 347 loadCategListing(idCat,storeOpts); 348 return; 349 } 350} 351if(boot&&boot.success){var bootBroken=false;try{var bv=boot.vitrine||[];for(var bi=0;bi<bv.length;bi++){var bu=(bv[bi]&&(bv[bi].image1||""))+(bv[bi]&&(bv[bi].image2||""));if(bu.indexOf("no-image")>=0){bootBroken=true;break;}}}catch(e){bootBroken=false;}if(bootBroken){boot=null;}else{if(!renderCategListing(boot,1)){getVitrineCateg(idCat);return;}if(until>0){window.categRestoring=true;restoreCategListingToProduct(idCat,until);}return;}} 352else if(boot&&window._categNumisPaginate&&boot.vitrine&&boot.vitrine.length){var bootBrokenNumis=false;try{var bvn=boot.vitrine||[];for(var bni=0;bni<bvn.length;bni++){var bun=(bvn[bni]&&(bvn[bni].image1||""))+(bvn[bni]&&(bvn[bni].image2||""));if(bun.indexOf("no-image")>=0){bootBrokenNumis=true;break;}}}catch(e){bootBrokenNumis=false;}if(bootBrokenNumis){boot=null;}else{if(!renderCategListing(boot,1)){getVitrineCateg(idCat);return;}if(until>0){window.categRestoring=true;restoreCategListingToProduct(idCat,until);}return;}} 353if(until>0){window.categRestoring=true;getVitrineCateg(idCat);return;} 354getVitrineCateg(idCat);} 355function restoreCategListingToProduct(idCat,untilId){untilId=parseInt(untilId,10)||0;if(!(untilId>0)){window.categRestoring=false;return;}window.categRestoring=true;try{if(history&&history.scrollRestoration){history.scrollRestoration="manual";}}catch(e){}var opts=mergeCategRestoreOpts({locateUntilId:untilId,locateOnly:1},idCat);var payload={methode:"getProductsCategoryListing",idCat:idCat,locateUntilId:untilId,locateOnly:1};if(opts.sort!=null){payload.sort=opts.sort;}if(opts.cherche!=null){payload.cherche=opts.cherche;}if(opts.sortOnce!=null){payload.sortOnce=opts.sortOnce;}if(opts.sortPays!=null){payload.sortPays=opts.sortPays;}if(opts.sortPeriode!=null){payload.sortPeriode=opts.sortPeriode;}if(opts.sortValFac!=null){payload.sortValFac=opts.sortValFac;}if(opts.sortAutoPol!=null){payload.sortAutoPol=opts.sortAutoPol;}if(opts.sortTypeMetal!=null){payload.sortTypeMetal=opts.sortTypeMetal;}if(opts.sortPrices!=null){payload.sortPrices=opts.sortPrices;}if(opts.sortYears!=null){payload.sortYears=opts.sortYears;}if(window._categNumisPaginate){payload.pageSize=getCategNumisPageSize();}$.post("/workerApi",payload,function(raw){var r=null;try{r=(typeof raw==="string")?JSON.parse(raw):raw;}catch(e){r=null;}if(!r||!r.success){window.categRestoring=false;if(typeof positionCateg==="function"){positionCateg({sticky:1});}return;}var targetStart=parseInt(r.targetStart,10)||0;var pageSize=parseInt(r.pageSize,10)||25;if(!r.found){window.categRestoring=false;try{sessionStorage.removeItem("categBackProd");}catch(e){}$("#backProd").val("");return;}
355if(window._categNumisPaginate){var targetPage=Math.floor(targetStart/pageSize)+1;var dest=categNumisPageUrl(targetPage);if(categPathNorm(dest)!==categPathNorm(location.pathname)){try{if(navigator.sendBeacon){navigator.sendBeacon("/actionEntry",new Blob([new URLSearchParams({preserveCategFilters:"1",backProd:String(untilId),preserveCategIdCat:String(idCat)}).toString()],{type:"application/x-www-form-urlencoded"}));}else{$.post("/actionEntry",{preserveCategFilters:1,backProd:untilId,preserveCategIdCat:idCat});}}catch(e){}try{var snap=JSON.parse(sessionStorage.getItem("categBackProd")||"null")||{};snap.id=String(untilId);snap.idCat=String(idCat);snap.path=dest;snap.ts=Date.now();sessionStorage.setItem("categBackProd",JSON.stringify(snap));}catch(e2){}location.replace(dest);return;}if(typeof positionCateg==="function"){positionCateg({sticky:1});}return;}if(targetStart<=0||$("#prod"+untilId).length){if(typeof positionCateg==="function"){positionCateg({sticky:1});}return;}var start=pageSize;function loadNext(){if(start>targetStart){if(typeof positionCateg==="function"){positionCateg({sticky:1});}return;}loadCategListing(idCat,{start:start,replace:0,onDone:function(){if($("#prod"+untilId).length){if(typeof positionCateg==="function"){positionCateg({sticky:1});}return;}start+=pageSize;loadNext();}});}loadNext();}).fail(function(){window.categRestoring=false;if(typeof positionCateg==="function"){positionCateg({sticky:1});}});} 356function getVitrineCateg(idCat,sorting,displayCat){encours=0;var opts={replace:1};if(sorting!=null){opts.sort=sorting;opts.start=0;opts.resetPage=1;}else if(window._categNumisPaginate){opts.start=getCategNumisStart();}else{opts.start=0;}if(displayCat!=null){opts.displayCat=displayCat;}var until=getCategRestoreTargetId();if(until>0&&!getCategViewSnapshot()){window.categRestoring=true;opts=mergeCategRestoreOpts(opts,idCat);if(typeof applyCategFilterUiFromSnapshot==="function"){applyCategFilterUiFromSnapshot(getCategRestoreSnapshot());}loadCategListing(idCat,$.extend({},opts,{onDone:function(){restoreCategListingToProduct(idCat,until);}}));return;}loadCategListing(idCat,opts);} 357function searchVitrineCateg(idCat,what){loadCategListing(idCat,{cherche:what,start:0,replace:1,resetPage:1});} 358function getVitrineCategHtmlFallback(idCat,extra,replace,onDone){var payload=$.extend({idCat:idCat},extra||{});delete payload.locateUntilId;delete payload.locateOnly;delete payload.untilId;$.post("/getVitrineCateg",payload,function(data){if(replace){$("#contentCategVitrine").empty().html(data);}else{$("#waitLoader").remove();$("#contentCategVitrine").append(data);}isFavorite();if(typeof onDone==="function"){onDone();}else if(typeof positionCateg==="function"){positionCateg();}}).fail(function(){window.categRestoring=false;window.categRestoreActive=false;if(typeof onDone==="function"){onDone();}});} 359function categUiHasVisibleFilters(){ 360 if(($("#search-categ").val()||"").trim()){return true;} 361 if($(".itemsOrders.active").filter(function(){return!$(this).hasClass("JQrazS");}).length){return true;} 362 if($(".itemsOnces.active").filter(function(){var c=this.className||"";return !/\btriOnce0\b/.test(c);}).length){return true;} 363 if($(".itemsPays.active").not(".pays-1").length){return true;} 364 if($(".itemsPeriode.active").not(".periode-1").length){return true;} 365 if($(".itemsValFac.active").not(".ValFac-1").length){return true;} 366 if($(".itemsAutoPol.active").not(".AutoPol-1").length){return true;} 367 if($(".itemsTypeMetal.active").not(".TypeMetal-1").length){return true;} 368 try{if($("#slidePrix").length){var pv=$("#slidePrix").bootstrapSlider("getValue");var mn=$("#slidePrix").data("slider-min"),mx=$("#slidePrix").data("slider-max");if(pv&&pv.length>=2&&!(String(pv[0])===String(mn)&&String(pv[1])===String(mx))){return true;}}}catch(e){} 369 try{if($("#slideAnnee").length){var yv=$("#slideAnnee").bootstrapSlider("getValue");var yn=$("#slideAnnee").data("slider-min"),yx=$("#slideAnnee").data("slider-max");if(yv&&yv.length>=2&&!(String(yv[0])===String(yn)&&String(yv[1])===String(yx))){return true;}}}catch(e){} 370 return false; 371} 372function renderCategListing(retour,replace){var $box=$("#contentCategVitrine");var tplP=$box.data("tpl");var txtEmpty=$box.data("txtempty")||"";if(!tplP||!retour||!retour.success){return false;}var html="";var list=retour.vitrine||[];if(!list.length&&replace){html="<p>"+txtEmpty+"</p>";}for(var i in list){if(!list.hasOwnProperty(i)){continue;}html+=buildCategProductHtml(list[i]);}if(replace){$box.empty().html(html);}else{$("#waitLoader").remove();$box.append(html);}window.theNext=retour.nextStart||0;window.deja=retour.nb||0;window.posDep=0;
372$("#inputLastTurn").val(window.theNext);$("#howMany").val(window.deja);if(replace&&window._categNumisPaginate){updateCategNumisPagination(retour);}if(window.lazySizes&&lazySizes.autoSizer){lazySizes.autoSizer.checkElems();}isFavorite();$(".BStooltip").tooltip();return true;} 373function loadCategListing(idCat,opts){opts=opts||{};var replace=opts.replace?1:0;var onDone=(typeof opts.onDone==="function")?opts.onDone:null;var start=opts.start!=null?parseInt(opts.start,10)||0:0;if(replace&&window._categNumisPaginate&&opts.resetPage&&!opts.locateUntilId){categNumisStripPageFromUrl();start=0;}if(replace){clearCategViewSnapshot();$("#contentCategVitrine").prepend('<img src="https://cdn.achat-or-et-argent.fr/ressources_v4/images/structure/common/loader.gif" alt="loader" id="waitLoader" style="width:100px;">');}var payload={methode:"getProductsCategoryListing",idCat:idCat,start:start};if(opts.locateUntilId){payload.locateUntilId=opts.locateUntilId;payload.locateOnly=1;}if(opts.sort!=null){payload.sort=opts.sort;}if(opts.cherche!=null){payload.cherche=opts.cherche;}if(opts.clear){payload.clear=1;}if(opts.sortOnce!=null){payload.sortOnce=opts.sortOnce;}if(opts.sortPays!=null){payload.sortPays=opts.sortPays;}if(opts.sortPeriode!=null){payload.sortPeriode=opts.sortPeriode;}if(opts.sortValFac!=null){payload.sortValFac=opts.sortValFac;}if(opts.sortAutoPol!=null){payload.sortAutoPol=opts.sortAutoPol;}if(opts.sortTypeMetal!=null){payload.sortTypeMetal=opts.sortTypeMetal;}if(opts.sortPrices!=null){payload.sortPrices=opts.sortPrices;}if(opts.sortYears!=null){payload.sortYears=opts.sortYears;}if(opts.sens!=null){payload.sens=opts.sens;}if(opts.displayCat!=null){payload.displayCat=opts.displayCat;}if(opts.pageSize!=null){payload.pageSize=opts.pageSize;}else if(window._categNumisPaginate){payload.pageSize=getCategNumisPageSize();}var done=function(){if(window.categRestore){window.categRestore.loading=false;}if(replace){persistCategFiltersStoreFromUi(idCat,!!opts.clear);}if(onDone){onDone();}else if(typeof positionCateg==="function"){positionCateg();}};$.post("/workerApi",payload,function(raw){var retour=null;try{retour=(typeof raw==="string")?JSON.parse(raw):raw;}catch(e){retour=null;}if(retour&&retour.locate){if(onDone){onDone(retour);}return;}if(!renderCategListing(retour,replace)){getVitrineCategHtmlFallback(idCat,opts,replace,done);}else{done();}}).fail(function(){getVitrineCategHtmlFallback(idCat,opts,replace,done);});} 374 375function checkNumberInput(){$("input[type='number']").on('click change keyup keypress touchstart',function(event){return scanToucheFloat(event);});} 376function getSearchList(typeS){$.post("/getSearchList",{type:typeS},function(datas){datas=$.parseJSON(datas);if(datas['return']==true){$("#searchList").html(datas['resultat']);}});} 377if(!RegExp.escape){RegExp.escape=function(s){return String(s).replace(/[\\^$*+?.()|[\]{}]/g,'\\$&');};} 378function scanToucheFloat(evenement){var reCarSpeciaux=/[\x00\x08\x0D\x2E]/;var reCarValides=/\d/;var codeDecimal=codeTouche(evenement);var car=String.fromCharCode(codeDecimal);var autorisation=reCarValides.test(car)||reCarSpeciaux.test(car);return autorisation;} 379function scanToucheInt(evenement){var reCarSpeciaux=/[\x00\x08\x0D]/;var reCarValides=/\d/;var codeDecimal=codeTouche(evenement);var car=String.fromCharCode(codeDecimal);var autorisation=reCarValides.test(car)||reCarSpeciaux.test(car);return autorisation;} 380function codeTouche(evenement){for(prop in evenement){if(prop=='which')return(evenement.which);} 381return(evenement.keyCode);} 382function sqlToJsDate(sqlDate){var sqlDateArr1=sqlDate.split("-");var sYear=sqlDateArr1[0];var sMonth=(Number(sqlDateArr1[1])-1).toString();var sqlDateArr2=sqlDateArr1[2].split(" ");var sDay=sqlDateArr2[0];var sqlDateArr3=sqlDateArr2[1].split(":");var sHour=sqlDateArr3[0];var sMinute=sqlDateArr3[1];var sqlDateArr4=sqlDateArr3[2].split(".");var sSecond=sqlDateArr4[0];var sMillisecond=(sqlDateArr4[1]>=0)?sqlDateArr4[1]:0;return new Date(sYear,sMonth,sDay,sHour,sMinute,sSecond,sMillisecond);} 383function generateChartData(idCours,duree,typeD,sorte){var chartData=[];var lesDatas=new Array;$.ajax({type:"POST",async:false,data:"idmetal="+idCours+"&duree="+duree+"&type="+typeD+"&sorte="+sorte,url:'/getCoursChart',success:function(msg){lesDatas=JSON.parse(msg);}});$.each(lesDatas,function(index,value){chartData.push({date:sqlToJsDate(value.datetime),value:(value.valeur)});});return chartData;} 384function generateChartData5(idCours,duree,typeD,sorte){var chartData=[];var lesDatas=new Array;$.ajax({type:"POST",async:false,data:"idmetal="+idCours+"&duree="+duree+"&type="+typeD+"&sorte="+sorte,url:'/getCoursChart',success:function(msg){lesDatas=JSON.parse(msg);}});$.each(lesDatas,function(index,value){chartData.push({date:value.datetime,value:value.valeur});});return chartData;} 385function addBasket(typePanier){if(typePanier==0){var prod=$("#pachat").serialize();} 386else{var prod=$("#pvente").serialize();} 387openPopin('ajoutPanier-'+prod+'-'+typePanier);} 388function getBasket(){$.post("/checkBasket",function(retour){$(".panierDropdown").html(retour);});} 389function checkItem(idItem,maxi){$.post("/gestBasket",{idACtion:6,idItem:idItem},function(retour){if(retour>=maxi){$("#achQte").attr("min","1");$("#btA").removeAttr("disabled");$("#btA").text(messages[9]);checkStock(idItem);} 390else{if(parseInt($("#achQte").val())>=maxi){$("#btA").text(messages[9]);$("#btA").removeAttr("disabled");} 391else{$("#btA").text(messages[8]+" : "+maxi);$("#btA").attr("disabled",true);}} 392checkStock(idItem);$("#veQte").val(1);});} 393function checkStock(idItem){$.post("/gestBasket",{idACtion:10,idItem:idItem},function(retour){$("#achQte").attr("max",retour);
393if(retour==0){$("#pachat").addClass('d-none');} 394if(parseInt($("#achQte").val())>parseInt(retour)){$("#achQte").val(retour);}});} 395function delItem(idItem,idBasket,typeBasket){$.post("/gestBasket",{idACtion:0,idItem:idItem,idBasket:idBasket,typeBasket:typeBasket},function(retour){document.location.reload();});} 396function modifBasket(nba,px,idItem,idBasket,typeBasket){$.post("/gestBasket",{idACtion:1,nba:nba,px:px,idItem:idItem,idBasket:idBasket,typeBasket:typeBasket},function(retour){result=JSON.parse(retour);$('#qteProduit-'+idItem).val(result['nbItem']);if(result['reload']=='reload'){document.location.reload();} 397else{getBasket();getOption(typeBasket);}});} 398function getOption(typeBasket){$.post("/gestBasket",{idACtion:2,typeBasket:typeBasket},function(retour){$('#optionsContent').html(retour);listenOption();majOptionLive();});} 399function checkOption(typeBasket){$.post("/gestBasket",{idACtion:4,typeBasket:typeBasket},function(retour){retour=$.parseJSON(retour);$("#optOffText").text(retour[1000]);$("#optOff").val(retour[1000]);});} 400function stockLivraison(livraison,typeBasket){return $.post("/gestBasket",{idACtion:5,livraison:livraison,typeBasket:typeBasket});} 401function getRecap(typeBasket,cb,extra){var d={typeBasket:typeBasket};if(extra&&typeof extra==="object"){for(var k in extra)if(extra.hasOwnProperty(k))d[k]=extra[k];}$.post("/getRecap",d,function(retour){$("#recapBasket").html(retour);if(typeof cb==="function")cb();});} 402function modifOption(nba,px,idItem,idLie,idBasket,typeBasket){$.post("/gestBasket",{idACtion:3,nba:nba,px:px,idItem:idItem,idLie:idLie,idBasket:idBasket,typeBasket:typeBasket});calcTotalFirst();} 403function getTmp(valeur,tmp){return(valeur*tmp)/100;} 404function getTpv(valeurV,valeurA,dateA,tpv,reduc,decalage){var maintenant=new Date();var dateAncien=new Date(dateA);diff=new Date(maintenant-dateAncien);var an=Math.floor(diff/1000/60/60/24/365.25);var pv=valeurV-valeurA;var reduction=0;if(an>2){reduction=(reduc*(an-decalage))/100;} 405var tax=(pv-(pv*reduction))*tpv/100;return tax+"|"+an;} 406function calcTPVTMP(montant,tmpP,justif,vente,achat,dateA,tpvP,reduc,decalage,sansTaxe,prixUnitaire,seuil,tmpReduite){if(sansTaxe){var pu=(prixUnitaire!=null&&prixUnitaire!=="")?parseFloat(prixUnitaire):parseFloat(montant);var s=(seuil!=null&&seuil!=="")?parseFloat(seuil):0;if(pu<=s){return"TMP|0";}var rate=(tmpReduite!=null&&tmpReduite!=="")?parseFloat(tmpReduite):tmpP;var tmp=(montant*rate)/100;tmp=(tmp>=0)?tmp:0;if(justif){tpv=getTpv(vente,achat,dateA,tpvP,reduc,decalage).split("|");tpvr=(tpv[0]>=0)?tpv[0]:0;return(tmp>tpvr)?"TPV|"+tpvr+"|"+tpv[1]+"|"+tpv[2]+"|"+tpv[3]:"TMP|"+tmp;}else{return"TMP|"+tmp;}}var tmp=0;var tpv=0;tmp=getTmp(montant,tmpP);tmp=(tmp>=0)?tmp:0;if(justif){tpv=getTpv(vente,achat,dateA,tpvP,reduc,decalage).split("|");tpvr=(tpv[0]>=0)?tpv[0]:0;return(tmp>tpvr)?"TPV|"+tpvr+"|"+tpv[1]+"|"+tpv[2]+"|"+tpv[3]:"TMP|"+tmp;} 407else{return"TMP|"+tmp;}} 408function get_html_translation_table(table,quoteStyle){var entities={} 409var hashMap={} 410var decimal 411var constMappingTable={} 412var constMappingQuoteStyle={} 413var useTable={} 414var useQuoteStyle={} 415constMappingTable[0]='HTML_SPECIALCHARS' 416constMappingTable[1]='HTML_ENTITIES' 417constMappingQuoteStyle[0]='ENT_NOQUOTES' 418constMappingQuoteStyle[2]='ENT_COMPAT' 419constMappingQuoteStyle[3]='ENT_QUOTES' 420useTable=!isNaN(table)?constMappingTable[table]:table?table.toUpperCase():'HTML_SPECIALCHARS' 421useQuoteStyle=!isNaN(quoteStyle)?constMappingQuoteStyle[quoteStyle]:quoteStyle?quoteStyle.toUpperCase():'ENT_COMPAT' 422if(useTable!=='HTML_SPECIALCHARS'&&useTable!=='HTML_ENTITIES'){throw new Error('Table: '+useTable+' not supported')} 423entities['38']='&' 424if(useTable==='HTML_ENTITIES'){entities['160']=' ' 425entities['161']='¡' 426entities['162']='¢' 427entities['163']='£' 428entities['164']='¤' 429entities['165']='¥' 430entities['166']='¦' 431entities['167']='§' 432entities['168']='¨' 433entities['169']='©' 434entities['170']='ª' 435entities['171']='«' 436entities['172']='¬' 437entities['173']='­' 438entities['174']='®' 439entities['175']='¯' 440entities['176']='°' 441entities['177']='±' 442entities['178']='²' 443entities['179']='³' 444entities['180']='´' 445entities['181']='µ' 446entities['182']='¶' 447entities['183']='·' 448entities['184']='¸' 449entities['185']='¹' 450entities['186']='º' 451entities['187']='»' 452entities['188']='¼' 453entities['189']='½' 454entities['190']='¾' 455entities['191']='¿' 456entities['192']='À' 457entities['193']='Á' 458entities['194']='Â' 459entities['195']='Ã' 460entities['196']='Ä' 461entities['197']='Å' 462entities['198']='Æ' 463entities['199']='Ç' 464entities['200']='È' 465entities['201']='É' 466entities['202']='Ê' 467entities['203']='Ë' 468entities['204']='Ì' 469entities['205']='Í' 470entities['206']='Î' 471entities['207']='Ï' 472entities['208']='Ð' 473entities['209']='Ñ' 474entities['210']='Ò' 475entities['211']='Ó' 476entities['212']='Ô' 477entities['213']='Õ' 478entities['214']='Ö' 479entities['215']='×' 480entities['216']='Ø' 481entities['217']='Ù' 482entities['218']='Ú' 483entities['219']='Û' 484entities['220']='Ü' 485entities['221']='Ý' 486entities['222']='Þ' 487entities['223']='ß' 488entities['224']='à' 489entities['225']='á' 490entities['226']='â' 491entities['227']='ã' 492entities['228']='ä' 493entities['229']='å' 494entities['230']='æ' 495entities['231']='ç' 496entities['232']='è' 497entities['233']='é' 498entities['234']='ê' 499entities['235']='ë' 500entities['236']='ì' 501entities['237']='í' 502entities['238']='î' 503entities['239']='ï' 504entities['240']='ð' 505entities['241']='ñ' 506entities['242']='ò' 507entities['243']='ó' 508entities['244']='ô' 509entities['245']='õ' 510entities['246']='ö' 511entities['247']='÷' 512entities['248']='ø' 513entities['249']='ù' 514entities['250']='ú' 515entities['251']='û' 516entities['252']='ü' 517entities['253']='ý' 518entities['254']='þ' 519entities['255']='ÿ'} 520if(useQuoteStyle!=='ENT_NOQUOTES'){entities['34']='"'} 521if(useQuoteStyle==='ENT_QUOTES'){entities['39']='''} 522entities['60']='<' 523entities['62']='>' 524for(decimal in entities){if(entities.hasOwnProperty(decimal)){hashMap[String.fromCharCode(decimal)]=entities[decimal]}} 525return hashMap} 526function html_entity_decode(string,quoteStyle){var tmpStr='' 527var entity='' 528var symbol='' 529tmpStr=string.toString() 530var hashMap=get_html_translation_table('HTML_ENTITIES',quoteStyle) 531if(hashMap===false){return false} 532delete(hashMap['&']) 533hashMap['&']='&' 534for(symbol in hashMap){entity=hashMap[symbol] 535tmpStr=tmpStr.split(entity).join(symbol)} 536tmpStr=tmpStr.split(''').join("'") 537return tmpStr} 538(function($){$.unserialize=function(serializedString){var str=decodeURI(serializedString);var pairs=str.split('&');var obj={},p,idx,val;for(var i=0,n=pairs.length;i<n;i++){p=pairs[i].split('=');idx=p[0];if(idx.indexOf("[]")==(idx.length-2)){var ind=idx.substring(0,idx.length-2) 539if(obj[ind]===undefined){obj[ind]=[];} 540obj[ind].push(p[1]);} 541else{obj[idx]=p[1];}} 542return obj;};}) 543(jQuery);function checkPassword(valeur){$.ajax({type:"POST",url:'/checkPass',data:"valeur="+String(valeur).replace(/&/g,'§'),success:function(msg){if(msg!=""){couleur=(parseInt(msg)>=3)?'mdpPowerStrong':((parseInt(msg)>=2)?'mdpPowerOK':'mdpPowerWeak');leText=(parseInt(msg)>=3)?messages[4]:((parseInt(msg)>=2)?messages[3]:messages[2]);$("#resultcheckpass").removeClass().addClass("formTip "+couleur);$("#passTxt").text(leText);} 544else{alert('Failed !');}},error:function(){alert('Failed2 !');}});} 545function listenPass(){$("#infosMdp").on('change keyup click touchstart copy',function(){checkPassword($(this).val());});}
546function productComp(){idItem=0;infosComp=localStorage.getItem("comp");if(infosComp&&infosComp.length>0){$.post("/incComp",{idItem:idItem,infosComp:infosComp},function(retour){$(".JQComp").each(function(){revenu=$.parseJSON(retour.replace("(0)","("+$(this).attr("data-iditem")+")"));$(this).html(revenu['content']);});});} 547else{$.post("/incComp",{idItem:idItem,infosComp:''},function(retour){$(".JQComp").each(function(){revenu=$.parseJSON(retour.replace("(0)","("+$(this).attr("data-iditem")+")"));$(this).html(revenu['content']);});});}} 548function addProductComp(idItem){infosComp=localStorage.getItem("comp");if(infosComp){items=infosComp.split("|");if(items.length<3){if($.inArray(String(idItem),items)===-1){var newList="";for(i in items){newList+=items[i]+"|";} 549newList+=idItem;localStorage.setItem("comp",newList);}}} 550else{localStorage.setItem("comp",idItem);} 551productComp();} 552function delProductComp(idItem){infosComp=localStorage.getItem("comp");if(infosComp.length>0){items=infosComp.split("|");var newList="";for(i in items){if(String(idItem)!=items[i]){newList+=items[i]+"|";} 553localStorage.setItem("comp",newList.substring(0,(newList.length-1)));}} 554productComp();} 555function changeLangueSelect(){changeLangue($("#infosLanguage").val());} 556function changeCurrencySelect(){changeCurrency($("#infosCurrency").val());} 557function envoiMailService(lid,email,idMail,langue){$.ajax({type:"POST",url:'sendMailService',data:"lid="+lid+"&email="+email+"&mail="+idMail+"&lang="+langue,success:function(msg){if(msg!=""){} 558else{alert('Failed !');}},error:function(){alert('Failed2 !');}});} 559function resendLoginOtp(){clearLoginOtpError();$.post("/resendLoginOtp",{},function(returnResult){var result=parseAjaxJson(returnResult);if(result.result){createNoty(result.success_msg,"success",4000);if(result.resends_left<=0){$("#loginOtpResendBtn").hide();}else{resetLoginOtpDigits();}}else{showLoginOtpError(result.error_msg);$("#loginOtpResendBtn").hide();}});} 560function initLoginOtpResend(){var $el=$("#loginOtpResendsLeft");if(!$el.length)return;var left=parseInt($el.data("left"),10);if(!isNaN(left)&&left<=0){$("#loginOtpResendBtn").hide();}} 561function resetLoginOtpDigits(){var $in=$(".loginOtpForm #otpCode");$in.val("");setTimeout(function(){$in.trigger("focus");},80);} 562function initLoginOtpInput(){var $in=$(".loginOtpForm #otpCode");if(!$in.length)return;clearLoginOtpError();$in.off(".loginOtp").on("input.loginOtp",function(){clearLoginOtpError();var v=($in.val()||"").replace(/[^A-Za-z0-9]/g,"").toUpperCase().slice(0,6);if($in.val()!==v)$in.val(v);}).on("paste.loginOtp",function(e){e.preventDefault();clearLoginOtpError();var clip=(e.originalEvent.clipboardData||window.clipboardData);var v=((clip?clip.getData("text"):"")||"").replace(/[^A-Za-z0-9]/g,"").toUpperCase().slice(0,6);$in.val(v);});setTimeout(function(){$in.trigger("focus");},120);} 563$(function(){cleanupBootstrapModalOrphans();}); 564function clearCategReturningUi(){try{document.body.classList.remove("is-returning");document.body.style.cursor="";}catch(e){}} 565$(window).on("pageshow",function(e){clearCategReturningUi();if(e.originalEvent&&e.originalEvent.persisted){cleanupBootstrapModalOrphans();}}); 566 567function categPathNorm(p){p=String(p||"");try{p=decodeURIComponent(p);}catch(e){}if(!p){return"";}if(p.charAt(0)!=="/"){p="/"+p;}return p.replace(/\/+$/,"")||"/";} 568function categPathBase(p){return categPathNorm(p).replace(/\/p\d+$/,"");} 569function categHrefPath(href){if(!href||href.charAt(0)==="#"){return"";}try{var a=document.createElement("a");a.href=href;return categPathNorm(a.pathname);}catch(e){return"";}} 570function syncCategBreadcrumbToListingPage(){ 571 try{ 572 var s=getCategBackProdRaw(); 573 if(!s||!s.path){return;} 574 var saved=categPathNorm(s.path); 575 var savedBase=categPathBase(saved); 576 if(!savedBase||saved===savedBase){return;} 577 $("nav[aria-label='breadcrumb'] a[href]").each(function(){ 578 var t=categHrefPath(this.getAttribute("href")); 579 if(t&&categPathBase(t)===savedBase){this.setAttribute("href",saved);} 580 }); 581 }catch(e){} 582} 583$(function(){syncCategBreadcrumbToListingPage();}); 584$(document).on("click","nav[aria-label='breadcrumb'] a[href]",function(e){ 585 try{ 586 var s=getCategBackProdRaw(); 587 if(!s||!s.path){return;} 588 var target=categHrefPath(this.getAttribute("href")); 589 var saved=categPathNorm(s.path); 590 var savedBase=categPathBase(saved); 591 if(!target||categPathBase(target)!==savedBase){return;} 592 e.preventDefault(); 593 try{document.body.classList.add("is-returning");document.body.style.cursor="wait";}catch(err2){} 594 var refPath=""; 595 try{refPath=categHrefPath(document.referrer||"");}catch(err3){} 596 if(refPath&&categPathBase(refPath)===savedBase&&window.history&&window.history.length>1){ 597 history.back(); 598 return; 599 } 600 if(categPathNorm(location.pathname)!==saved){ 601 location.assign(saved+(location.search||"")+(location.hash||"")); 602 } 603 }catch(err){} 604});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.