PageSourceSearch

https://www.gites-de-france-var.fr/lib_2/js/elementsWeb/moteur_inptRechercheMulti.js?t=1741711295

js gites-de-france-var.fr collected 2026-10-02 20:51:28 UTC 35,182 bytes, 744 lines download raw bytes

1var _reqAjaxMoteur;
2var _timerPourMoteurLieu;
3
4$(document).ready(function () {
5    if ($('.moteur_inptRechercheMutli')) {
6        $('.moteur_inptRechercheMutli').focus(function() {
7            $('.ui-drp-fade').click();
8            // on ne gère pas l'historique dans le cas du moteur avec lien car ça demande à avoir un formulaire avec toutes les données dedans pour le remplir
9            if (!$('moteur_divRechercheMultiSansLien')) {
10                return;
11            }
12            // on va chercher l'historique dans le localStorage
13            var previousSearch = getPreviousSearch();
14            if (!previousSearch instanceof Array || previousSearch.length == 0) {
15                return;
16            }
17
18            var voyageur = '';
19            var voyageurs = '';
20            var recherchesRecentes = '';
21            // on recup les 3 mots clés à utiliser pour la génération de l'historique
22            var result;
23            if (sessionStorage['getMotsClesHistorique'] !== undefined) {
24                result = JSON.parse(sessionStorage['getMotsClesHistorique']);
25            } else {
26                $.ajax({
27                    url: '/lib_2/ajax/infosCGI.php',
28                    type: 'POST',
29                    dataType: 'json',
30                    async: false,
31                    data: {
32                        typeInfo: 'getMotsClesHistorique'
33                    },
34                    success: function(r) {
35                        sessionStorage.setItem('getMotsClesHistorique', JSON.stringify(r));
36                        result = r;
37                    }
38                });
39            }
40            voyageur = result.voyageur;
41            voyageurs = result.voyageurs;
42            recherchesRecentes = result.recherchesRecentes;
43
44            $('#moteur_divMultiAutoComplete').hide();
45
46            var htmlHistorique = '<div class="historique">' + '<p class="categorie">' + recherchesRecentes + '</p>' + '<ul class="itea_ul">';
47            var selected = 'selected';
48            
49            // on parcourt les différentes recherches
50            for (var i = 0; i < previousSearch.length; i++) {
51                // transformation du form serialisé en object
52                var datePassees = false;
53                var tabCrit = previousSearch[i].split('&');
54                console.log('previousSearch tabCrit:', tabCrit);
55                if (tabCrit.indexOf('lieucgi=') > 0 && tabCrit.indexOf('deb=') > 0) {
56                    continue;
57                }
58
59                var tabInfo = new Object();
60                for (var j = 0; j < tabCrit.length; j++) {
61                    var couple = tabCrit[j].split('=');
62                    var key = couple[0];
63                    var value = couple[1];
64
65                    if (key === 'lieucgi') {
66                        // il arrive que le lieu soit deux fois encodé, on le désencode deux fois et on remplace les + par des espaces
67                        tabInfo.valreel = decodeURIComponent(decodeURIComponent(value)).replace(/\+/g, ' ');
68                    } else if (key === 'lno') {
69                        if (tabInfo.ref === '' || tabInfo.ref === undefined) {
70                            tabInfo.ref = value;
71                        }
72                    } else if ($.inArray(key, ['INSEE', 'DEP', 'REGION_ADM', 'REGION_SUP', 'REGION', 'INFOTOURFD', 'INFOTOUR']) !== -1) {
73                        tabInfo.cgi = key;
74                        tabInfo.valcgi = value;
75                    } else if (key === 'lnoident') {
76                        if (tabInfo.lnoident === '' || tabInfo.lnoident === undefined) {
77                            tabInfo.lnoident = value;
78                        }
79                    } else if (key === 'deb') { // deb, fin et nbp_min sont toujours présent dans le form même si on ne séléctionnep as de valeur pour eux
80                        var objDateDeb = new OBJDate(decodeURIComponent(decodeURIComponent(value)));
81                        var today = new OBJDate();
82                        if (objDateDeb.estAvant(today.toString()) && !objDateDeb.estEgale(today.toString())) {
83                            datePassees = true;
84                        }
85                        tabInfo.dateDeb = value; // defaut = ""
86                    } else if (key === 'fin') {
87                        var objDateFin = new OBJDate(decodeURIComponent(decodeURIComponent(value)));
88                        tabInfo.dateFin = value; // defaut = ""
89                    } else if (key === 'nbp_min') {
90                        tabInfo.nbPers = value; // defaut = "n"
91                    } else if (key === 'urlListe') {
92                        tabInfo.url = value; // defaut = 'liste'
93                    } else if (key === 'input-drp-arrival-name') {
94                        tabInfo.stringArrivee = decodeURIComponent(value.replace(/\+/g, ' '));
95                    } else if (key === 'input-drp-departure-name') {
96                        tabInfo.stringDepart = decodeURIComponent(value.replace(/\+/g, ' '));;
97                    } else if (key === 'longitude') {
98                        tabInfo.longitude = value;
99                        tabInfo.cgi = 'VILLE_ETRANGER';
100                    } else if (key === 'latitude') {
101                        tabInfo.latitude = value;
102                    }
103                }
104
105                if (datePassees) {
106                    tabInfo.dateDeb = '';
107                    tabInfo.dateFin = '';
108                    tabInfo.stringArrivee = '';
109                    tabInfo.stringDepart = '';
110                }
111                //on regarde en premier si toutes les info de l'objet sont undefined, ça n'est pas censé arriver, 
111c'est juste une sécurité
112                //on regarde ensuite si les champs ont tous leur valeur par défaut (pour éviter d'afficher une recherche vide)
113                if (tabInfo.ref === undefined && tabInfo.valreel === undefined && tabInfo.dateDeb === undefined && tabInfo.dateFin === undefined) {
114                    continue;
115                } else if (tabInfo.ref === undefined && tabInfo.dateDeb === '' && tabInfo.dateFin === '' && tabInfo.nbPers === 'n') {
116                    continue;
117                }
118
119                // on mets toutes les infos dans le li même si elles sont vide ou undefined
120                // on lui ajoute la fonction onclick fillInputsHistoriqueMoteurMulti(this)
121                // la class selected permet l'highlight et la navigation avec les fleches
122                htmlHistorique += "<li nbp_min='" + tabInfo.nbPers + "' deb='" + tabInfo.dateDeb + "' fin='" + tabInfo.dateFin + "' stringArrivee='" + tabInfo.stringArrivee + "' stringDepart='" + tabInfo.stringDepart + "' class='" + selected + "' onclick='fillInputsHistoriqueMoteurMulti(this);' data-numLi='" + parseInt(i + 1) + "' data-url ='" + tabInfo.url + "' ";
123                if (typeof tabInfo.valreel !== 'undefined' && tabInfo.valreel !== "" && tabInfo.valreel !== "undefined") {
124                    htmlHistorique += ' valreel="' + tabInfo.valreel + '"';
125                    if (typeof tabInfo.cgi !== 'undefined' && tabInfo.cgi !== "") {
126                        htmlHistorique += ' cgi="' + decodeURIComponent(decodeURIComponent(tabInfo.cgi)) + '" val_cgi="' + tabInfo.valcgi + '" ';
127                    } else if (typeof tabInfo.lnoident !== 'undefined' && tabInfo.lnoident !== "") {
128                        htmlHistorique += ' lnoident="' + tabInfo.lnoident + '"';
129                    }
130                } else if (typeof tabInfo.ref !== 'undefined' && tabInfo.ref !== "" && tabInfo.ref !== "undefined") {
131                    htmlHistorique += ' ref="' + tabInfo.ref + '" lnoident="' + tabInfo.lnoident + '" ';
132                }
133                if (typeof tabInfo.longitude !== 'undefined' && typeof tabInfo.latitude !== 'undefined') {
134                    htmlHistorique += ' data-longitude="' + tabInfo.longitude + '" data-latitude="' + tabInfo.latitude + '"';
135                }
136                htmlHistorique += ' >';
137                // on génére le premier span, on met soit le lieu soit la ref dedans
138                htmlHistorique += '<span class="lieu">';
139
140                if (tabInfo.valreel !== undefined && tabInfo.valreel !== "" && tabInfo.valreel !== "undefined") {
141                    htmlHistorique += tabInfo.valreel;
142                } else if (typeof tabInfo.ref !== 'undefined' && tabInfo.ref !== "" && tabInfo.ref !== "undefined") {
143                    htmlHistorique += tabInfo.ref;
144                }
145                htmlHistorique += '</span>';
146
147                // on génére le deuxième span, on met les dates dedans
148                htmlHistorique += '<span class="dates"> ';
149
150                if ((tabInfo.dateDeb !== undefined && tabInfo.dateDeb !== "") || (tabInfo.dateFin !== undefined && tabInfo.dateFin !== "")) {
151                    if (tabInfo.dateDeb !== undefined && tabInfo.dateDeb !== "" && tabInfo.stringArrivee !== undefined && tabInfo.stringArrivee !== "") {
152                        htmlHistorique += '<span class="dateTxt">' + tabInfo.stringArrivee + '</span>';
153                        htmlHistorique += '<span class="dateFormatDate" style="display:none">' + objDateDeb.toString('dd.mm.yy') + '</span>';
154                        if (tabInfo.dateFin !== undefined && tabInfo.dateFin !== "" && tabInfo.stringDepart !== undefined && tabInfo.stringDepart !== "") { // si jamais on ne mets pas de date de fin, on ne mets pas le tiret
155                            htmlHistorique += ' - ';
156                        }
157                    }
158                    if (tabInfo.dateFin !== undefined && tabInfo.dateFin !== "" && tabInfo.stringDepart !== undefined && tabInfo.stringDepart !== "") {
159                        htmlHistorique += '<span class="dateTxt">' + tabInfo.stringDepart + '</span>';
160                        htmlHistorique += '<span class="dateFormatDate" style="display:none">
160' + objDateFin.toString('dd.mm.yy') + '</span>';
161                    }
162                }
163                htmlHistorique += '</span>';
164
165                // on génére le troisième span, on met le nombre de personnes dedans
166                htmlHistorique += '<span class="voyageurs">';
167                if (tabInfo.nbPers !== undefined && tabInfo.nbPers !== "" && tabInfo.nbPers !== "n" && parseInt(tabInfo.nbPers) > 0) {
168                    htmlHistorique += tabInfo.nbPers;
169                    if (parseInt(tabInfo.nbPers) > 1) { //selon le nombre de personnes, on utilise un des deux mots clés recup par ajax
170                        htmlHistorique += ' ' + voyageurs;
171                    } else {
172                        htmlHistorique += ' ' + voyageur;
173                    }
174                }
175                htmlHistorique += '</span>';
176
177                htmlHistorique += '</li>';
178                if (selected === "selected") {
179                    selected = "";
180                }
181            }
182            htmlHistorique += '</ul>';
183            htmlHistorique += '</div>';
184            $('#moteur_divMultiAutoComplete').html(htmlHistorique);
185
186            // on gère la navigation avec les flèches, la séléction avec entré et tab, et le changement de classe lors du survol des li
187            var divChampChoix = 'moteur_divMultiAutoComplete';
188            var moteur = $('#moteur_divMultiAutoComplete');
189            var li = $('#' + divChampChoix + ' ul>li');
190            var liSelected = $('#' + divChampChoix + ' ul').find('.selected');
191            var next, nextNum;
192            $(window).keydown(function(e) {
193
194                if (e.which === 40) {
195                    li.removeClass('selected');
196                    nextNum = parseInt(liSelected.attr('data-numLi')) + 1;
197                    next = $('#' + divChampChoix + ' ul').find("[data-numLi='" + nextNum + "']");
198                    if (next.length > 0) {
199                        liSelected = next.addClass('selected');
200                    } else {
201                        liSelected = li.eq(0).addClass('selected');
202                    }
203                    if (liSelected.offset().top + liSelected.height() > moteur.offset().top + moteur.height() || liSelected.offset().top < moteur.offset().top) {
204                        moteur.scrollTo(liSelected);
205                    }
206                } else if (e.which === 38) {
207                    li.removeClass('selected');
208                    nextNum = parseInt(liSelected.attr('data-numLi')) - 1;
209                    next = $('#' + divChampChoix + ' ul').find("[data-numLi='" + nextNum + "']");
210                    if (next.length > 0) {
211                        liSelected = next.addClass('selected');
212                    } else {
213                        liSelected = li.last().addClass('selected');
214                    }
215                    if (liSelected.offset().top + liSelected.height() > moteur.offset().top + moteur.height() || liSelected.offset().top < moteur.offset().top) {
216                        moteur.scrollTo(liSelected);
217                    }
218                } else if (e.which === 13) {
219                    if ($('#' + divChampChoix).is(':visible')) {
220                        e.preventDefault();
221                        $('#' + divChampChoix + ' ul').find('.selected').click();
222                        return false;
223                    }
224                } else if (e.which === 9) {
225                    if ($('#' + divChampChoix).is(':visible')) {
226                        $('#' + divChampChoix + ' ul').find('.selected').click();
227                    }
228                }
229
230            });
231
232            li.on('mouseenter', function(e) {
233                e.preventDefault();
234                li.removeClass('selected');
235                $(this).addClass('selected');
236            });
237
238            $('#moteur_divMultiAutoComplete').show();
239        });
240
241        // gère le clic en dehors du moteur, similaire à ITEA_clicOutBody
242        var zone = "init"; //init: on initialise OU on est dans la div
243        $(".moteurMultiCritere").each(function() {
244            $(this).bind("click", function() {
245                zone = "init";
246            })
247            $(this).on("touchstart", function() { // il faut aussi gérer sur appareils tactiles
248                zone = "init";
249            })
250        });
251        $("body").bind("click", function() {
252            if (zone != "init") {
253                if ($('#moteur_divMultiAutoComplete').is(":visible")) {
254                    clickOut_moteur_inptRechercheMutli();
255                    zone = "init";
256                }
257            } else {
258                zone = "out";
259            }
260        });
261        $("body").on("touchstart", function() { // il faut aussi gérer sur appareils tactiles
262            if (zone != "init") {
263                if ($('#moteur_divMultiAutoComplete').is(":visible")) {
264                    clickOut_moteur_inptRechercheMutli();
265                    $('#moteur_inptRechercheMutli').blur();
266                    zone = "init";
267                }
268            } else {
269                zone = "out";
270            }
271        });
272
273        $('#moteur_inptRechercheMutli').closest('form').on('submit', function() {
274            var chaine = $(this).serialize();
275            if (
276                ($('#moteur_inptRechercheMutli').attr('name') === 'lieucgi' && $('#moteur_inptRechercheMutliHidden').attr('name') === 'lnoident') ||
277                ($('#moteur_inptRechercheMutli').attr('name') === 'lieucgi' && $('input[name="longitude"]').length > 0 && $('input[name="latitude"]').length > 0)
278            ) {
279                $('#moteur_inptRechercheMutli').attr("name", "");
280            }
281            setPreviousSearch(chaine);
282        });
283
284        $('.moteur_inptRechercheMutli').onblur = function(evt) {
285            if ($('.moteur_inptRechercheMutli').value === "") {
286                //$('.moteur_inptRechercheMutli').value=$('.moteur_inptRechercheMutli').attr("title"); // on laisse le placeholder faire son taf en fait. sinon souci avec traducteur auto google.
287                $('#moteur_inptRechercheMutliHidden').value = "";
288            }
289        };
290        $('.moteur_inptRechercheMutli').on("input", function() {
291            console.log('moteur_initMoteurCommun input ' + $('#moteur_inptRechercheMutli').val());
292            if (_timerPourMoteurLieu !== undefined) {
293                try {
294                    console.log('moteur_initMoteurCommun input clearTimeout _timerPourMoteurLieu');
295                    clearTimeout(_timerPourMoteurLieu);
296                } catch (error) {
297                    console.log('moteur_initMoteurCommun input error clearTimeout');
298                }
299            }
300
301            var avecLien = 'true';
302            var idDivMoteur = '#moteur_divRechercheMulti';
303            if ($('#moteur_divRechercheMultiSansLien').length > 0) {
304                avecLien = 'false';
305                idDivMoteur = '#moteur_divRechercheMultiSansLien';
306            }
307
308            if ($('#moteur_inptRechercheMutli').val() == '') {
309                $('#moteur_inptRechercheMutliHidden').val('');
310                $('#moteur_inptRechercheMutliHidden').attr('name', '');
311            }
312
313            var priseEnCompteCrits = true;
314            if ($(idDivMoteur).attr("data-priseEnCompteCriteres") === "fal
314se") {
315                priseEnCompteCrits = false;
316            }
317
318            var avecinfostour = true;
319            if ($(idDivMoteur).attr("data-avecinfostour") === "false") {
320                avecinfostour = false;
321            }
322            var avecInseeAffiche = false;
323            if ($(idDivMoteur).data('avec-insee-affiche') === true) {
324                avecInseeAffiche = true;
325            }
326            var dpt = "";
327            if ($('.moteur_inptRechercheMutli').attr("data-depfiltre")) {
328                dpt = $("moteur_inptRechercheExpress").attr("data-depfiltre");
329            }
330            var libelleDansAutoCompleteur = '';
331            if ($('.moteur_inptRechercheMutli').attr("data-libelleDansAutoCompleteur")) {
332                libelleDansAutoCompleteur = 'false';
333            }
334            var gestprod = false;
335            if ($(idDivMoteur).attr('data-gestprod') === "true") {
336                gestprod = true;
337            }
338            var avecRegion = true;
339            if ($(idDivMoteur).attr('data-avecRegion') === "false") {
340                avecRegion = false;
341            }
342            var avecDep = true;
343            if ($(idDivMoteur).attr('data-avecDep') === "false") {
344                avecDep = false;
345            }
346            var avecMicroRegion = false;
347            if ($(idDivMoteur).attr('data-avecMicroRegion') === "true") {
348                avecMicroRegion = true;
349            }
350            var nbCommunesAffiche = 3;
351            if (parseInt($(idDivMoteur).attr('data-nbCommunesAffiche')) > 0) {
352                nbCommunesAffiche = parseInt($(idDivMoteur).attr('data-nbCommunesAffiche'));
353            }
354            let communesFirst = $(idDivMoteur).attr('data-communesFirst') === 'true';
355
356            changeAttrNameBasedOnInputType();
357
358            // on laisse un timer 500 ms pour taper, ensuite on lance l'appel ajax
359            // si la valeur de l'input est changé alors qu'une req ajax est en cours, on l'annule
360            _timerPourMoteurLieu = setTimeout(function() {
361                console.log('moteur_initMoteurCommun setAutocompleteForRechercheMulti input:' + $('#moteur_inptRechercheMutli').val());
362                setAutocompleteForRechercheMulti('moteur_inptRechercheMutli', 'moteur_divMultiAutoComplete', '', dpt, libelleDansAutoCompleteur, gestprod, priseEnCompteCrits, avecinfostour, avecInseeAffiche, avecLien, avecRegion, avecDep, avecMicroRegion, nbCommunesAffiche, communesFirst);
363            }, 200);
364
365        });
366        $("#moteur_divRechercheMulti, #moteur_divRechercheMultiSansLien").mouseleave(function() {
367            $("#moteur_divMultiAutoComplete li").removeClass('selected');
368        });
369    }
370});
371
372function changeAttrNameBasedOnInputType() {
373    // on change le name de l'input selon sa cible, si on cherche un lieu c'est lieucgi et si on cherche une ref c'est lno
374    var text = $('#moteur_inptRechercheMutli').val();
375    if (text.match('^[0-9a-zA-Z]+[0-9]$') !== null) {
376        $('#moteur_inptRechercheMutli').attr('name', 'lno');
377    } else {
378        $('#moteur_inptRechercheMutli').attr('name', 'lieucgi');
379    }
380}
381
382function getPreviousSearch(){
383    var pastSearches = [];
384    if(window.localStorage["pastSearches"]) {
385         pastSearches = JSON.parse(window.localStorage["pastSearches"]);
386    }
387    return pastSearches;
388}
389
390function clickOut_moteur_inptRechercheMutli () {
391    if($('#moteur_divMultiAutoComplete .conteneurAutoCompleteur').length > 0) {
392        if ($($('#moteur_divMultiAutoComplete .conteneurAutoCompleteur li')[0]).find('a').length == 0) {
393            $('#moteur_divMultiAutoComplete .conteneurAutoCompleteur li')[0].click();
394        } else {
395            $('#moteur_inptRechercheMutli').val('');
396            $('#moteur_inptRechercheMutli').attr('data-valeursaisie', '');
397        }
398    }
399    $('#moteur_divMultiAutoComplete').hide();
400}
401
402function setPreviousSearch(chaine){
403    var pastSearches = [];
404    if(window.localStorage["pastSearches"]){
405        pastSearches = JSON.parse(localStorage["pastSearches"]);
406        for(var i = 0; i < pastSearches.length; i++) {
407            if(chaine === pastSearches[i]) {
408                return ;
409            }
410        }
411    }
412    pastSearches.unshift(chaine);
413    if(pastSearches.length > 5) { 
414        pastSearches.pop();
415    }
416    window.localStorage["pastSearches"] = JSON.stringify(pastSearches);        
417}
418
419function setAutocompleteForRechercheMulti(idChampSaisie, divChampChoix, communeDansAutoComplet, departements, libelleDansAutoCompleteur, gestprod, priseEnCompteCrits, avecinfostour, avecInseeAffiche, avecLien, avecRegion, avecDep, avecMicroRegion, nbCommunesAffiche, communesFirst) {
420    if(typeof(priseEnCompteCrits) === "undefined") priseEnCompteCrits = true;
421    if(typeof(avecinfostour) === "undefined") avecinfostour = true;
422    if(typeof(avecInseeAffiche) === "undefined") avecInseeAffiche = false;
423    if(typeof(avecRegion) === "undefined") avecRegion = true; 
424    if(typeof(avecDep) === "undefined") avecDep = true;
425    if(typeof(avecMicroRegion) === "undefined") avecMicroRegion = false;
426    if(typeof(nbCommunesAffiche) === "undefined") nbCommunesAffiche = 3;
427    var url="/lib_2/ajax/infosCGI.php";
428    var valInput = $('#' + idChampSaisie).val();
429    var moteur = $('#'+divChampChoix);        
430    if (valInput.length === 0) {
431        moteur.empty();
432        moteur.hide();
433        return;
434    }
435    var data = {
436      departements,
437      valInput,
438      typeInfo: "AUTOCOMPLETEMULTI",
439      avecRegion,
440      avecDep,
441      avecMicroRegion,
442      nbCommunesAffiche,
443      RETURNLNKTOFICHE: true,
444      avecinfostour,
445      communesFirst,
446    };
447
448    if(communeDansAutoComplet){
449        data = {affComm : true };
450    }
451    if(libelleDansAutoCompleteur){
452        data = {libelleDansAutoCompleteur : false };
453    }
454    if(gestprod){
455        data = {RETURNREFGESTPROD : true };
456    }
457    if(avecLien === 'false'){
458        data.TYPEREPONSE = 'JS';
459    }
460    
461    if (_reqAjaxMoteur !== undefined) {
462        try {
463            _reqAjaxMoteur.abord();
464        } catch (error) {
465            console.log('setAutocompleteForRechercheMulti error abord');
466        }
467    }
468    
469    _reqAjaxMoteur = $.ajax({
470            url: url,
471            type: 'GET',
472            data: data,
473            beforeSend : function(){
474                if(moteur.find('li').length === 0){
475                    moteur.hide();
476                }
477            },
478            success:function(rep){   
479                moteur.empty();
480                moteur.append('<div class="conteneurAutoCompleteur">'+rep+'</div>');
481                if(window.moteurInitAutoCompletMultiple){ // fonction définie dans recette fédé
482                    moteurInitAutoCompletMultiple();
483                }
484                
485                $('#'+divChampChoix+' ul>li').each(function(){
486                    $(this).attr('onClick','onClickLiMoteurAutoCompleteMulti(this,' + avecLien + ')');
487                });
488                if(rep.length>0){
489                    moteur.show();
490                }
491                else{
492                    moteur.hide();
493                }
494
495                var li = $('#'+divChampChoix+' ul>li');
496                var liSelected = $('#'+divChampChoix+' ul').find('.selected');
497                $(window).keydown(function(e){
498                    if(e.which === 40){
499                        li.removeClass('selected');
500                        nextNum = parseInt(liSelected.attr('data-numLi'))+1;
501                        next = $('#'+divChampChoix+' ul').find("[data-numLi='" + nextNum + "']");
502                        if(next.length > 0){
503                            liSelected = next.addClass('selected');
504                        }else{
505                            liSelected = li.eq(0).addClass('selected');
506                        }
507                        if(liSelected.offset().top+liSelected.height()>moteur.offset().top+moteur.height() || liSelected.offset().top<moteur.offset().top){
508                            moteur.scrollTo(liSelected);
509                        }
510                    }else if(e.which === 38){
511                        li.removeClass('selected');
512                        nextNum = parseInt(liSelected.attr('data-numLi'))-1;
513                        next = $('#'+divChampChoix+' ul').find("[data-numLi='" + nextNum + "']");
514                        if(next.length > 0){
515                            liSelected = next.addClass('selected');
516                        }else{
517                            liSelected = li.last().addClass('selected');
518                        }
519                        if(liSelected.offset().top+liSelected.height()>moteur.offset().top+moteur.height() || liSelected.offset().top<moteur.offset().top){
520                            moteur.scrollTo(liSelected);
521                        }
522                    }else if(e.which === 13){
523                        if( $('#'+divChampChoix).is(':visible')){
524                            e.preventDefault();
525                            $('#'+divChampChoix+' ul').find('.selected').trigger('click');
526                            return false;
527                        }
528                    }
529                    else if(e.which === 9){
530                        if( $('#'+divChampChoix).is(':visible')){
531                            $('#'+divChampChoix+' ul').find('.selected').trigger('click');
532                        }
533                    }
534                    
535                });
536                
537                li.on('mouseenter',function(e){
538                    e.preventDefault();
539                    li.removeClass('selected');
540                    $(this).addClass('selected');
541                });
542            }
543    });
544}
545
546function fillInputsHistoriqueMoteurMulti(element){    
547    if(typeof $(element).attr('valreel') !== 'undefined'){
548        var lieu = $(element).attr('valreel');
549        var cgi = $(element).attr('cgi');
550        var valcgi = $(element).attr('val_cgi');
551    } else if( typeof $(element).attr('ref') !== 'undefined' ){
552        var ref = $(element).attr('ref');
553    }
554    var lnoident = $(element).attr('lnoident');
555    var nbPers = $(element).attr('nbp_min');
556    var deb = $(element).attr('deb');
557    var fin = $(element).attr('fin');
558    var stringArrivee = $(element).attr('stringArrivee');
559    var stringDepart = $(element).attr('stringDepart');
560    var url = $(element).attr('data-url');
561    var valDefaut = $('#moteur_inptRechercheMutli').attr('data-defaut');
562    
563    $('#moteur_inptLong').attr('name', '');
564    $('#moteur_inptLat').attr('name', '');
565    $('#moteur_inptRayon').attr('name', '');
566    
567    if(lieu !== undefined && lieu !== 'undefined' && lieu !== ''){
568        $('#moteur_inptRechercheMutli').val(decodeURIComponent(decodeURIComponent(lieu)).replace(/\+/g,' '));
569        $("#moteur_inptRechercheMutliHidden").attr("name",'');
570        $("#moteur_inptRechercheMutliHidden").attr("value",'');
571        if(cgi === 'VILLE_ETRANGER') {
572            $('#moteur_inptLong').attr('name', 'longitude');
573            $('#moteur_inptLong').val($(element).data('longitude'));
574            $('#moteur_inptLat').attr('name', 'latitude');
575            $('#moteur_inptLat').val($(element).data('latitude'));
576            $('#moteur_inptRayon').attr('name', 'rayon');
577            $('#moteur_inptRayon').val('20');
578        } else if(cgi !== undefined && cgi !== 'undefined' && cgi !== '' ){
579            $("#moteur_inptRechercheMutliHidden").attr("name",cgi);
580            $("#moteur_inptRechercheMutliHidden").attr("value",valcgi);
581        }else if(lnoident !== undefined && lnoident !== 'undefined' && lnoident!==''){
582            $("#moteur_inptRechercheMutliHidden").attr("name","lnoident");
583            $("#moteur_inptRechercheMutliHidden").attr("value",lnoident);
584        }
585    }else if(ref !== undefined && ref !== 'undefined' && ref !== ''){
586        $('#moteur_inptRechercheMutli').val(ref);
587        $("#moteur_inptRechercheMutliHidden").attr("name","lnoident");
588        $("#moteur_inptRechercheMutliHidden").attr("value",lnoident);
589    }else{
590        $('#moteur_inptRechercheMutli').val(valDefaut);
591    }
592    
593    if(deb !== 'undefined' && deb !== ""){
594        deb = decodeURIComponent(decodeURIComponent(deb));
595        $("#input-drp-start-id").val(deb);
596        if (stringArrivee !== 'undefined' && stringArrivee !== "") {
597            $('#input-drp-arrival-id').val(stringArrivee);
598            if(window.setDateHisto){ // fonction définie dans recette fédé
599                setDateHisto();
600            }
601        }
602    }
603    else{
604        $('#input-drp-arrival-id').val('');
605        $("#input-drp-start-id").val('');
606    }
607    
608    if(fin !== 'undefined' && fin !== ""){
609        fin = decodeURIComponent(decodeURIComponent(fin));
610        $("#input-drp-end-id").val(fin);
611        if (stringDepart !== 'undefined' && stringDepart !== "") {
612            $('#input-drp-departure-id').val(stringDepart);
613            if(window.setDateHisto){ // fonction définie dans recette fédé
614                setDateHisto();
615            }            
616        }
617    }else{
618        $("#input-drp-end-id").val('');
619        $('#input-drp-departure-id').val('');
620        if(deb !== 'undefined' && deb !== ""){
621            $(".drp-end-container").click();
622        }
623    }
624    
625    if(nbPers !== 'undefined' && nbPers !== "" && nbPers !== "n"){
626        $("#moteur_selectDenbp_min").val(parseInt(nbPers));
627        if($("#moteurPrincipalCapacite .ui-selectmenu-button").length>0){
628            $("#moteur_selectDenbp_min").selectmenu( "refresh" );
629        }
630    }else{
631        $("#moteur_selectDenbp_min").val('n');
632        if($("#moteurPrincipalCapacite .ui-selectmenu-button").length>0){
633            $("#moteur_selectDenbp_min").selectmenu( "refresh" );
634        }
635    }
636    
637    if(url !== 'undefined' && url !== ""){
638        // 336664
639        var urlDecode = decodeURIComponent(url);
640        $('#urlListeHidden').val(urlDecode);
641        if(urlDecode.split('.').pop().length === 0 || (urlDecode.split('.').pop() !== 'html' && urlDecode.split('.').pop() !== 'php')){
642            urlDecode += '.html';
643        }
644        if(urlDecode.substring(0, 1) !== '/'){
645            urlDecode = '/'+urlDecode;
646        }
647        $('#moteur_inptRechercheMutli').parents('form').attr('action',urlDecode);
648    }else{
649        $('#urlListeHidden').val('liste');
650        $('#moteur_inptRechercheMutli').parents('form').attr('action','/liste.html');
651    }
652    
653    if(window.setMajMoteurResponsive){ // fonction définie dans re
653cette fédé
654        setMajMoteurResponsive();
655    }
656    
657    $('#moteur_divMultiAutoComplete').hide();
658}
659
660function onClickLiMoteurAutoCompleteMulti(element, avecLien){
661    fillInputMoteurRechercheMulti(element);
662
663    if(window.initClickPropositionLieu){ // fonction définie dans recette fédé
664        initClickPropositionLieu();
665    }
666
667    if (avecLien) {
668        var cgi, value;
669        if(typeof $(element).attr('ref')!== 'undefined'){
670            cgi = 'lnoident';
671            value = $(element).attr("ident"); 
672        }else{
673            var cgi = $(element).attr("cgi");
674            if(typeof cgi !== 'undefined'){
675                value = $(element).attr("val_cgi");
676            }else{
677                cgi = 'lnoident';
678                value = $(element).attr("ident");
679            }
680        }
681        
682        var urlListe = document.location.href;
683        if($(element).data("url") && $(element).data("url").length>0){
684            urlListe = $(element).data("url");
685        }            
686        var url = getUrlWithLstParam(urlListe, cgi, value);
687        // on cherche la distcomm mise dans le formulaire 
688        var inputDistcomm = $('.moteur_inptRechercheMutli').siblings('input[name="distcomm"]');
689        if(inputDistcomm !== undefined && inputDistcomm.length > 0){
690            url = getUrlWithLstParam(url, 'distcomm',inputDistcomm.val());
691        }
692        // on enlève les paramètres de la carte pour afficher la carte au bon endroit
693        url = removeParamGoogleMaps(url);
694
695        document.location.href = url;
696        moteur_affMessageLoadingMoteur();
697    }
698}
699
700function fillInputMoteurRechercheMulti(element){
701    $('#moteur_inptLong').attr('name', '');
702    $('#moteur_inptLat').attr('name', '');
703    $('#moteur_inptRayon').attr('name', '');
704    if(typeof $(element).attr('ref')!== 'undefined'){     
705        $('#moteur_inptRechercheMutli').val($(element).attr('ref'));
706        var ident = $(element).attr("ident"); 
707        $("#moteur_inptRechercheMutliHidden").attr("name","lnoident");
708        $("#moteur_inptRechercheMutliHidden").attr("value",ident);
709    }else{
710        $('#moteur_inptRechercheMutli').val($(element).attr('valreel'));
711        changeAttrNameBasedOnInputType();
712        var cgi = $(element).attr("cgi");
713        if (cgi === 'VILLE_ETRANGER'){
714            $('#moteur_inptLong').attr('name', 'longitude');
715            $('#moteur_inptLong').val($(element).data('longitude'));
716            $('#moteur_inptLat').attr('name', 'latitude');
717            $('#moteur_inptLat').val($(element).data('latitude'));
718            $('#moteur_inptRayon').attr('name', 'rayon');
719            $('#moteur_inptRayon').val('20');
720        } else if(typeof cgi !== 'undefined'){
721            var val_cgi = $(element).attr("val_cgi");
722            $("#moteur_inptRechercheMutliHidden").attr("name",cgi);
723            $("#moteur_inptRechercheMutliHidden").attr("value",val_cgi);
724        }else{
725            var ident = $(element).attr("ident");
726            $("#moteur_inptRechercheMutliHidden").attr("name","lnoident");
727            $("#moteur_inptRechercheMutliHidden").attr("value",ident);
728        }
729
730    }
731
732    if($(element).attr('data-url').length>0){
733        var url = $(element).attr('data-url');
734        if(url.split('.').pop().length === 0 || (url.split('.').pop() !== 'html' && url.split('.').pop() !== 'php')){
735            url += '.html';
736        }
737        if(url.substring(0, 1) !== '/'){
738            url = '/'+url;
739        }
740        $('#moteur_inptRechercheMutli').parents('form').attr('action',url);
741        $('#urlListeHidden').val($(element).attr('data-url'));
742    }
743    $('#moteur_divMultiAutoComplete').hide();
744}

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.