1/* Formulario de Contato */ 2jQuery(document).ready(function(){ 3 jQuery('.form-contato').submit(function(){ 4 var nome = jQuery(this).find('[name="nome"]').val(); 5 var email = jQuery(this).find('[name="email"]').val(); 6 var telefone = jQuery(this).find('[name="telefone"]').val(); 7 var assunto = jQuery(this).find('[name="assunto"]').val(); 8 var mensagem = jQuery(this).find('[name="mensagem"]').val(); 9 if(nome.trim() === ''){ 10 jQuery(this).find('[name="nome"]').addClass('is-invalid'); 11 return false; 12 } else { 13 jQuery(this).find('[name="nome"]').removeClass('is-invalid'); 14 } 15 if(email.trim() === ''){ 16 jQuery(this).find('[name="email"]').addClass('is-invalid'); 17 return false; 18 } else { 19 jQuery(this).find('[name="email"]').removeClass('is-invalid'); 20 } 21 if(telefone.trim() === ''){ 22 jQuery(this).find('[name="telefone"]').addClass('is-invalid'); 23 return false; 24 } else { 25 jQuery(this).find('[name="telefone"]').removeClass('is-invalid'); 26 } 27 if(assunto.trim() === ''){
28 jQuery(this).find('[name="assunto"]').addClass('is-invalid'); 29 return false; 30 } else { 31 jQuery(this).find('[name="assunto"]').removeClass('is-invalid'); 32 } 33 if(mensagem.trim() === ''){ 34 jQuery(this).find('[name="mensagem"]').addClass('is-invalid'); 35 return false; 36 } else { 37 jQuery(this).find('[name="mensagem"]').removeClass('is-invalid'); 38 } 39 var dados = jQuery(this).serialize(); 40 var url_base = jQuery(this).find('[name="url"]').val(); 41 $(".btn-contato").attr("disabled", true); 42 $(".btn-contato").addClass('btn-loading'); 43 jQuery.ajax({ 44 type: "POST", 45 url: url_base + "funcao-contato", 46 data: dados, 47 success: function(data) { 48 if(data=='success'){ 49 Swal.fire({ 50 title: "Contato enviado com sucesso!", 51 text: "Agradecemos seu contato! Em breve, entraremos em contato!", 52 icon: "success" 53 }); 54 jQuery('.form-contato')[0].reset(); 55 $(".btn-contato").attr("disabled", false); 56 $(".btn-contato").removeClass('btn-loading'); 57 } else if(result[0]==2){ 58 erro(1); 59 } 60 } 61 }); 62 return false; 63 }); 64}); 65 66// Matricula 67function verificaMatricula(id, id_duracao, url_base, retorno, acao, destino, modulo) { 68 $.ajax({
69 type: "POST", 70 url: url_base + "funcao-prova", 71 data: { 72 id: id, 73 id_duracao: id_duracao, 74 retorno: retorno, 75 acao: acao, 76 destino: destino 77 }, 78 success: function(response) { 79 if (response === "1") { 80 window.location.href = url_base + "login/cadastro"; 81 } else if (response === "2") { 82 erro(1); 83 } else if (response === "3") { 84 Swal.fire({ 85 icon: "success", 86 text: "Você já possui uma matrÃcula neste curso.", 87 footer: '<a href="' + url_base + 'conta/meus-cursos">Ir para meus cursos.</a>' 88 }); 89 } else if (response === "4") { 90 Swal.fire({ 91 position: "center", 92 icon: "success", 93 title: "Matricula realizada com sucesso.", 94 showConfirmButton: false, 95 timer: 1500 96 }).then(() => { 97 window.location.href = url_base + "cursos/modulo/"+ destino +"/"+ modulo; 98 }); 99 } else if (response === "5") { 100 erro(1); 101 } 102 }, 103 error: function(error) { 104 console.error("Erro na requisição AJAX:", error); 105 } 106 }); 107} 108 109// Certificado 110function certificadoGratis(id_aluno, id_matricula, url_base, acao, curso) { 111 Swal.fire({ 112 text: "Você tem certeza que deseja emitir o certificado grátis do curso " + curso + " ?", 113 showDenyButton: true,
114 showCancelButton: false, 115 confirmButtonText: 'Sim', 116 denyButtonText: 'Não', 117 customClass: { 118 actions: 'my-actions', 119 cancelButton: 'order-1 right-gap', 120 confirmButton: 'order-2', 121 denyButton: 'order-3', 122 } 123 }).then((result) => { 124 if (result.isConfirmed) { 125 $.post(url_base + "funcao-prova", { 126 id_aluno: id_aluno, 127 id_matricula: id_matricula, 128 acao: acao 129 }, 130 function(data, status) { 131 result = data.split("|"); 132 if (result[0] === "1") { 133 location.reload(); 134 } else if (result[0] === "2") { 135 window.location.href = url_base + "conta/meus-certificados"; 136 //location.reload(); 137 //window.open(url_base + "certificado/download/" + result[1], '_blank'); 138 } else if (result[0] === "3") { 139 erro(1); 140 } 141 } 142 ); 143 144 } 145 }) 146} 147 148function downloadCertificadoGratis(codigo, url_base) { 149 window.location.href = url_base + "conta/meus-certificados"; 150 //window.open(url_base + "certificado/download/" + codigo + "/visualizar", '_blank'); 151} 152 153// Carrinho 154$(document).ready(function() { 155 jQuery('.form-carrinho').submit(function() { 156 var dados = jQuery(this).serialize(); 157 $(".btn-carrinho").attr("disabled", true); 158 $(".btn-carrinho").addClass('btn-loading'); 159 jQuery.ajax({ 160 type: "POST", 161 url: "../funcao-carrinho", 162 data: dados, 163 success: function(data) { 164 result = data.split("|"); 165 if (result[0] == 1) { 166 sucesso(1); 167 $(".btn-carrinho").attr("disabled", false); 168 $(".btn-carrinho").removeClass('btn-loading'); 169 } else if (result[0] == 2) { 170 erro(1); 171 $(".btn-carrinho").attr("disabled", false); 172 $(".btn-carrinho").removeClass('btn-loading'); 173 } else if (result[0] == 3) { 174 Swal.fire('Desculpe', 'O campo quantidade não pode ser menor que 1.', 'error'); 175 $(".btn-carrinho").attr("disabled", false); 176 $(".btn-carrinho").removeClass('btn-loading'); 177 } else if (result[0] == 4) { 178 location.reload(); 179 $(".btn-carrinho").attr("disabled", false); 180 $(".btn-carrinho").removeClass('btn-loading'); 181 } else if (result[0] == 5) { 182 Swal.fire('Desculpe', 'Este cupom não exite ou já encontra-se expirado.', 'error'); 183 $(".btn-carrinho").attr("disabled", false); 184 $(".btn-carrinho").removeClass('btn-loading'); 185 } 186 } 187 }); 188 return false; 189 }); 190 $(".selecionavel").on("click", function(event) { 191 var checkbox = $(this).find("input[type='checkbox']"); 192 if (!$(event.target).is('select') && !$(event.target).is('input[type="checkbox"]')) { 193 checkbox.prop("checked", !checkbox.prop("checked")); 194 calculaValor(checkbox); 195 } 196 }); 197 $('[id^="floatingSelect"]').on('change', function() { 198 var id_matricula = $(this).attr('id').replace('floatingSelect', ''); 199 var id_duracao = $(this).val(); 200 $.ajax({
201 type: 'POST', 202 url: '../funcao-carrinho', 203 data: { 204 id_matricula: id_matricula, 205 id_duracao: id_duracao, 206 acao: "YWx0ZXJhci1kdXJhY2Fv" 207 }, 208 success: function(response) { 209 location.reload(); 210 }, 211 error: function(error) { 212 console.log(error); 213 } 214 }); 215 }); 216 $("#meu-carrinho").submit(function(event) { 217 var cursosSelecionados = $(":checkbox:checked").not("#id_frete").length; 218 var freteSelecionado = $("#id_frete").is(":checked"); 219 220 if (cursosSelecionados === 0 || (cursosSelecionados === 0 && freteSelecionado)) { 221 Swal.fire({ 222 text: 'Selecione pelo menos um curso antes de continuar.', 223 icon: 'error' 224 }); 225 event.preventDefault(); 226 } 227 }); 228}); 229 230var total = 0.00; 231function calculaValor(checkbox) { 232 var valor = parseFloat($(checkbox).data('valor')); 233 if ($(checkbox).prop('checked')) { 234 total += valor; 235 } else { 236 total -= valor; 237 } 238 $(".valor").text("R$ " + total.toFixed(2).replace(".", ",")); 239 $(".valor_total").text("R$ " + total.toFixed(2).replace(".", ",")); 240} 241 242/*$(document).ready(function() { 243 $('#form-checkout__identificationNumber').addClass('cpf').mask('000.000.000-00', {reverse: true}); 244 $('#form-checkout__identificationType').change(function() { 245 var selectedOption = $(this).val(); 246 if (selectedOption === 'CNPJ') { 247 $('#form-checkout__identificationNumber').removeClass('cpf').addClass('cnpj').unmask().mask('00.000.000/0000-00', {reverse: true}); 248 } else { 249 $('#form-checkout__identificationNumber').removeClass('cnpj').addClass('cpf').unmask().mask('000.000.000-00', {reverse: true}); 250 } 251 }); 252 $('#form-checkout__identificationNumber').blur(function() { 253 if ($(this).hasClass('cpf')) { 254 validarCPF(this); 255 } else if ($(this).hasClass('cnpj')) { 256 validarCNPJ(this); 257 } 258 }); 259});*/ 260 261function excluirCupom() { 262 Swal.fire({ 263 title: "Deseja excluir este cupom?", 264 text: "de desconto?", 265 showDenyButton: true,
266 showCancelButton: false, 267 confirmButtonText: 'Sim', 268 denyButtonText: 'Não', 269 customClass: { 270 actions: 'my-actions', 271 cancelButton: 'order-1 right-gap', 272 confirmButton: 'order-2', 273 denyButton: 'order-3', 274 } 275 }).then((result) => { 276 if (result.isConfirmed) { 277 $.post("../funcoes", { 278 _metode: 'cmVtb3Zlci1jdXBvbQ==' 279 }, 280 function(data, status) { 281 location.reload(); 282 } 283 ); 284 285 } 286 }) 287} 288 289// Carrega Cursos Index 290let offset = 0; 291const limite = 12; 292 293function carregarCursos(tipo, id = null, titulo = null) { 294 $.ajax({ 295 url: '../carrega-curso', 296 method: 'POST', 297 data: { 298 tipo: tipo, 299 limite: limite, 300 offset: offset, 301 id: id, 302 titulo: titulo 303 }, 304 success: function(response) { 305 $('.row-cursos').append(response); 306 offset += limite; 307 if (response.trim() === '') { 308 $('#btn-carrega').hide(); 309 } 310 } 311 }); 312} 313 314/* Sair */ 315function sair(nome) { 316 Swal.fire({ 317 title: "Olá <strong>" + nome + "</strong>, você realmente deseja sair de sua conta?", 318 icon: 'warning', 319 showCancelButton: true, 320 confirmButtonText: 'Sim', 321 cancelButtonText: 'Cancelar' 322 }).then((result) => { 323 if (result.isConfirmed) { 324 location.href = '?fechar=sessao' 325 } 326 }); 327} 328 329function getEndereco() { 330 $(".form-horizontal").LoadingOverlay("show"); 331 if ($.trim($(".cep").val()) != "") { 332 $.ajax({
333 type: "GET", 334 url: "https://apps.widenet.com.br/busca-cep/api/cep.xml?code=" + $(".cep").val(), 335 dataType: "xml", 336 success: function(xml) { 337 $(xml).find('xml').each(function() { 338 $("input[name='endereco']").val($(this).find('address').text()); 339 $("input[name='bairro']").val($(this).find('district').text()); 340 $("input[name='cidade']").val($(this).find('city').text()); 341 switch ($(this).find('state').text()) { 342 case "AC": 343 $("select[name='id_estado']").val("1"); 344 break; 345 case "AL": 346 $("select[name='id_estado']").val("2"); 347 break; 348 case "AP": 349 $("select[name='id_estado']").val("3"); 350 break; 351 case "AM": 352 $("select[name='id_estado']").val("4"); 353 break; 354 case "BA": 355 $("select[name='id_estado']").val("5"); 356 break; 357 case "CE": 358 $("select[name='id_estado']").val("6"); 359 break; 360 case "ES": 361 $("select[name='id_estado']").val("7"); 362 break; 363 case "GO": 364 $("select[name='id_estado']").val("8"); 365 break; 366 case "MA": 367 $("select[name='id_estado']").val("9"); 368 break; 369 case "MT": 370 $("select[name='id_estado']").val("10"); 371 break; 372 case "MS": 373 $("select[name='id_estado']").val("11"); 374 break; 375 case "MG": 376 $("select[name='id_estado']").val("12"); 377 break; 378 case "PA": 379 $("select[name='id_estado']").val("13"); 380 break; 381 case "PB": 382 $("select[name='id_estado']").val("14"); 383 break; 384 case "PR": 385 $("select[name='id_estado']").val("15"); 386 break; 387 case "PE": 388 $("select[name='id_estado']").val("16"); 389 break; 390 case "PI": 391 $("select[name='id_estado']").val("17"); 392 break; 393 case "RJ": 394 $("select[name='id_estado']").val("18"); 395 break; 396 case "RN": 397 $("select[name='id_estado']").val("19"); 398 break; 399 case "RS": 400 $("select[name='id_estado']").val("20"); 401 break; 402 case "RO": 403 $("select[name='id_estado']").val("21"); 404 break; 405 case "RR": 406 $("select[name='id_estado']").val("22"); 407 break; 408 case "SC": 409 $("select[name='id_estado']").val("23"); 410 break; 411 case "SP": 412 $("select[name='id_estado']").val("24"); 413 break; 414 case "SE": 415 $("select[name='id_estado']").val("25"); 416 break; 417 case "TO": 418 $("select[name='id_estado']").val("26"); 419 break; 420 case "DF": 421 $("select[name='id_estado']").val("27"); 422 break; 423 } 424 425 $("input[name='numero']").val(""); 426 $("input[name='complemento']").val(""); 427 $(".form-horizontal").LoadingOverlay("hide"); 428 }); 429 $("input[name='numero']").focus(); 430 }, 431 error: function() { 432 bootbox.alert("<strong>Desculpe! :(</strong><br /><br />Não encontramos o endereço com o cep digitado, por favor tente novamente."); 433 } 434 }); 435 } 436} 437 438function mostraSenha(id) { 439 var senhaInput = $('#' + id); 440 var tipoInput = senhaInput.attr('type'); 441 if (tipoInput === 'password') { 442 senhaInput.attr('type', 'text'); 443 } else { 444 senhaInput.attr('type', 'password'); 445 } 446} 447 448/* Habilitar input */ 449function desabilitar(valor, a, b) { 450 var status = document.getElementById(a).disabled; 451 if (valor == 'sim' && !status) { 452 document.getElementById(a).disabled = true; 453 } else { 454 document.getElementById(a).disabled = false; 455 } 456} 457 458 459/* Valida CNPJ */ 460function _cnpj(cnpj) { 461 cnpj = cnpj.replace(/[^\d]+/g, ''); 462 if (cnpj == '') return false; 463 if (cnpj.length != 14) 464 return false; 465 // Elimina CNPJs invalidos conhecidos 466 if (cnpj == "00000000000000" || 467 cnpj == "11111111111111" || 468 cnpj == "22222222222222" || 469 cnpj == "33333333333333" || 470 cnpj == "44444444444444" || 471 cnpj == "55555555555555" || 472 cnpj == "66666666666666" || 473 cnpj == "77777777777777" || 474 cnpj == "88888888888888" || 475 cnpj == "99999999999999") 476 return false; 477 // Valida DVs 478 tamanho = cnpj.length - 2 479 numeros = cnpj.substring(0, tamanho); 480 digitos = cnpj.substring(tamanho); 481 soma = 0; 482 pos = tamanho - 7; 483 for (i = tamanho; i >= 1; i--) { 484 soma += numeros.charAt(tamanho - i) * pos--; 485 if (pos < 2) 486 pos = 9; 487 } 488 resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; 489 if (resultado != digitos.charAt(0)) 490 return false; 491 tamanho = tamanho + 1; 492 numeros = cnpj.substring(0, tamanho); 493 soma = 0; 494 pos = tamanho - 7; 495 for (i = tamanho; i >= 1; i--) { 496 soma += numeros.charAt(tamanho - i) * pos--; 497 if (pos < 2) 498 pos = 9; 499 } 500 resultado = soma % 11 < 2 ? 0 : 11 - soma % 11; 501 if (resultado != digitos.charAt(1)) 502 return false; 503 return true; 504} 505 506/* Valida CNPJ */ 507function validarCNPJ(el) { 508 if (!_cnpj(el.value)) { 509 var cnpj = el.value; 510 el.value = ""; 511 $("input[name='cnpj']").addClass('is-invalid'); 512 $(".mensagem-cnpj").html('Este CNPJ <b>(' + cnpj + ')</b> e inválido, por favor tente novamente.'); 513 } else { 514 $("input[name='cnpj']").removeClass('is-invalid'); 515 $(".mensagem-cnpj").html(''); 516 } 517} 518 519/* Validação CPF */ 520function _cpf(cpf) { 521 cpf = cpf.replace(/[^\d]+/g, ''); 522 if (cpf == '') return false; 523 if (cpf.length != 11 || 524 cpf == "00000000000" || 525 cpf == "11111111111" || 526 cpf == "22222222222" || 527 cpf == "33333333333" || 528 cpf == "44444444444" || 529 cpf == "55555555555" || 530 cpf == "66666666666" || 531 cpf == "77777777777" || 532 cpf == "88888888888" || 533 cpf == "99999999999") 534 return false; 535 add = 0; 536 for (i = 0; i < 9; i++) 537 add += parseInt(cpf.charAt(i)) * (10 - i); 538 rev = 11 - (add % 11); 539 if (rev == 10 || rev == 11) 540 rev = 0; 541 if (rev != parseInt(cpf.charAt(9))) 542 return false; 543 add = 0; 544 for (i = 0; i < 10; i++) 545 add += parseInt(cpf.charAt(i)) * (11 - i); 546 rev = 11 - (add % 11); 547 if (rev == 10 || rev == 11) 548 rev = 0; 549 if (rev != parseInt(cpf.charAt(10))) 550 return false; 551 return true; 552} 553 554function validarCPF(el) { 555 if (!_cpf(el.value)) { 556 var cpf = el.value; 557 el.value = ""; 558 $("input[name='cpf']").addClass('is-invalid'); 559 $(".mensagem-cpf").html('Este CPF <b>(' + cpf + ')</b> e inválido, por favor tente novamente.'); 560 } else { 561 $("input[name='cpf']").removeClass('is-invalid'); 562 $(".mensagem-cpf").html(''); 563 } 564} 565 566/* Mascaras Imput */ 567$(document).ready(function() { 568 $('.data').mask('00/00/0000'); 569 $('.hora').mask('00:00:00'); 570 $('.data_hora').mask('00/00/0000 00:00:00'); 571 $('.cep').mask('00000-000'); 572 $('.telefone_fixo').mask('(00) 0000-0000'); 573 $('.cpf').mask('000.000.000-00', { 574 reverse: true 575 });
576 $('.cnpj').mask('00.000.000/0000-00', { 577 reverse: true 578 }); 579 $('.inscricao').mask('00000000000-00', { 580 reverse: true 581 }); 582 $('.dinheiro').mask('000.000.000.000.000,00', { 583 reverse: true 584 }); 585 $('.dinheiro_dois').mask("#.##000.00", { 586 reverse: true 587 }); 588 $('.ip').mask('099.099.099.099'); 589 $('.cupom-licenca').mask('AAAA-AAAA-AAAA-AAAA'); 590 $('.porcentagem').mask('##0,00%', { 591 reverse: true 592 }); 593 $('.campo-n').mask("#.##0.000", { 594 reverse: true 595 }); 596 $('.crp').mask('00/0000999'); 597}); 598var SPMaskBehavior = function(val) { 599 return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; 600 }, 601 spOptions = { 602 onKeyPress: function(val, e, field, options) { 603 field.mask(SPMaskBehavior.apply({}, arguments), options); 604 } 605 }; 606 607/* Mascara Telefone */ 608$('.telefone').mask(SPMaskBehavior, spOptions);
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.