1// Services 2 3//const serviceIP = 'https://apiweb.clubhipico.cl/'; 4const serviceIP = 'https://apiweb.clubhipico.cl/'; 5const serviceVersion = ''; 6const serviceUrl = serviceIP; 7 8let globalCalendar = JSON.parse(sessionStorage.getItem('calendario_')); 9let globalCalendarInscritos = JSON.parse(sessionStorage.getItem('calendarioInscritos')); 10let _next_query = sessionStorage.getItem('time_calendar'); 11let _next_query2 = sessionStorage.getItem('time_calendar2'); 12 13async function getCalendarFromService() { 14 try { 15 let result; 16 let urlData = serviceCalendarios(); 17 result = await $.ajax({ 18 type: 'GET', 19 url: urlData 20 }); 21 return result; 22 } catch (error) { 23 return null; 24 } 25} 26 27async function getCalendarFromServiceInscritos() { 28 try { 29 let result; 30 let urlData = serviceCalendariosInscritos(); 31 result = await $.ajax({ 32 type: 'GET', 33 url: urlData 34 }); 35 return result; 36 } catch (error) { 37 return null; 38 } 39} 40 41async function getCalendarFromServiceYear(year, month = null) { 42 if (year && month) { 43 try { 44 let result; 45 let urlData = serviceCalendariosYear(year, month); 46 result = await $.ajax({ 47 type: 'GET', 48 url: urlData 49 }); 50 return result; 51 } catch (error) { 52 return null; 53 } 54 } else { 55 let current = moment(); 56 try { 57 let result; 58 let urlData = serviceCalendariosYear(current.format('YYYY'), current.format('MM')); 59 result = await $.ajax({ 60 type: 'GET', 61 url: urlData 62 }); 63 return result; 64 } catch (error) { 65 return null; 66 } 67 } 68 69} 70
71async function setGlobalCalendar() { 72 73 // if(_next_query){ 74 // console.log('now +5', moment(_next_query).add(5, 'hours')); 75 // console.log('time_calendar', time_calendar); 76 // if (!globalCalendar || moment(_next_query) >= moment(_next_query).add(5, 'hours')) { 77 // globalCalendar = await getCalendarFromService(); 78 // sessionStorage.setItem('calendario', JSON.stringify(globalCalendar)); 79 // sessionStorage.setItem('time_calendar', moment().format('YYYY-MM-DD HH:mm:ss')); 80 // } 81 // }else if(!globalCalendar){ 82 // globalCalendar = await getCalendarFromService(); 83 // sessionStorage.setItem('calendario', JSON.stringify(globalCalendar)); 84 // sessionStorage.setItem('time_calendar', moment().format('YYYY-MM-DD HH:mm:ss')); 85 // } 86 87 globalCalendar = await getCalendarFromServiceYear(); 88 // sessionStorage.setItem('calendario', JSON.stringify(globalCalendar)); 89 // sessionStorage.setItem('time_calendar', moment().format('YYYY-MM-DD HH:mm:ss')); 90 return globalCalendar; 91} 92 93async function setGlobalCalendarInscritos() { 94 globalCalendarInscritos = await getCalendarFromServiceInscritos(); 95 return globalCalendarInscritos; 96} 97
98function getGlobalCalendar() { 99 if (!globalCalendar) { 100 globalCalendar = setGlobalCalendar(); 101 } 102 return globalCalendar; 103} 104 105function getGlobalCalendarInscritos() { 106 if (!globalCalendar) { 107 globalCalendar = setGlobalCalendar(); 108 } 109 return globalCalendar; 110} 111 112async function getGlobalCalendarAsync() { 113 if (!globalCalendar) { 114 globalCalendar = setGlobalCalendar(); 115 } 116 return globalCalendar; 117} 118 119async function getGlobalCalendarAsyncInscritos() { 120 if (!globalCalendarInscritos) { 121 globalCalendarInscritos = setGlobalCalendarInscritos(); 122 } 123 return globalCalendarInscritos; 124} 125 126function serviceCalendarios() { 127 //let _DATE = moment().format('YYYY'); 128 // return serviceUrl + 'calendarios'; 129 //return serviceUrl + 'calendarios/' + _DATE; 130 let _DATE1 = moment().subtract(2, 'Y').format('YYYY-MM-DD'); 131 let _DATE2= moment().add(1, 'Y').format('YYYY-MM-DD'); 132 return serviceUrl + 'calendarios/between/' + _DATE1 +'/' + _DATE2; 133} 134 135function serviceCalendariosInscritos() { 136 let date = moment().add(5, 'M'); 137 let _DATE = moment().startOf('month').format('YYYY-MM-DD'); 138 let _DATE2 = date.endOf('month').format('YYYY-MM-DD'); 139 // return serviceUrl + 'calendarios'; 140 return serviceUrl + 'calendarios/eventos/' + _DATE + '/' + _DATE2; 141} 142 143function serviceCalendariosYear(year, month = null) { 144 145 if (month) { 146 return serviceUrl + 'calendarios/' + year + '/' + month; 147 //return serviceUrl + 'calendarios/' + year; 148 } else { 149 return serviceUrl + 'calendarios/' + year; 150 } 151 //let _DATE1 = moment().subtract(2, 'Y').format('YYYY-MM-DD'); 152 //let _DATE2= moment().add(2, 'M').format('YYYY-MM-DD'); 153 //return serviceUrl + 'calendarios/between/' + _DATE1 +'/' + _DATE2; 154 155 // return serviceUrl + 'calendarios/'+_DATE; 156} 157 158function serviceProgramas(fecha) { 159 return serviceUrl + 'v1/programa/carreras' + '/' + fecha; 160} 161 162function serviceProgramasHome(fecha) { 163 return serviceUrl + 'v2/programa/home' + '/' + fecha; 164} 165 166function serviceResultados(fecha) { 167 return serviceUrl + 'v3/programa/resultado' + '/' + fecha; 168} 169 170function servicePozos(fecha) { 171 return serviceUrl + 'pozos' + '/' + fecha; 172} 173 174function servicePozosCarrera(fecha, carrera) { 175 return serviceUrl + 'pozos' + '/' + fecha + '/' + carrera; 176} 177 178function serviceRepetidos(fecha) { 179 return serviceUrl + 'v4/repetidos' + '/' + fecha; 180} 181 182function servicePozosCarrera(fecha, carrera) { 183 return serviceUrl + 'pozos' + '/' + fecha + '/' + carrera; 184} 185 186function serviceApuestas(fecha) { 187 return serviceUrl + 'v2/apuestas' + '/' + fecha; 188} 189 190function servicePronosticos(fecha) { 191 return serviceUrl + 'v1/pronosticos' + '/' + fecha; 192} 193 194function serviceCarreras(fecha) { 195 return serviceUrl + 'v2/programa/home' + '/' + fecha; 196} 197 198function hrefPrograma(fecha) { 199 window.location.href = get_home_url_carreras + '/resumen-jornada/?fecha=' + fecha; 200} 201 202function hrefResultados(fecha) { 203 window.location.href = get_home_url_carreras + '/resultados/?fecha=' + fecha; 204} 205 206function hrefProgramaResultados(fecha) { 207 window.location.href = get_home_url_carreras + '/programa-y-resultados/?fecha=' + fecha; 208} 209 210function hrefAprontes(fecha) { 211 window.location.href = get_home_url_carreras + '/aprontes/?fecha=' + fecha + ''; 212} 213 214function hrefListaAprontes(fecha) { 215 window.location.href = get_home_url_carreras + '/lista-de-aprontes/?fecha=' + fecha + ''; 216} 217 218function hrefHuinchadas(fecha) { 219 window.location.href = get_home_url_carreras + '/huinchadas/?fecha=' + fecha; 220} 221 222function hrefProgramaPDF(fecha) { 223 window.location.href = get_home_url_carreras + '/programa-pdf/?fecha=' + fecha; 224} 225 226function hrefPozos(fecha) { 227 window.location.href = get_home_url_carreras + '/pozos/?fecha=' + fecha; 228} 229 230function hrefInscritos(fecha) { 231 window.location.href = get_home_url_carreras + '/inscritos/?fecha=' + fecha; 232} 233 234function hrefTrakus(fecha) { 235 window.location.href = get_home_url_carreras + '/gmax/?fecha=' + fecha; 236} 237 238function hrefVolante(fecha) { 239 window.location.href = get_home_url_carreras + '/volante/?fecha=' + fecha; 240} 241 242function hrefAprontesHuinchadas(fecha) { 243 window.location.href = get_home_url_carreras + '/aprontes-huinchadas/?fecha=' + fecha; 244} 245 246function hrefNovedades(fecha) { 247 window.location.href = get_home_url_carreras + '/novedades-de-la-reunion/?fecha=' + fecha; 248} 249 250function hrefActaComisarios(fecha) { 251 window.location.href = get_home_url_carreras + '/acta-de-comisarios/?fecha=' + fecha; 252} 253
254function hrefClubGanadores(fecha) { 255 window.location.href = get_home_url_carreras + '/club-de-ganadores/?fecha=' + fecha; 256} 257 258function getUrlPrograma(fecha, carrera, hipodromo) { 259 if (hipodromo == 'chs') { 260 return '<a href="' + get_home_url_carreras + '/programa-y-resultados/?fecha=' + fecha + '&carrera=' + carrera + '">' + fecha + '</a>'; 261 } else { 262 return fecha; 263 } 264} 265 266function getUrlResultados(fecha, carrera, hipodromo) { 267 if (hipodromo == 'chs') { 268 return '<a href="' + get_home_url_carreras + '/resultados/?fecha=' + fecha + '&carrera=' + carrera + '">' + fecha + '</a>'; 269 } else { 270 return fecha; 271 } 272} 273 274function getUrlFS(rut) { 275 return get_home_url_carreras + '/perfil-fina-sangre/?fs_rut=' + rut; 276} 277 278function getButtonCalendar(functionName) { 279 return '<button type="button" onclick="calendarInit(' + functionName + ')" class="btn btn-outline-secondary btn-calendar" style="border-radius : 5px; margin-top: -8px;"><img src="' + directory_uri + '/assets/images/calendar.png" alt=""></button>'; 280} 281 282let dataNumerosCarreras = null; 283 284// -- Carreras suspendidas/anuladas ------------------------------------- 285// ES_CARRERAS.ESTADO_SERIE: '3','4','5','6' = carrera anulada/suspendida 286// ('5' = "Anulada, pista en mal estado", tipico por temporal). 287// Solo v1/programa/resultado/{fecha} expone estado_serie. 288var ESTADOS_CARRERA_SUSPENDIDA = ['3', '4', '5', '6']; 289var _mapaEstadoSerie = {}; 290var _estadoSerieFecha = null; 291 292function _esCarreraSuspendida(estadoSerie) { 293 return ESTADOS_CARRERA_SUSPENDIDA.indexOf(String(estadoSerie)) !== -1; 294} 295 296function _cargarEstadoSerieCarreras(fecha, cb) { 297 if (!fecha) { if (cb) cb(); return; } 298 jQuery.ajax({ 299 type: 'GET', 300 url: serviceUrl + 'v1/programa/resultado/' + fecha, 301 success: function (msg) { 302 var data = Array.isArray(msg) ? msg : (msg && msg.data ? msg.data : []); 303 _mapaEstadoSerie = {}; 304 (data || []).forEach(function (c) { 305 _mapaEstadoSerie[c.numero_carrera] = c.estado_serie; 306 }); 307 _estadoSerieFecha = fecha; 308 if (cb) cb(); 309 }, 310 error: function () { _estadoSerieFecha = fecha; if (cb) cb(); } 311 }); 312} 313 314// Aviso al clickear una carrera suspendida (mensaje claro, no el modal generico). 315function showCarreraSuspendida() { 316 if (window.Swal && typeof Swal.fire === 'function') { 317 Swal.fire({ 318 icon: 'info', 319 title: 'Carrera suspendida', 320 text: 'Esta carrera fue suspendida y no se disputó, por lo que no tiene resultados.', 321 confirmButtonText: 'Entendido', 322 confirmButtonColor: '#5B9B59' 323 }); 324 } else { 325 alert('Esta carrera fue suspendida y no se disputó.'); 326 } 327} 328 329function setDataNumerosCarreras(response, section, fecha, carrera) { 330 dataNumerosCarreras = response; 331 // Cargar estado_serie antes de renderizar para marcar las suspendidas. 332 _cargarEstadoSerieCarreras(fecha, function () { 333 mainRenderNumerosCarreras(section, fecha, carrera); 334 }); 335} 336 337function mainRenderNumerosCarreras(section, fecha, carrera) { 338 _renderNumerosCarreras(section, fecha, carrera); 339} 340 341 342function calcularDistanciaResumida(distancia, pista) { 343 let tipo = pista == 1 ? 'P' : 'A'; 344 return distancia + tipo; 345} 346 347function tipoDeCarrera(tipo) { 348 if (tipo == 'Handicap') { 349 return 'H'; 350 } else if (tipo == 'Clásico Condicional') { 351 return 'ClCd'; 352 } else if (tipo == 'Clásico Condicional Gr. 1') { 353 return 'ClCdG1'; 354 } else if (tipo == 'Clásico Condicional Gr. 2') { 355 return 'ClCdG2'; 356 } else if (tipo == 'Clásico Condicional Gr. 3') { 357 return 'ClCdG3'; 358 } else if (tipo == 'Clásico Condicional Listada') { 359 return 'ClCdL'; 360 } else if (tipo == 'Clásico Handicap') { 361 return 'ClH'; 362 } else if (tipo == 'Clásico Handicap Gr. 1') { 363 return 'ClHG1'; 364 } else if (tipo == 'Clásico Handicap Gr. 2') { 365 return 'ClHG2'; 366 } else if (tipo == 'Clásico Handicap Gr. 3') { 367 return 'ClHG3'; 368 } else if (tipo == 'Clásico Handicap Libre') { 369 return 'ClHL'; 370 } else if (tipo == 'Clásico Handicap Libre Gr. 1') { 371 return 'ClHLG1'; 372 } else if (tipo == 'Clásico Handicap Libre Gr. 2') { 373 return 'ClHLG2'; 374 } else if (tipo == 'Clásico Handicap Libre Gr. 3') { 375 return 'ClHLG3'; 376 } else if (tipo == 'Clásico Handicap Libre Listada') { 377 return 'ClHLL'; 378 } else if (tipo == 'Clásico Handicap Listada') { 379 return 'ClHL'; 380 } else if (tipo == 'Clásico Peso Reglamento') { 381 return 'ClPR'; 382 } else if (tipo == 'Clásico Peso Reglamento Gr. 1') { 383 return 'ClPRG1'; 384 } else if (tipo == 'Clásico Peso Reglamento Gr. 2') { 385 return 'ClPRG2'; 386 } else if (tipo == 'Clásico Peso Reglamento Listada') { 387 return 'ClPRL'; 388 } else if (tipo == 'Clásico Peso Reglamento Gr. 3') { 389 return 'ClPRG3'; 390 } else if (tipo == 'Condicional') { 391 return 'Cd'; 392 } else if (tipo == 'Condicional Con Descargo') { 393 return 'CdD'; 394 } else if (tipo == 'Condicional Especial') { 395 return 'CdE'; 396 } else if (tipo == 'Especial Handicap') { 397 return 'EsH'; 398 } else if (tipo == 'Handicap Especial') { 399 return 'HEs'; 400 } else if (tipo == 'Handicap Libre') { 401 return 'HL'; 402 } else { 403 return '(NR)'; 404 } 405} 406 407function condicionGanadorAbreviado(tipo, sexo, edad, sup = null, inf = null) { 408 var letra = ''; 409 var _tipo = '' 410 411 if (sexo) { 412 if (sexo == 'H') { 413 letra = 'H'; 414 } else if (sexo == 'M') { 415 letra = 'M'; 416 } else if (sexo == 'C') { 417 letra = 'C'; 418 } else { 419 letra = 'MH'; 420 } 421 } 422 423 if (sup && inf) { 424 return letra + '' + sup + '-' + inf; 425 } else { 426 if (tipo) { 427 if (tipo == 'P' || tipo == 'O') { 428 return letra + edad + 'N'; 429 } else { 430 return letra + edad + 'G'; 431 } 432 } else { 433 return letra + edad; 434 } 435 } 436 437} 438 439 440function _renderNumerosCarreras(section, fecha, carrera) { 441 442 dataNumerosCarreras.forEach(function (row) { 443 let html = $('.owl-carreras'); 444 let url = _urlBySection(section) + '?fecha=' + fecha + '&carrera=' + row.numero_carrera; 445 let selected = row.numero_carrera == carrera ? 'selected' : ''; 446 let timeS = moment(moment(row.hora_carrera, 'HH:mm:ss')).format('HH:mm') + 'Hrs.'; 447 448 let corrida = 'corrida'; 449 let icon = 'fa fa-bell text-secondary'; 450 let time = timeS; 451 452 453 if (row.resultados == 'false' || row.resultados == false) { 454 corrida = ''; 455 icon = 'fa fa-clock-o'; 456 time = timeS; 457 } 458 459 let fechaCarrera = fecha;
460 //console.log('anulada -> ' + fecha == '2023-06-30') 461 462 if(fechaCarrera == '2023-06-30' && position == 15){ 463 corrida = 'anulada'; 464 icon = 'fas fa fa-circle-exclamation text-white'; 465 } 466 467 if(fechaCarrera == '2024-06-14'){ 468 corrida = 'anulada'; 469 icon = 'fas fa fa-circle-exclamation text-white'; 470 } 471 472 let _suspendida = _esCarreraSuspendida(_mapaEstadoSerie[row.numero_carrera]); 473 474 if (_suspendida) { 475 // Carrera anulada/suspendida: etiqueta clara, sin enlace a resultados. 476 html.append($('<div onclick="showCarreraSuspendida()"><div class="box-carreras col suspendida ' + selected + '" style="opacity:.7">' + 477 ' <div class="number-box-carrera">' + 478 ' <span class="font-28 black">' + row.numero_carrera + '</span><span class="black position-grade">a</span>' + 479 ' </div>' + 480 ' <span class="carrera-status"><b class="text-danger">SUSPENDIDA</b></span>' + 481 ' <span class="carrera-status bold d-block">' + calcularDistanciaResumida(row.distancia, row.numero_pista) + '</span>' + 482 ' <span class="carrera-status bold">' + tipoDeCarrera(row.nombre_carrera) + '' + condicionGanadorAbreviado(row.condicion_ganador, row.sexo, row.edad, row.indice_superior, row.indice_inferior) + '</span>' + 483 ' </div></div>')); 484 } else if (section == 'resultados' && corrida == 'corrida') { 485 html.append($('<a href="' + url + '"><div class="box-carreras col ' + corrida + ' ' + selected + '">' + 486 ' <div class="number-box-carrera">' + 487 ' <span class="font-28 black">' + row.numero_carrera + '</span><span class="black position-grade">a</span>' + 488 ' </div>' + 489 ' <span class="carrera-status"><b></i> ' + time + '</b></span>' + 490 ' <span class="carrera-status bold d-block">' + calcularDistanciaResumida(row.distancia, row.numero_pista) + '</span>' + 491 ' <span class="carrera-status bold">' + tipoDeCarrera(row.nombre_carrera) + '' + condicionGanadorAbreviado(row.condicion_ganador, row.sexo, row.edad, row.indice_superior, row.indice_inferior) + '</span>' + 492 ' </div></a>')); 493 } else if (section == 'resultados' && corrida != 'corrida') { 494 html.append($('<div onclick="showNoResultData()"><div class="box-carreras col ' + corrida + ' ' + selected + '">' + 495 ' <div class="number-box-carrera">' + 496 ' <span class="font-28 black">' + row.numero_carrera + '</span><span class="black position-grade">a</span>' + 497 ' </div>' + 498 ' <span class="carrera-status"><b></i> ' + time + '</b></span>' + 499 ' <span class="carrera-status bold d-block">' + calcularDistanciaResumida(row.distancia, row.numero_pista) + '</span>' + 500 ' <span class="carrera-status bold">' + tipoDeCarrera(row.nombre_carrera) + '' + condicionGanadorAbreviado(row.condicion_ganador, row.sexo, row.edad, row.indice_superior, row.indice_inferior) + '</span>' + 501 ' </div></div>')); 502 } else { 503 html.append($('<a href="' + url + '"><div class="box-carreras col ' + corrida + ' ' + selected + '">' + 504 ' <div class="number-box-carrera">' + 505 ' <span class="font-28 black">' + row.numero_carrera + '</span><span class="black position-grade">a</span>' + 506 ' </div>' + 507 ' <span class="carrera-status"><b></i> ' + time + '</b></span>' + 508 ' <span class="carrera-status bold d-block">' + calcularDistanciaResumida(row.distancia, row.numero_pista) + '</span>' + 509 ' <span class="carrera-status bold">' + tipoDeCarrera(row.nombre_carrera) + '' + condicionGanadorAbreviado(row.condicion_ganador, row.sexo, row.edad, row.indice_superior, row.indice_inferior) + '</span>' + 510 ' </div></a>')); 511 } 512 }); 513 $('.owl-carreras .owl-next').click(function () { 514 owl.trigger('next.owl.carousel'); 515 }); 516 517 $('.owl-carreras .owl-prev').click(function () { 518 owl.trigger('prev.owl.carousel', [300]); 519 }) 520} 521 522function _renderNumerosJornadas(section, fecha, dates) {
523 let carrera = 1; 524 525 dates.forEach(function (row) { 526 let fecha_carrera = !moment.isMoment(moment(row.fecha_reunion)) ? row.fecha_reunion : moment(row.fecha_reunion).lang('es') 527 let data_fecha = moment(fecha) 528 529 let html = $('#owl-jornadas'); 530 let url = ''; 531 url = row.carreras ? _urlBySection(section) + '?fecha=' + fecha_carrera.format('YYYY-MM-DD') : '#'; 532 if (section == 'inscritos' && fecha_carrera.format('YYYY-MM-DD') == '2021-10-31' || fecha_carrera.format('YYYY-MM-DD') == '2021-11-05') { 533 console.log('entra-log1'); 534 url = _urlBySection(section) + '?fecha=' + fecha_carrera.format('YYYY-MM-DD'); 535 } 536 537 let selected = fecha_carrera.format('YYYY-MM-DD') == data_fecha.format('YYYY-MM-DD') ? 'active' : ''; 538 carrera = dates.findIndex(d => d.fecha_reunion = fecha); 539 let corrida; 540 if (fecha_carrera.format('YYYY-MM-DD') <= moment().format('YYYY-MM-DD')) { 541 corrida = row.carreras ? 'ball-date first' : 'ball-date'; 542 } else if (row.carreras) { 543 corrida = 'ball-date'; 544 } else { 545 corrida = 'no-programa'; 546 547 if (section == 'inscritos' && fecha_carrera.format('YYYY-MM-DD') == '2021-10-31' || fecha_carrera.format('YYYY-MM-DD') == '2021-11-05') { 548 console.log('entra-log2'); 549 corrida = row.carreras ? 'ball-date first' : 'ball-date'; 550 } 551 } 552 553 554 html.append($('<a href="' + url + '">' + 555 '<div class="ball-date font-23 thin ' + corrida + ' ' + selected + '"' + 556 ' <span class="ball-date-day-number d-block">' + fecha_carrera.format('DD') + '</span>\n' + 557 ' <span class="ball-date-day-name black uppercase font-15" style="line-height: .7">' + fecha_carrera.format('ddd') + '</span>\n' + 558 '</div>' + 559 '</a>')); 560 561 }); 562 563 let owl = $('#owl-jornadas'); 564 565 // Posiciona el carrusel en la jornada activa para que quede visible (sin 566 // forzar el centro; si es la ultima del mes queda visible como ultima, 567 // Owl clampea el scroll con loop:false). 568 // El indice se toma del ball ya renderizado con .active y NO de 569 // dates.findIndex, porque el codigo previo corrompe dates[0].fecha_reunion 570 // (hay un assignment 'd.fecha_reunion = fecha' en la linea de 'carrera'). 571 let jornadaBalls = $('#owl-jornadas .ball-date'); 572 let activeIndex = jornadaBalls.index(jornadaBalls.filter('.active')); 573 574 owl.owlCarousel({ 575 loop: false, 576 margin: 10, 577 autoWidth: true, 578 nav: false, 579 stagePadding: 50, 580 startPosition: activeIndex > -1 ? activeIndex : 0, 581 }); 582 583 $('.owl-jornadas .owl-next').click(function () { 584 owl.trigger('next.owl.carousel'); 585 }); 586 587 $('.owl-jornadas .owl-prev').click(function () { 588 owl.trigger('prev.owl.carousel', [300]); 589 }) 590} 591 592function _renderNumerosInscripciones(section, fecha, dates) {
593 let carrera = 1; 594 if (section != 'gmax') { 595 596 597 console.log(dates); 598 dates.forEach(function (row) { 599 let fecha_carrera = !moment.isMoment(moment(row.fecha_reunion)) ? row.fecha_reunion : moment(row.fecha_reunion).lang('es') 600 let data_fecha = moment(fecha); 601 let html = $('#owl-jornadas'); 602 let url = row.carreras ? _urlBySection(section) + '?fecha=' + fecha_carrera.format('YYYY-MM-DD') : '#'; 603 let selected = fecha_carrera.format('YYYY-MM-DD') == data_fecha.format('YYYY-MM-DD') ? 'active' : ''; 604 carrera = dates.findIndex(d => d.fecha_reunion = fecha); 605 let corrida; 606 if (fecha_carrera.format('YYYY-MM-DD') <= moment().format('YYYY-MM-DD')) { 607 corrida = row.carreras ? 'ball-date first' : 'ball-date'; 608 } else if (row.carreras) { 609 corrida = 'ball-date'; 610 } else { 611 corrida = 'no-programa'; 612 } 613 614 615 html.append($('<a href="' + url + '">' + 616 '<div class="ball-date font-23 thin ' + corrida + ' ' + selected + '"' + 617 ' <span class="ball-date-day-number d-block">' + fecha_carrera.format('DD') + '</span>\n' + 618 ' <span class="ball-date-day-name black uppercase font-15" style="line-height: .7">' + fecha_carrera.format('ddd') + '</span>\n' + 619 '</div>' + 620 '</a>')); 621 622 }); 623 624 let owl = $('#owl-jornadas'); 625 owl.owlCarousel({ 626 loop: false, 627 margin: 10, 628 autoWidth: true, 629 // center: true, 630 nav: false, 631 stagePadding: 50, 632 }); 633 634 $('.owl-jornadas .owl-next').click(function () { 635 owl.trigger('next.owl.carousel'); 636 }); 637 638 $('.owl-jornadas .owl-prev').click(function () { 639 owl.trigger('prev.owl.carousel', [300]); 640 }) 641 642 $('.owl-jornadas .owl-prev').on('changed.owl.carousel', function (event) { 643 setTimeout(function () { 644 var activeEls = $('.owl-item.active').eq(8); // .eq(1) to get the "middle image out of 3 actives" 645 setCarouselCaption(activeEls); 646 }, 1); 647 }); 648 649 650 } 651 652 // $(".owl-jornadas").trigger("to.owl.carousel", [dates, 6]) 653} 654 655function setCarouselCaption(el) { 656 $(".owl-item").removeClass("target"); 657 el.addClass("target"); 658} 659 660function initHeader(fecha,dates) { 661 let new_date = moment(fecha); 662 let data; 663 if (dates) { 664 data = dates.find(d => d.fecha_reunion == fecha); 665 } 666 let date = moment(data.fecha_reunion).lang('es'); 667 let div = $('#inject-calendar'); 668 let render = '<h2 class="font-40 r-title-40 light text-primary uppercase">\n' + 669 ' ' + date.format('DD') + ' <span class="black">DE ' + date.format('MMMM') + ' ' + date.format('YYYY') + '</span>\n' + 670 '</h2>\n' + 671 '<h3 class="title-reunion light uppercase">\n' + 672 ' <span class="black" >REUNIÃN Nº ' + data.numero_reunion + ' | </span>CLUB HÃPICO DE SANTIAGO\n' + 673 '</h3>'; 674 div.html(render); 675} 676 677 678async function injectCalendar(fecha = null, functionName = 'resumen-jornada') { 679 console.log(fecha); 680 let new_date = moment(fecha); 681 var dates = null; 682 if (functionName == 'inscritos') { 683 dates = await getGlobalCalendarAsyncInscritos(); 684 } else { 685 dates = await getCalendarFromServiceYear(new_date.format('YYYY'), new_date.format('MM')); 686 } 687 console.log('dates : ', dates); 688 let data; 689 if (dates) { 690 data = dates.find(d => d.fecha_reunion == fecha); 691 } 692 693 if (data) { 694 let div2 = $('#inject-comparador') 695 let div = $('#inject-calendar'); 696 div.html(''); 697 let date = moment(data.fecha_reunion).lang('es'); 698 let search_date = moment(data.fecha_reunion).format('MM-YYYY'); 699 let nextMonth = moment(data.fecha_reunion).add(1, 'M').format('MM-YYYY'); 700 let fechas = null; 701 if (functionName == 'inscritos') { 702 fechas = dates.filter(d => moment(d.fecha_reunion).format('MM-YYYY') >= search_date && moment(d.fecha_reunion).format('MM-YYYY') <= nextMonth); 703 //renderPelotas(fechas, date, functionName); 704 } else { 705 fechas = dates.filter(d => moment(d.fecha_reunion).format('MM-YYYY') == search_date); 706 renderPelotas(fechas, date, functionName); 707 } 708 709 // let fechas = dates.filter(d => moment(d.fecha_reunion).format('MM-YYYY') == search_date); 710 711 712 let render = '<h2 class="font-40 r-title-40 light text-primary uppercase">\n' + 713 ' ' + date.format('DD') + ' <span class="black">DE ' + date.format('MMMM') + ' ' + date.format('YYYY') + '</span>\n' + 714 '</h2>\n' + 715 '<h3 class="title-reunion light uppercase">\n' + 716 ' <span class="black" >REUNIÃN Nº ' + data.numero_reunion + ' | </span>CLUB HÃPICO DE SANTIAGO\n' + 717 '</h3>'; 718 719 let render2 = '<div class="d-inline-flex mt-3"><h2 class="font-23 r-title-22 light text-primary uppercase">\n' + 720 ' ' + date.format('DD') + ' <span class="black">DE ' + date.format('MMMM') + ' ' + date.format('YYYY') + '</span>\n' + 721 '<h2 class="font-23 ml-2 light uppercase">\n' + 722 ' <span class="black" >REUNIÃN Nº ' + data.numero_reunion + ' | </span>
722CHS\n' + 723 '</h2></div>' + 724 '<div class="d-block" id="name-race-comparador"></div>'; 725 726 calendarInit(functionName); 727 728 div.html(render); 729 div2.html(render2); 730 731 } else { 732 let date = moment(new Date()).lang('es'); 733 let render = date.format('DD') + ' <span class="extra-bold">DE ' + date.format('MMMM') + ' ' + date.format('YYYY') + '</span>'; 734 calendarInit(functionName); 735 $('.title-calendar').html(render); 736 } 737 738} 739 740function renderPelotas(dates = null, selected = null, functionName) { 741 if (functionName != 'inscritos') { 742 _renderNumerosJornadas(functionName, selected, dates); 743 } else { 744 _renderNumerosJornadasInscripciones(functionName, selected, dates); 745 } 746 747} 748 749function _urlBySection(section) { 750 console.log("_urlBySection section: " + section); 751 if (section == 'aprontes') { 752 return get_home_url_carreras + '/aprontes/' 753 } 754 if (section == 'pozos') { 755 return get_home_url_carreras + '/pozos/' 756 } 757 if (section == 'lista-de-aprontes') { 758 return get_home_url_carreras + '/lista-de-aprontes/' 759 } 760 if (section == 'huinchadas') { 761 return get_home_url_carreras + '/huinchadas/' 762 } 763 if (section == 'resumen-jornada') { 764 return get_home_url_carreras + '/resumen-jornada/' 765 } 766 if (section == 'programa-resultados') { 767 return get_home_url_carreras + '/programa-y-resultados/' 768 } 769 if (section == 'aprontes-huinchadas') { 770 return get_home_url_carreras + '/aprontes-huinchadas/' 771 } 772 if (section == 'acta-de-comisarios') { 773 return get_home_url_carreras + '/acta-de-comisarios/' 774 } 775 if (section == 'volante') { 776 return get_home_url_carreras + '/volante/' 777 } 778 if (section == 'programa-pdf') { 779 return get_home_url_carreras + '/programa-pdf/' 780 } 781 if (section == 'club-de-ganadores') { 782 return get_home_url_carreras + '/club-de-ganadores/' 783 } 784 if (section == 'novedades-de-la-reunion') { 785 return get_home_url_carreras + '/novedades-de-la-reunion/' 786 } 787 if (section == 'gmax') { 788 return get_home_url_carreras + '/gmax/' 789 } 790 if (section == 'resultados') { 791 return get_home_url_carreras + '/resultados/' 792 } 793 if (section == 'inscritos') { 794 return get_home_url_carreras + '/inscritos/' 795 } 796 if (section == 'programa-digital') { 797 return get_home_url_carreras + '/programa-digital/' 798 } 799} 800 801 802let xhrPistas; 803 804function getDataPistasPalizadas(fecha_evento = null, aplicarRedimension = false, pista = false) { 805 806 let _fecha; 807 808 if (fecha_evento) { 809 _fecha = moment(fecha_evento).format('DD-MM-YYYY'); 810 } else { 811 _fecha = moment(new Date()).format('DD-MM-YYYY'); 812 } 813 814 if (xhrPistas && xhrPistas.status != 4) { 815 xhrPistas.abort(); 816 } 817 818 xhrPistas = $.ajax({ 819 type: 'POST', 820 url: adminAjax, 821 data: { 822 action: 'filtro_pistas_y_palizadas', 823 fecha_carrera: _fecha, 824 }, 825 success: function (msg) { 826 let response = JSON.parse(msg); 827 renderPistasPalizadas(response, aplicarRedimension, pista); 828 }, 829 error: function (msg) { 830 831 } 832 }); 833} 834 835function renderPistasPalizadas(data, aplicarRedimension, pista) { 836 837 if (data.result) { 838 839 $('#rodillo_pista1').html(data.pista_1.rodillo + ' %'); 840 $('#condicion_pista1').html(data.pista_1.cancha + ' MTS'); 841 $('#humedad_pista1').html(data.pista_1.humedad + ' %'); 842 $('#corte_pasto_pista1').html(data.pista_1.corte_pasto + ' CM'); 843 $('#cancha_pista1').html(data.pista_1.cancha); 844 $('#dureza_pista1').html(data.pista_1.dureza + ' CM'); 845 $('#pista_disponible1').html(data.pista_1.pista_disponible + ' MTS'); 846 847 $('#acondicionador_pista2').html(data.pista_2.acondicionador + ' %'); 848 $('#condicion_pista2').html(data.pista_2.cancha); 849 $('#pista_disponible2').html(data.pista_2.pista_disponible + ' MTS'); 850 $('#humedad_pista2').html(data.pista_2.humedad + ' %'); 851 $('#cancha_pista2').html(data.pista_2.cancha); 852 $('#rastra_pista2').html(data.pista_2.rastra + '%'); 853 $('#profundidad_rasta_pista2').html(data.pista_2.profundidad_de_rastra + ' CM'); 854 855 $('#temp-max').html(data.datos_metereologicos.temperatura_maxima + ' ºC'); 856 $('#temp-min').html(data.datos_metereologicos.temperatura_minima + ' ºC'); 857 858 $('#humedad').html(data.datos_metereologicos.humedad + '%'); 859 $('#viento').html(data.datos_metereologicos.viento + ' KM/H'); 860 $('#posibilidad_de_lluvia').html(data.datos_metereologicos.posibilidad_de_lluvia + '%'); 861 $('#visibilidad').html(data.datos_metereologicos.visibilidad + ' KM'); 862 863 $('#temp_min').html(data.datos_metereologicos.temperatura_minima + 'º'); 864 $('#temp_max').html(data.datos_metereologicos.temperatura_maxima + 'º'); 865 866 } 867 868 if (aplicarRedimension && pista) { 869 870 if ($(window).width() > 768) { 871 let h = $('.pistas-clima').outerHeight(); 872 if (pista === 1) { 873 $('.show-pasto').addClass('d-flex'); 874 $('.show-pasto').css('height', h + 'px'); 875 $('.show-arena').addClass('d-none'); 876 } 877 878 if (pista === 2) { 879 $('.show-arena').addClass('d-flex'); 880 $('.show-arena').removeClass('mt-md-1'); 881 $('.show-arena').css('height', h + 'px'); 882 $('.show-pasto').addClass('d-none'); 883 } 884 } else { 885 let h = 100; 886 if (pista === 1) { 887 $('.show-pasto').addClass('d-flex'); 888 $('.show-pasto').css('height', h + '%'); 889 $('.show-arena').addClass('d-none'); 890 } 891 892 if (pista === 2) { 893 $('.show-arena').addClass('d-flex'); 894 $('.show-arena').removeClass('mt-md-1'); 895 $('.show-arena').css('height', h + '%'); 896 $('.show-pasto').addClass('d-none'); 897 } 898 } 899 900 } 901} 902 903async function getProximoPrograma(dates) { 904 905 let now = moment.unix();
906 let calendar = dates; 907 let reversed = calendar.reverse(); 908 let match = false; 909 let count = 0; 910 var array_next = []; 911 var fecha_return; 912 let filter_date = reversed.filter(f => f.fecha_reunion == now.format('YYYY-MM-DD')); 913 calendar.forEach(function (elem) { 914 let _fecha = moment(elem.fecha_reunion); 915 _fecha.set({hour: 23, minute: 59, second: 59}); 916 if (_fecha.valueOf() >= moment().valueOf() && elem.carreras) { 917 array_next.push(elem); 918 } 919 }); 920 console.log('array_next', array_next); 921 array_next.reverse(); 922 console.log('array_next', array_next); 923 reversed.forEach(function (elem) { 924 if (elem.carreras && !match) { 925 if (count == 0) { 926 927 if (moment(elem.fecha_reunion).valueOf() == now.valueOf()) { //se nego la condicion revisar 928 $('#title-next-races-widget').html(''); 929 $('#title-next-races-widget').html('<h4 class="text-white thin mt-md-0 mt-3 uppercase font-18 pb-2 inline">' + 930 '<i class="fa fa-file-o text-gold mr-2" aria-hidden="true"></i> <span id="widget_home_name_race">JORNADA </span>\n' + 931 ' <span class="extra-bold">' + elem.numero_reunion + '<span class="light"> | </span>' + moment(elem.fecha_reunion).format('DD-MM-YYYY') + '</span>\n' + 932 ' </h4>'); 933 } else if (!moment().isSameOrAfter(elem.fecha_reunion)) { 934 $('#title-next-races-widget').html(''); 935 $('#title-next-races-widget').html('<h4 class="text-white thin mt-md-0 mt-3 uppercase font-18 pb-2 inline">' + 936 '<i class="fa fa-file-o text-gold mr-2" aria-hidden="true"></i> <span id="widget_home_name_race">JORNADA </span>\n' + 937 ' <span class="extra-bold">' + array_next[0].numero_reunion + '<span class="light"> | </span>' + moment(array_next[0].fecha_reunion).format('DD-MM-YYYY') + '</span>\n' + 938 ' </h4>'); 939 } else { 940 $('#title-next-races-widget').html(''); 941 $('#title-next-races-widget').html('<h4 class="text-white thin mt-md-0 mt-3 uppercase font-18 pb-2 inline">' + 942 '<i class="fa fa-file-o text-gold mr-2" aria-hidden="true"></i> <span id="widget_home_name_race">JORNADA </span>\n' + 943 ' <span class="extra-bold">' + elem.numero_reunion + '<span class="light"> | </span>' + moment(elem.fecha_reunion).format('DD-MM-YYYY') + '</span>\n' + 944 ' </h4>'); 945 946 } 947 match = true; 948 let _now = moment().format('YYYY-MM-DD 23:59:59') 949 let date_rece_now = moment(elem.fecha_reunion).format('YYYY-MM-DD 23:59:59'); 950 // date_rece_now.set({hour:23,minute:59,second:59}); 951 now.set({hour: 23, minute: 59, second: 59}); 952 console.log('date_rece_now', date_rece_now); 953 console.log('_now', _now); 954 955 956 if (date_rece_now.valueOf() == _now.valueOf()) { 957 fecha_return = elem.fecha_reunion 958 } else if (array_next.length) { 959 fecha_return = array_next[0].fecha_reunion 960 } else { 961 fecha_return = elem.fecha_reunion; 962 } 963 964 } 965 count++ 966 967 } 968 969 }); 970 971 return fecha_return; 972} 973 974function _renderNumerosJornadasInscripciones(section, fecha, dates) {
975 let carrera = 1; 976 977 dates.forEach(function (row) { 978 let fecha_carrera = !moment.isMoment(moment(row.fecha_reunion)) ? row.fecha_reunion : moment(row.fecha_reunion).lang('es') 979 let data_fecha = moment(fecha); 980 981 let html = $('#owl-jornadas'); 982 let url = ''; 983 url = row.inscripciones ? _urlBySection(section) + '?fecha=' + fecha_carrera.format('YYYY-MM-DD') : '#'; 984 if (section == 'inscritos' && fecha_carrera.format('YYYY-MM-DD') == '2021-10-31' || fecha_carrera.format('YYYY-MM-DD') == '2021-11-05') { 985 console.log('entra-log1'); 986 url = _urlBySection(section) + '?fecha=' + fecha_carrera.format('YYYY-MM-DD'); 987 } 988 989 let selected = fecha_carrera.format('YYYY-MM-DD') == data_fecha.format('YYYY-MM-DD') ? 'active' : ''; 990 carrera = dates.findIndex(d => d.fecha_reunion = fecha); 991 let corrida; 992 if (fecha_carrera.format('YYYY-MM-DD') <= moment().format('YYYY-MM-DD')) { 993 corrida = row.inscripciones ? 'ball-date first' : 'ball-date'; 994 } else if (row.inscripciones) { 995 corrida = 'ball-date'; 996 } else { 997 corrida = 'no-programa'; 998 999 if (section == 'inscritos' && fecha_carrera.format('YYYY-MM-DD') == '2021-10-31' || fecha_carrera.format('YYYY-MM-DD') == '2021-11-05') { 1000 console.log('entra-log2'); 1001 corrida = row.inscripciones ? 'ball-date first' : 'ball-date'; 1002 } 1003 } 1004 1005 if(fechaCarrera == '2023-06-30' && position == 15){ 1006 corrida = 'anulada'; 1007 icon = 'fas fa fa-circle-exclamation text-white'; 1008 } 1009 1010 if(fechaCarrera == '2024-06-14'){ 1011 corrida = 'anulada'; 1012 icon = 'fas fa fa-circle-exclamation text-white'; 1013 } 1014 1015 if(fechaCarrera == '2024-06-21' && position >= 12){ 1016 corrida = 'anulada'; 1017 icon = 'fas fa fa-circle-exclamation text-white'; 1018 time = 'Suspendida' 1019 1020 } 1021 1022 html.append($('<a href="' + url + '">' + 1023 '<div class="ball-date font-23 thin ' + corrida + ' ' + selected + '"' + 1024 ' <span class="ball-date-day-number d-block">' + fecha_carrera.format('DD') + '</span>\n' + 1025 ' <span class="ball-date-day-name black uppercase font-15" style="line-height: .7">' + fecha_carrera.format('ddd') + '</span>\n' + 1026 '</div>' + 1027 '</a>')); 1028 1029 }); 1030 1031 let owl = $('#owl-jornadas'); 1032 1033 // Posiciona el carrusel en la jornada activa para que quede visible (sin 1034 // forzar el centro; si es la ultima del mes queda visible como ultima, 1035 // Owl clampea el scroll con loop:false). 1036 // El indice se toma del ball ya renderizado con .active y NO de 1037 // dates.findIndex, porque el codigo previo corrompe dates[0].fecha_reunion 1038 // (hay un assignment 'd.fecha_reunion = fecha' en la linea de 'carrera'). 1039 let jornadaBalls = $('#owl-jornadas .ball-date'); 1040 let activeIndex = jornadaBalls.index(jornadaBalls.filter('.active')); 1041 1042 owl.owlCarousel({ 1043 loop: false, 1044 margin: 10, 1045 autoWidth: true, 1046 nav: false, 1047 stagePadding: 50, 1048 startPosition: activeIndex > -1 ? activeIndex : 0, 1049 }); 1050 1051 $('.owl-jornadas .owl-next').click(function () { 1052 owl.trigger('next.owl.carousel'); 1053 }); 1054 1055 $('.owl-jornadas .owl-prev').click(function () { 1056 owl.trigger('prev.owl.carousel', [300]); 1057 }) 1058}
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.