1(function($) { 2 3 $(document).ready(function() { 4 5 6 $( "#filtro-continuar" ).on( "click", function() { 7 var pasoActual = ''; 8 $('.filtro-step.activo').each(function() { 9 pasoActual = parseInt($(this).data("src")); 10 }); 11 12 13 14 if(pasoActual == 4){ 15 16 ejecutaPaso4(); 17 18 19 20 } 21 else{ 22 23 pasoActual = pasoActual + 1; 24 25 $('.filtro-step').each(function() { 26 $(this).removeClass("activo"); 27 28 }); 29 30 $('.filtro-step[data-src="'+pasoActual+'"]').addClass('activo'); 31 32 $(".filtro-banegador-steps li").removeClass("activo"); 33 $(".filtro-banegador-steps li.step-"+pasoActual).addClass("activo"); 34 35 36 37 if(pasoActual == 4){ 38 var contMetodo = 0; 39 $('.filtro-tarjeta.filtro-cuarto-nivel:visible').each(function() { 40 contMetodo++; 41 }); 42 43 44 if(contMetodo == 0){ 45 // Salta el paso 4 y va directo a los resultados 46 ejecutaPaso4(); 47 } 48 49 50 } 51 } 52 53 $(".filtro-footer").fadeOut(); 54 }); 55 56 57 58 $( ".gatilla-filtro-sello" ).on( "click", function() { 59 var tipoFiltro = $(this).data("src"); 60 var title = $(this).data("title"); 61 62 activaElementoHTML($(this), tipoFiltro); 63 64 /*setTimeout(function(){ 65 66 }, 500)*/ 67 68 addInput(tipoFiltro, "paso1"); 69 70 inputContinuar("paso1"); 71 72 }); 73 74 75 76 77 $( ".gatilla-filtro-nivel" ).on( "click", function() { 78 var existeActivo = false; 79 var elementoActual = $(this); 80 81 $('.gatilla-filtro-nivel.activo').each(function() { 82 if ($(this).hasClass("activo") && !$(this).is(elementoActual)) { 83 existeActivo = true; 84 } 85 }); 86 87 if(existeActivo){ 88 alert("Solo puede seleccionar un Curso"); 89 } 90 else{ 91 var tipoFiltro = $(this).data("src"); 92 var sello = $(this).data("sello"); 93 var title = $(this).data("title"); 94 95 //alert("click") 96 activaElementoHTML($(this), tipoFiltro); 97 98 99 100 addInput(tipoFiltro, "paso2"); 101 102 inputContinuar("paso2"); 103 } 104 105 106 }); 107 108 109 110 111 112 $( ".gatilla-filtro-area" ).on( "click", function() { 113 var tipoFiltro = $(this).data("src"); 114 var sello = $(this).data("sello"); 115 var nivel = $(this).data("nivel"); 116 var curso = $(this).data("curso"); 117 var title = $(this).data("title"); 118 119 //alert("click") 120 activaElementoHTML($(this), tipoFiltro); 121 122 123 124 addInput(tipoFiltro, "paso3"); 125 126 inputContinuar("paso3"); 127 128 }); 129 130 131 132 133 $( ".gatilla-filtro-metodo" ).on( "click", function() { 134 var tipoFiltro = $(this).data("src"); 135 var sello = $(this).data("sello"); 136 var nivel = $(this).data("nivel"); 137 var curso = $(this).data("curso"); 138 var area = $(this).data("area"); 139 var title = $(this).data("title"); 140 141 //alert("click") 142 activaElementoHTML($(this), tipoFiltro); 143 144 145 146 addInput(tipoFiltro, "paso4"); 147 148 inputContinuar("paso4"); 149 150 }); 151 152 153 154 155 156 157 158 // Verifica si es un dispositivo táctil 159 const isTouchDevice = 'ontouchstart' in document.documentElement; 160 161 $(document).ready(function() { 162 if (isTouchDevice) { 163 // Usamos 'touchstart' en lugar de 'click' para dispositivos táctiles 164 $('.select-hover').on('touchstart', function(e) { 165 // Evitamos que el toque cierre el filtro si ya está abierto 166 e.stopPropagation(); 167 168 // Obtenemos el .filtro-hover relacionado 169 const filtroHover = $(this).find('.filtro-hover'); 170 171 // Ocultamos solo los elementos .filtro-hover que estén visibles, excepto el actual 172 $('.filtro-hover').not(filtroHover).filter(':visible').slideUp(); 173 174 // Si el filtro-hover actual está visible, lo ocultamos, de lo contrario, lo mostramos 175 if (filtroHover.is(':visible')) { 176 filtroHover.slideUp(); 177 } else { 178 filtroHover.slideDown(); 179 } 180 }); 181 182 // Si hacemos clic fuera de cualquier tarjeta, ocultamos todas las .filtro-hover 183 $(document).on('touchstart', function(e) { 184 // Verifica si el toque ocurrió dentro de un .select-hover 185 if (!$(e.target).closest('.select-hover').length) { 186 $('.filtro-hover').slideUp(); 187 } 188 }); 189 } 190 }); 191 192 193 194 195 196 197 198 }); 199 200 201 202 203 204 205 function ejecutaPaso4(){ 206 var result = []; 207 208 // Recorremos todos los elementos con clase .gatilla-filtro-metodo y .activo 209 $('.gatilla-filtro-metodo.activo').each(function() { 210 var sello = $(this).data('sello'); 211 var nivel = $(this).data('nivel'); 212 var curso = $(this).data('curso'); 213 var area = $(this).data('area'); 214 var metodo = $(this).data('title'); 215 216 // Buscar si el sello ya existe en el array result 217 var selloObj = result.find(obj => obj.title === sello); 218 if (!selloObj) { 219 selloObj = { title: sello, child: [] }; 220 result.push(selloObj); 221 } 222 223 // Buscar si el nivel ya existe dentro del sello 224 var nivelObj = selloObj.child.find(obj => obj.title === nivel); 225 if (!nivelObj) { 226 nivelObj = { title: nivel, child: [] }; 227 selloObj.child.push(nivelObj); 228 } 229 230 // Buscar si el curso ya existe dentro del nivel 231 var cursoObj = nivelObj.child.find(obj => obj.title === curso); 232 if (!cursoObj) {
233 cursoObj = { title: curso, child: [] }; 234 nivelObj.child.push(cursoObj); 235 } 236 237 // Buscar si el área ya existe dentro del curso 238 var areaObj = cursoObj.child.find(obj => obj.title === area); 239 if (!areaObj) { 240 areaObj = { title: area, child: [] }; 241 cursoObj.child.push(areaObj); 242 } 243 244 // Agregar el método dentro del área 245 areaObj.child = areaObj.child || []; 246 areaObj.child.push({ title: metodo }); 247 }); 248 249 // Convertimos el resultado a un JSON y lo mostramos en la consola 250 //console.log(JSON.stringify(result, null, 2)); 251 $('#input_json_final').val(JSON.stringify(result)); 252 253 254 var jsonFinal = $('#input_json_final').val().trim(); 255 256 // Verificar si el campo está vacÃo 257 if (jsonFinal !== '') { 258 $('#filtro-form').submit(); 259 } 260 } 261 262 263 264 265 function addInput(tipoFiltro, paso){ 266 267 if(paso == "paso1"){ 268 var titulos = []; 269 $('.filtro-tarjeta.activo').each(function() { 270 var title = $(this).data("title"); 271 272 $('.filtro-segundo-nivel').hide(); 273 $('.filtro-segundo-nivel[data-sello="'+title+'"]').each(function() { 274 $(this).show(); 275 }); 276 277 if (title) { 278 titulos.push(title); 279 } 280 }); 281 282 // gatilla-filtro-nivel 283 // gatilla-filtro-area 284 // gatilla-filtro-metodo 285 286 287 288 $('#input_sello').val(JSON.stringify(titulos)); 289 } 290 291 292 293 294 if(paso == "paso2"){ 295 var titulos = []; 296 $('.filtro-tercer-nivel').hide(); 297 $('.gatilla-filtro-nivel.activo').each(function() { 298 var title = $(this).data("title"); 299 var nivel = $(this).data("nivel"); 300 var sello = $(this).data("sello"); 301 302 //alert(title + " - " + nivel + " - " + sello) 303 304 305 $('.filtro-tercer-nivel[data-sello="'+sello+'"][data-nivel="'+nivel+'"][data-curso="'+title+'"]').each(function() { 306 $(this).show(); 307 }); 308 309 if (title) { 310 titulos.push(title); 311 } 312 }); 313 314 $('#input_nivel').val(JSON.stringify(titulos)); 315 } 316 317 318 if(paso == "paso3"){ 319 var titulos = []; 320 $('.filtro-cuarto-nivel').hide(); 321 $('.gatilla-filtro-area.activo').each(function() { 322 var title = $(this).data("title"); 323 var sello = $(this).data("sello"); 324 var nivel = $(this).data("nivel"); 325 var curso = $(this).data("curso"); 326 var title = $(this).data("title"); 327 328 329 330 331 $('.filtro-cuarto-nivel[data-sello="'+sello+'"][data-nivel="'+nivel+'"][data-curso="'+curso+'"][data-area="'+title+'"]').each(function() { 332 $(this).show(); 333 }); 334 335 if (title) { 336 titulos.push(title); 337 } 338 }); 339 340 $('#input_area').val(JSON.stringify(titulos)); 341 } 342 343 344 345 if(paso == "paso4"){ 346 var titulos = []; 347 348 $('.gatilla-filtro-metodo.activo').each(function() { 349 var title = $(this).data("title"); 350 var sello = $(this).data("sello"); 351 var nivel = $(this).data("nivel"); 352 var curso = $(this).data("curso"); 353 var title = $(this).data("title"); 354 355 356 if (title) { 357 titulos.push(title); 358 } 359 }); 360 361 $('#input_metodo').val(JSON.stringify(titulos)); 362 } 363 364 365 366 } 367 368 369 370 371 372 function inputContinuar(paso){ 373 374 if(paso == "paso1"){
375 var inputValue = $('#input_sello').val(); 376 } 377 if(paso == "paso2"){ 378 var inputValue = $('#input_nivel').val(); 379 } 380 if(paso == "paso3"){ 381 var inputValue = $('#input_area').val(); 382 } 383 if(paso == "paso4"){ 384 var inputValue = $('#input_metodo').val(); 385 } 386 387 388 if (inputValue === "" || inputValue === "[]") { 389 $(".filtro-footer").fadeOut(); 390 } else { 391 $(".filtro-footer").fadeIn(); 392 } 393 } 394 395 396 397 function activaElementoHTML(element, tipoFiltro){ 398 if(tipoFiltro == "sello"){ 399 if(element.hasClass( "activo" )){ 400 element.removeClass("activo"); 401 } 402 else{ 403 element.addClass("activo"); 404 } 405 } 406 407 if(tipoFiltro == "nivel"){ 408 if(element.hasClass( "activo" )){ 409 element.removeClass("activo"); 410 } 411 else{ 412 element.addClass("activo"); 413 } 414 415 var parent = element.parent().parent().parent(); 416 417 var contActivos = 0; 418 $(parent).find(' .gatilla-filtro-nivel').each(function() { 419 if($(this).hasClass( "activo" )){ 420 contActivos++; 421 } 422 }); 423 424 if(contActivos > 0){ 425 $(parent).addClass("activo"); 426 $(parent).find('.filtro-hover').addClass("activo"); 427 } 428 else{ 429 $(parent).removeClass("activo"); 430 $(parent).find('.filtro-hover').removeClass("activo"); 431 } 432 433 } 434 435 436 437 if(tipoFiltro == "area"){ 438 var parent = element.parent().parent(); 439 440 if(element.hasClass( "activo" )){ 441 element.removeClass("activo"); 442 $(parent).removeClass("activo"); 443 } 444 else{ 445 element.addClass("activo"); 446 $(parent).addClass("activo"); 447 } 448 449 450 } 451 452 453 if(tipoFiltro == "metodo"){ 454 var parent = element.parent(); 455 456 if(element.hasClass( "activo" )){ 457 element.removeClass("activo"); 458 $(parent).removeClass("activo"); 459 } 460 else{ 461 element.addClass("activo"); 462 $(parent).addClass("activo"); 463 } 464 465 466 } 467 468 469 } 470 })(jQuery);
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.