Critere.prototype.constructor = Critere; function Critere(curcat,brand,model,min_price,max_price,min_yearmodel,max_yearmodel,mileage,cubic,energy,color,gearbox,ss_cat,advanced,mainzone,mileage_mini,multicritere,selectorBrand,min_pfisc,max_pfisc,min_pdin,max_pdin,newSearch){ this.newSearch = typeof newSearch !== 'undefined' ? newSearch : false; if (!selectorBrand) { this.selectorBrand = '#brand'; } else { this.selectorBrand = selectorBrand; } if (multicritere) { this.multicritereInit = multicritere; } else { this.multicritereInit = ''; } this.selectorModel = '#model'; this.brandInit = brand; this.modelInit = model; this.curcat = curcat; this.prefered_min_price = min_price; this.prefered_max_price = max_price; this.prefered_min_yearmodel = min_yearmodel; this.prefered_max_yearmodel = max_yearmodel; this.prefered_mileage_mini = mileage_mini; this.prefered_mileage = mileage; this.prefered_min_pfisc = min_pfisc; this.prefered_max_pfisc = max_pfisc; this.prefered_min_pdin = min_pdin; this.prefered_max_pdin = max_pdin; if (cubic) { var T = cubic.split(/\|/); this.prefered_min_cubic = T[0]; this.prefered_max_cubic = T[1]; } else { this.prefered_min_cubic = ''; this.prefered_max_cubic = ''; } this.energy = energy; this.color = color; this.gearbox = gearbox; this.advanced=advanced; this.vpmainzone= mainzone; this.ss_cat=(ss_cat!=null ? ss_cat:''); this.combo_brand = $(this.selectorBrand); this.countbrand = 0; this.combo_model = $(this.selectorModel); this.combo_prix_maxi = document.getElementById('prix_maxi'); this.combo_prix_mini = document.getElementById('prix_mini'); this.combo_yearmodel_maxi = document.getElementById('yearmodel_maxi'); this.combo_yearmodel_mini = document.getElementById('yearmodel_mini'); this.combo_region = document.getElementById('cp'); this.combo_mileage_mini = document.getElementById('mileage_mini'); this.combo_mileage = document.getElementById('mileage'); this.combo_co2 = document.getElementById('amount'); this.combo_version = document.getElementById('DynVersionReload'); this.combo_min_cubic = document.getElementById('min_cubic'); this.combo_max_cubic = document.getElementById('max_cubic'); this.hidden_cubic = document.getElementById('cubic'); this.input_cp = document.getElementById('cp'); this.checkbox_dpt = document.getElementById('departement'); this.combo_Energy = document.getElementById('energie'); this.combo_color = document.getElementById('couleur'); this.combo_gearbox = document.getElementById('gearbox'); this.WhatCatT = (document.getElementById('WhatCatT') != null ? document.getElementById('WhatCatT').value : null); this.marque = []; this.ss_cat_found = ';'; this.isDev = false; this.isRec = false; this.isProd = false; if (window.location.href.match(new RegExp('\.lacentrale\.dev'))) { this.isDev = true; this.pathStatic = '/'; //window.location.href.replace(new RegExp('^[^.]*\.([^.]*\.lacentrale\.dev/).*$'),'http://dev-lc-static.$1'); } else if (window.location.href.match(new RegExp('srvwrec')) || window.location.href.match(new RegExp('192\.168\.1\.4'))) { this.isRec = true; this.pathStatic = 'http://srvwrec:81/'; } else { this.isProd = true; this.pathStatic = 'https://static.lacentrale.fr/'; } if(curcat=='auto') this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'40,41,42,43,44,45,46,47,48,49,50,80,81,82,83,85')); else if(curcat=='moto' && this.advanced) this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'60,61,62,63,64,65,66,67,68,69,72')); else if(curcat=='utils') this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'81,82,83,85')); else if(curcat=='loisir') this.ob_cat = new Category(curcat,'re',(this.ss_cat!='' ? this.ss_cat:'506,507,508,510,423')); this.Init_static_marque(); if (this.curcat!='od') { if(this.WhatCatT!=null) { this.CatChange(this.WhatCatT); } if(this.vpmainzone == 'tz_main_home.php' || !this.newSearch) { this.fill_make(); } if (this.ob_cat) { this.ob_cat.filter_ss_cat(); } if(this.vpmainzone == 'tz_main_home.php'){ this.fill_max_price(); } /*** ajouter pour retour au mode liste deroulante ***/ if (this.combo_yearmodel_mini) this.fill_min_yearmodel(); if (this.combo_yearmodel_maxi) this.fill_max_yearmodel(); if (this.combo_min_cubic && this.combo_max_cubic) { this.fill_cubic(); } } this.Init(); } //------------------partie publique-----------------------// Critere.prototype.Init_static_marque = function(){ for(var i=0;i< this.combo_brand[0].options.length;i++) { this.marque[i]=this.combo_brand[0].options[i]; } }; Critere.prototype.Init = function() { this.fill_region(); this.fill_energy(); this.fill_color(); this.fill_gearbox(); this.check_crit_categorie(); }; Critere.prototype.MakeChange = function(brandSelect, modelSelect) { this.fill_model(brandSelect, modelSelect); }; Critere.prototype.CatChange = function(curcat) { if(curcat) { this.curcat = curcat; } this.fill_make(); this.clearVersion(); this.check_crit_categorie(); if(this.combo_min_cubic && this.combo_max_cubic) { this.fill_cubic(); } document.form.action = (document.getElementById('galerie')? 'galerie_':'listing_')+(this.curcat=='loisir'?'camping_car-caravane':(this.curcat=='utils'?'auto':this.curcat))+'.php'; }; Critere.prototype.ModelChange = function() { this.clearVersion(); }; Critere.prototype.MaxPriceChange = function() { this.setPrefMaxPrice(); }; Critere.prototype.MinPriceChange = function() { this.fill_max_price(); }; Critere.prototype.MaxCubicChange = function() { this.setPrefMaxCubic(); this.calc_cubic(); }; Critere.prototype.MinCubicChange = function() { this.setPrefMinCubic(); this.fill_cubic(); this.calc_cubic(); }; Critere.prototype.MaxYearmodelChange = function() { this.setPrefMaxYearmodel(); }; Critere.prototype.MinYearmodelChange = function() { this.setPrefMinYearmodel(); this.fill_max_yearmodel(); }; Critere.prototype.CO2Load = function(value) { var co2_array = ['', '90', '150','180']; for(var i=1;i0 && Tres.length>0 && Tcp[i].length==0) { Tres[Tres.length]=Tcp[i]; } else if(/^[0-9][0-9]$/.test(Tcp[i])) { Tres[Tres.length]=Tcp[i]; } else if(/^[0-9]$/.test(Tcp[i])) { Tres[Tres.length]=Tcp[i]; } else if(/^(2A|2B|[A-Z]|[A-Z][A-Z])$/.test(Tcp[i])) { Tres[Tres.length]=Tcp[i]; } } for(var k in Tres){ j=(parseInt(k)+1); while(j0 || res=='2A' || res=='2B'); }; Critere.prototype.calcMulticritere = function(submitFlag) { var multicritere = ''; var self = this; var brand, model; var nbCritere = 0; $(self.selectorBrand).each(function() { if (brand = $(this).val()) { nbCritere++; model = $(this).parent().next('.modele').find('.modelSelect').val(); multicritere += (multicritere?';':'') + brand.toLowerCase(); if (model) { multicritere += '|' + model.toLowerCase(); } } }); $('[name=multicriteres]').val(multicritere); if (nbCritere>1 && submitFlag) { $('.brandSelect').prop('disabled', true); $('.modelSelect').prop('disabled', true); } }; Critere.prototype.calcCo2 = function () { if(this.combo_co2!=null && (this.curcat=='auto' || this.curcat=='utils')){ if(this.combo_co2.value != 0 && !isNaN(this.combo_co2.value) && this.combo_co2.value<10){ var co2_array = ['', '90', '150','180']; this.combo_co2.value = co2_array[this.combo_co2.value]; } else if (this.combo_co2.value == 0) { this.combo_co2.value = ''; } } } Critere.prototype.go_and_submit = function() { if(!document.form) { return; } if(this.input_cp!=null) { this.input_cp.value=this.input_cp.value.replace(/,$/,''); } this.calcCo2(); this.calcMulticritere(true); this.check_dpt('efface'); this.calc_cubic(); document.form.submit(); }; Critere.prototype.SubmitAdvanced = function() { var adresse = 'listing_' + (this.curcat == 'loisir' ? 'camping_car-caravane' : (this.curcat == 'utils' ? 'auto' : this.curcat)) + '.php?'; var cat=this.get_cat(); adresse = adresse + 'SS_CATEGORIE=' + cat; if (this.combo_brand) { adresse = adresse + '&marque=' + this.combo_brand.val(); } if (this.combo_model) { adresse = adresse + '&modele=' + this.combo_model.val(); } if (document.getElementById('cp')) { adresse = adresse + '&cp=' + document.getElementById('cp').options[document.getElementById('cp').selectedIndex].value; } if (this.combo_prix_maxi) { adresse = adresse + '&prix_maxi=' + this.combo_prix_maxi.options[this.combo_prix_maxi.selectedIndex].value; } if (document.getElementById('energie')) { adresse = adresse + '&energie=' + document.getElementById('energie').options[document.getElementById('energie').selectedIndex].value; } adresse = adresse + '&advanced=1'; window.location = adresse; }; Critere.prototype.set_region = function(idx){ /*selecting a region*/ this.combo_region.selectedIndex = idx; }; Critere.prototype.fill_region = function(){ if(!this.combo_region || !this.combo_region.options) { return; } var Tregion = [ ['Région',''], ['Auvergne-Rhône-Alpes','01,03,07,15,26,38,42,43,63,69,73,74'], ['Bourgogne-Franche-Comté','21,25,39,58,70,71,89,90'], ['Bretagne','22,29,35,56'], ['Centre-Val de Loire','18,28,36,37,41,45'], ['Corse','2A,2B,20'], ['Grand Est','08,10,51,52,54,55,57,67,68,88'], ['Hauts-de-France','02,59,60,62,80'], ['Île-de-France','75,77,78,91,92,93,94,95'], ['Normandie','14,27,50,61,76'], ['Nouvelle-Aquitaine','16,17,19,23,24,33,40,47,64,79,86,87'], ['Occitanie','09,11,12,30,31,32,34,46,48,65,66,81,82'], ['Pays de la Loire','44,49,53,72,85'], ['Provence-Alpes-Côte d\'Azur','04,05,06,13,83,84'], ]; for(var i=0;i ((min_cubic > 0) ? parseInt(min_cubic, 10) : 0)) { this.combo_max_cubic.options[max_len++] = new Option ( format(labelCubicMoto[i]) + ' cm3 maxi.' , labelCubicMoto[i] ); if(this.prefered_max_cubic && labelCubicMoto[i] == this.prefered_max_cubic) { this.combo_max_cubic.options[max_len - 1].selected = true; } } } }; Critere.prototype.calc_cubic = function() { if (this.curcat!='moto' && this.curcat!='quad' && this.curcat!='scooter') { return; } if (this.combo_max_cubic && this.combo_min_cubic && (this.combo_min_cubic.selectedIndex > 0 || this.combo_max_cubic.selectedIndex > 0)) { this.hidden_cubic.value = this.combo_min_cubic.value+'|'+this.combo_max_cubic.value; } else { this.hidden_cubic.value = ''; } }; Critere.prototype.check_crit_categorie = function() { var T_champs = ['couleur','energie','mileage','gearbox','warranty','nb_beds','nb_seats','length','width','yearmodel_mini','yearmodel_maxi','brand','model','mileage','pfisc_mini','pfisc_maxi','pdin_mini','pdin_maxi','mileage_mini'], T_disable = [], classe=''; T_disable[0] = ['423,425|423|425|426|427|428|84','energie|gearbox']; T_disable[1] = ['426','yearmodel_maxi|yearmodel_mini|couleur']; T_disable[2] = ['426|427|428','warranty|nb_seats|length|width|version|brand|model|mileage|mileage_mini']; T_disable[3] = ['423,425|423|425','warranty|nb_seats|length|width|version|mileage|mileage_mini|pfisc_mini|pfisc_maxi|pdin_mini|pdin_maxi']; var cat=this.get_cat(); for (var k=0;k0) { return; } document.getElementById('brand').disabled=true; classe = document.getElementById('brand').className; classe = classe + ' disabledT'; document.getElementById('brand').className = classe; document.getElementById('model').disabled=true; classe = document.getElementById('model').className; classe = classe + ' disabledT'; document.getElementById('model').className = classe; }; Critere.prototype.fill_static_marque = function(TabMarque){ var label = this.marque[0].text, temp, marque = TabMarque.split(/;/); this.marque = [new Option(label,'')]; for(var i=0;i', { value: utils.encodeBrandModelParameter(brandList[i]).replace(/\+/g,' '), text: brandList[i] })); } if(self.ob_cat!=null){ if(self.ob_cat.compt == self.ob_cat.comptchecked || self.ob_cat.comptchecked==0 ){ for(var m=self.marque.length-1;m>=1;m--) { $(this).find("option:eq(0)").after($('