PageSourceSearch

https://www.uach.cl/uach/js/porto/custom.js

js uach.cl collected 2026-09-24 07:45:54 UTC 20,751 bytes, 462 lines download raw bytes

1        const loader = document.querySelector("#carga");
2        var path = window.location.hostname;
3
4        var listarUrl = 'https://'+path+'/uach/lib/php/listar.php';
5        var searchUrl = 'https://'+path+'/uach/lib/php/search.php';
6        var areaConUrl = 'https://'+path+'/uach/lib/php/search.php';
7
8        getAreaConocimiento();
9
10        //Filtrando por ciudad
11        //document.getElementById("boton1").addEventListener("click", () => getFilter('VALDIVIA'));
12        //document.getElementById("boton2").addEventListener("click", () => getFilter('SEDE PUERTO MONTT'));
13        //document.getElementById("boton3").addEventListener("click", () => getFilter('COYHAIQUE'));
14
15        async function facultades() {
16            
17            loading.style.display = 'block';
18            myItems.style.display = 'none';
19            let facultades = document.querySelector('#facultades');
20            facultades = facultades.value;
21            console.log(facultades);
22            const url = searchUrl;
23            const data = { dato: facultades, servicio: 'SelectorFacultadSearch' };
24            const opciones = {
25              method: 'POST',
26              headers: { 'Content-Type': 'application/json' },
27              body: JSON.stringify(data)
28            };
29            try {
30                const response = await fetch( url, opciones );
31                if (!response.ok) {
32                  throw new Error('Error en la solicitud');
33                }
34                loading.style.display = 'none';
35                const data = await response.json();
36                myItems.style.display = 'flex';
37                document.getElementById("myItems").innerHTML = data;
38            } catch (error) {
39                console.error('Error:', error);
40            }
41        }
42        async function areasconocimiento() {
43
44            loading.style.display = 'block';
45            myItems.style.display = 'none';
46            const areaSelect = document.querySelector('#area');
47            area = areaSelect.value;
48            console.log(area);
49            const url = areaConUrl;
50            const data = { dato: area, servicio: 'SelectorAreaSearch' };
51
52            const opciones = {
53              method: 'POST',
54              headers: { 'Content-Type': 'application/json' },
55              body: JSON.stringify(data)
56            };
57
58            try {
59                const response = await fetch( url, opciones );
60                if (!response.ok) {
61                  throw new Error('Error en la solicitud');
62                }
63                loading.style.display = 'none';
64                const data = await response.json();
65                myItems.style.display = 'flex';
66                document.getElementById("myItems").innerHTML = data;
67            } catch (error) {
68                console.error('Error:', error);
69            }
70        }
71
72        async function getFilter(citeSearch) {
73            loading.style.display = 'block';
74            myItems.style.display = 'none';
75            const url = '../uach/lib/php/search.php';
76            const data = { dato: citeSearch, servicio: 'ButtonSearch' };
77            console.log(data);
78            const opciones = {
79              method: 'POST',
80              headers: { 'Content-Type': 'application/json' },
81              body: JSON.stringify(data)
82            };
83            try {
84                const response = await fetch( url, opciones );
85                if (!response.ok) {
86                  throw new Error('Error en la solicitud');
87                }
88                loading.style.display = 'none';
89                const data = await response.json();
90                myItems.style.display = 'flex';
91                document.getElementById("myItems").innerHTML = data;
92            } catch (error) {
93                console.error('Error:', error);
94            }
95        }
96        function getCarreras() {
97            fetch("../uach/lib/php/listar.php")
98            .then(response => response.json())
99            .then(datos => {
100                let html = themeSegmento(datos);
101                document.getElementById("myItems").innerHTML = html;
102            });
103        }
104        async function getCarreraRelacion(codigo) {
105
106            const url = searchUrl;
107            const data = { dato: codigo, servicio: 'getCarreraRelacion' };
108            console.log(codigo);
109            const opciones = {
110              method: 'POST',
111              headers: { 'Content-Type': 'application/json' },
112              body: JSON.stringify(data)
113            };
114            try {
115                const response = await fetch( url, opciones );
116                if (!response.ok) {
117                  throw new Error('Error en la solicitud');
118                }
119
120                const data = await response.json();
121
122                document.getElementById("myItems").innerHTML = data;
123            } catch (error) {
124                console.error('Error:', error);
125            }
126        }
127        function getAreaConocimiento() {
128
129            if (window.location.pathname == '/') {
130                fetch(listarUrl)
131                .then(response => response.json())
132                .then(datos => {
133                    let html = themeSegmentoArea(datos);
134                    document.getElementById("myItems").innerHTML = html;
135                });
136
137            }
138        }
139        async function search(getData) {
140
141            getData = getData.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); //es necesario quitar caracteres raros
142            
143            loading.style.display = 'block';
144            myItems.style.display = 'none';
145            const url = searchUrl;
146            //const data = { search: getData };
147            const data = { dato: getData, servicio: 'InputSearch' };
148            if (getData.length < 3) {
149                loading.style.display = 'none';
150                //document.getElementById("myItems").innerHTML = "Escribe al menos 3 caracteres...";
151                return;
152            }
153            const opciones = {
154              method: 'POST',
155              headers: { 'Content-Type': 'application/json' },
156              body: JSON.stringify(data)
157            };
158            try {
159                const response = await fetch( url, opciones );
160                if (!response.ok) {
161                  throw new Error('Error en la solicitud');
162                }
163                loading.style.display = 'none';
164                const data = await response.json();
165                //console.log(data);
166                myItems.style.display = 'flex';
167                document.getElementById("myItems").innerHTML = data;
168            } catch (error) {
169                loading.style.display = 'none';
170                console.error('Error:', error);
171            }
172        }
173        async function searchInputExterno() {
174            loading.style.display = 'block';
175            myItems.style.display = 'none';
176            const url = searchUrl;
177
178            /*Obteniendo datos del input*/
179            const input = document.getElementById("buscarCarreras");
180            const getData = input.value;
181
182            //const data = { search: getData };
183            const data = { dato: getData, servicio: 'InputSearch' };
184            console.log(getData);
185            const opciones = {
186              method: 'POST',
187              headers: { 'Content-Type': 'application/json' },
188              body: JSON.stringify(data)
189            };
190
191            const section = document.getElementById("targetSection"); //Cargando ID Target
192            section.scrollIntoView({ behavior: "smooth" }); //Para desplazar
193
194            try {
195                const response = await fetch( url, opciones );
196                if (!response.ok) {
197                  throw new Error('Error en la solicitud');
198                }
199                loading.style.display = 'none';
200                const data = await response.json();
201                //console.log(data);
202                myItems.style.display = 'flex';
203                document.getElementById("myItems").innerHTML = data;
204            } catch (error) {
205                loading.style.display = 'none';
206                console.error('Error:', error);
207            }
208        }
209        function viewSearchRestult(data){
210            const getCarreras = document.getElementById("getCarreras");
211            getCarreras.innerHTML = "";
212            for(let i=0; i < data.length; i++){
213                const li = document.createElement("li");
214                li.innerHTML = data[i]["CarNombre"];
215                getCarreras.appendChild(li);
216            }
217        }
218
219        function themeSegmento(datos){
220            let html = '';
221            for (let carreras of datos) {
222                let htmlSegment = `
223										<div class="col mb-4 col-md-4 col-lg-4 isotope-item valdivia">
224											<div class="card portfolio-item">
225												
226													<span class="thumb-info thumb-info-lighten">
227														<span class="thumb-info-wrapper">
228                                                        <a href="${carreras.CarUrl}">
229															<img src="https://${path}/uach/themeporto/img/admision/carreras/${carreras.CarImagen}" class="img-fluid rounded-top" alt="">
230															<span class="thumb-info-title">
231																<span class="thumb-info-inner">${carreras.CarCodigo} / ${carreras.CarNombre}</span>
232																<span class="thumb-info-type">${carreras.Ciudad}</span>
233															</span>
234															<span class="thumb-info-action">
235																<span class="thumb-info-action-icon bg-dark opacity-8"><i class="fas fa-plus"></i></span>
236															</span>
237                                                        </a>
238														</span>
239													</span>
240												
241											</div>
242										</div>
243                `;
244                html += htmlSegment;
245            }
246            return html;
247        }
248
249        function themeSegmentoArea(datos){
250            let html = '';
251            for (let carreras of datos) {
252                //console.log(carreras);
253                img = carreras;
254                txt = carreras;
255                if (txt=="tecnologia") {txt='Área Tecnología'}
256                if (txt=="silvoagropecuaria") {txt='Área Silvoagropecuaria'}
257                if (txt=="arteyarquitectura") {txt='Área Artes y Arquitectura'}
258                if (txt=="educacion") {txt='Área Educación'}
259                if (txt=="derecho") {txt='Área Derecho'}
260                if (txt=="cienciassociales") {txt='Área Ciencias Sociales'}
261                if (txt=="humanidades") {txt='Área Humanidades'}
262                if (txt=="salud") {txt='Área Salud'}
263                if (txt=="cienciasnaturalesymatematicas") {txt='Área Ciencias Naturales y Matemáticas'}
264                if (txt=="cienciasbasicas") {txt='Área Ciencias Basicas'}
265                if (txt=="administracionynegocios") {txt='Área Administración y Negocios'}
266                let htmlSegment = 
267                    `<div class="col-sm-9 col-md-6 col-lg-4 pb-3 mb-3 mb-lg-0 bg-transparent">
268                        <div class="card border-0 h-90 bg-color-transparent">
269                            <!--<section class="rounded-top-5 parallax section section-background h-300px bg-size-cover m-0" style="background-image: url(https://${path}/uach/_imag/uach/admision/filtro/areaconocimiento/${img}.jpg);">-->
270                                <!--<div class="position-absolute right-0 top-0 d-flex justify-content-end w-100 py-2 px-3 z-index-3">
271                                    <span class="rounded-2 text-center bg-primary text-color-light line-height-2 px-2 py-1">
272                                        <span class="position-relative z-index-2">Estudiantes</span>
273                                    </span>
274                                </div>-->
275                            <!--</section>-->
276
277                            <div class="card-img-top position-relative rounded-top-5">          
278                                <img class="img-fluid rounded-top-5 w-100 overflow" src="/uach/_imag/uach/admision/filtro/areaconocimiento/${img}.jpg">
279                            </div>
280
281                            <div class="card-body py-4 px-2 border rounded-bottom-5 bg-color-light">
282                                <h4 class="card-title text-6 line-height-3 font-weight-semibold">${txt}</h4>
283                                <!--<p class="mb-2 text-5">${carreras.CarCodigo} / ${carreras.CarNombre}</p>-->
284                                <!--<div class="post-meta">-->
285                                    <!--<span>${txt}</span>-->
286                                    <span class="btn btn-rounded btn-danger btn-modern d-block d-sm-inline-block float-sm-end mt-3 mt-sm-0" onclick="areasconocimiento_init('${carreras}')">Ver Más</span>
287                                <!--</div>-->
288                             </div>
289                        </div>
290                    </div>`
291                ;
292                html += htmlSegment;
293            }
294            return html;
295        }
296        /*
297        function themeSegmentoArea(datos){
298            let html = '';
299            for (let carreras of datos) {
300                img = carreras.CarAreaCon;
301                txt = carreras.CarAreaCon;
302                if (txt=="tecnologia") {txt='Tecnología'}
303                if (txt=="silvoagropecuaria") {txt='Silvoagropecuaria'}
304                if (txt=="arteyarquitectura") {txt='Artes y Arquitectura'}
305                if (txt=="educacion") {txt='Educación'}
306                if (txt=="derecho") {txt='Derecho'}
307                if (txt=="cienciassociales") {txt='Ciencias Sociales'}
308                if (txt=="salud") {txt='Salud'}
309                if (txt=="cienciasnaturalesymatematicas") {txt='Ciencias Naturales y Matemáticas'}
310                if (txt=="cienciasbasicas") {txt='Ciencias Basicas'}
311                if (txt=="administracionynegocios") {txt='Administración y Negocios'}
312                let htmlSegment = 
313                    `<div class="col-sm-9 col-md-6 col-lg-4 pb-3 mb-3 mb-lg-0 bg-transparent">
314                    <div class="card border-0 h-90" onclick="areasconocimiento_init('${carreras.CarAreaCon}')">
315                        <div class="card-img-top position-relative">
316                            <div class="position-absolute right-0 d-flex justify-content-end w-100 py-2 px-3 z-index-3">
317                                <span class="rounded-2 text-center bg-primary text-color-light line-height-2 px-2 py-1">
318                                    <span class="position-relative z-index-2">
319                                    Estudiantes
320                                    </span>
321                                </span>
322                            </div>
323                            <img src="https://${path}/uach/_imag/uach/admision/filtro/areaconocimiento/${img}.jpg" class="img-fluid rounded-top" style="width: 100%; height: 230px;" alt="Lorem Ipsum Dolor">
324                        </div>
325                        <div class="card-body py-4 px-2 border">
326                            <h5 class="card-title text-6 line-height-3 font-weight-semibold">${txt}</h5>
327                            <p class="mb-2 text-5">${carreras.CarCodigo} / ${carreras.CarNombre}</p>
328                                <div class="post-meta">
329                                        <span>${txt}</span>
330                                            <span class="d-block d-sm-inline-block float-sm-end mt-3 mt-sm-0"><a href="${carreras.CarUrl}" class="btn btn-rounded btn-danger btn-modern">Ver Más</a></span>
331                                        </div>
332                         </div>
333                     </div>
334                    </div>`
335
336
337                ;
338                html += htmlSegment;
339            }
340            return html;
341        }
342        */
343        /* Esto soluciona carga por areaconocimiento */
344        async function areasconocimiento_init(area) {
345
346            loading.style.display = 'block';
347            myItems.style.display = 'none';
348            console.log(area);
349            const url = '../uach/lib/php/search.php';
350            const data = { dato: area, servicio: 'SelectorAreaSearch' };
351
352            const opciones = {
353              method: 'POST',
354              headers: { 'Content-Type': 'application/json' },
355              body: JSON.stringify(data)
356            };
357
358            try {
359                const response = await fetch( url, opciones );
360                if (!response.ok) {
361                  throw new Error('Error en la solicitud');
362                }
363                loading.style.display = 'none';
364                const data = await response.json();
365                myItems.style.display = 'flex';
366
367                const section = document.getElementById("targetSection"); //Cargando ID Target
368                section.scrollIntoView({ behavior: "smooth" }); //Para desplazar
369
370                document.getElementById("myItems").innerHTML = data;
371            } catch (error) {
372                console.error('Error:', error);
373            }
374        }
375
376        async function DetectThisMovil() {
377
378            await new Promise(resolve => setTimeout(resolve, 500));
379
380            //let esMovil = /Mobi|Android|iPhone/i.test(navigator.userAgent);
381
382            let esMovil = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
383            
384            return esMovil;
385
386            console.log("URL completa: " + window.location.href);
387            console.log("Protocolo: " + window.location.protocol);
388            console.log("Host (dominio): " + window.location.hostname);
389            console.log("Ruta: " + window.location.pathname);
390            console.log("Puerto: " + window.location.port);
391            console.log("Parámetros: " + window.location.search);
392
393        }
394
395        DetectThisMovil().then(esMovil => {
396            if (esMovil) {
397                //console.log("True movil ;)");
398
399                var miElemento = document.getElementById("jsnonemovil");
400                miElemento.style.setProperty("display", "none", "important");
401
402                var miElemento1 = document.getElementById("jsnonemovil-1");
403                miElemento1.style.setProperty("display", "none", "important");
404
405            } else {
406                //console.log("false movil ;)");
407            }
408        });
409
410/*
411        document.getElementById('formContactCarreras').addEventListener('submit', function(event) {
412            event.preventDefault(); // Evita el envío real del formulario
413            
414            console.log('form enviado ;)');
415            
416            // Obtener los valores del formulario
417            const rut = document.getElementById('rut').value;
418            const nombres = document.getElementById('nombre').value;
419            const apellido = document.getElementById('apellido').value;
420            const email = document.getElementById('email').value;
421            const telefono = document.getElementById('telefono').value;
422            const curso = document.getElementById('curso').value;
423            const carCodigoInt1 = document.getElementById('carrera').value;
424
425            const url = 'https://www.uach.cl/dw/especiales.php';
426
427            const myHeaders = new Headers();
428            myHeaders.append("Content-Type", "text/plain");
429
430            const raw = JSON.stringify({
431                  "servicio": 'registrapostulante',
432                  "rut": rut,
433                  "nombres": nombres,
434                  "apellido1": apellido,
435                  "email": email,
436                  "telefono": telefono,
437                  "comuna": "",
438                  "colegio": "",
439                  "rbd": "",
440                  "curso": curso,
441                  "carCodigoInt1": carCodigoInt1,
442                  "carCodigoInt2": "",
443                  "carCodigoInt3": "",
444                  "carOtraCarrera": "",
445                  "origen": "web-formSiteCarreras"
446            });
447
448            const requestOptions = {
449                  method: "POST",
450                  headers: myHeaders,
451                  body: raw,
452                  redirect: "follow"
453            };
454
455            fetch(url, requestOptions)
456            .then((response) => response.text())
457            .then((result) => console.log(result))
458            .catch((error) => console.error(error));
459
460            
461        });
462*/

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.