PageSourceSearch

https://www.icex.es/etc.clientlibs/icex-elena/components/content/s…ibs.min.4ba2afc1259c0e921adea1c6a7b162d7.js

js icex.es collected 2026-10-01 08:36:35 UTC 8,343 bytes, 178 lines download raw bytes

1document.addEventListener('DOMContentLoaded', () => {
2    Searcher.init()
3})
4
5const Searcher = {
6    // search_terms: ["Afganistán","Albania","Alemania","Andorra","Angola","Anguila","Antártida","Antarctica","Antigua y Barbuda","Arabia Saudita","Argelia","Algeria","Argentina","Armenia","Aruba","Australia","Austria","Azerbaiyán","Bélgica","Bahamas","Bahrein","Bangladesh","Barbados","Belice","Benín","Bhután","Bielorrusia","Birmania","Bolivia","Bosnia y Herzegovina","Botsuana","Brasil","Brunéi","Bulgaria","Burkina Faso","Burundi","Cabo Verde","Camboya","Camerún","Canadá","Chad","Chile","China","Chipre","Ciudad del Vaticano","Colombia","Comoras","República del Congo","República Democrática del Congo","Corea del Norte","Corea del Sur","Costa de Marfil","Costa Rica","Croacia","Cuba","Curazao","Dinamarca","Dominica","Ecuador","Egipto","El Salvador","Emiratos Árabes Unidos","Eritrea","Eslovaquia","Eslovenia","España","Estados Unidos de América","Estonia","Etiopía","Filipinas","Finlandia","Fiyi","Francia","Gabón","Gambia","Georgia","Ghana","Gibraltar","Granada","Grecia","Groenlandia","Guadalupe","Guam","Guatemala","Guayana Francesa","Guernsey","Guinea","Guinea Ecuatorial","Guinea-Bissau","Guyana","Haití","Honduras","Hong kong","Hungría","India","Indonesia","Irán","Irak","Irlanda","Isla Bouvet","Isla de Man","Isla de Navidad","Isla Norfolk","Islandia","Islas Bermudas","Islas Caimán","Islas Cocos (Keeling)","Islas Cook","Islas de Åland","Islas Feroe","Israel","Italia","Jamaica","Japón","Jersey","Jordania","Kazajistán","Kenia","Kirguistán","Kiribati","Kuwait","Líbano","Laos","Lesoto","Letonia","Liberia","Libia","Libya","Liechtenstein","Lituania","Luxemburgo","México","Mónaco","Macao","Macedônia","Madagascar","Malasia","Malawi","Mali","Malta","Marruecos","Martinica","Mauricio","Mauritania","Mayotte","Micronesia","Moldavia","Mongolia","Montenegro","Montserrat","Mozambique","Namibia","Nauru","Nepal","Nicaragua","Nigeria","Noruega","Polonia","Portugal","Puerto Rico","Ruanda","Rumanía","Rusia","Sahara Occidental","Senegal","Serbia","Seychelles","Sierra Leona","Singapur","Sint Maarten","Siria","Somalia","Sri lanka","Sudáfrica","Sudán","Suecia","Suiza","Surinám","Swazilandia","Tayikistán","Tailandia","Taiwán","Tanzania","Timor Oriental","Togo","Tokelau","Tonga","Trinidad y Tobago","Tunez","Turkmenistán","Turquía","Tuvalu","Ucrania","Uganda","Uruguay","Uzbekistán","Vanuatu","Venezuela","Vietnam","Wallis y Futuna","Yemen","Yibuti","Zambia","Zimbabue"],
7    search: document.getElementsByClassName("js-search-header"),
8    icons: document.getElementsByClassName('js-icon-select'),
9    dropdowns: document.getElementsByClassName('js-dropdown-filter'),
10    dropdowns_inputs: document.getElementsByClassName('js-dropdown-input'),
11
12    max: 6,
13    resultados: null,
14    activeInput: null,
15
16    init () {
17        // Searcher.setToggleButtons()  // ! MinBreeze
18
19        Searcher.setSize()
20        // window.addEventListener( 'resize',  Searcher.setSize)
21	},
22
23    setToggleButtons () {
24
25        for (const search of Searcher.search) {
26            let inputSearch = search.querySelector(".js-inputSearch")
27            let suggestions = search.querySelector(".js-suggestions-search")
28            let link =  search.dataset.link
29
30            const urlParams = new URLSearchParams(window.location.search);
31            inputSearch.value = urlParams.get('busqueda')
32
33            window.addEventListener( 'scroll', () => {
34                suggestions.classList.remove('dropdown--show')
35            })
36
37            inputSearch.addEventListener( 'focus', () => { 
38                Searcher.activeDropdown =  inputSearch.parentNode.querySelector('.js-dropdown-input')
39                Searcher.closeUnSelectedDropdowns()
40                suggestions.classList.add('dropdown--show')
41            })
42
43            inputSearch.addEventListener( 'input', () => { 
44                suggestions.classList.add('dropdown--show')
45                
46                filter(inputSearch)
47                showSuggestions(inputSearch,suggestions,Searcher.resultado)
48                setOption(inputSearch,link)
49                Searcher.hideCards(inputSearch)
50            })  
51            
52        }
53
54        function filter(input) {
55            if (input.value != "") {
56                let resultado = Searcher.search_terms.filter((keyword) => JSON.stringify(keyword) 
57                    .toLowerCase()
58                    .includes(input.value.toLowerCase())
59                )
60                Searcher.resultado = resultado
61            }
62            else {
63                Searcher.resultado = ""
64            }
65        }
66
67        function showSuggestions(input,suggestions,resultados) {
68
69            const suggestions_filters =  suggestions.querySelector(".js-dropdown-filter")
70            let count = 0
71            suggestions_filters.innerHTML = ""
72            
73            for (const resultado of resultados) {
74                var filter_letters = new RegExp(input.value, 'gi')
75
76                if (count == Searcher.max) {
77                    return
78                }
79
80                /*Creamos nuevo tag*/
81                let newTag = document.createElement("div");
82                let image = document.createElement("span");
83                let value = document.createElement("p");
84
85                newTag.className = "option js-option"
86                if (count < Math.round(Searcher.max/2)) {
87                    newTag.className = "option visited js-option"
88                }
89                newTag.dataset.key  = resultado
90
91                image.className = "icon-option"
92                if (count < Math.round(Searcher.max/2)) {
93                    image.className = "icon--alarm"
94                }
95                else {
96                    image.className = "icon--magnifier"
97                }
98                newTag.appendChild(image)
99
100                value.className = "js-option-value"
101                value.innerHTML = resultado.replace(filter_letters, function(str) {return '<b lass="match">'+str+'</b>'})
102                newTag.appendChild(value)
103
104                /*Metemos el tag en la seción de tags*/
105                suggestions_filters.appendChild(newTag)
106
107                count++
108            }
109        }
110
111        function setOption(input,link) {
112            options =  input.parentNode.parentNode.querySelector('.js-dropdown-filter').children
113
114            for( const option of options ) {
115                option.addEventListener( 'click', () => {
116                    Searcher.closeAllDropdowns()
117                    window.open(link+"?busqueda="+option.querySelector(".js-option-value").textContent,"_self"); 
118                })
119            }
120        }
121
122    },
123
124    setSize() {
125        for (const search of Searcher.search) {
126            if (search.offsetWidth != 0) {
127                let suggestions = search.querySelector(".js-suggestions-search")
128                if (!suggestions) return
129                suggestions.style.width = search.offsetWidth + "px"
130            }
131        }
132    },
133
134    hideCards(inputSearch) {
135        let container_cards = document.querySelector("#title-text-cards")
136
137        if (container_cards == undefined) {
138            return
139        }
140
141        if (inputSearch.value != "") {
142            container_cards.classList.add("title-text-cards-filters--hide")
143        }
144        else {
145            container_cards.classList.remove("title-text-cards-filters--hide")
146        }
147    },
148
149    closeUnSelectedDropdowns () {   
150
151        for( const dropdown of Searcher.dropdowns ) {
152            if( dropdown !== Searcher.activeDropdown ) dropdown.classList.remove('dropdown--show')
153        }
154
155        for( const dropdown of Searcher.dropdowns_inputs ) {
156            if( dropdown !== Searcher.activeDropdown ) dropdown.classList.remove('dropdown--show')
157        }
158
159        for( const icon of Searcher.icons ) {
160            icon.classList.remove('icon-select--flip')
161        }
162    },
163
164    closeAllDropdowns () {
165
166        for( const dropdown of Searcher.dropdowns ) {
167            dropdown.classList.remove('dropdown--show')
168        }
169
170        for( const dropdown of Searcher.dropdowns_inputs ) {
171            dropdown.classList.remove('dropdown--show')
172        }
173
174        for( const icon of Searcher.icons ) {
175            icon.classList.remove('icon-select--flip')
176        }
177    },
178}   

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.