186
| <![CDATA[<script type="text/javascript">
var WildfireInscricao = {
form: null,
formLogin: null,
formRecupera: null,
formAcompanhantes: null,
formUser: null,
formTransferencia: null,
paisSelect: null,
estadoSelect: null,
municipioSelect: null,
hash: null,
init: function () {
this.loadSteps();
this.loadSelect2();
this.loadLoginValidate();
this.loadRecuperaValidate();
this.loadAcompanhanteValidate();
this.loadUserValidate();
this.loadTransferenciaValidate();
this.setChange();
this.setClickEvents();
this.validateCPF();
this.validateCPFAcompanhante();
this.mascaras();
this.validateDn();
this.resumoShow();
},
setChange: function() {
this.paisSelect.on('change',function () {
let obj = jQuery(this);
let pais = obj.val();
let valor = jQuery('#pais option:selected').data('valor');
let texto = jQuery('#pais option:selected').html();
jQuery(".pais-label").html(texto);
jQuery('.valor-pais').html(valor);
if(pais === 'BR'){
jQuery('.passaporte-container').hide();
jQuery('.zipcode-container').hide();
jQuery('.estado-container').show();
jQuery('.cidade-container').show();
jQuery('.cpf-container').show();
jQuery('.cep-container').show();
}else{
jQuery('.passaporte-container').show();
jQuery('.estado-container').hide();
jQuery('.cidade-container').hide();
jQuery('.cpf-container').hide();
jQuery('.cep-container').hide();
jQuery('.zipcode-container').show();
}
});
this.estadoSelect.on('change',function () {
let obj = jQuery(this);
let uf = obj.val();
WildfireInscricao.loadMunicipiosAjax(uf);
});
},
loadMunicipiosAjax: function(vuf){
jQuery.get( "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=getMunicipios&format=json",{uf: vuf}, function(r) {
WildfireInscricao.municipioSelect.html('');
var newOption = new Option('Selecione a cidade', '', false, false);
WildfireInscricao.municipioSelect.append(newOption).trigger('change');
jQuery.each(r.data, function (index, obj) {
var newOption = new Option(obj.nome_municipio, obj.muncod, false, false);
WildfireInscricao.municipioSelect.append(newOption);
});
WildfireInscricao.municipioSelect.trigger('change');
})
.done(function() {
})
.fail(function() {
alert( "error" );
})
.always(function() {
});
},
loadSelect2: function(){
this.paisSelect = jQuery('#pais');
this.paisSelect.select2({
width: '280'
});
this.estadoSelect = jQuery('#estado');
this.estadoSelect.select2();
this.municipioSelect = jQuery('#cidade');
this.municipioSelect.select2();
},
loadSteps: function () {
this.form = jQuery("#form-inscricao");
this.form.validate({
errorPlacement: function(error, element) {
if (element.attr("name") == "concordo" ) {
error.insertAfter("#label-concordo");
}else if (element.attr("name") == "aceite_divulgacao" ) {
error.insertAfter("#label-nao-aceitedivulgacao");
}else if(element.attr("name") == "pais"){
error.insertAfter("#select-pais");
} else if(element.attr("name") == "genero"){
error.insertAfter("#genero");
} else if(element.attr("name") == "possui_resumo"){
error.insertAfter("#possui_resumo");
} else if(element.attr("name") == "estado"){
error.insertAfter("#select-estado");
} else if(element.attr("name") == "cidade"){
error.insertAfter("#select-cidade");
} else {
error.insertAfter(element);
}
},
rules: {
confirm: {
equalTo: "#senha",
minlength: 4
},
senha:{
minlength: 4
},
email: {
email: true
}
}
});
this.form.children("div").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
forceMoveForward: false,
enableAllSteps: false,
labels: {
cancel: "Cancelar",
current: "Etapa atual",
pagination: "Paginação",
finish: "Finalizar",
next: "Avançar",
previous: "Voltar",
loading: "Carregando..."
},
onStepChanging: function (event, currentIndex, newIndex)
{
let arrValues = jQuery('#form-inscricao').serializeArray();
jQuery.each(arrValues, function (index, obj) {
let valor = obj.value
if(obj.name === "estado" || obj.name === "cidade"){
valor = jQuery("#"+obj.name+" option:selected").html();
}
if(obj.name === "genero"){
valor = jQuery("input[name=genero]:checked").data('genero')
}
if(obj.name === "possui_resumo"){
valor = jQuery("input[name=possui_resumo]:checked").data('possui_resumo')
}
if(obj.name === "ids_resumos"){
var ids = valor;
if(ids == "" || jQuery("input[type='radio'][id='aprovado-nao']").is(':checked') == true){
jQuery(".ids_resumos-container").hide();
}else{
jQuery(".ids_resumos-container").show();
jQuery('#text-input-'+obj.name).html(valor);
}
}
if(obj.name === "datanascimento"){
var datanascimento = valor;
var arrDataNascimento = datanascimento.split('-');
var stringFormatada = arrDataNascimento[2] + '/' + arrDataNascimento[1] + '/' + arrDataNascimento[0];
jQuery('#text-input-'+obj.name).html(stringFormatada);
}else{
jQuery('#text-input-'+obj.name).html(valor);
}
});
WildfireInscricao.form.validate().settings.ignore = ":disabled,:hidden";
return WildfireInscricao.form.valid();
},
onFinishing: function (event, currentIndex)
{
WildfireInscricao.form.validate().settings.ignore = ":disabled,:hidden";
return WildfireInscricao.form.valid();
},
onFinished: function (event, currentIndex)
{
let arrValues = jQuery('#form-inscricao').serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=save&format=json",
data: arrValues,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-inscricao").html(response.message).show();
jQuery(".wizard .steps ul li.last").removeClass('done');
}else{
jQuery("#form-inscricao").hide();
WildfireInscricao.hash = response.data.hash;
WildfireInscricao.showUserInfo();
}
},
error: function () {
console.log("something went wrong steps");
return false;
}
});
return false;
}
});
},
loadLoginValidate: function(){
this.formLogin = jQuery("#form-login-inscricao");
this.formLogin.validate({
errorPlacement: function(error, element) {
error.insertAfter(element);
},
rules: {
email: {
email: true
}
}
});
},
loadRecuperaValidate: function(){
this.formRecupera = jQuery("#form-esquecisenha-inscricao");
this.formRecupera.validate({
errorPlacement: function(error, element) {
error.insertBefore('.recupera-senha');
},
rules: {
email: {
email: true
}
}
});
},
loadAcompanhanteValidate: function(){
this.formAcompanhantes = jQuery("#form-acompanhante-inscricao");
this.formAcompanhantes.validate({
errorPlacement: function(error, element) {
error.insertAfter(element);
},
rules: {
field: {
required: true
}
}
});
},
loadUserValidate: function(){
this.formUser = jQuery("#form-user-inscricao");
this.formUser.validate({
errorPlacement: function(error, element) {
error.insertAfter(element);
},
rules: {
}
});
},
loadTransferenciaValidate: function(){
this.formTransferencia = jQuery("#form-tranferencia-inscricao");
this.formTransferencia.validate({
errorPlacement: function(error, element) {
error.insertBefore('.transferencia-inscricao-label');
},
rules: {
}
});
},
setClickEvents: function () {
jQuery("#btn-voltar-inscricao").click(function () {
jQuery("#form-inscricao").show();
jQuery("#form-login-inscricao").hide();
return false;
});
jQuery("#btn-voltar-recupera-inscricao").click(function () {
jQuery("#form-login-inscricao").show();
jQuery("#form-esquecisenha-inscricao").hide();
return false;
});
jQuery("#btn-login-inscricao").click(function () {
let valid = WildfireInscricao.formLogin.valid();
if(valid){
WildfireInscricao.login();
}
return false;
});
jQuery("#btn-login-recupera-inscricao").click(function () {
let valid = WildfireInscricao.formRecupera.valid();
if(valid){
WildfireInscricao.recuperarSenha();
}
return false;
});
jQuery("#btn-save-extra").click(function () {
let valid = WildfireInscricao.formUser.valid();
if(valid){
WildfireInscricao.saveExtra();
}
jQuery("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
jQuery("#btn-transferir").click(function () {
jQuery('#form-tranferencia-inscricao').show();
jQuery("#form-user-inscricao").hide();
return false;
});
jQuery("#btn-acompanhantes").click(function () {
jQuery('#form-acompanhante-inscricao').show();
jQuery("#form-user-inscricao").hide();
return false;
});
jQuery("#btn-acompanhantes-voltar").click(function () {
jQuery('#form-acompanhante-inscricao').hide();
jQuery("#form-user-inscricao").show();
return false;
});
jQuery("#btn-salvar-acompanhantes").click(function () {
let valid = WildfireInscricao.formAcompanhantes.valid();
if(valid){
WildfireInscricao.saveAcompanhantes();
}
jQuery("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
jQuery("#btn-voltar-transferencia").click(function () {
jQuery('#form-tranferencia-inscricao').hide();
jQuery("#form-user-inscricao").show();
return false;
});
jQuery("#btn-consultar").click(function () {
jQuery("#id-inscricao").val('');
WildfireInscricao.checkNumInscricao();
return false;
});
jQuery("#btn-transferencia").click(function () {
WildfireInscricao.transferir();
return false;
});
jQuery("#btn-gru").click(function () {
WildfireInscricao.gerarGru();
return false;
});
jQuery("#btn-certificados").click(function () {
jQuery('#form-certificados').show();
jQuery("#form-user-inscricao").hide();
return false;
});
jQuery("#btn-certificados-voltar").click(function () {
jQuery('#form-certificados').hide();
jQuery("#form-user-inscricao").show();
return false;
});
jQuery(document).delegate("#printModal1", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert1").html());
jQuery(".imprimirModal").printThis();
return false;
});
jQuery(document).delegate("#printModal2", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert2").html());
jQuery(".imprimirModal").printThis();
return false;
});
jQuery(document).delegate("#printModal3", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert3").html());
jQuery(".imprimirModal").printThis();
return false;
});
jQuery(document).delegate("#printModal4", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert4").html());
jQuery(".imprimirModal").printThis();
return false;
});
jQuery(document).delegate("#printModal5", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert5").html());
jQuery(".imprimirModal").printThis();
return false;
});
jQuery(document).delegate("#printModal6", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert6").html());
jQuery(".imprimirModal").printThis();
return false;
});
jQuery(document).delegate("#printModal7", "click", function (event) {
jQuery(".imprimirModal").html(jQuery("#cert7").html());
jQuery(".imprimirModal").printThis();
return false;
});
},
openLogin: function(){
jQuery("#form-inscricao").hide();
jQuery("#form-login-inscricao").show();
},
openRecupera: function(){
jQuery("#form-login-inscricao").hide();
jQuery("#form-esquecisenha-inscricao").show();
},
recuperarSenha: function () {
let formSerialize = jQuery("#form-esquecisenha-inscricao").serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=recupera&format=json",
data: formSerialize,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-recupera-inscricao").html(response.message).show();
}else{
jQuery("#form-esquecisenha-inscricao").hide();
jQuery("#form-login-inscricao").show();
jQuery("#successo-recupera-inscricao").html(response.data.msg).show();
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
},
login: function () {
let formSerialize = jQuery("#form-login-inscricao").serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=login&format=json",
data: formSerialize,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-login-inscricao").html(response.message).show();
}else{
jQuery("#form-login-inscricao").hide();
WildfireInscricao.hash = response.data.hash;
WildfireInscricao.showUserInfo();
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
},
saveExtra: function () {
let formSerialize = jQuery("#form-user-inscricao").serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=saveExtra&format=json",
data: formSerialize,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-user-inscricao").html(response.message).show();
}else{
jQuery("#success-user-inscricao").html(response.data.msg).show();
jQuery("#form-user-inscricao input[name=idei]").val(response.data.id);
if(response.data.atividades !== null){
jQuery.each(response.data.atividades, function (index, obj) {
if(parseInt(obj.total) >= parseInt(obj.numvagas)){
jQuery("#form-user-inscricao input[name=atividadecampo][value=" + obj.id + "]").prop('disabled', true);
}
})
}
if(response.data.atividadespos !== null){
jQuery.each(response.data.atividadespos, function (index, obj) {
if(parseInt(obj.total) >= parseInt(obj.numvagas)){
jQuery("#form-user-inscricao input[name=atividadecampopos][value=" + obj.id + "]").prop('disabled', true);
}
})
}
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
},
saveAcompanhantes: function () {
let formSerialize = jQuery("#form-acompanhante-inscricao").serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=saveAcompanhantes&format=json",
data: formSerialize,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-acompanhante-inscricao").html(response.message).show();
}else{
jQuery("#sucesso-acompanhante-inscricao").html(response.data).show();
}
},
error: function () {
console.log("something went wrong save acompanhante");
return false;
}
});
},
showUserInfo: function () {
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=getUser&format=json",
data: {hash: WildfireInscricao.hash},
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#form-login-inscricao").show();
}else {
jQuery(".cpfPassaporte").removeClass("cpf");
jQuery("#form-user-inscricao").show();
jQuery("#user-boas-vindas").html(response.data.user.nome + ' ' + response.data.user.sobrenome);
jQuery("#user-inscricao").html(response.data.user.id);
jQuery("#num-inscricao").val(response.data.user.id);
jQuery("#form-user-inscricao input[name=id]").val(response.data.user.id);
jQuery("#user-situacao").html(response.data.user.situacao);
jQuery("#pais-usuario-transferencia").val(response.data.user.id_pais);
if (response.data.user.id_pais === 'BR') {
jQuery("#gerar-gru").show();
jQuery('.telefone').focusout(function () {
var phone, element;
element = jQuery(this);
element.unmask();
phone = element.val().replace(/\D/g, '');
if (phone.length > 12) {
element.mask("+99 (99) 99999-9999");
} else {
element.mask("+99 (99) 9999-9999?9");
}
}).trigger('focusout');
jQuery(".cpfPassaporte").addClass("cpf");
jQuery(".cpf").mask("999.999.999-99");
jQuery('.passaporte-container-acompanhante').hide();
jQuery('.cpf-container-acompanhante').show();
} else {
jQuery(".cpfPassaporte").removeClass("cpf");
jQuery("#cpf-acompanhante1").removeClass("cpfPassaporte");
jQuery("#cpf-acompanhante2").removeClass("cpfPassaporte");
jQuery("#cpf-acompanhante3").removeClass("cpfPassaporte");
jQuery("#pagamento-texto").show();
jQuery('.passaporte-container-acompanhante').show();
jQuery('.cpf-container-acompanhante').hide();
}
if (response.data.acompanhantes !== null) {
jQuery.each(response.data.acompanhantes, function (index, obj) {
if (index == 0) {
jQuery("#nome-acompanhante1").val(obj.nome);
jQuery("#sobrenome-acompanhante1").val(obj.sobrenome);
jQuery("#genero-acompanhante1").val(obj.genero);
jQuery("#form-acompanhante-inscricao input[name=genero1][value=" + obj.genero + "]").prop('checked', true);
jQuery("#nascimento-acompanhante1").val(obj.data_nascimento);
jQuery("#telefone-acompanhante1").val(obj.telefone);
jQuery("#email-acompanhante1").val(obj.email);
jQuery("#cpf-acompanhante1").val(obj.cpf);
} else if (index == 1) {
jQuery("#nome-acompanhante2").val(obj.nome);
jQuery("#sobrenome-acompanhante2").val(obj.sobrenome);
jQuery("#genero-acompanhante2").val(obj.genero);
jQuery("#form-acompanhante-inscricao input[name=genero2][value=" + obj.genero + "]").prop('checked', true);
jQuery("#nascimento-acompanhante2").val(obj.data_nascimento);
jQuery("#telefone-acompanhante2").val(obj.telefone);
jQuery("#email-acompanhante2").val(obj.email);
jQuery("#cpf-acompanhante2").val(obj.cpf);
} else if (index == 2) {
jQuery("#nome-acompanhante3").val(obj.nome);
jQuery("#sobrenome-acompanhante3").val(obj.sobrenome);
jQuery("#genero-acompanhante3").val(obj.genero);
jQuery("#form-acompanhante-inscricao input[name=genero3][value=" + obj.genero + "]").prop('checked', true);
jQuery("#nascimento-acompanhante3").val(obj.data_nascimento);
jQuery("#telefone-acompanhante3").val(obj.telefone);
jQuery("#email-acompanhante3").val(obj.email);
jQuery("#cpf-acompanhante3").val(obj.cpf);
}
})
}
if (response.data.certificados.length == 0) {
jQuery("#btn-certificados").hide();
} else {
jQuery.each(response.data.certificados, function (index, obj) {
let nomeCompleto = response.data.user.nome + ' ' + response.data.user.sobrenome;
let descricaoCertificado = obj.descricao;
let conteudoCertificado = obj.modelo.replace("#NOME#", nomeCompleto);
conteudoCertificado = conteudoCertificado.replace("#DESCRICAO#", descricaoCertificado);
jQuery("#btns-emissao").append('<button class="btn btn-default" type="button" data-toggle="modal" id="printModal' + obj.id + '" value="#cert' + obj.id + '">' + obj.tipo + '</button>');
let modal = '<div id="cert' + obj.id + '">';
modal += conteudoCertificado;
modal += '</div>';
jQuery("#modais").append(modal);
});
}
if (response.data.extra !== null) {
jQuery("#form-user-inscricao input[name=idei]").val(response.data.extra.id);
jQuery("#form-user-inscricao input[name=atividadecampo][value=" + response.data.extra.id_atividade_campo + "]").prop('checked', true);
jQuery("#form-user-inscricao input[name=atividadecampopos][value=" + response.data.extra.id_atividade_campo_pos + "]").prop('checked', true);
jQuery("#form-user-inscricao input[name=corrida][value=" + response.data.extra.corrida + "]").prop('checked', true);
jQuery("#form-user-inscricao input[name=jantar][value=" + response.data.extra.jantar + "]").prop('checked', true);
}
if (response.data.atividades !== null) {
jQuery.each(response.data.atividades, function (index, obj) {
if (parseInt(obj.total) >= parseInt(obj.numvagas)) {
jQuery("#form-user-inscricao input[name=atividadecampo][value=" + obj.id + "]").prop('disabled', true);
}
})
}
if (response.data.atividadespos !== null) {
jQuery.each(response.data.atividadespos, function (index, obj) {
if (parseInt(obj.total) >= parseInt(obj.numvagas)) {
jQuery("#form-user-inscricao input[name=atividadecampopos][value=" + obj.id + "]").prop('disabled', true);
}
})
}
if(response.data.user.pago == 1){
jQuery('.user-show-pago').show();
jQuery('#pagamento-efetuado').show();
jQuery('#pagamento-pendente').hide();
jQuery("#gerar-gru").hide();
jQuery("#pagamento-texto").hide();
}
if(response.data.user.id_situacao != 1){
jQuery('.user-hide-inativo').hide();
jQuery('#btn-transferir').hide();
jQuery('#btn-save-extra').hide();
}
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
},
checkNumInscricao: function () {
let valid = WildfireInscricao.formTransferencia.valid();
if(valid){
let data = this.formTransferencia.serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=checkNumInscricao&format=json",
data: data+'&hash='+WildfireInscricao.hash,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-transferencia-inscricao").html(response.message).show();
jQuery("#field-set-confirmacao").hide();
jQuery("#btn-transferencia").hide();
jQuery("#id-inscricao").val('');
}else{
jQuery("#error-transferencia-inscricao").hide();
jQuery("#btn-transferencia").show();
jQuery("#field-set-confirmacao").show();
jQuery("#nome-transferencia").html(response.data.nome +' '+response.data.sobrenome);
jQuery("#pais-transferencia").html(response.data.nome_pais_pt); jQuery("#instituicao-transferencia").html(response.data.instituicao);
jQuery("#id-inscricao").val(response.data.id);
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
}
},
transferir: function () {
let data = this.formTransferencia.serialize();
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=transferir&format=json",
data: data+'&hash='+WildfireInscricao.hash,
method: "POST",
success: function (response) {
if(response.success === false){
jQuery("#error-transferencia-inscricao").html(response.message).show();
jQuery("#field-set-confirmacao").hide();
}else{
jQuery("#success-user-transferencia").html(response.data.msg).show();
jQuery("#form-tranferencia-inscricao").hide();
jQuery("#form-user-inscricao").hide();
jQuery("#form-inscricao").show();
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
},
gerarGru: function () {
jQuery.ajax({
url: "http://ibama.gov.br/index.php?option=com_ajax&module=wildfireinscricao&method=gerarGru&format=json",
data: {hash: WildfireInscricao.hash},
method: "POST",
success: function (response) {
if(response.status === false){
jQuery("#error-user-inscricao").html(response.message).show();
}else{
if(response.data.status === true){
jQuery("#success-user-inscricao").html(response.data.mensagem).show();
jQuery("#error-user-inscricao").hide();
var win = window.open(response.data.url, '_blank');
if (win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Browser has blocked it
alert('Habilite os popups do seu navegador');
}
}else{
jQuery("#error-user-inscricao").html(response.data.mensagem).show();
jQuery("#success-user-inscricao").hide();
}
}
},
error: function () {
console.log("something went wrong login");
return false;
}
});
},
validateCPF: function(){
jQuery( ".cpf" ).change(function() {
jQuery("#error-cpf").hide();
var Soma;
var Resto;
var cpf = jQuery( ".cpf" ).val();
cpf = cpf.replace(/[^\d]+/g,'');
Soma = 0;
if (cpf == "00000000000") return jQuery("#error-cpf").html('CPF inválido').show();
for (i=1; i<=9; i++) Soma = Soma + parseInt(cpf.substring(i-1, i)) * (11 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(cpf.substring(9, 10)) ) return jQuery("#error-cpf").html('CPF inválido').show();
Soma = 0;
for (i = 1; i <= 10; i++) Soma = Soma + parseInt(cpf.substring(i-1, i)) * (12 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(cpf.substring(10, 11) ) ) return jQuery("#error-cpf").html('CPF inválido').show();
return true;
});
},
validateCPFAcompanhante: function(){
jQuery( ".cpfPassaporte" ).change(function() {
jQuery("#error-cpf-acompanhante").hide();
var Soma;
var Resto;
var cpf = jQuery( ".cpfPassaporte" ).val();
cpf = cpf.replace(/[^\d]+/g,'');
Soma = 0;
if (cpf == "00000000000") return jQuery("#error-cpf-acompanhante").html('CPF inválido').show();
for (i=1; i<=9; i++) Soma = Soma + parseInt(cpf.substring(i-1, i)) * (11 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(cpf.substring(9, 10)) ) return jQuery("#error-cpf-acompanhante").html('CPF inválido').show();
Soma = 0;
for (i = 1; i <= 10; i++) Soma = Soma + parseInt(cpf.substring(i-1, i)) * (12 - i);
Resto = (Soma * 10) % 11;
if ((Resto == 10) || (Resto == 11)) Resto = 0;
if (Resto != parseInt(cpf.substring(10, 11) ) ) return jQuery("#error-cpf-acompanhante").html('CPF inválido').show();
return true;
});
},
mascaras: function () {
jQuery("#pais").change(function () {
pais = jQuery( "#pais" ).val();
if(pais === 'BR'){
jQuery('.telefone').focusout(function(){
var phone, element;
element = jQuery(this);
element.unmask();
phone = element.val().replace(/\D/g, '');
if(phone.length > 12) {
element.mask("+99 (99) 99999-9999");
} else {
element.mask("+99 (99) 9999-9999?9");
}
}).trigger('focusout');
jQuery(".cpf").mask("999.999.999-99");
}
});
},
validateDn: function () {
jQuery( document ).ready(function() {
jQuery( "#datanascimento" ).change(function() {
jQuery("#error-nascimento").hide();
let nascimento = jQuery( "#datanascimento" ).val();
let dataAtual= new Date();
let data= new Date(nascimento);
if (data > dataAtual){
return jQuery("#error-nascimento").html('Data de nascimento inválida').show();
}
return true;
});
});
},
resumoShow: function () {
jQuery( document ).ready(function() {
jQuery('input[type="radio"]').click(function() {
if(jQuery(this).attr('id') == 'aprovado-sim') {
jQuery('.idsresumos-container').show();
}
else {
jQuery('.idsresumos-container').hide();
}
});
});
}
}
jQuery(function () {
WildfireInscricao.init();
});
</script>]]>
|