PageSourceSearch

https://www.electionsquebec.qc.ca/wp-content/themes/electionsqc/assets/js/algolia.js?ver=251104145935

js electionsquebec.qc.ca collected 2026-10-02 04:10:09 UTC 27,168 bytes, 817 lines download raw bytes

1var indexAlgolia = electionsQC.indexAlgolia;
2
3if (lang == "en-CA") {
4  
5  indexAlgolia += "_EN";
6
7  i18n.translator.add({
8      "values":{
9          "Aucun résultat pour cette recherche : ": "There are no results for this query: ",
10          "Provincial" : "Provincial",
11          "Municipal" : "Municipal",
12          "Scolaire" : "School board",
13          "Effacer la recherche" : "Clear search",
14          "Circonscription" : "Electoral division",
15          "Rechercher" : "Search",
16          "Tout afficher (" : "Show all (",
17          "Communiqué" : "Press release",
18          "Actualité" : "News",
19          "Offre d'emploi" : "Job offer",
20          "Événement" : "Event",
21          "Allocution" : "Speech",
22          "Circonscription" : "Electoral division",
23          "Pages" : "Pages",
24          "Communiqués de presse": "Press releases",
25          "Actualités": "News",
26          "Sans onglet": "Without tab",
27          " au ": " to ",
28          "Voir les ": "See all ",
29          " résultats":" results",
30          "Afficher plus": "Show more",
31          "Parti politique provincial" : "Provincial political party",
32          "Parti politique municipal" : "Municipal political party",
33          "/partis-et-autres-entites-politiques/partis-politiques/fiche-du-parti/":"/en/parties-and-other-political-entities/political-parties/party-details/",
34          "Coordonnées, rapports financiers, contributions et autres données sur ce parti politique.":"Contact details, financial reports, contributions and other data on this political party.",
35          "/partis-et-autres-entites-politiques/partis-politiques/fiche-du-parti-municipal/":"/en/parties-and-other-political-entities/political-parties/municipal-party-details/",
36          "Résultats et statistiques":"Results and statistics",
37          "Résultats, statistiques et taux de participation des élections récentes.":"Results, statistics and voter turnout of recent elections.",
38          "Canton": "Township",
39          "Cantons unis": "United townships",
40          "Établissement amérindien": "Indian settlement",
41          "Gouvernement régional": "Regional government",
42          "Municipalité": "Municipality",
43          "Territoire non organisé": "Non-organized territory",
44          "Paroisse": "Parish",
45          "Réserve indienne": "Indian reserve",
46          "Terres réservées aux Cris": "Cree reserve lands",
47          "Terres de la catégorie I pour les Inuits": "Inuit reserve lands",
48          "Terres réservées aux Naskapis": "Naskapi reserve lands",
49          "Ville": "City",
50          "Village cri": "Cree village",
51          "Village naskapi": "Naskapi village",
52          "Village": "Village",
53          "Village nordique": "Northern village",
54          "Résultats pour l'élection générale du ": "Résultats pour l'élection générale du ",
55          " avant la fusion":" before the merger",
56          "/resultats-et-statistiques/?mun=MUN_":"/en/results-and-statistics/?mun=MUN_",
57          "/resultats-et-statistiques/?mun=MRC_":"/en/results-and-statistics/?mun=MRC_"
58      }
59  })
60}else{
61
62  indexAlgolia += "_FR";
63
64}
65
66aa('init', {
67  appId: 'YH8D4OL5BY',
68  apiKey: 'e7c5e4809b481125adf0e91f5c47a185',
69  useCookie: false,
70});
71
72const searchClient = algoliasearch("YH8D4OL5BY", "e7c5e4809b481125adf0e91f5c47a185");
73
74//add indexNameToContainer
75$j("#hits").attr('data-insights-index', indexAlgolia);
76
77const search = instantsearch({
78  indexName: indexAlgolia,
79  searchClient,
80  searchFunction(helper) {
81    // Ensure we only trigger a search when there's a query
82    if (helper.state.query) {
83      helper.search();
84    }
85  },
86});
87
88const renderSearchBox = (renderOptions, isFirstRender) => {
89  const { query, refine, clear, isSearchStalled, widgetParams } = renderOptions;
90
91  if (isFirstRender) {
92
93    const container = $j(widgetParams.container);
94
95    const input = $j('<input>')
96      .addClass('form-control rechercheSearchBoxInput')
97      .attr('aria-label', i18n('Rechercher'));
98    
99    let debounceTimeout;
100    
101    input.on('input', event => {
102      const queryValue = event.target.value;
103
104      if(queryValue == ""){
105        $j(".btnFiltreRecherche").addClass("d-none");
106        $j(".nbHits").addClass("d-none");
107      }
108
109      clearTimeout(debounceTimeout);
110
111      debounceTimeout = setTimeout(() => {
112        search.helper.clearRefinements();
113        refine(queryValue);
114        // if (queryValue !== '') {
115        //   $j('.rechercheSearchBoxReset').removeClass('d-none');
116        // } else {
117        //   $j('.rechercheSearchBoxReset').addClass('d-none');
118        // }
119        if ($j(".filtreRechercheOverlay").is(":visible")) {
120          $j(".filtreRechercheOverlay").hide();
121          $j(".ongletsFiltre").addClass("d-none");
122          $j(".domainesFiltre").addClass("d-none");
123        }
124      }, 200);
125
126    });
127    
128    // const reset = $j('<a>')
129    //   .addClass('rechercheSearchBoxReset d-none')
130    //   .attr('title', i18n('Effacer la recherche'))
131    //   .attr('href', '#')
132    //   .text('')
133    //   .on('click', event => {
134    //     event.preventDefault();
135    //     clear();
136    //     search.helper.clearRefinements();
137    //     search.helper.setQuery('');
138    //     search.helper.search();
139    //     input.val('');
140    //     reset.addClass('d-none');
141    //     input.focus();
142    //     $j('#hits').html('');
143    //     $j(".facets").hide();
144    //     $j(".filtreRechercheOverlay").hide();
145    //   });
146
147    container.append(input);
148    // container.append(reset);
149
150  }
151
152};
153
154// create custom widget
155const customSearchBox = instantsearch.connectors.connectSearchBox(
156  renderSearchBox
157);
158
159function updateResultButtonCount(count) {
160  const resultButton = $j("#btnVoirResults");
161  const displayCount = count > 99 ? '99+' : count;
162  const text =  i18n('Voir les ') + displayCount + i18n(' résultats');
163  resultButton.text(text);
164}
165
166// Refinement list pour les onglets
167const customOngletRefinementList = instantsearch.connectors.connectRefinementList(
168  
169  ({ items, refine }) => {
170
171    const refinementList = $j('#ongletFacets');
172    refinementList.empty();
173
174    const allOngletValues = [
175      { value: 'provincial', label: i18n('Provincial') },
176      { value: 'municipal', label: i18n('Municipal') },
177      { value: 'scolaire', label: i18n('Scolaire') },
178      { value: 'notabs', label: i18n('Sans onglet') }
179    ];
180
181    const itemCounts = items.reduce((acc, item) => {
182      acc[item.value] = item.count;
183      return acc;
184    }, {});
185
186    allOngletValues.forEach((onglet) => {
187      const count = itemCounts[onglet.value] || 0;
188      const isRefined = items.some(item => item.value === onglet.value && item.isRefined);
189
190      const label = $j('<label>', { class: 'facet-item' });
191
192      const checkbox = $j('<input>', {
193        type: 'checkbox',
194        name: 'onglet',
195        class: 'checkBoxInput',
196        value: onglet.value,
197        checked: isRefined,
198        disabled: count === 0,
199      }).on('change', () => {
200        if (count > 0) {
201          refine(onglet.value);
202          const newTotal = search.helper.lastResults.nbHits;
203          updateResultButtonCount(newTotal);
204        }
205      });
206
207      const labelText = $j('<span>').text(`${i18n(onglet.label)}`);
208
209      if (count === 0) {
210        label.addClass('disabled');
211      }
212
213      label.append(checkbox, labelText);
214      refinementList.append(label);
215
216    });
217
218  }
219
220);
221
222// Instantation des refinements d'onglets
223const customOngletRefinementListWidget = customOngletRefinementList({
224  attribute: 'onglet',
225  operator: 'or',
226});
227
228//Liste de rafinement pour le type de post.
229const customTypeRefinementList = instantsearch.connectors.connectRefinementList(
230  
231  ({ items, refine }) => {
232    const transformedItems = [
233      { label: i18n('Pages'), value: 'page', count: 0 },
234      { label: i18n('Communiqués de presse'), value: 'elecqc_communiques', count: 0 },
235      { label: i18n('Actualités'), value: 'elecqc_actualites', count: 0 },
236    ];
237
238    items.forEach((item) => {
239      const transformedItem = transformedItems.find((ti) => ti.value === item.value);
240
241      if (transformedItem) {
242        transformedItem.count = item.count;
243        transformedItem.isRefined = item.isRefined;
244      }
245    });
246
247    const refinementList = $j('#typeFacets');
248    refinementList.empty();
249
250    transformedItems.sort((a, b) => a.value.localeCompare(b.value, 'fr'));
251
252    transformedItems.forEach((item) => {
253      const label = $j('<label>', { class: 'facet-item' });
254
255      const radio = $j('<input>', {
256        type: 'radio',
257        class: 'radioInput',
258        name: 'type',
259        value: item.value,
260        checked: item.isRefined,
261      }).on('change', () => {
262
263        $j(".clearRefinementsBtn").prop("checked", false);
264        
265        search.helper.clearRefinements();
266
267        transformedItems.forEach((ti) => {
268          ti.isRefined = false;
269        });
270
271        refine(item.value);
272
273        item.isRefined = true;
274
275        checkTypeRefinementList();
276
277      });
278
279      const labelText = $j('<span>').text(`${i18n(item.label)}`);
280
281      label.append(radio, labelText);
282      refinementList.append(label);
283    });
284
285  }
286);
287
288// Instantation des refinements de type
289const customTypeRefinementListWidget = customTypeRefinementList({
290  attribute: 'type',
291});
292
293const customCategoriesMenu = instantsearch.connectors.connectHierarchicalMenu(
294  ({ items, refine, createURL, instantSearchInstance }) => {
295    
296    const refinementList = $j('#categoriesFacets');
297    refinementList.empty();
298
299    let allCategories;
300
301    if (lang == "en-CA") {
302      allCategories = [
303        { value: 'Institutional', label: i18n('Institutional') },
304        { value: 'Municipal', label: i18n('Municipal') },
305        { value: 'Provincial', label: i18n('Provincial') },
306        { value: 'School board', label: i18n('School board') }
307      ];
308    }else{
309      allCategories = [
310        { value: 'Institutionnel', label: i18n('Institutionnel') },
311        { value: 'Municipal', label: i18n('Municipal') },
312        { value: 'Provincial', label: i18n('Provincial') },
313        { value: 'Scolaire', label: i18n('Scolaire') }
314      ];
315    }
316
317    const itemCounts = items.reduce((acc, item) => {
318      acc[item.value] = item.count;
319      return acc;
320    }, {});
321
322    allCategories.forEach((category) => {
323      const count = itemCounts[category.value] || 0;
324      const isRefined = items.some(item => item.value === category.value && item.isRefined);
325
326      const label = $j('<label>', { class: 'facet-item' });
327
328      const checkbox = $j('<input>', {
329        type: 'radio',
330        class: 'radioInput',
331        name: 'categories',
332        value: category.value,
333        checked: isRefined,
334        disabled: count === 0,
335      }).on('change', () => {
336        if (count > 0) {
337          refine(category.value);
338        }
339      });
340      
341      const labelText = $j('<span>').text(`${category.label}`);
342      if (count === 0) {
343        label.addClass('disabled');
344      }
345 
346      label.append(checkbox, labelText);
347      refinementList.append(label);
348    });
349  }
350);
351 
352// Instantiate the hierarchical menu widget
353const customCategoriesMenuWidget = customCategoriesMenu({
354  container: document.querySelector('#categoriesFacets'),
355  attributes: ['categories'],
356  limit: 100,
357});
358 
359
360search.addWidgets([
361  customOngletRefinementListWidget,
362  customTypeRefinementListWidget,
363  customCategoriesMenuWidget,
364]);
365
366 
367search.addWidgets([
368 
369  instantsearch.widgets.configure({
370    clickAnalytics: true,
371    hitsPerPage: 10,
372    maxValuesPerFacet: 1000,
373    facetingAfterDistinct: true,
374  }),
375 
376  customSearchBox({
377    container: document.querySelector('#searchbox'),
378  }),
379 
380  instantsearch.widgets.infiniteHits({
381    container: "#hits",
382    escapeHTML: false,
383    templates: {
384      item: function(hit){
385
386        //Gestion de l'affichage des résultats des provinciales part et gen.
387        if (hit.type === "histo_election") {
388          var urlRes;
389
390          if(hit.typeElection === "G"){
391            urlRes = i18n("/resultats-et-statistiques/resultats-generales/");
392            urlRes += hit.date + "/";
393          }else{
394            urlRes = i18n("/resultats-et-statistiques/resultats-partielles/");
395            urlRes += hit.date + "/" + hit.bsq + "/";
396          }
397          
398          var texteDesc = i18n("Résultats, statistiques et taux de participation des élections récentes.");
399          return `
400          <article>
401            <p class="typeHit">${hit.typeHit}</p>
402            <a class="algoliaClickLink" href="${urlRes}" data-insights-object-id="${hit.objectID}" data-insights-position="${hit.__position}" data-insights-query-id="${hit.__queryID}">
403              <strong>${instantsearch.highlight({ attribute: 'title', hit })}</strong>
404            </a>
405            <p class="descHit">${texteDesc}</p>
406          </article>
407          `;
408        }
409
410        //Gestion de l'affichage des parti politique
411        if (hit.type === "parti_politique_prov" || hit.type === "parti_politique_mun") {
412          var urlPP;
413          if(hit.type === "parti_politique_prov"){
414            urlPP = i18n("/partis-et-autres-entites-politiques/partis-politiques/fiche-du-parti/");
415            urlPP = urlPP + hit.ppID + "/" + hit.oldID + "/";
416          }else{
417            urlPP = i18n("/partis-et-autres-entites-politiques/partis-
417politiques/fiche-du-parti-municipal/");
418            urlPP = urlPP + hit.ppID + "/";
419          }
420          var texteDesc = i18n("Coordonnées, rapports financiers, contributions et autres données sur ce parti politique.");
421          return `
422          <article>
423            <p class="typeHit">${hit.typeHit}</p>
424            <a class="algoliaClickLink" href="${urlPP}" data-insights-object-id="${hit.objectID}" data-insights-position="${hit.__position}" data-insights-query-id="${hit.__queryID}">
425              <strong>${instantsearch.highlight({ attribute: 'title', hit })}</strong>
426            </a>
427            <p class="descHit">${texteDesc}</p>
428          </article>
429          `;
430        }
431
432        //Gestion de l'affichage des résultats des muni.
433        if (hit.type === "resultats_mun") {
434          var urlPP;
435          var designationMun;
436          if(hit.munmrc === "MRC"){
437            urlPP = i18n("/resultats-et-statistiques/?mun=MRC_");
438          }else{
439            urlPP = i18n("/resultats-et-statistiques/?mun=MUN_");
440          }
441            urlPP = urlPP + hit.codegeo + "#municipal";
442          var texteDesc = i18n("Résultats, statistiques et taux de participation des élections récentes.");
443
444          switch(hit.designation){
445            case "CT":
446              designationMun = i18n("Canton");  
447              break;
448            case "CU":
449              designationMun = i18n("Cantons unis");
450              break;
451            case "CT":
452            case "EI":
453              designationMun = i18n("Établissement amérindien");
454              break;
455            case "GR":
456              designationMun = i18n("Gouvernement régional");
457              break;
458            case "M":
459              designationMun = i18n("Municipalité");
460              break;
461            case "NO":
462              designationMun = i18n("Territoire non organisé");
463              break;
464            case "P":
465              designationMun = i18n("Paroisse");
466              break;
467            case "R":
468              designationMun = i18n("Réserve indienne");
469              break;
470            case "TC":
471              designationMun = i18n("Terres réservées aux Cris");
472              break;
473            case "TI":
474              designationMun = i18n("Terres de la catégorie I pour les Inuits");
475              break;
476            case "TK":
477              designationMun = i18n("Terres réservées aux Naskapis"); 
478              break;
479            case "V":
480              designationMun = i18n("Ville");
481              break;
482            case "VC":
483              designationMun = i18n("Village cri");
484              break;
485            case "VK":
486              designationMun = i18n("Village naskapi");
487              break;
488            case "VL":
489              designationMun = i18n("Village");
490              break;
491            case "VN":
492              designationMun = i18n("Village nordique");
493              break;
494            default:
495              designationMun = hit.designation;
496         }
497
498         if(hit.statutMunicipalite == "I"){
499          designationMun += i18n(" avant la fusion");
500         }
501
502          return `
503          <article>
504            <p class="typeHit">${designationMun}</p>
505            <a class="algoliaClickLink" href="${urlPP}" data-insights-object-id="${hit.objectID}" data-insights-position="${hit.__position}" data-insights-query-id="${hit.__queryID}">
506              <strong>${instantsearch.highlight({ attribute: 'title', hit })}</strong>
507            </a>
508            <p class="descHit">${texteDesc}</p>
509          </article>
510          `;
511        }
512
513        var datePublicationItem = '';
514        if (hit.datePublication && (hit.type === 'elecqc_actualites' || hit.type === 'elecqc_communiques')) {
515          var publicationDate = new Date(hit.datePublication);
516          var options = { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' };
517          datePublicationItem = " (" + publicationDate.toLocaleDateString(lang, options) + ")";
518        }
519
520        var dateEventItem = '';
521      if (hit.type === 'elecqc_evenements') {
522        var dateDebut = hit.dateDebut ? new Date(hit.dateDebut) : null;
523        var dateFin = hit.dateFin ? new Date(hit.dateFin) : null;
524        var dateOptions = { day: 'numeric', month: 'long', timeZone: 'UTC' };
525        var yearOptions = { year: 'numeric', timeZone: 'UTC' };
526
527        if (dateDebut && dateFin) {
528          if (dateDebut.toLocaleDateString() === dateFin.toLocaleDateString()) {
529            dateEventItem = " (" + dateDebut.toLocaleDateString(lang, { ...dateOptions, year: 'numeric' }) + ")";
530          } else if (dateDebut.getFullYear() === dateFin.getFullYear()) {
531            dateEventItem = " (" + dateDebut.toLocaleDateString(lang, dateOptions) + i18n(" au ") + dateFin.toLocaleDateString(lang, dateOptions) + " " + dateDebut.toLocaleDateString(lang, yearOptions) + ")";
532          } else {
533            dateEventItem = " (" + dateDebut.toLocaleDateString(lang, { ...dateOptions, year: 'numeric' }) + i18n(" au ") + dateFin.toLocaleDateString(lang, { ...dateOptions, year: 'numeric' }) + ")";
534          }
535        } else if (dateDebut) {
536          dateEventItem = " (" + dateDebut.toLocaleDateString(lang, { ...dateOptions, year: 'numeric' }) + ")";
537        } else if (dateFin) {
538          dateEventItem = " (" + dateFin.toLocaleDateString(lang, { ...dateOptions, year: 'numeric' }) + ")";
539        }
540      }
541
542        var highlightedTitle = instantsearch.highlight({ attribute: 'title', hit }),
543          highlightedResume = instantsearch.highlight({ attribute: 'resume', hit }),
544          onglet = hit.onglet ? hit.onglet : '';
545
546        return `
547        <article>
548          <p class="typeHit">${hit.typeHit}${datePublicationItem}${dateEventItem}</p>
549          <a class="algoliaClickLink" href="${hit.url}"
550          data-insights-object-id="${hit.objectID}"
551          data-insights-position="${hit.__position}"
552          data-insights-query-id="${hit.__queryID}">
553          <strong>${highlightedTitle}</strong>
554          </a><span class="badge bg-secondary">${onglet}</span>
555          <p class="descHit">${highlightedResume}</p>
556        </article>
557        `;
558      },
559      empty: "<p>" + i18n("Aucun résultat pour cette recherche&nbsp;: ") + "<q>{{ query }}</q></p>",
560      showMoreText: i18n("Afficher plus"),
561    },
562    cssClasses: {
563      root: "resultsRecherche",
564      list: "resultsRechercheList",
565      item: "resultsRechercheHits",
566      emptyRoot: "noResultsRecherche",
567      loadMore: "btn btnElectionqc plusDeResutlatBTN",
568    },
569    transformItems: function(items){
570
571      return items.map((item) => ({
572        ...item,
573        onglet: (function(){
574          var ongletToReturn = "";
575          switch(item.onglet){
576            case "provincial":
577              ongletToReturn = i18n("Provincial");
578              break;
579            case "municipal":
580              ongletToReturn = i18n("Municipal");
581              break;
582            case "scolaire":
583              ongletToReturn = i18n("Scolaire");
584              break;
585            default:
586              ongletToReturn = "";
587          }
588          return ongletToReturn;
589        })(),
590        typeHit: (function(){
591          var typeToReturn = "";
592          switch(item.type){
593            case "elecqc_communiques":
594              typeToReturn = i18n("Communiqué");
595              break;
596            case "page":
597              typeToReturn = "";
598              break;
599            case "elecqc_actualites":
600              typeToReturn = i18n("Actualité");
601              break;
602            case "elecqc_emplois":
603              typeToReturn = i18n("Offre d'emploi");
604              break;
605            case "elecqc_evenements":
606              typeToReturn = i18n("Événement");
607              break;
608            case "elecqc_allocutions":
609              typeToReturn = i18n("Allocution");
610              break;
611            case "circ":
612              typeToReturn = i18n("Circonscription");
613              break;
614            case "parti_politique_prov":
615              typeToReturn = i18n("Parti politique provincial");
616              break;
617            case "parti_politique_mun":
618              typeToReturn = i18n("Parti politique municipal");
619              break;
620            case "histo_election":
621            case "resultats_mun":
622              typeToReturn = i18n("Résultats et statistiques");
623              break;
624            default:
625              typeToReturn = "";
626          }
627          return typeToReturn;
628        })()
629      }));
630    }
631  }),
632]);
633
634search.on('render', () => {
635
636  const totalResults = search.helper.lastResults ? search.helper.lastResults.nbHits : 0;
637  updateResultButtonCount(totalResults);
638
639  $j('.nbHits').text(totalResults + i18n(" résultats"));
640
641  $j(".resultsRecherche .resultsRechercheHits a").each(function(i){
642
643    if($j(this)[0].pathname === window.location.pathname){
644      $j(this).click(function(e){
645        $j(".btnFermerRechercheOverlay").click();
646        if($j(this)[0].hash != ""){
647          let newOnglet = $j(this)[0].hash.substring(1);
648          newOnglet = document.querySelector(".nav-link[data-activetab='"+newOnglet+"']");
649          let activeTab = new bootstrap.Tab(newOnglet);
650          activeTab.show();
651          scrollTo("#nav-tab");
652        }
653      });
654    }
655
656  });
657
658  setOnClickInsight();
659
660  setTimeout(() => {
661    if(search.helper.lastResults.nbHits && search.helper.lastResults.nbHits > 0){
662      $j(".btnFiltreRecherche").removeClass("d-none");
663      $j(".nbHits").removeClass("d-none");
664    }else{
665      $j(".btnFiltreRecherche").addClass("d-none");
666      $j(".nbHits").addClass("d-none");
667    }
668  }, 100);
669  
670});
671
672function setOnClickInsight(){
673  $j(".algoliaClickLink").click(function(e){
674    
675    var insightsObjectId = [$j(this).data('insights-object-id')];
676    var insightsPosition = [$j(this).data('insights-position')];
677    var insightsQueryId = $j(this).data('insights-query-id');
678
679    aa('clickedObjectIDsAfterSearch', {
680        index: indexAlgolia,
681        eventName: "Lien recherche clicked",
682        queryID: insightsQueryId,
683        objectIDs: insightsObjectId,
684        positions: insightsPosition
685    });
686
687  });
688}
689
690function checkTypeRefinementList(){
691  const selectedTypeRefinement = $j(".typeFacets .facet-item input:checked").val();
692
693  if (selectedTypeRefinement === "page") {
694
695    $j(".ongletsFiltre").removeClass("d-none");
696    $j(".domainesFiltre").addClass("d-none");
697
698  }else if (selectedTypeRefinement === "elecqc_communiques" || selectedTypeRefinement === "elecqc_actualites") {
699
700    $j(".domainesFiltre").removeClass("d-none");
701    $j(".ongletsFiltre").addClass("d-none");
702
703  } else {
704
705    $j(".ongletsFiltre").addClass("d-none");
706    $j(".domainesFiltre").addClass("d-none");
707
708  }
709}
710
711search.start();
712
713$j(document).ready(function() {
714  ouvertureRecherche();
715  fermetureRecherche();
716  gestionBtnFiltre();
717  $j('#searchbox input').on('input', function(event) {
718    $j("#clearRefinementsBtn").remove();
719    if ($j(this).val() === '') {
720      $j('#hits').html('');
721    }
722  });
723});
724
725function ouvertureRecherche(){
726
727  $j(".rechercheInput").click(function(e) {
728    $j(".fullPageMenu").slideUp(function(){
729      $j(this).css("visibility", "hidden");
730    }); 
731    $j(".fullPageRecherche").css("visibility", "visible").hide().slideDown(function(){
732      $j(".rechercheSearchBoxInput").focus();
733      trapTabInsideRecherche();
734    });
735    $j(".fullPageOverlay").removeClass("d-none");
736    $j("body").addClass("noScrollOverlay");
737  });
738
739  $j(".btnMenuRecherche, .btnRechercheMenuOverlay").click(function(e){
740    e.preventDefault();
741    $j(".fullPageMenu").slideUp(function(){
742      $j(this).css("visibility", "hidden");
743    }); 
744    $j(".fullPageRecherche").css("visibility", "visible").hide().slideDown(function(){
745      $j(".rechercheSearchBoxInput").focus();
746      trapTabInsideRecherche();
747    });
748    $j(".fullPageOverlay").removeClass("d-none");
749    $j("body").addClass("noScrollOverlay");
750  });
751
752}
753
754function fermetureRecherche(){
755  $j(".btnFermerRechercheOverlay").click(function(e){
756      e.preventDefault();
757      $j(".fullPageRecherche").slideUp(function(){
758          $j(this).css("visibility", "hidden");
759      });
760      $j(".fullPageOverlay").addClass("d-none");
761      $j("body").removeClass("noScrollOverlay");
762  });
763}
764
765function gestionBtnFiltre(){
766
767  $j(".btnFiltreRecherche").click(function(e){
768    e.preventDefault();
769    if($j(".filtreRechercheOverlay").is(":visible")){
770      $j(".filtreRechercheOverlay").hide();
771    }else{
772      $j(".filtreRechercheOverlay").show();
773    }
774  });
775
776  $j(".btnFermerFiltre, .btnFermerFiltreX").click(function(e){
777    e.preventDefault();
778    $j(".filtreRechercheOverlay").hide();
779  });
780
781  $j(".btnEffacerFiltre").click(function(e){
782    e.preventDefault();
783    search.helper.clearRefinements().search();
784    if($j(".filtreRechercheOverlay").is(":visible")){
785      $j(".ongletsFiltre").addClass("d-none");
786      $j(".domainesFiltre").addClass("d-none");
787    }
788  });
789
790}
791
792function trapTabInsideRecherche(){
793  const  focusableElements ='button, [href], input, select, textarea, [tabindex]:not
793([tabindex="-1"])';
794  const modal = document.querySelector('.fullPageRecherche');
795  const firstFocusableElement = modal.querySelectorAll(focusableElements)[0];
796  const focusableContent = modal.querySelectorAll(focusableElements);
797  const lastFocusableElement = focusableContent[focusableContent.length - 1];       
798
799  document.addEventListener('keydown', function(e) {
800      let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
801      if(!isTabPressed){
802          return;
803      }
804      if(e.shiftKey){
805          if (document.activeElement === firstFocusableElement) {
806          lastFocusableElement.focus();
807          e.preventDefault();
808          }
809      }else{ 
810          if (document.activeElement === lastFocusableElement){ 
811              firstFocusableElement.focus();
812              e.preventDefault();
813          }
814      }
815  });
816
817}

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.