// JavaScript Document var opciones = []; opciones.push([91,'Absoluta','1900-01-01','2008-12-31',1,'']); opciones.push([90,'Chupetines','2020-01-01','2022-12-31',1,'']); opciones.push([89,'Categoría A','2017-01-01','2019-12-31',1,'']); opciones.push([92,'Categoría B','2014-01-01','2016-12-31',1,'']); opciones.push([93,'Categoría C','2011-01-01','2013-12-31',1,'']); opciones.push([94,'Categoría D','2009-01-01','2010-12-31',1,'']); function gsports_includes() { gsports_includeLibreria('https://sports.gormatica.com/css/estilov2.css','css',null); gsports_init(); } function gsports_init() { $(document).ready(function(e) { if ($("#gsports_inscripciones").length) { $("#gsports_inscripciones").html("
"); gsports_pruebas(); } if ($("#gsports_clasificacion").length) gsports_clasificacion(0,0); if ($("#gsports_inscritos").length) gsports_inscritos(0,0); }); // Numeric only control handler jQuery.fn.gsports_solodni = function() { return this.each(function() { $(this).keydown(function(e) { var key = e.charCode || e.keyCode || 0; return ( key == 8 || //BORRAR key == 9 || //TABULADOR key == 17 || //CONTROL key == 67 || //c CTRL+C key == 86 || //v CTRL+V key == 88 || //x CTRL+X key == 110 || (key >= 36 && key <= 40) || // CURSORES (key >= 48 && key <= 57) || (key >= 65 && key <= 90) || (key >= 96 && key <= 105) ); }); }); }; } function gsports_agregarCorredor() { $.ajax( "https://sports.gormatica.com/api/inscripcion.php", { type: 'POST', cache:false, data : $("#gsports_forminscripcion").serialize()} ) .done(function(html) { $("#gsports_inscripciones").html( html ); }) .fail(function() { alert( "error 432324 enviando datos" ); }) } function gsports_clasificacion(edicion, prueba) { $.ajax( "https://sports.gormatica.com/api/clasificacion.php?gs_carrera=4&gs_edicion="+edicion+"&gs_prueba="+prueba, { dataType: "html", cache: false } ) .done ( function (html) { $("#gsports_clasificacion").html( html ); } ); } function gsports_finalizar(url) { window.location.href=url; } function gsports_inscritos(edicion, prueba) { $.ajax( "https://sports.gormatica.com/api/inscritos.php?gs_carrera=4&gs_edicion="+edicion+"&gs_prueba="+prueba, { dataType: "html", cache: false } ) .done ( function (html) { $("#gsports_inscritos").html( html ); } ); } function gsports_chequea() { var soymenor = false; var prueba = $("#gs_prueba").val(); $("#btnenviar").attr("disabled", "disabled"); if ($("input[name=u_sexo]:checked").val()!="M" && $("input[name=u_sexo]:checked").val()!="F") gsports_ponERROR("sexo"); else gsports_ponOK("sexo"); if ($("#u_nombre").val().length <3) gsports_ponERROR("nombre"); else gsports_ponOK("nombre"); if ($("#u_apellidos").val().length <=3) gsports_ponERROR("apellidos"); else gsports_ponOK("apellidos"); if ($("#u_poblacion").val().length <=3) gsports_ponERROR("poblacion"); else gsports_ponOK("poblacion"); if ($("#u_telefono").val().length <9 || !$("#u_telefono").val().match('^(0|[1-9][0-9]*)$')) { $("#gs_info_telefono").css("display", ""); gsports_ponERROR("telefono"); } else { $("#gs_info_telefono").css("display", "none"); gsports_ponOK("telefono"); } if ($("#u_correo").val().length>6) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if(emailReg.test( $("#u_correo").val() )) gsports_ponOK("correo"); else gsports_ponERROR("correo"); } else gsports_ponERROR("correo"); if ($("#dia").val() && $("#mes").val() && $("#ano").val()) { gsports_ponOK("ano"); nacimiento = $("#ano").val()+"-"+$("#mes").val()+"-"+$("#dia").val(); var autorizacion = ""; var primero; var puedecorrer = false; soymenor = nacimiento > "2005-12-24"; $.each (opciones, function (clave, valor) { if (valor[0] == prueba) { if (nacimiento >= valor[2] && nacimiento <= valor[3]) { puedecorrer = true; autorizacion = valor[5]; } } }); if (!puedecorrer) { gsports_ponERROR("ano"); $("#gs_aviso_edad").addClass("gs_error"); $("#gs_aviso_edad").html("Lo sentimos, no se permite la participación en la carrera seleccionada a participantes con la edad que has introducido."); } else if (autorizacion && soymenor) { $("#gs_aviso_edad").removeClass("gs_error").addClass("gs_info"); $("#gs_aviso_edad").html("Los menores de 18 años deben presentar una autorización firmada por el padre, madre o tutor que puedes DESCARGAR AQUÍ y entregarla antes de la salida."); } else { $("#gs_aviso_edad").removeClass("gs_error").removeClass("gs_info").html(""); } } if (!soymenor && !gsports_nif($("#u_dni").val())) gsports_ponERROR("dni"); else gsports_ponOK("dni"); if (soymenor) { $("#av-dni").html(""); $("#u_dni").attr("placeholder", "Opcional"); } else { $("#dni").removeAttr("placeholder"); } if ($("input[name=reserva]").is(":checked")) { if ($("input[name=reserva]:checked").val()==1) { $("#span_reservas").css("display", "inline"); /* if ($("#u_reservas").val()=="" ) gsports_ponERROR("reserva"); else */ gsports_ponOK("reserva"); } else { $("#u_reservas").val(""); $("#span_reservas").css("display", "none"); gsports_ponOK("reserva"); } } else gsports_ponERROR("reserva"); if ($("#u_talla").val()) gsports_ponOK("talla"); else gsports_ponERROR("talla"); if ($("#recogida").val()>=0) gsports_ponOK("dorsal"); else gsports_ponERROR("dorsal"); if ($("#aceptacion").prop("checked") && !$(".aviso2").hasClass("error")) $("#btnenviar").removeAttr("disabled"); else $("#btnenviar").attr("disabled", "disabled"); } function gsports_comprobarCodigo() { $.ajax( "https://sports.gormatica.com/api/checkCodigo.php?dni="+$("#u_dni").val()+"&correo="+$("#u_correo").val()+"&codigo="+$("#codigo").val()+"", { dataType: "json", cache: false } ) .done ( function (salida) { if (salida.ok) { $("#gs_usuario").val(salida.usuario); $("#gs_seg").val(salida.seg); gsports_enviar(); } else { $("#resultadoCodigo").html("El código introducido no es correcto. Si tienes problemas con la inscripción, puedes contactar con nosotros a través de Whatsapp o del teléfono en el número 650564622."); gsports_ponERROR("codigo"); } }); } function gsports_comprobarDNI() { var dni = $("#u_dni").val(); var correo = $("#u_correo").val(); $.ajax( "https://sports.gormatica.com/api/checkDNI.php?carrera=4&edicion=2023&dni="+dni+"&correo="+correo+"", { dataType: "html", cache: false } ) .done ( function (html) { if (html != "") { //$("#dni").prop("readonly", true); //$("#correo").prop("readonly", true); $("#gsports_comprobarExiste").replaceWith(html); $("#codigo").keyup(function(e) { if ($("#codigo").val().length == 4) { $("#btnenviar").html('Continuar '); gsports_ponOK("codigo"); $("#btnenviar").removeAttr("disabled"); } else { gsports_ponERROR("codigo"); $("#btnenviar").attr("disabled", "disabled"); } }); } }); } function gsports_comprobarMenor() { if ($("#menor").prop("checked")) { $("#av-dni").html(""); $("#u_dni").attr("placeholder", "Opcional"); } else { $("#av-dni").html(""); $("#dni").removeAttr("placeholder"); } $("#u_dni").keyup(); } function gsports_eliminar(corredor, seg,c) { if (confirm("¿Seguro que quieres eliminar este participante de la inscripción?")) { $.ajax( "https://sports.gormatica.com/api/eliminar.php?corredor="+corredor+"&seg="+seg, { dataType: "json", cache: false } ) .done(function(salida) { if (salida.ok) { gsports_resumen(c); } else { alert("ERROR INESPERADO - No se pudo eliminar el corredor"); } }) .fail(function() { alert( "error 23423 enviando datos" ); }) } } function gsports_finalizar(url) { window.location.href=url; } function gsports_enviar() { $.ajax( "https://sports.gormatica.com/api/inscripcion.php", { type: 'POST', cache:false, data : $("#gsports_forminscripcion").serialize()} ) .done(function(html) { $("#gsports_inscripciones").html( html ); if ($("#gsports_forminscripcion").length) { //$("#dni").gsports_solodni(); gsports_chequea(); $("#gsports_forminscripcion :input").change(gsports_chequea); } }) .fail(function() { alert( "error 432324 enviando datos" ); }) } function gsports_includeLibreria(ruta,tipo,callbackFunc){ var head = document.getElementsByTagName('head')[0]; if(tipo=='js') { var se1 = document.createElement('script'); se1.src = ruta; if(callbackFunc!=null) se1.onload=callbackFunc; head.appendChild(se1); } if(tipo=='css') { var cssNode_jquery = document.createElement('link'); cssNode_jquery.type = 'text/css'; cssNode_jquery.rel = 'stylesheet'; cssNode_jquery.href = ruta; cssNode_jquery.media = 'screen'; head.appendChild(cssNode_jquery); } if(tipo=='div') { var nombre=ruta; iCl('body').append(''); } } function gsports_nif(value){ var validChars = 'TRWAGMYFPDXBNJZSQVHLCKET'; var nifRexp = /^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKET]{1}$/i; var nieRexp = /^[XYZ]{1}[0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKET]{1}$/i; var str = value.toString().toUpperCase(); if (!nifRexp.test(str) && !nieRexp.test(str)) return false; var nie = str .replace(/^[X]/, '0') .replace(/^[Y]/, '1') .replace(/^[Z]/, '2'); var letter = str.substr(-1); var charIndex = parseInt(nie.substr(0, 8)) % 23; if (validChars.charAt(charIndex) === letter) return true; return false; } function gsports_ponERROR(id){ $("#av-"+id).html(''); $("#av-"+id).addClass("error"); } function gsports_ponOK (id) { $("#av-"+id).html(''); $("#av-"+id).removeClass("error"); } function gsports_pruebas() { $("#gsports_inscripciones").load("https://sports.gormatica.com/api/inscripcion.php?pruebas&"+$("#gsports_forminscripcion").serialize(), { cache: false } ); } function gsports_resumen(c) { $("#gsports_inscripciones").load("https://sports.gormatica.com/api/inscripcion.php?gs_compra="+c+"&resumen=1&gs_carrera=4&gs_edicion=2023", { cache: false } ); } function gsports_usuario(prueba) { $.ajax( "https://sports.gormatica.com/api/inscripcion.php?usuario&gs_prueba="+prueba+"&"+$("#gsports_forminscripcion").serialize(), { dataType: "html", cache: false } ) .done ( function (html) { $("#gsports_inscripciones").html( html ); document.location = "#inscripcion"; //$("#dni").gsports_solodni(); $("#gsports_forminscripcion :input").keyup(function(e) { if (!$("#menor").prop("checked")&&!gsports_nif($("#u_dni").val())) gsports_ponERROR("dni"); else gsports_ponOK("dni"); if ($("#u_correo").val().length>6) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if(emailReg.test( $("#u_correo").val() )) gsports_ponOK("correo"); else gsports_ponERROR("correo"); } else gsports_ponERROR("correo"); if (!$(".aviso2").hasClass("error")) $("#btnenviar").removeAttr("disabled"); else $("#btnenviar").attr("disabled", "disabled"); }); } ) } gsports_includes();