1$(function() { 2 3 $("body").tooltip({ selector: '[data-toggle=tooltip]' }); 4 5 $(this).bind("contextmenu", function(e) { 6 //e.preventDefault(); 7 }); 8 9 $("select").each(function(index) { 10 if ($(this).data('value') != '') { 11 $(this).val($(this).data('value')); 12 $(this).change(); 13 } 14 }); 15 16 $('[data-method="last12months"]').each(function(index) { 17 loadTeacherReport($(this)) 18 }); 19 20 $("textarea").each(function(index) { 21 if ($("#" + $(this).attr('id') + '-length').length > 0) { 22 $(this).restrictLength($("#" + $(this).attr('id') + '-length')); 23 } 24 }); 25 26 $('[data-load="video"]').each(function(index) { 27 openMedia(event, $(this).data('id'), '', 'V'); 28 }); 29 30 $('#telefoneCelular').mask('(99) 99999-9999', { placeholder: "(99) 99999-9999" }); 31 $('#cep').mask('99999999', { placeholder: "99999999" }); 32 if ($("#idEstado").length > 0) loadEstado($('#idEstado').attr("data-info"), $('#idCidade').attr("data-info"), $('#idBairro').attr("data-info")); 33 $('#cep').focus(function() { $('#cep').attr('data-info', $('#cep').val()); }); 34 $('#telefoneCasa').mask('(99) 9999-9999', { placeholder: "(99) 9999-9999" }); 35 if ($("#idTopicoVideoAbrir").length > 0 && $("#idTopicoVideoAbrir").val().length > 0) { 36 openMedia(event, 'item-' + $("#token").val() + '-' + $("#idTopicoVideoAbrir").val(), '', 'V'); 37 } 38 39 if ($("[data-date]").length > 0) { 40 $("[data-date]").mask('00/00/0000'); 41 $("[data-date]").datepicker({ 42 autoclose: true, 43 todayHighlight: true, 44 todayBtn: true, 45 format: 'dd/mm/yyyy' 46 }); 47 } 48 49 $('[data-method="gerarPDF"]').each(function(index) { 50 gerarPDF($(this).data('div'), $(this).data('path'), 0, 0, carregarCorrecao); 51 }); 52 $('.tab-pedidos').first().addClass("active"); 53 $('.div-pedidos').first().addClass("active show"); 54 55 if ($(".mceEditor").length > 0 || $('.mceEditorComentario').length > 0) { 56 57 const toolbar = 'forecolor backcolor bold italic underline | alignleft aligncenter alignright al
57ignjustify | removeformat | subscript superscript | charmap emoticons'; 58 59 tinymce.init({ 60 editor_selector: 'mceEditor', 61 mode: "specific_textareas", 62 height: 350, 63 menubar: false, 64 browser_spellcheck: true, 65 language: 'pt_BR', 66 branding: false, 67 plugins: [ 68 'advlist autolink lists link image charmap print preview anchor', 69 'searchreplace visualblocks fullscreen', 70 'insertdatetime media wordcount textcolor emoticons' 71 ], 72 toolbar: toolbar 73 }); 74 75 76 tinymce.init({ 77 editor_selector: 'mceEditorComentario', 78 mode: "specific_textareas", 79 height: 300, 80 browser_spellcheck: true, 81 menubar: false, 82 language: 'pt_BR', 83 branding: false, 84 plugins: [ 85 'advlist autolink lists link image charmap print preview anchor', 86 'searchreplace visualblocks fullscreen', 87 'insertdatetime media wordcount textcolor emoticons' 88 ], 89 toolbar: toolbar 90 }); 91 } 92 93 94 if ($("#divDocument textarea").length > 0) { 95 setTimeout(carregarCorrecao(), 2000); 96 } 97 98 if ($("#listaTopicos").length > 0) { 99 if ($('#listaTopicos li').length == 1) { 100 $('#listaTopicos li').click(); 101 } 102 } 103 104 if ($("#token").length > 0) { 105 sincronizarVideo(false); 106 setInterval(temporizadorSendLog, 2000); 107 } 108 109 window.onbeforeunload = confirmExit; 110 function confirmExit() { 111 if (typeof $('#token').val() !== "undefined") { 112 sincronizarVideo(true); 113 } 114 } 115 116 if ($('#graficoTema').length > 0) { 117 var ctx1 = document.getElementById("graficoTema"); 118 var myChart1 = new Chart(ctx1, { 119 type: 'bar', 120 data: { 121 labels: labelTema, 122 datasets: [{ 123 label: 'Questão por Assunto', 124 data: listaValor1, 125 backgroundColor: 'rgb(210, 214, 222)', 126 borderColor: 'rgb(210, 214, 222)', 127 fill: true, 128 borderWidth: 1 129 }, 130 { 131 label: 'Seus Acertos por Assunto', 132 data: listaValor2, 133 backgroundColor: 'rgba(60,141,188,0.9)', 134 borderColor: 'rgba(60,141,188,0.9)', 135 fill: true, 136 borderWidth: 1 137 } 138 ], 139 }, 140 options: { 141 responsive: true, 142 tooltips: { 143 mode: 'index', 144 intersect: false, 145 }, 146 hover: { 147 mode: 'nearest', 148 intersect: true 149 }, 150 animationEnabled: true, 151 animationDuration: 2000, 152 responsiveAnimationDuration: 2000, 153 animation: { 154 duration: 2000, 155 easing: 'easeOutBack' 156 } 157 } 158 }); 159 160 var ctx2 = document.getElementById("graficoRange"); 161 var myChart2 = new Chart(ctx2, { 162 data: { 163 datasets: [{ 164 type: 'line', 165 label: 'Line Dataset', 166 data: listaRangePercentual 167 }, { 168 type: 'bar', 169 label: 'Bar Dataset', 170 data: listaRangeValor, 171 }], 172 labels: listaRangeTitulo 173 }, 174 options: { 175 responsive: true, 176 tooltips: { 177 mode: 'index', 178 intersect: false, 179 }, 180 hover: { 181 mode: 'nearest', 182 intersect: true 183 }, 184 animationEnabled: true, 185 animationDuration: 2000, 186 responsiveAnimationDuration: 2000, 187 animation: { 188 duration: 2000, 189 easing: 'easeOutBack' 190 } 191 } 192 }); 193 194 var ctx3 = document.getElementById("graficoHistorico"); 195 var myChart3 = new Chart(ctx3, { 196 type: 'line', 197 data: { 198 labels: listaHistoricoTitulo, 199 datasets: [ 200 { 201 label: 'Pontuação', 202 data: listaHistoricoValor, 203 borderColor: 'rgba(60,141,188,0.9)', 204 borderWidth: 1 205 } 206 ], 207 }, 208 options: { 209 responsive: true, 210 tooltips: { 211 mode: 'index', 212 intersect: false, 213 }, 214 hover: { 215 mode: 'nearest', 216 intersect: true 217 }, 218 animationEnabled: true, 219 animationDuration: 2000, 220 responsiveAnimationDuration: 2000, 221 animation: { 222 duration: 2000, 223 easing: 'easeOutBack' 224 } 225 } 226 }); 227 228 var ctx4 = document.getElementById("graficoTemaGeral"); 229 var myChart1 = new Chart(ctx4, { 230 type: 'bar', 231 data: { 232 labels: labelTemaGeral, 233 datasets: [{ 234 label: 'Questão por Assunto', 235 data: listaValorGeral1, 236 backgroundColor: 'rgb(210, 214, 222)', 237 borderColor: 'rgb(210, 214, 222)', 238 fill: true, 239 borderWidth: 1 240 }, 241 { 242 label: 'Seus Acertos por Assunto', 243 data: listaValorGeral2, 244 backgroundColor: 'rgba(60,141,188,0.9)', 245 borderColor: 'rgba(60,141,188,0.9)', 246 fill: true, 247 borderWidth: 1 248 } 249 ], 250 }, 251 options: { 252 indexAxis: 'y', 253 responsive: true, 254 tooltips: { 255 mode: 'index', 256 intersect: false, 257 }, 258 hover: { 259 mode: 'nearest', 260 intersect: true 261 }, 262 plugins: { 263 legend: { 264 position: 'right', 265 }, 266 title: { 267 display: true, 268 text: 'Todas as avaliações' 269 } 270 }, 271 animationEnabled: true, 272 animationDuration: 2000,
273 responsiveAnimationDuration: 2000, 274 animation: { 275 duration: 2000, 276 easing: 'easeOutBack' 277 } 278 } 279 }); 280 281 var ctx4 = document.getElementById("graficoDisciplinaGeral"); 282 var myChart1 = new Chart(ctx4, { 283 type: 'bar', 284 data: { 285 labels: labelDisciplinaGeral, 286 datasets: [{ 287 label: 'Questão por Assunto', 288 data: listaValorDisciplinaGeral1, 289 backgroundColor: 'rgb(210, 214, 222)', 290 borderColor: 'rgb(210, 214, 222)', 291 fill: true, 292 borderWidth: 1 293 }, 294 { 295 label: 'Seus Acertos por Assunto', 296 data: listaValorDisciplinaGeral2, 297 backgroundColor: 'rgba(60,141,188,0.9)', 298 borderColor: 'rgba(60,141,188,0.9)', 299 fill: true, 300 borderWidth: 1 301 } 302 ], 303 }, 304 options: { 305 indexAxis: 'y', 306 responsive: true, 307 tooltips: { 308 mode: 'index', 309 intersect: false, 310 }, 311 hover: { 312 mode: 'nearest', 313 intersect: true 314 }, 315 plugins: { 316 legend: { 317 position: 'right', 318 }, 319 title: { 320 display: true, 321 text: 'Todas as avaliações' 322 } 323 }, 324 animationEnabled: true, 325 animationDuration: 2000, 326 responsiveAnimationDuration: 2000, 327 animation: { 328 duration: 2000, 329 easing: 'easeOutBack' 330 } 331 } 332 }); 333 334 } 335 336 if ($(".test-comentado-video1").length > 0) { 337 openMedia(null, $(".test-comentado-video1").attr('id'), '', 'V'); 338 } 339 340 //FUNCOES DARKMODE 341 let isDarkTheme; 342 let shouldUpdateServer = false; 343 344 if ($("body").hasClass("theme-dark")) { 345 isDarkTheme = true; 346 } else if ($("body").hasClass("theme-light")) { 347 isDarkTheme = false; 348 } else { 349 const defaultTheme = $("#sidebar").data("default-theme"); 350 isDarkTheme = defaultTheme === "dark"; 351 shouldUpdateServer = true; 352 } 353 354 setTheme(isDarkTheme, shouldUpdateServer ? 1 : 0); 355 356 if (document.getElementById("toggle-theme") != null) { 357 document.getElementById("toggle-theme").addEventListener("click", function() { 358 const isDarkTheme = localStorage.getItem("darkTheme") === "true"; 359 const newTheme = !isDarkTheme; 360 localStorage.setItem("darkTheme", newTheme); 361 setTheme(newTheme, 1); 362 }); 363 } 364 365 $('.slick-responsive-auto.single').slick({ 366 lazyLoad: 'ondemand', 367 mobileFirst: false, 368 dots: true, 369 arrows: true, 370 slidesToShow: 1, 371 slidesToScroll: 1, 372 infinite: false, 373 autoplay: true, 374 autoplaySpeed: 3500, 375 }); 376 377 $('.slick-responsive-auto.double').slick({ 378 lazyLoad: 'ondemand', 379 mobileFirst: false, 380 dots: true, 381 arrows: true, 382 slidesToShow: 2, 383 slidesToScroll: 1, 384 infinite: false, 385 autoplay: true, 386 autoplaySpeed: 3500, 387 responsive: [ 388 { 389 breakpoint: 1000, 390 settings: { 391 slidesToShow: 2, 392 } 393 }, 394 { 395 breakpoint: 600, 396 settings: { 397 slidesToShow: 2, 398 } 399 }] 400 }); 401 402 $('.slick-responsive-auto.triple').slick({ 403 lazyLoad: 'ondemand', 404 mobileFirst: false, 405 dots: true, 406 arrows: true, 407 slidesToShow: 3, 408 slidesToScroll: 1, 409 infinite: false, 410 autoplay: true, 411 autoplaySpeed: 3500, 412 responsive: [ 413 { 414 breakpoint: 1000, 415 settings: { 416 slidesToShow: 2, 417 } 418 }, 419 { 420 breakpoint: 600, 421 settings: { 422 slidesToShow: 1, 423 } 424 }] 425 }); 426 427 $('.slick-responsive-auto.quadruple').slick({ 428 lazyLoad: 'ondemand', 429 mobileFirst: false, 430 dots: true, 431 arrows: true, 432 slidesToShow: 4, 433 slidesToScroll: 1, 434 infinite: false, 435 autoplay: false, 436 autoplaySpeed: 3500, 437 responsive: [ 438 { 439 breakpoint: 1000, 440 settings: { 441 slidesToShow: 3, 442 } 443 }, 444 { 445 breakpoint: 600, 446 settings: { 447 slidesToShow: 2, 448 } 449 }, 450 { 451 breakpoint: 400, 452 settings: { 453 slidesToShow: 1, 454 } 455 }] 456 }); 457 458 $('.slick-responsive-auto.quintuple').slick({ 459 lazyLoad: 'ondemand', 460 mobileFirst: false, 461 dots: true, 462 arrows: true, 463 slidesToShow: 5, 464 slidesToScroll: 1, 465 infinite: false, 466 autoplay: false, 467 autoplaySpeed: 3500, 468 responsive: [ 469 { 470 breakpoint: 1000, 471 settings: { 472 slidesToShow: 4, 473 } 474 }, 475 { 476 breakpoint: 600, 477 settings: { 478 slidesToShow: 2, 479 } 480 }] 481 }); 482 483 if ($("#btnCopyLinkPix").length > 0) { 484 $('#btnCopyLinkPix').click(function() { 485 var copyText = document.getElementById("copyLinkPix"); 486 copyText.select(); 487 document.execCommand("copy"); 488 }); 489 } 490 491 $('#searchTrigger').on('click', function() { 492 $('#searchOverlay').addClass('show'); 493 $('#searchOverlay input').focus(); 494 }); 495 $('#closeSearch').on('click', function() { 496 $('#searchOverlay').removeClass('show'); 497 }); 498 $(document).on('keydown', function(e) { 499 if (e.key === 'Escape') { 500 $('#searchOverlay').removeClass('show'); 501 } 502 }); 503 $('#searchOverlay').on('click', function(e) { 504 if (e.target === this) { 505 $(this).removeClass('show'); 506 } 507 }); 508}); 509 510function setTheme(isDarkTheme, server) { 511 if (isDarkTheme == true) { 512 if (server == 1) { 513 setThemeServer("theme-dark"); 514 } 515 if ($('#toggle-theme .light').length > 0) { 516 $('#toggle-theme .light').hide(); 517 $('#toggle-theme .dark').show(); 518 } else { 519 $('#toggle-theme i').attr('class', 'far fa-sun-bright'); 520 } 521 $("body").removeClass("theme-light").addClass("theme-dark"); 522 } else { 523 if (server == 1) { 524 setThemeServer("theme-light"); 525 } 526 if ($('#toggle-theme .dark').length > 0) { 527 $('#toggle-theme .dark').hide(); 528 $('#toggle-theme .light').show(); 529 } else { 530 $('#toggle-theme i').attr('class', 'far fa-moon'); 531 } 532 $("body").removeClass("theme-dark").addClass("theme-light"); 533 } 534} 535 536function setThemeServer(theme) { 537 $.ajax({ 538 url: "/portal/setTheme", 539 type: "POST", 540 data: { theme: theme }, 541 success: function (response) { 542 }, 543 error: function (xhr, status, error) { 544 } 545 }); 546} 547 548 549function temporizadorSendLog() { 550 sincronizarVideo(false); 551} 552 553function sleep(delay) { 554 var start = new Date().getTime(); 555 while (new Date().getTime() < start + delay); 556} 557 558function carregarCorrecao() { 559 560 $('.fas.fa-circle.flag-comentario').each(function() { 561 $(this).remove(); 562 }); 563 $('.linhaCorrecao').each(function() { 564 $(this).remove(); 565 }); 566 567 if ($(".flag-correcao").length > 0 && $("#idAvaliacaoAluno").val() != null && $("#idAvaliacaoAluno").val() > 0) { 568 $.getJSON("/portal/getFlagComentario", { format: "json", id: $("#idAvaliacaoAluno").val() }).done(function(data) { 569 if (data != null) { 570 for (var i = 0; i < data.length; i++) { 571 if (data[i].tipo == 1) { 572 var varLargura = getWidth() / data[i].largura; 573 var varAltura = getHeight() / data[i].altura; 574 var esquerda = (data[i].esquerda * varLargura);
575 var topo = (data[i].topo * varAltura); 576 criarIcone(data[i].id, topo, esquerda, data[i].largura, data[i].altura, data[i].comentario, '#' + data[i].cor); 577 } else if (data[i].tipo == 2) { 578 var varLargura = getWidth() / data[i].largura; 579 var varAltura = getHeight() / data[i].altura; 580 var esquerda = (data[i].esquerda * varLargura); 581 var topo = (data[i].topo * varAltura); 582 var esquerda2 = (data[i].esquerda2 * varLargura); 583 var topo2 = (data[i].topo2 * varAltura); 584 criarLinha(data[i].id, esquerda, topo, esquerda2, topo2, '#' + data[i].cor); 585 criarEventoApagarLinha(data[i].id); 586 } 587 588 } 589 if ($("#divDocument img").length > 0) { 590 $("#divDocument img").css({ float: 'right' }); 591 //$("#divDocument img").css({position: 'absolute',top: '0px',left: '0px'}); 592 } else if ($("#divDocument canvas").length > 0) { 593 $("#divDocument canvas").css({ float: 'right' }); 594 } 595 } 596 }); 597 } 598} 599 600function toggleFlagComentario() { 601 const pontosVermelhos = document.querySelectorAll('.flag-comentario'); 602 pontosVermelhos.forEach(ponto => { 603 if (ponto.style.display === "") { 604 ponto.style.display = "none"; 605 } else { 606 ponto.style.display = ""; 607 } 608 }); 609} 610 611function editarTextoAvaliacao() { 612 toggleFlagComentario(); 613 614 const textArea = document.getElementById('textoAvaliacao'); 615 textArea.removeAttribute('readonly'); 616 617 const botaoEditar = document.getElementById('btnEditarAvaliacao'); 618 botaoEditar.disabled = true; 619} 620 621function openTopic(event, objectMain, token, local, isComplement) { 622 if ($('#' + token + local).length == 0) { 623 var contentHtml = $(objectMain).html(); 624 $(objectMain).html($(objectMain).html() + '<span class="badge badge-warning badge-media">' + label01 + '...</span>'); 625 $.getJSON("/portal/getTopico", { format: "json", token: token }).done(function(data) { 626 contentHtml = contentHtml + '<ul class="list-unstyled" id="' + token + local + '">'; 627 if (data.listTopics != null) { 628 for (var i = 0; i < data.listTopics.length; i++) { 629 var comentario = ''; 630 if (data.listTopics[i] != null && data.listTopics[i].comentario != null && data.listTopics[i].comentario.length > 0) { 631 comentario = '<span class="badge badge-success badge-media badge-media-' + data.tipo + '">' + data.listTopics[i].comentario + '</span>'; 632 } 633 if (isComplement == false) comentario = ''; 634 contentHtml += '<li onclick="openTopic(event, this, \'' + data.token + '-' + data.listTopics[i].token + '\', \'' + local + '\',' + isComplement + ')"><div class="texto">' + data.listTopics[i].nome + comentario + '</div></li>'; 635 } 636 } 637 if (data.listTopicsMedia != null) { 638 for (var i = 0; i < data.listTopicsMedia.length; i++) { 639 var styleIcon = ''; 640 var complement = ''; 641 var corIcon = 'text-dark' 642 var corBadge = 'badge-dark' 643 if (data.listTopicsMedia[i].vistoFinal == 'S') { 644 corIcon = 'text-success'; 645 corBadge = 'badge-success'; 646 } else if (data.listTopicsMedia[i].visto == 'S') { 647 corIcon = 'text-checked'; 648 corBadge = 'badge-checked'; 649 } 650 651 if (data.listTopicsMedia[i].tipoMidia == 'V') { 652 if (data.listTopicsMedia[i].videoTO != null && data.listTopicsMedia[i].videoTO.tipo != null && data.listTopicsMedia[i].videoTO.tipo == 'D') { 653 styleIcon = 'fas fa-volume-up pr-2 media-class'; 654 } else { 655 styleIcon = 'fas fa-video pr-2 media-class'; 656 } 657 complement = '<span class="media-complement">(' + data.listTopicsMedia[i].videoTO.duracaoFormatadoExtenso + ')</span><span class="badge ' + corBadge + ' badge-media" id="badgeMedia' + data.listTopicsMedia[i].token + '">' + getMaxVistoFormatado(data.listTopicsMedia[i].maxVistoFormatado, data.listTopicsMedia[i].maxVisto) + '</span><i class="fas fa-user-clock media-video-complement" onmouseout="closeVideoTime(this)" onmouseleave="closeVideoTime(this)" onmouseenter="getVideoTime(this)" id="iconClock-' + data.listTopicsMedia[i].videoTO.tipo + '-' + data.listTopicsMedia[i].videoTO.param + '"></i>'; 658 if ($('#temFlagVisto').val() == 'S') complement += '<i class="fas fa-user-check media-video-complement mr-2" data-video="' + data.listTopicsMedia[i].videoTO.param + '" data-visto="' + data.listTopicsMedia[i].marcadoVisto + '" onclick="marcarVistoEvent(event,\'' + data.listTopicsMedia[i].token + '\')" id="iconCheck-' + data.listTopicsMedia[i].token + '"></i>'; 659 } else if (data.listTopicsMedia[i].tipoMidia == 'D') { 660 styleIcon = 'far fa-file pr-2 media-class'; 661 } else if (data.listTopicsMedia[i].tipoMidia == 'U') { 662 styleIcon = 'fas fa-link pr-2 media-class'; 663 } else if (data.listTopicsMedia[i].tipoMidia == 'A') { 664 styleIcon = 'fas fa-check-circle pr-2 media-class'; 665 if (data.listTopicsMedia[i].avaliacaoTO.quantidadePergunta > 0) { 666 complement = '<span class="badge ' + corBadge + ' badge-media">' + data.listTopicsMedia[i].avaliacaoTO.quantidadePergunta + ' ' + label31 + '</span>'; 667 } else { 668 complement = ''; 669 } 670 } else if (data.listTopicsMedia[i].tipoMidia == 'C') { 671 styleIcon = 'fas fa-file-alt pr-2 media-class'; 672 } else if (data.listTopicsMedia[i].tipoMidia == 'H') { 673 styleIcon = 'fas fa-comment-alt pr-2 media-class'; 674 } else if (data.listTopicsMedia[i].tipoMidia == 'F') { 675 styleIcon = 'fas fa-comments pr-2 media-class'; 676 } else if (data.listTopicsMedia[i].tipoMidia == 'O') { 677 styleIcon = 'fas fa-align-justify pr-2 media-class'; 678 } else if (data.listTopicsMedia[i].tipoMidia == 'I') { 679 styleIcon = 'fas fa-project-diagram pr-2 media-class'; 680 } else if (data.listTopicsMedia[i].tipoMidia == 'Q') { 681 styleIcon = 'far fa-smile pr-2 media-class'; 682 } else if (data.listTopicsMedia[i].tipoMidia == 'L') { 683 styleIcon = 'fas fa-pager pr-2 media-class'; 684 } else if (data.listTopicsMedia[i].tipoMidia == '') { 685 styleIcon = 'fas fa-comments pr-2 media-class'; 686 } 687 if (isComplement == false) complement = ''; 688 styleIcon += ' ' + corIcon; 689 690 if (data.listTopicsMedia[i].liberado == 0) { 691 contentHtml += '<li class="li-topico-video" onclick="openMedia(event, \'' + data.token + '-' + data.listTopicsMedia[i].token + '\', \'' + data.listTopicsMedia[i].titulo + '\', \'' + data.listTopicsMedia[i].tipoMidia + '\')"><i class="' + styleIcon + '" id="iconMedia' + data.listTopicsMedia[i].token + '"></i>' + data.listTopicsMedia[i].titulo + complement + '</li>'; 692 } else if (data.listTopicsMedia[i].liberado == 1) { 693 complement = '<span class="ml-1 badge badge-primary float-right mt-2 p-1">Data da Liberação: ' + data.listTopicsMedia[i].textoLiberacao + '</span>'; 694 contentHtml += '<li class="li-topico-video" onclick="openMediaAlert(event, \'Este conteúdo estará liberado na data: ' + data.listTopicsMedia[i].textoLiberacao + '\')"><i class="' + styleIcon + '" id="iconMedia' + data.listTopicsMedia[i].token + '"></i>' + data.listTopicsMedia[i].titulo + complement + '</li>'; 695 } else if (data.listTopicsMedia[i].liberado == 2) { 696 complement = '<span class="ml-1 badge badge-primary float-right mt-2 p-1">Em breve este conteúdo estará disponível</span>'; 697 contentHtml += '<li class="li-topico-video" onclick="openMediaAlert(event, \'Em breve este conteúdo estará disponível\')"><i class="' + styleIcon + '" id="iconMedia' + data.listTopicsMedia[i].token + '"></i>' + data.listTopicsMedia[i].titulo + complement + '</li>'; 698 } 699 } 700 } 701 contentHtml += '</ul>'; 702 703 if ($('#' + token + local).length == 0) $(objectMain).html(contentHtml); 704 $('#' + token + local).collapse('show'); 705 }); 706 } else { 707 if ($('#' + token + local).hasClass('collapse show')) { 708 $('#' + token + local).collapse('hide'); 709 } else { 710 $('#' + token + local).collapse('show'); 711 } 712 } 713 event.stopPropagation(); 714} 715 716function getVideoTime(item) { 717 $('#' + item.id).data("mouseIsOver", true); 718 $.getJSON("/portal/getTempoVideo", { format: "json", chave: item.id, token: $('#token').val() }).done(function(data) { 719 var dados = "<b>" + label02 + ": </b>" + data.duracaoFormatado + '<br>'; 720 if (data.visto == 1) { 721 dados += "<b>" + label03 + ": </b>" + label04 + "<br>"; 722 } else { 723 dados += "<b>" + label05 + ": </b>" + data.visualizacoesPossiveis + '<br>'; 724 dados += "<b>" + label06 + ": </b>" + data.tempoAssistidoFormatado + '<br>'; 725 dados += "<b>" + label07 + ": </b>" + data.restantes + '<br>'; 726 dados += "<b>" + label08 + ": </b>" + data.tempoMaxFormatado + '<br>'; 727 dados += "<b>" + label09 + ": </b>" + data.parouAonde + '<br>'; 728 } 729 730 $('#' + item.id).popover( 731 { 732 title: label10, 733 content: dados, 734 html: true, 735 container: "body", 736 trigger: "manual", 737 placement: "top" 738 } 739 ) 740 if ($('#' + item.id).data("mouseIsOver") == true) { 741 $('#' + item.id).popover('show') 742 } 743 }); 744} 745 746function closeVideoTime(item) { 747 $('#' + item.id).data("mouseIsOver", false); 748 $('#' + item.id).popover('hide'); 749} 750 751function openMedia(event, id, titulo, tipo) { 752 753 if (tipo != 'A') { 754 if (titulo != '') $('#modalTitle').text(titulo) 755 if ($('#modal1').length > 0) $('#modal1').modal('show'); 756 if ($('#modal1').length > 0) $('#modal1').css('padding-right', '0');
757 $('#tipo').val(tipo); 758 $('#iFrameDocument').addClass('d-none') 759 $('#divDocument').addClass('d-none') 760 if ($('#modalBodyMedia').length > 0) $('#modalBodyMedia').removeClass('d-none'); 761 if ($('#modalBodyMediaTeacher').length > 0) { 762 $('#modalBodyMediaTeacher').show(); 763 $('#modalBodyMediaTeacher').removeClass('d-none'); 764 } 765 } 766 767 var url = '/portal/media?token=' + id; 768 $.ajax({ 769 url: url, 770 dataType: 'html', 771 type: 'GET', 772 async: true, 773 success: function(data) { 774 775 if (tipo == 'A') { 776 if (titulo != '') $('#modalTitle').text(titulo) 777 if ($('#modal1').length > 0) $('#modal1').modal('show'); 778 if ($('#modal1').length > 0) $('#modal1').css('padding-right', '0'); 779 $('#tipo').val(tipo); 780 $('#iFrameDocument').addClass('d-none') 781 $('#divDocument').addClass('d-none') 782 if ($('#modalBodyMedia').length > 0) $('#modalBodyMedia').removeClass('d-none'); 783 if ($('#modalBodyMediaTeacher').length > 0) { 784 $('#modalBodyMediaTeacher').show(); 785 $('#modalBodyMediaTeacher').removeClass('d-none'); 786 } 787 } 788 789 if (typeof resetDocumentoDRM === 'function') { 790 resetDocumentoDRM(); 791 } 792 793 if ($('#modalBodyMedia').length > 0) $('#modalBodyMedia').html(data); 794 if ($('#modalBodyMediaTeacher').length > 0) $('#modalBodyMediaTeacher').html(data); 795 if (tipo == 'D' || tipo == 'U') marcaVistoIcone(id); 796 if ($('#descricaoVideo').length > 0 && $('#descricaoVideo').val().length > 0 && $('#videoText').length > 0) { 797 $('#videoText').text($('#descricaoVideo').val()); 798 } 799 }, 800 error: function(xhr, textStatus, errorThrown) { 801 if (xhr.status === 404) { 802 alert('Conteúdo não encontrado.'); 803 return; 804 } 805 806 console.error('Erro ao carregar:', xhr.status, errorThrown); 807 alert('Não foi possível carregar o conteúdo.'); 808 } 809 810 }); 811 if (event != null) event.stopPropagation(); 812} 813 814function marcaVistoIcone(id){ 815 if($('#icone-' + id).length > 0) { 816 $('#icone-' + id).addClass('complete'); 817 } 818} 819function openMediaAlert(event, message) { 820 821 alert(message); 822 if (event != null) event.stopPropagation(); 823} 824 825function getDisciplina() { 826 if ($('#idCurso').val() != '') { 827 $.getJSON("/portal/getDisciplina", { format: "json", idCurso: $('#idCurso').val() }).done(function(data) { 828 $("#idDisciplina").empty(); 829 $("#idDisciplina").append($("<option></option>").val('').html(label11)); 830 $.each(data, function() { 831 $("#idDisciplina").append($("<option></option>").val(this['id']).html(this['nome'])); 832 }); 833 $("#idDisciplina").val($("#idDisciplina").data('value')); 834 if ($("#idDisciplina option").length == 2) { 835 $("#idDisciplina").prop("selectedIndex", 1); 836 } 837 $("#idDisciplina").change(); 838 }); 839 } 840} 841 842function getProfessor() { 843 if ($('#idCurso').val() != '' && $('#idDisciplina').val() != '') { 844 $.getJSON("/portal/getProfessor", { format: "json", idCurso: $('#idCurso').val(), idDisciplina: $('#idDisciplina').val() }).done(function(data) { 845 $("#idProfessor").empty(); 846 $("#idProfessor").append($("<option></option>").val('').html(label12)); 847 $.each(data, function() { 848 $("#idProfessor").append($("<option></option>").val(this['id']).html(this['apelido'])); 849 }); 850 $("#idProfessor").val($("#idProfessor").data('value')); 851 if ($("#idProfessor option").length == 2) { 852 $("#idProfessor").prop("selectedIndex", 1); 853 } 854 }); 855 } 856} 857 858function setAlunoQuestao(idQuestao, idAlternativa) { 859 $.getJSON("/portal/setAlunoQuestao", { format: "json", idQuestao, idAlternativa }).done(function(data) { 860 var descri = document.getElementById("desc" + idAlternativa); 861 descri.style.fontWeight = 700; 862 var certo = document.getElementById("opcao" + data.idAlternativaCerta); 863 certo.style.backgroundColor = '#90EE90'; 864 if (data.acertou == "N") { 865 var errado = document.getElementById("opcao" + idAlternativa); 866 errado.style.backgroundColor = '#FF6961'; 867 } 868 869 $(":radio").click(function() { 870 var radioName = $(this).attr("name"); //Get radio name 871 $(":radio[name='" + radioName + "']").attr("disabled", true); //Disable all with the same name 872 }); 873 }); 874} 875 876function randomIntFromInterval(min, max) { // min and max included 877 return Math.floor(Math.random() * (max - min + 1) + min) 878} 879 880function stamp(posicao, x, y, height, width, degrees, firstPage, texto, helveticaFont) { 881 var siteFont = 15; 882 if (posicao == 1) { 883 x = 0; 884 y = height - 8; 885 degrees = 0; 886 } else if (posicao == 2) { 887 x = 20; 888 y = 10; 889 degrees = 90; 890 } else if (posicao == 3) { 891 x = 0; 892 y = 0; 893 degrees = 0; 894 } else if (posicao == 4) { 895 x = 10; 896 y = 0; 897 degrees = 55; 898 } else if (posicao == 6) { 899 siteFont = 5; 900 } 901 firstPage.drawText(texto, { 902 x: x, 903 y: y, 904 size: siteFont, 905 font: helveticaFont, 906 opacity: opacity, 907 color: PDFLib.rgb(colorR, colorG, colorB), 908 rotate: PDFLib.degrees(degrees), 909 }); 910} 911 912function stamper(pdfUrl, texto, arquivo, tipo, botao, modal, iframeDocumento, posicao, mobile) { 913 var xhr = new XMLHttpRequest(); 914 xhr.open('GET', pdfUrl, true); 915 xhr.responseType = 'arraybuffer'; 916 texto = removeAcento(texto); 917 918 xhr.onload = function(e) { 919 if (xhr.status == 200) { 920 var buffer = xhr.response; 921 PDFLib.PDFDocument.load(buffer, { ignoreEncryption: false }).then(function(pdfDoc) { 922 pdfDoc.getPages(); 923 return pdfDoc; 924 }).catch(function(err) { 925 console.warn('pdf-lib nao conseguiu ler o PDF, reconstruindo com pdf.js', err); 926 return reconstruirPdfProtegido(buffer); 927 }).then(function(pdfDoc) { 928 continuarStamper(pdfDoc, texto, arquivo, tipo, botao, modal, iframeDocumento, posicao, mobile); 929 }).catch(function(err) { 930 console.error('Falha ao processar PDF', err); 931 if (botao != null) { 932 $('#' + botao).removeAttr('disabled'); 933 } 934 if (modal != null) { 935 $("#" + modal).modal("hide"); 936 } 937 alert('Nao foi possivel abrir este PDF. O arquivo pode estar corrompido ou protegido.'); 938 }); 939 } 940 }; 941 942 xhr.send(); 943 944 945} 946 947function reconstruirPdfProtegido(buffer) { 948 if (typeof pdfjsLib === 'undefined') { 949 return Promise.reject(new Error('pdf.js indisponivel')); 950 } 951 if (!pdfjsLib.GlobalWorkerOptions.workerSrc) { 952 pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js'; 953 } 954 var data = new Uint8Array(buffer.slice(0)); 955 return pdfjsLib.getDocument({ data: data }).promise.then(function(pdf) { 956 return PDFLib.PDFDocument.create().then(function(novoDoc) { 957 var indice = 1; 958 function processarPagina() { 959 if (indice > pdf.numPages) { 960 return novoDoc; 961 } 962 return pdf.getPage(indice).then(function(page) { 963 var viewportBase = page.getViewport({ scale: 1 }); 964 var escala = 2; 965 var viewport = page.getViewport({ scale: escala }); 966 var canvas = document.createElement('canvas'); 967 canvas.width = viewport.width; 968 canvas.height = viewport.height; 969 var ctx = canvas.getContext('2d'); 970 return page.render({ canvasContext: ctx, viewport: viewport }).promise.then(function() { 971 var jpegDataUrl = canvas.toDataURL('image/jpeg', 0.85); 972 canvas.width = 0; 973 canvas.height = 0; 974 return novoDoc.embedJpg(jpegDataUrl); 975 }).then(function(imagem) { 976 var novaPagina = novoDoc.addPage([viewportBase.width, viewportBase.height]); 977 novaPagina.drawImage(imagem, { 978 x: 0, 979 y: 0, 980 width: viewportBase.width, 981 height: viewportBase.height 982 }); 983 indice = indice + 1; 984 return processarPagina(); 985 }); 986 }); 987 } 988 return processarPagina(); 989 }); 990 }); 991} 992 993function continuarStamper(pdfDoc, texto, arquivo, tipo, botao, modal, iframeDocumento, posicao, mobile) { 994 if ($('#nomeAula').length > 0) pdfDoc.setTitle($('#nomeAula').val()); 995 pdfDoc.setAuthor($(document).attr("title")); 996 pdfDoc.embedFont(PDFLib.StandardFonts.Helvetica).then(function(helveticaFont) { 997 var pages = pdfDoc.getPages(); 998 var i; 999 for (i = 0; i < pages.length; ++i) { 1000 var firstPage = pages[i]; 1001 var dim = firstPage.getSize();
1002 var height = dim.height; 1003 var width = dim.width; 1004 var x = 0; 1005 var y = 0; 1006 var degrees = 0; 1007 1008 if (posicao == 5) { 1009 stamp(posicao, 0, height - 8, height, width, 0, firstPage, texto, helveticaFont); 1010 stamp(posicao, 20, 10, height, width, 90, firstPage, texto, helveticaFont); 1011 stamp(posicao, 0, 0, height, width, 0, firstPage, texto, helveticaFont); 1012 stamp(posicao, 10, 0, height, width, 55, firstPage, texto, helveticaFont); 1013 } else if (posicao == 6) { 1014 var arrayTexto = texto.split(';'); 1015 x = randomIntFromInterval(100, width - 100); 1016 y = randomIntFromInterval(100, height - 100); 1017 stamp(posicao, x, y, height, width, 0, firstPage, arrayTexto[0], helveticaFont); 1018 stamp(posicao, width / 2, height / 2, height, width, 0, firstPage, arrayTexto[0], helveticaFont); 1019 stamp(4, x, y, height, width, 0, firstPage, arrayTexto[1], helveticaFont); 1020 } else { 1021 stamp(posicao, x, y, height, width, degrees, firstPage, texto, helveticaFont); 1022 } 1023 1024 } 1025 1026 pdfDoc.save().then(function(pdfBytes) { 1027 if (tipo == 'I') { 1028 var blob = new Blob([pdfBytes], { type: 'application/pdf' }); 1029 var blob_src = URL.createObjectURL(blob); 1030 if (mobile == true || mobile == 'true') { 1031 gerarPDF('divDocument', blob_src, 0, 0, null); 1032 } else { 1033 1034 if (iframeDocumento != null && iframeDocumento.length > 0) { 1035 $('#' + iframeDocumento).attr('src', blob_src); 1036 } else { 1037 window.location.href = blob_src; 1038 } 1039 } 1040 } else { 1041 download(pdfBytes, arquivo, "application/pdf"); 1042 } 1043 }); 1044 1045 if (botao != null) { 1046 $('#' + botao).removeAttr('disabled'); 1047 } 1048 if (modal != null) { 1049 setTimeout(function() { 1050 $("#" + modal).modal("hide"); 1051 }, 500); 1052 } 1053 1054 }); 1055} 1056 1057 1058$(document).on("click", '[name="btnMaterialDownload"]', function() { 1059 1060 $('#btnMaterialDownload' + $(this).data('value')).prop("disabled", "true"); 1061 $('#btnMaterialDownload' + $(this).data('value')).data('html', $('#btnMaterialDownload' + $(this).data('value')).html()); 1062 $('#btnMaterialDownload' + $(this).data('value')).html('<span class="icon"> <i class="fal fa-hourglass-half" aria-hidden="true"></i></span>'); 1063 1064 $("#modalLoading").modal({ 1065 backdrop: "static", 1066 keyboard: false, 1067 show: true 1068 }); 1069 var id = $(this).data('value'); 1070 var token = $(this).data('token'); 1071 var frame = $(this).data('frame'); 1072 1073 var path = $(this).data('path'); 1074 var posicao = $(this).data('posicao'); 1075 if (path.toLowerCase().substr(-3) != 'pdf') posicao = 0; 1076 1077 gerarPDFStamper(posicao, id, 'D', token, 'btnMaterialDownload' + id, 'modalLoading', frame, false); 1078 1079}); 1080 1081function gerarPDFStamper(posicao, id, tipo, token, btnMaterialDownload, modalLoading, iframeDocumento, mobile, tipoDocumento) { 1082 1083 //console.log(posicao + ' - ' + id + ' - ' + tipo + ' - ' + token + ' - ' + btnMaterialDownload + ' - ' + modalLoading + ' - ' + iframeDocumento+ ' - ' + mobile + ' - ' + tipoDocumento); 1084 1085 if (posicao != null && posicao > 0 && posicao < 10) { 1086 if (tipoDocumento == 'D' && (mobile == false || mobile == 'false')) { 1087 $('#divDocument').hide(); 1088 $('#' + iframeDocumento).show(); 1089 } else { 1090 $('#divDocument').show(); 1091 $('#' + iframeDocumento).hide(); 1092 mobile = true; 1093 } 1094 fetch('/portal/documento-online-key?idDocumento=' + id + '&tipo=' + tipo + '&token=' + token).then(response => { 1095 return response.json(); 1096 }).then(function(data) { 1097 if (data != null) { 1098 stamper(data.url, data.nome, data.arquivo, data.tipo, btnMaterialDownload, modalLoading, iframeDocumento, posicao, mobile); 1099 if ($('.divDocumentoAguarde').length > 0) $('.divDocumentoAguarde').hide(); 1100 habilitaBotaoDownload(btnMaterialDownload); 1101 1102 } 1103 }).catch(err => { 1104 alert('Erro na busca do documento'); 1105 if (modalLoading != null) { 1106 setTimeout(function() { 1107 $("#" + modalLoading).modal("hide"); 1108 if ($('.divDocumentoAguarde').length > 0) $('.divDocumentoAguarde').hide(); 1109 if (btnMaterialDownload != null) $('#' + btnMaterialDownload).removeAttr('disabled'); 1110 }, 500); 1111 } 1112 habilitaBotaoDownload(btnMaterialDownload); 1113 1114 }); 1115 } else { 1116 1117 if (iframeDocumento != null) { 1118 var filenameurl = $('#path').val().replace(/\.pdf$/i, ''); 1119 $('#divDocument').hide(); 1120 $('.divDocumentoAguarde').show(); 1121 $('#' + iframeDocumento).attr('src', '/portal/documento-marca
1121do/' + filenameurl + '?tipo=' + tipo + '&idDocumento=' + id + '&token=' + token); 1122 $('#' + iframeDocumento).on('load', function () { 1123 $('.divDocumentoAguarde').hide(); 1124 }); 1125 } else { 1126 var filename; 1127 fetch('/portal/documento-marcado?tipo=' + tipo + '&idDocumento=' + id + '&token=' + token) 1128 .then(res => { 1129 filename = res.headers.get('content-disposition').split('filename=')[1]; 1130 return res.blob(); 1131 }) 1132 .then(blob => { 1133 const url = window.URL.createObjectURL(blob); 1134 const a = document.createElement('a'); 1135 a.style.display = 'none'; 1136 a.href = url; 1137 a.download = filename; 1138 document.body.appendChild(a); 1139 a.click(); 1140 window.URL.revokeObjectURL(url); 1141 habilitaBotaoDownload(btnMaterialDownload); 1142 }).catch(function(error) { 1143 $("#modalLoading").modal("hide"); 1144 console.error(error); 1145 }); 1146 } 1147 } 1148} 1149 1150function habilitaBotaoDownload(btnMaterialDownload) { 1151 if ($('#' + btnMaterialDownload).length > 0) { 1152 if ($('#' + btnMaterialDownload).data('html') != null && $('#' + btnMaterialDownload).data('html').length > 0) { 1153 $('#' + btnMaterialDownload).html($('#' + btnMaterialDownload).data('html')); 1154 } 1155 $('#' + btnMaterialDownload).removeAttr('disabled'); 1156 setTimeout(function() { 1157 $("#modalLoading").modal("hide"); 1158 if (btnMaterialDownload != null) $('#' + btnMaterialDownload).removeAttr('disabled'); 1159 }, 500); 1160 } 1161} 1162 1163$('.btnDownloadTrilha').click(function() { 1164 downloadArquivoTrilha($(this).attr('id')); 1165}); 1166 1167function downloadArquivoTrilha(idButton) { 1168 var id = $('#idDocumento').val(); 1169 var path = $('#path').val(); 1170 var posicao = $('#posicao').val(); 1171 var token = $('#token').val(); 1172 1173 if (path != '' && path.toLowerCase().substr(-3) != 'pdf') posicao = 0; 1174 1175 gerarPDFStamper(posicao, id, 'D', token, idButton, 'modalLoading', null, false, 'D'); 1176 1177} 1178 1179function downloadFromFrame() { 1180 $('#btnDownloadDownloadFrame').prop("disabled", "true"); 1181 $("#modalLoading").modal({ 1182 backdrop: "static", 1183 keyboard: false, 1184 show: true 1185 }); 1186 var id = $('#btnDownloadDownloadFrame').data('value'); 1187 var token = $('#btnDownloadDownloadFrame').data('token'); 1188 var frame = $('#btnDownloadDownloadFrame').data('frame'); 1189 1190 var path = $('#btnDownloadDownloadFrame').data('path'); 1191 var posicao = $('#btnDownloadDownloadFrame').data('posicao'); 1192 if (path.toLowerCase().substr(-3) != 'pdf') posicao = 0; 1193 1194 gerarPDFStamper(posicao, id, 'D', token, 'btnDownloadDownloadFrame', 'modalLoading', frame, false); 1195} 1196 1197$('[name="btnDownloadBoleto"]').click(function() { 1198 window.open('/portal/boleto-download?id=' + $(this).data('value'), '_self'); 1199}); 1200 1201$(document).on("click", '[name="btnMaterialView"]', function() { 1202 $('#modalBodyMedia').addClass('d-none') 1203 $('#iFrameDocument').removeClass('d-none'); 1204 $('#divDocument').removeClass('d-none'); 1205 $('#modalDialog1').width('100%'); 1206 $('#modalDialog1').height('100%'); 1207 $('#modalDialog1').css('max-width', '100%'); 1208 $('.modal-content').css('background-color', '#FFFFFF'); 1209 if ($('#modalBodyMediaTeacher').length > 0) $('#modalBodyMediaTeacher').hide(); 1210 copyDownloadButton($(this).data('value')); 1211 1212 var heightVideo = $(window).height() - 50; 1213 if ($('#iFrameDocument').length > 0) $('#iFrameDocument').height(heightVideo); 1214 if ($('#divDocument').length > 0) $('#divDocument').height(heightVideo); 1215 1216 $('#btnDownload').data('value', $(this).data('value')) 1217 1218 $('#modalTitle').text($(this).data('title')) 1219 $('#modal1').modal('show'); 1220 1221 if ($(this).data('tipo') == 'D') { 1222 if ($(this).data('mobile') == true) { 1223 $('#divDocument').show(); 1224 $('#iFrameDocument').hide(); 1225 } else { 1226 $('#divDocument').hide(); 1227 $('#iFrameDocument').show(); 1228 } 1229 $('#btnDownload').show(); 1230 } else if ($(this).data('tipo') == 'C') { 1231 $('#divDocument').hide(); 1232 $('#iFrameDocument').show(); 1233 $('#btnDownload').show(); 1234 } else if ($(this).data('tipo') == 'L') { 1235 $('#divDocument').hide(); 1236 $('#iFrameDocument').show(); 1237 $('#btnDownload').hide(); 1238 } else if ($(this).data('tipo') == 'S') { 1239 $('#iFrameDocument').hide(); 1240 $('#divDocument').show(); 1241 $('#btnDownloadDownloadFrame').hide(); 1242 } 1243 var path = $(this).data('path'); 1244 var posicao = $(this).data('posicao'); 1245 if (path.toLowerCase().substr(-3) != 'pdf') posicao = 0; 1246 1247 carregarMaterial($(this).data('tipo'), $(this).data('value'), $(this).data('token'), path, $(this).data('inicial'), $(this).data('final'), 'divDocument', 'iFrameDocument', posicao, $(this).data('mobile')); 1248}); 1249 1250function carregarMaterial(tipo, idDocumento, token, path, paginaInicial, paginaFinal, divDocumento, iframeDocumento, posicao, mobile) { 1251 1252 if (tipo == 'D') { 1253 if (posicao != null && posicao > 0 && posicao < 10) { 1254 fetch('/portal/documento-online-key?idDocumento=' + idDocumento + '&tipo=I&token='
1254+ token).then(response => { 1255 return response.json(); 1256 }).then(function(data) { 1257 if (data != null) { 1258 stamper(data.url, data.nome, data.arquivo, data.tipo, 'btnMaterialDownload' + idDocumento, 'modalLoading', iframeDocumento, posicao, mobile); 1259 } 1260 }).catch(err => { 1261 $('#btnMaterialDownload' + idDocumento).removeAttr('disabled'); 1262 alert('Erro na busca do documento'); 1263 setTimeout(function() { 1264 $("#modalLoading").modal("hide"); 1265 }, 500); 1266 }); 1267 } else { 1268 $('.divDocumentoAguarde').show(); 1269 var filenameurl = path.replace(/\.pdf$/i, ''); 1270 $('#' + iframeDocumento).attr('src', ''); 1271 $('#' + iframeDocumento).attr('src', '/portal/documento-marcado/' + filenameurl + '?tipo=I&idDocumento=' + idDocumento + '&token=' + token); 1272 $('#' + iframeDocumento).on('load', function () { 1273 $('.divDocumentoAguarde').hide(); 1274 }); 1275 } 1276 } else if (tipo == 'S') { 1277 loadDocument(idDocumento); 1278 gerarPDFDocumento(divDocumento, idDocumento, 'I', token, paginaInicial, paginaFinal); 1279 } else if (tipo == 'L') { 1280 $.getJSON("/portal/getLettore", { format: "json" }).done( 1281 function(data) { 1282 if (data != null && data.status == 0) { 1283 var url = 'https://ebooks.hexag.online/embed/' + path; 1284 if (paginaInicial != null && paginaInicial > 0) url += '/' + paginaInicial; 1285 if (paginaFinal != null && paginaFinal > 0) url += '/' + paginaFinal; 1286 url += '?token=' + data.message 1287 $('#' + iframeDocumento).attr('src', url); 1288 } else { 1289 alert(data.message); 1290 } 1291 }); 1292 } 1293} 1294 1295$('#btnInquirySend').click(function() { 1296 1297 if ($("#inquiryForm").valid() == false) { 1298 return false; 1299 } 1300 1301 $(this).prop('disabled', true); 1302 1303 $.post("/portal/salvarDuvida", $("#inquiryForm").serialize(), function(data) { 1304 if (data.status == 0) { 1305 location.href = data.message; 1306 } else { 1307 alert(data.message); 1308 $('#btnInquirySend').prop('disabled', false); 1309 1310 } 1311 }, 'json'); 1312}); 1313 1314$('#btnForumSend').click(function() { 1315 if (!$("#forumForm").valid()) { 1316 return; 1317 } 1318 $.post("/portal/salvarForum", $("#forumForm").serialize(), function(data) { 1319 if (data.status == 0) { 1320 location.href = data.message; 1321 } else { 1322 alert(data.message); 1323 } 1324 }, 'json'); 1325}); 1326 1327 1328function salvarComentarioForum(layout) { 1329 if ($("#comment").val().length == 0) return; 1330 $.post("/portal/salvarComentario", { idForum: $("#idForum").val(), comentario: $("#comment").val() }, function(data) { 1331 var content = ''; 1332 if (layout == 2) { 1333 content += '<div class="wrapper-inner"><div class="row"><div class="col-list-outer"><div class="row"><div class="col-list-inner">'; 1334 content += '<div class="list-image"><div class="image">'; 1335 if (data.pathFotoTemp != null) { 1336 content += '<div class="avatar">'; 1337 content += '<img class="mr-3 img-thumbnail" src="' + data.pathFotoTemp + '" width="50px" height="50px">'; 1338 content += '</div>'; 1339 } else { 1340 content += '<div class="media">'; 1341 content += '<span class="user-initials">' + data.nomePrimeiraLetra + '</span>'; 1342 content += '</div>'; 1343 } 1344 content += '</div></div></div>'; 1345 content += '<div class="col-list-inner"><div class="inner"><div><div class="list-text">'; 1346 content += '<div class="title">'; 1347 content += '<h3>' + data.primeiroNome + '</h3>'; 1348 content += '</div>'; 1349 content += '</div>'; 1350 content += '<div class="list-time">'; 1351 content += '<span> <span> ' + data.dataInclusaoFormatada + '</span>'; 1352 content += '</span>'; 1353 content += '</div></div>'; 1354 content += '<div class="list-quote"><div class="quote">'; 1355 content += '<span> ' + data.comentario + ' </span>'; 1356 content += '</div></div></div></div></div></div></div></div>'; 1357 } else { 1358 content += '<div class="media">'; 1359 if (data.pathFotoTemp != null) { 1360 content += '<div class="avatar"><img class="mr-3 img-thumbnail" src="' + data.pathFotoTemp + '" width="50px" height="50px"></div>'; 1361 } else { 1362 content += '<div class="media"><span class="user-initials">' + data.nomePrimeiraLetra + '</span></div>'; 1363 } 1364 content += '<div class="media-body"><h5 class="mt-0 forum-comment-title">' + data.primeiroNome + ' - ' + data.dataInclusaoFormatada + '</h5>' + data.comentario + '</div></div><hr>'; 1365 } 1366 $('#listComments').append(content); 1367 $("#comment").val(''); 1368 }, 'json'); 1369} 1370 1371$('#idTipoRequerimento').change(function() { 1372 var data = $('#idTipoRequerimento').val();
1373 var arrayTipo = data.split('-'); 1374 1375 if (arrayTipo[1] == 'S') { 1376 $("#divCurso").show(); 1377 } else { 1378 $("#divCurso").hide(); 1379 } 1380 if (arrayTipo[3] == 'S') { 1381 $("#divMotivoCancelamento").show(); 1382 } else { 1383 $("#divMotivoCancelamento").hide(); 1384 } 1385 if (arrayTipo[2] == 'S') { 1386 getCursos(null); 1387 } else { 1388 getCursos("'A'"); 1389 } 1390}); 1391 1392$('#fileUpload').change(function(event) { 1393 var files = event.target.files; 1394 if ($("#btnAvaliacaoFileSend").length) $('#btnAvaliacaoFileSend').prop('disabled', true); 1395 receberVariosArquivos(files, $(this).data('type'), $(this).data('id'), $(this).data('directory'), null, false); 1396}); 1397 1398function receberVariosArquivos(files, tipo, idUser, directory, nomeCampoTemp, dataDelete) { 1399 1400 var divFileUpload = $('#divFileUpload' + tipo); 1401 var numberItens = $('div[id^="divBoxFile"]').length; 1402 1403 for (var i = 0; i < files.length; i++) { 1404 var index = i + numberItens; 1405 1406 //Box para o arquivo 1407 var divBoxFile = $("<div/>"); 1408 divBoxFile.attr('id', 'divBoxFile' + index); 1409 divFileUpload.append(divBoxFile); 1410 1411 var labelDocumento = document.createElement('input'); 1412 labelDocumento.type = 'hidden'; 1413 1414 if (nomeCampoTemp != null) { 1415 labelDocumento.name = nomeCampoTemp; 1416 labelDocumento.id = nomeCampoTemp; 1417 } else { 1418 labelDocumento.name = 'itemNomeArquivo' + tipo; 1419 labelDocumento.id = 'labelDocumento' + tipo + index; 1420 } 1421 labelDocumento.value = converteArquivoInternet(files[i].name); 1422 divFileUpload.append(labelDocumento); 1423 1424 var divFileProgress = $("<div/>"); 1425 divFileProgress.attr('id', 'divFileProgress' + index); 1426 divFileProgress.addClass('float-left w-100 progress'); 1427 divFileProgress.append('<div class="progress-bar bg-success" role="progressbar" id="progress' + tipo + index + '" style="width: 0%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>'); 1428 divFileUpload.append(divFileProgress); 1429 1430 uploadFile(files[i], index, tipo, idUser, directory, dataDelete); 1431 } 1432} 1433 1434function uploadFile(file, indice, tipo, idUser, directory, dataDelete) { 1435 var nameFile = converteArquivoInternet(file.name); 1436 var formData = new FormData(); 1437 formData.append("file", file, idUser + "." + nameFile); 1438 formData.append('diretorio', directory); 1439 formData.append('delete', dataDelete); 1440 if ($('#pathTempDocumento').length > 0) $('#pathTempDocumento').val(nameFile); 1441 1442 var xhr = new XMLHttpRequest(); 1443 xhr.upload.addEventListener("progress", function(e) { uploadProgress(e, indice, tipo) }, false); 1444 xhr.addEventListener("progress", function(e) { uploadProgress(e, indice, tipo) }, false); 1445 xhr.addEventListener("load", function(e) { uploadComplete(e, indice, tipo, directory, nameFile, idUser) }, false); 1446 xhr.open("POST", "/portal/RecebeArquivo", true); 1447 xhr.send(formData); 1448} 1449 1450function uploadProgress(event, indice, tipo) { 1451 var progress = Math.round(event.loaded / event.total * 100); 1452 $('#progress' + tipo + indice).width(progress + '%'); 1453} 1454 1455function uploadComplete(event, index, tipo, directory, nameFile, idUser) { 1456 1457 //Verifica se arquivo esta la 1458 $.post("/portal/verificaArquivoProfessor", { directory: directory, nameFile: nameFile, idUser:idUser}, function(data) { 1459 if (data.status == 0) { 1460 $('#progress' + tipo + index).width('100%'); 1461 alert(data.message); 1462 if ($("#btnAvaliacaoFileSend").length) $('#btnAvaliacaoFileSend').prop('disabled', false); 1463 if ($("#btnSalvarDocumentoAluno").length) $('#btnSalvarDocumentoAluno').prop('disabled', false); 1464 1465 //Inativa o progress 1466 $('#divFileProgress' + index).remove(); 1467 1468 //Cria os itens de download e delete 1469 var divBoxFile = $('#divBoxFile' + index); 1470 var divFileDoc = $("<div/>"); 1471 divFileDoc.attr('id', 'divFileDoc' + index); 1472 divFileDoc.addClass('float-left mr-1'); 1473 divFileDoc.html('<a href="javascript:dowloadArquivoTemp(\'' + directory + '\',\'' + nameFile + '\');">' + nameFile + '</a>'); 1474 divBoxFile.append(divFileDoc); 1475 var divFileDocX = $("<div/>"); 1476 divFileDocX.attr('id', 'divFileDocX' + index); 1477 divFileDocX.addClass('float-left mr-1'); 1478 divFileDocX.html('<a href="javascript:apagarArquivoUpload(' + index + ',\'' + tipo + '\',\'' + directory + '\',\'' + nameFile + '\')" class="txtFonteArquivo">X</a>'); 1479 divBoxFile.append(divFileDocX); 1480 } else { 1481 alert(data.message); 1482 if ($("#btnAvaliacaoFileSend").length) $('#btnAvaliacaoFileSend').prop('disabled', true); 1483 $("#divBoxFile" + index).remove() 1484 $("#divFileProgress" + index).remove() 1485 $('#fileUpload').val(''); 1486 } 1487 }, 'json'); 1488 1489} 1490 1491function apagarArquivoUpload(indice, tipo, directory, nameFile) { 1492 if (confirm('Confirma apagar o arquivo: ' + nameFile + '?') == true) { 1493 $.post("/portal/deleteFile", { directory: directory, nameFile: $("#labelDocumento" + tipo + indice).val() }, function(data) { }, 'json'); 1494 $('#divBoxFile' + indice).remove(); 1495 $('#fileUpload').val(''); 1496 } 1497} 1498 1499function dowloadArquivoTemp(directory, nameFile) { 1500 window.open('/portal/dowloadArquivoTemp?directory=' + directory + '&nameFile=' + nameFile, '_self'); 1501} 1502 1503 1504function converteArquivoInternet(texto) { 1505 1506 var nome = texto; 1507 var extensao = ""; 1508 1509 var posicao = texto.lastIndexOf("."); 1510 if (posicao > 0) { 1511 nome = texto.substring(0, posicao); 1512 extensao = texto.substring(posicao); 1513 } 1514 1515 1516 var nomeTemp = nome; 1517 var nome = ''; 1518 for (var i = 0; i < nomeTemp.length; i++) {
1519 if (nomeTemp[i].charCodeAt(0) < 255) { 1520 nome += nomeTemp[i]; 1521 } 1522 } 1523 1524 nome = removeAcento(nome); 1525 nome = nome.replace(/[`~!@#$%^&*()_|ªº°+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '-'); 1526 nome = nome.trim().replace(/[.]/gi, ""); 1527 nome = nome.trim().replace(/ /gi, " "); 1528 nome = nome.replace(/[ ]/gi, "-"); 1529 nome = nome.replace(/[+?]/gi, "-"); 1530 nome = nome.replace(/--/gi, "-"); 1531 nome = nome.replace(/--/gi, "-"); 1532 nome = nome.replace(/--/gi, "-"); 1533 nome = nome.replace(/[,]/gi, ""); 1534 nome = nome.replace(/[:]/gi, ""); 1535 1536 return nome + extensao; 1537} 1538 1539function removeAcento(texto) { 1540 1541 // acento agudo 1542 texto = texto.replace(/[á]/gi, "a"); 1543 texto = texto.replace(/[é]/gi, "e"); 1544 texto = texto.replace(/[í]/gi, "i"); 1545 texto = texto.replace(/[ó]/gi, "o"); 1546 texto = texto.replace(/[ú]/gi, "u"); 1547 texto = texto.replace(/[Á]/gi, "A"); 1548 texto = texto.replace(/[É]/gi, "E"); 1549 texto = texto.replace(/[Í]/gi, "I"); 1550 texto = texto.replace(/[Ó]/gi, "O"); 1551 texto = texto.replace(/[Ú]/gi, "U"); 1552 1553 // acento circunflexo 1554 texto = texto.replace(/[â]/gi, "a"); 1555 texto = texto.replace(/[ê]/gi, "e"); 1556 texto = texto.replace(/[î]/gi, "i"); 1557 texto = texto.replace(/[ô]/gi, "o"); 1558 texto = texto.replace(/[û]/gi, "u"); 1559 texto = texto.replace(/[Â]/gi, "A"); 1560 texto = texto.replace(/[Ê]/gi, "E"); 1561 texto = texto.replace(/[Î]/gi, "I"); 1562 texto = texto.replace(/[Ô]/gi, "O"); 1563 texto = texto.replace(/[Û]/gi, "U"); 1564 1565 // til 1566 texto = texto.replace(/[ã]/gi, "a"); 1567 texto = texto.replace(/[õ]/gi, "o"); 1568 texto = texto.replace(/[Ã]/gi, "A"); 1569 texto = texto.replace(/[Õ]/gi, "O"); 1570 1571 // ce-cedilha 1572 texto = texto.replace(/[ç]/gi, "c"); 1573 texto = texto.replace(/[Ç]/gi, "C"); 1574 1575 // trema 1576 texto = texto.replace(/[ü]/gi, "u"); 1577 texto = texto.replace(/[Ü]/gi, "U"); 1578 1579 // crase 1580 texto = texto.replace(/[à]/gi, "a"); 1581 texto = texto.replace(/[è]/gi, "e"); 1582 texto = texto.replace(/[ì]/gi, "i"); 1583 texto = texto.replace(/[ò]/gi, "o"); 1584 texto = texto.replace(/[ù]/gi, "u"); 1585 texto = texto.replace(/[À]/gi, "A"); 1586 texto = texto.replace(/[È]/gi, "E"); 1587 texto = texto.replace(/[Ì]/gi, "I"); 1588 texto = texto.replace(/[Ò]/gi, "O"); 1589 texto = texto.replace(/[Ù]/gi, "U"); 1590 return texto; 1591} 1592 1593function getCursos(situacao) { 1594 getCursos(situacao, false, null); 1595} 1596 1597function getCursos(situacao, pacote, duvida) { 1598 $.getJSON("/portal/getCursos", { format: "json", situacao: situacao, duvida: duvida }).done(function(data) { 1599 $("#idCurso").empty(); 1600 $("#idCurso").append($("<option></option>").val('').html(label13)); 1601 $.each(data, function() { 1602 $("#idCurso").append($("<option></option>").val(this['tipoCurso'] + '-' + this['idCurso']).html(this['nomeComercial'])); 1603 if (pacote == true) { 1604 $.each(this['listaAlunoCursoPacoteTO'], function() { 1605 $("#idCurso").append($("<option></option>").val(this['tipoCurso'] + '-' + this['idCurso']).html('  ' + this['nomeComercial'])); 1606 }); 1607 } 1608 }); 1609 $("#idCurso").val($("#idCurso").data('value')); 1610 if ($("#idCurso option").length == 2) { 1611 $("#idCurso").prop("selectedIndex", 1); 1612 } 1613 $("#idCurso").change(); 1614 }); 1615} 1616 1617$('#btnRequestSend').click(function() { 1618 if (!$("#requestForm").valid()) { 1619 return; 1620 } 1621 $.post("/portal/salvarRequerimento", $("#requestForm").serialize(), function(data) { 1622 if (data.status == 0) { 1623 location.href = data.message; 1624 } else { 1625 alert(data.message); 1626 } 1627 }, 'json'); 1628}); 1629 1630$("#idEstado").change(function() { 1631 loadCidade(0, 0); 1632}); 1633 1634$("#idCidade").change(function() { 1635 loadBairro(0); 1636}); 1637 1638function loadBairro(idBairro) { 1639 if ($("#idCidade").val() == null) return; 1640 var url = "/listBairro?idCidade=" + $("#idCidade").val(); 1641 $("#idBairro").prop('options').length = 0 1642 $.getJSON(url, { format: "json" }).done(function(data) { 1643 $.each(data, function(i, item) { 1644 $("#idBairro").append($("<option />").val(item.id).text(item.nome)); 1645 }); 1646 if (idBairro > 0) $("#idBairro").val(idBairro); 1647 }); 1648} 1649 1650function loadCidade(idCidade, idBairro) { 1651 if ($("#idEstado").val() == null) return; 1652 var url = "/listCidade?idEstado=" + $("#idEstado").val(); 1653 $("#idCidade").prop('options').length = 0 1654 $.getJSON(url, { format: "json" }).done(function(data) { 1655 $.each(data, function(i, item) { 1656 $("#idCidade").append($("<option />").val(item.id).text(item.nome)); 1657 }); 1658 if (idCidade > 0) { 1659 $("#idCidade").val(idCidade); 1660 if (idBairro >
1660 0) loadBairro(idBairro); 1661 } else { 1662 $("#idCidade").change(); 1663 } 1664 }); 1665} 1666 1667function loadEstado(idEstado, idCidade, idBairro) { 1668 var url = "/listEstado"; 1669 $("#idEstado").prop('options').length = 0 1670 $.getJSON(url, { format: "json" }).done(function(data) { 1671 $.each(data, function(i, item) { 1672 $("#idEstado").append($("<option />").val(item.id).text(item.nome)); 1673 }); 1674 if (idEstado > 0) { 1675 $("#idEstado").val(idEstado); 1676 if (idCidade > 0) loadCidade(idCidade, idBairro); 1677 } else { 1678 $("#idEstado").change(); 1679 } 1680 }); 1681} 1682 1683$("#cep").blur(function() { 1684 if ($('#cep').attr('data-info') != $('#cep').val()) { 1685 var url = "/cep?cep=" + $("#cep").val(); 1686 $.getJSON(url, { format: "json" }).done(function(data) { 1687 $("#endereco").val(data.endereco); 1688 loadEstado(data.bairroTO.cidadeTO.estadoTO.id, data.bairroTO.cidadeTO.id, data.bairroTO.id); 1689 }); 1690 } 1691}); 1692 1693 1694$('#btnPerfilSend').click(function() { 1695 if (!$("#perfilForm").valid()) { 1696 return; 1697 } 1698 $.post("/portal/salvarPerfil", $("#perfilForm").serialize(), function(data) { 1699 $('#mensagem').text(data.message); 1700 $('#mensagem').removeClass('invisible'); 1701 }, 'json'); 1702}); 1703 1704$('#modal1').on('hide.bs.modal', function(e) { 1705 if ($("#gravacao").length = 1 && $("#gravacao").val() == 'S') { 1706 e.preventDefault(); 1707 e.stopPropagation(); 1708 return false; 1709 } 1710 if (typeof resetDocumentoDRM === 'function') { 1711 resetDocumentoDRM(); 1712 } 1713 1714 if (e.target.id != 'modalEstatistica' && e.target.id != 'modalSimulado' && e.target.id != 'dataAgendamento' && e.target.id != 'modalComentario') { 1715 sincronizarMediaRotina(); 1716 if ($('#modalBodyMedia').length > 0 && $('#modalBodyMedia').html() !== undefined && $('#modalBodyMedia').html().indexOf('iframeBoletim') == -1) { 1717 $('#modalBodyMedia').html(''); 1718 } else { 1719 $('#iframeBoletim').attr('src', ''); 1720 } 1721 $('#modalBodyMedia').html(''); 1722 return true; 1723 } 1724}) 1725 1726function sincronizarMediaRotina() { 1727 if (typeof $('#token').val() !== "undefined") { 1728 sincronizarVideo(true); 1729 } 1730} 1731function sincronizarVideo(enviar) { 1732 for (var i = 0; i < localStorage.length; i++) { 1733 var key = localStorage.key(i); 1734 if (key.length >= 6) { 1735 if (key.substring(0, 7) == 'TUTOR2-') { 1736 var data = localStorage.getItem(key); 1737 var arrayKey = key.split('-'); 1738 var arrayTempo = data.split('-'); 1739 token = arrayKey[1]; 1740 idVideo = arrayKey[2]; 1741 tipoVideo = arrayKey[3]; 1742 tempoTotal = arrayTempo[0]; 1743 tempoMax = arrayTempo[1]; 1744 tempo1 = arrayTempo[2]; 1745 controleDuracao = arrayTempo[3]; 1746 controleConsumo = arrayTempo[4]; 1747 controlePercentual = arrayTempo[5]; 1748 1749 if (enviar == false) { 1750 var hora = localStorage.getItem('TUTOR-TIME'); 1751 var horaAtual = getCompleteDate(); 1752 if ((diffHours(horaAtual, hora)) > 300) { 1753 enviar = true; 1754 } 1755 } 1756 if (enviar == true && tempoTotal > 0) { 1757 mediaClose(token, idVideo, tipoVideo, tempoTotal, tempoMax, tempo1, controleDuracao, controleConsumo, controlePercentual); 1758 localStorage.removeItem(key); 1759 } 1760 } 1761 } 1762 } 1763} 1764 1765function mediaClose(token, idVideo, tipoVideo, tempoTotal, tempoMax, tempo, controleDuracao, controleConsumo, controlePercentual) { 1766 1767 var consumo = false; 1768 if ($('#spanTempoVisto').length > 0) { 1769 consumo = true; 1770 } 1771 1772 //console.log('mediaClose:' + tempoTotal + '-' + tempoMax + '-' + idVideo + '-' + controleDuracao + '-' + controleConsumo + '-' + controlePercentual); 1773 1774 $.post("/portal/media-close", { 1775 token: token, 1776 tipoVideo: tipoVideo, 1777 tempoTotal: tempoTotal, 1778 tempoMax: tempoMax, 1779 tempoUltimo: tempo, 1780 idVideo: idVideo, 1781 tipoVideo: tipoVideo, 1782 consumo: consumo, 1783 controleDuracao: controleDuracao, 1784 controleConsumo: controleConsumo, 1785 controlePercentual: controlePercentual 1786 }, function(data) { 1787 if (data != null) { 1788 if (consumo == true) { 1789 $('#spanTempoVisto').html(data); 1790 } else { 1791 $("#box-consumo").html(label14 + ': ' + data.percentualConsumido + '%'); 1792 $("#box-total").html(label15 + ': ' + data.percentualFinal + '%'); 1793 if (data.alunoCertificado != null && data.alunoCertificado == 'S') { 1794 $("#divIconCertificado").css("display", "unset"); 1795 } 1796 $("#controleConsumo").val(data.controleConsumo); 1797 if (typeof atualizaPercentuais === 'function') { 1798 atualizaPercentuais(data); 1799 } 1800 } 1801 } 1802 }, 'json'); 1803} 1804 1805function marcarVistoEvent(event, idMediaAtualizar) { 1806 if (event != null) event.stopPropagation(); 1807 idVideo = $('#iconCheck-' + idMediaAtualizar).data("video"); 1808 if ($('#iconCheck-' + idMediaAtualizar).data("visto") == 1) { 1809 visto = 0 1810 } else { 1811 visto = 1 1812 } 1813 marcarVisto($('#token').val(), idVideo, visto, idMediaAtualizar); 1814} 1815 1816function marcarVisto(token, idVideo, visto, idMediaAtualizar) { 1817 $.post("/portal/marcar-visto", { 1818 token: token, 1819 idVideo: idVideo, 1820 visto: visto 1821 }, function(data) { 1822 if (data != null) { 1823 if (data.percentualConsumido != null) $("#box-consumo").html(label14 + ': ' + data.percentualConsumido + '%'); 1824 if (data.percentualFinal != null) $("#box-total").html(label15 + ': ' + data.percentualFinal + '%'); 1825 if (data.alunoCertificado != null && data.alunoCertificado == 'S') { 1826 $("#divIconCertificado").css("display", "unset"); 1827 } 1828 if (idMediaAtualizar != null) { 1829 $('#iconCheck-' + idMediaAtualizar).data("visto", visto); 1830 $('#iconMedia' + idMediaAtualizar).removeClass('text-checked'); 1831 $('#iconMedia' + idMediaAtualizar).removeClass('text-success'); 1832 $('#iconMedia' + idMediaAtualizar).removeClass('text-dark'); 1833 $('#badgeMedia' + idMediaAtualizar).removeClass('badge-success'); 1834 $('#badgeMedia' + idMediaAtualizar).removeClass('badge-checked'); 1835 $('#badgeMedia' + idMediaAtualizar).removeClass('badge-dark'); 1836 if (visto == 1) { 1837 $('#badgeMedia' + idMediaAtualizar).addClass('badge-success'); 1838 $('#iconMedia' + idMediaAtualizar).addClass('text-success'); 1839 $('#badgeMedia' + idMediaAtualizar).html(label34); 1840 } else { 1841 if (data.maxTempo == 0) { 1842 $('#badgeMedia' + idMediaAtualizar).addClass('badge-dark'); 1843 $('#iconMedia' + idMediaAtualizar).addClass('text-dark'); 1844 $('#badgeMedia' + idMediaAtualizar).html(label32); 1845 } else { 1846 $('#badgeMedia' + idMediaAtualizar).addClass('badge-checked'); 1847 $('#iconMedia' + idMediaAtualizar).addClass('text-checked'); 1848 $('#badgeMedia' + idMediaAtualizar).html(label33 + ' ' + data.maxTempoFormatado); 1849 } 1850 } 1851 } 1852 } 1853 }, 'json'); 1854} 1855 1856$('#btnMaterial').click(function() { 1857 if ($('#divVideoMaterial').attr('class') == 'd-none') { 1858 $('#divVideoMaterial').removeClass('d-none') 1859 $('#divVideoMaterial').addClass('col-md-3') 1860 $('#divVideoVideo').removeClass('col-md-3') 1861 $('#divVideoVideo').removeClass('col-md-6') 1862 $('#divVideoVideo').removeClass('col-md-12') 1863 $('#divVideoVideo').addClass('col-md-9') 1864 $('#divVideoChat').addClass('d-none') 1865 $('#divVideoChat').removeClass('col-md-3') 1866 $('#divBlocoNota').addClass('d-none'); 1867 $('#divBlocoNota').removeClass('col-md-3'); 1868 $('#divDuvida').addClass('d-none'); 1869 $('#divDuvida').removeClass('col-md-3') 1870 } else { 1871 $('#divVideoMaterial').addClass('d-none') 1872 $('#divVideoMaterial').removeClass('col-md-3') 1873 $('#divVideoMaterial').removeClass('col-md-6') 1874 $('#divVideoMaterial').removeClass('col-md-9') 1875 $('#divVideoVideo').removeClass('col-md-3') 1876 $('#divVideoVideo').removeClass('col-md-6') 1877 $('#divVideoVideo').removeClass('col-md-9') 1878 $('#divVideoVideo').addClass('col-md-12') 1879 } 1880}); 1881 1882$('#btnChat').click(function() { 1883 if ($('#divVideoChat').attr('class') == 'd-none') { 1884 $('#divVideoMaterial').addClass('d-none') 1885 $('#divVideoMaterial').removeClass('col-md-3') 1886 $('#divVideoChat').removeClass('d-none') 1887 $('#divVideoChat').addClass('col-md-3') 1888 $('#divVideoVideo').removeClass('col-md-12') 1889 $('#divVideoVideo').addClass('col-md-9') 1890 $('#divDuvida').addClass('d-none'); 1891 $('#divDuvida').removeClass('col-md-3') 1892 $('#divBlocoNota').addClass('d-none'); 1893 $('#divBlocoNota').removeClass('col-md-3'); 1894 1895 var url = '/portal/chat?idChatMultimedia=' + $('#idChatMultimedia').val(); 1896 $.ajax({ 1897 url: url, 1898 dataType: 'html', 1899 type: 'GET', 1900 async: true, 1901 success: function(data) { 1902 $('#divVideoChat').html(data); 1903 } 1904 }); 1905 1906 scroll(); 1907 } else { 1908 $('#divVideoChat').addClass('d-none') 1909 $('#divVideoChat').removeClass('col-md-3') 1910 $('#divVideoVideo').removeClass('col-md-9') 1911 $('#divVideoVideo').addClass('col-md-12') 1912 $('#divVideoChat').html(''); 1913 } 1914}); 1915 1916function loadTCC() { 1917 if ($('#idChatMultimedia').length > 0 && $('#idChatMultimedia').val() > 0 && $('#divVideoChat').length > 0 && $('#tokenOrientador').val().length > 0 && $('#tokenAluno').val().length > 0) { 1918 1919 var url = '/portal/chat?idChatMultimedia=' + $('#idChatMultimedia').val() + '&tokenAluno=' + $('#tokenAluno').val() + '&tokenProfessor=' + $('#tokenOrientador').val(); 1920 $.ajax({ 1921 url: url, 1922 dataType: 'html', 1923 type: 'GET', 1924 async: true, 1925 success: function(data) { 1926 $('#divVideoChat').html(data); 1927 } 1928 }); 1929 setTimeout("scroll()", 1000); 1930 } 1931} 1932 1933 1934clockCheckOnline(2000) 1935function clockCheckOnline(tempo) { 1936 var t = setTimeout("checkOnline()", tempo); 1937} 1938 1939 1940function checkOnline() { 1941 if (window.location.pathname == '/portal/login') return; 1942 if (window.location.pathname == '/portal/esqueci-a-senha') return; 1943 if (window.location.pathname == '/portal/validar-login') return; 1944 if (window.location.pathname == '/portal/validar-login-juspodium') return; 1945 if (window.location.pathname == '/portal/multiplo-login') return; 1946 if (window.location.pathname == '/portal/validar-codigo') return; 1947 if (window.location.pathname == '/portal/enviar-senha') return; 1948 1949 $.getJSON("/portal/checkOnline", { format: "json" }).done(function(data) { 1950 if (data != null && data.id != null && data.tipo == 'B') { 1951 if (typeof window.abrirCadastroBiometria === 'function') { 1952 window.abrirCadastroBiometria(data); 1953 } 1954 } else if (data != null && data.id != null && (data.tipo == 'C' || data.tipo == 'S')) { 1955 $.notify({ icon: 'glyphicon glyphicon glyphicon-ok', message: data.nome, url: '/portal/aviso-detalhe/' + data.id }, { type: 'info', z_index: 1000000 }); 1956 } else if (data != null && data.titulo != null && data.tipo == 'Q') { 1957 window.open('/portal/' + data.link + '?chave=' + data.titulo, '_self'); 1958 } else if (data != null && data.titulo != null && data.tipo == 'L') { 1959 alert(data.titulo); 1960 window.open('/portal/' + data.link, '_self'); 1961 } else if (data != null && data.id != null && data.tipo == 'P') { 1962 $('#idContratoPadrao').val(data.id); 1963 $('#idContratoPadraoContrato').val(data.idAlunoMensalidade); 1964 $('#dealPopupTitle').html(data.nome); 1965 $('#dealPopupDescription').html(data.conteudoContrato); 1966 $('#dealPopup').modal('show'); 1967 $('#dealPopupFrame').hide(); 1968 $('#dealPopupDescription').show(); 1969 1970 } else if (data != null && data.id != null && data.tipo == 'F') { 1971 if (window.location.pathname != '/portal/' + data.link) { 1972 $('#modalFormularioFrame').attr('src', '/portal/' + data.link); 1973 $('#modalFormulario').modal('show'); 1974 } 1975 } 1976 }).fail(function(jqXHR) { 1977 if (jqXHR.status === 401 || jqXHR.status === 403) { 1978 window.location.href = "/portal/login"; 1979 } else { 1980 if (jqXHR.responseText.indexOf("<!DOCTYPE html>") !== -1) { 1981 window.location.href = "/portal/login"; 1982 } 1983 } 1984 }); 1985 clockCheckOnline(300000); 1986 1987} 1988function closeModal() { 1989 $("#modalFormulario").modal("hide"); 1990} 1991 1992function removerArquivoAvaliacao(idAvaliacaoAluno, token) { 1993 if (confirm('Tem certeza que deseja remover o arquivo?') == true) { 1994 $.post("/portal/removerArquivoAvaliacao", { idAvaliacaoAluno: idAvaliacaoAluno }, function(data) { 1995 if (data.message.length > 0) { 1996 alert(data.message); 1997 } 1998 if ($('#modal1').length > 0) { 1999 document.location.reload(true); 2000 } else if (data.status == 0) { 2001 openMedia(event, token); 2002 } 2003 }, 'json'); 2004 } 2005} 2006 2007function enviarArquivoAvaliacao(idAvaliacaoAluno, idAlunoMensalidade, idAvaliacao, idTopico, tipoCurso, idCurso, token) { 2008 if (verificaArquivo(document.getElementById('fileUpload'), ",.mp3,.xlsx,.xls,.png,.gif,.jpeg,.jpg,.doc,.docx,.pdf,.ppt,.pptx,", 52428800, '50MB') == false) { 2009 return false;
2010 } 2011 2012 if ($('#btnAvaliacaoFileSend') != null && $('#btnAvaliacaoFileSend').length > 0) { 2013 $('#btnAvaliacaoFileSend').prop("disabled", true); 2014 } 2015 2016 var idAvaliacaoProposta = null; 2017 if ($('#idAvaliacaoProposta').length > 0) idAvaliacaoProposta = document.getElementById('idAvaliacaoProposta').value; 2018 $.post("/portal/enviarArquivoAvaliacao", { 2019 arquivo: converteArquivoInternet(document.getElementById('fileUpload').files[0].name), 2020 idAvaliacaoAluno: idAvaliacaoAluno, 2021 idAlunoMensalidade: idAlunoMensalidade, 2022 idAvaliacao: idAvaliacao, 2023 idTopico: idTopico, 2024 tipoCurso: tipoCurso, 2025 idCurso: idCurso, 2026 idAvaliacaoProposta: idAvaliacaoProposta 2027 }, function(data) { 2028 2029 if (data.message.length > 0) { 2030 alert(data.message); 2031 } 2032 if ($('#listAvaliacoes').length > 0) { 2033 document.location.reload(true); 2034 } else if (data.status == 0) { 2035 openMedia(event, token); 2036 } 2037 }, 'json'); 2038} 2039 2040function enviarTextoAvaliacao(idAvaliacaoAluno, idAlunoMensalidade, idAvaliacao, idTopico, tipoCurso, idCurso, chave) { 2041 const texto = document.getElementById("textoAvaliacao").value; 2042 2043 2044 if (texto.length < 1) return false; 2045 2046 var idAvaliacaoProposta = null; 2047 if ($('#idAvaliacaoProposta').length > 0) idAvaliacaoProposta = document.getElementById('idAvaliacaoProposta').value; 2048 $.post("/portal/enviarTextoAvaliacao", { 2049 texto: texto, 2050 idAvaliacaoAluno: idAvaliacaoAluno, 2051 idAlunoMensalidade: idAlunoMensalidade, 2052 idAvaliacao: idAvaliacao, 2053 idTopico: idTopico, 2054 tipoCurso: tipoCurso, 2055 idCurso: idCurso, 2056 idAvaliacaoProposta: idAvaliacaoProposta 2057 }, function(data) { 2058 if (data.message.length > 0) { 2059 alert(data.message); 2060 } 2061 if (data.status == 0) { 2062 if ($('#listAvaliacoes').length > 0) { 2063 location.reload(); 2064 } else if ($('#modal1').length > 0) { 2065 $('#modal1').modal('hide'); 2066 } 2067 } 2068 }, 'json'); 2069} 2070 2071function verificaArquivo(arquivoParam, extensoesOk, tamanhoArquivo, tamanhoArquivoDescricao) { 2072 2073 var extensao = ',' + arquivoParam.value.substr(arquivoParam.value.length - 4).toLowerCase() + ','; 2074 if (extensao.substr(1, 1) != '.') { 2075 extensao = ',' + arquivoParam.value.substr(arquivoParam.value.length - 5).toLowerCase() + ','; 2076 } 2077 if (extensao.substr(1, 1) != '.') { 2078 alert(label16 + ': ' + extensoesOk.substring(1, extensoesOk.length - 1)); 2079 return false; 2080 } 2081 if (arquivoParam.value == "") { 2082 alert(label17); 2083 return false; 2084 } else if (extensoesOk.indexOf(extensao) == -1) { 2085 alert(label16 + ': ' + extensoesOk.substring(1, extensoesOk.length - 1)); 2086 return false; 2087 } else if (arquivoParam.files[0].size > tamanhoArquivo) { 2088 alert(label18 + tamanhoArquivoDescricao + '.'); 2089 return false; 2090 } 2091 return true; 2092} 2093$('#btnClose1').click(function() { 2094 if ($('#modalBodyMedia').length > 0 && $('#modalBodyMedia').html() !== undefined && $('#modalBodyMedia').html().indexOf('iframeBoletim') == -1) { 2095 $('#modalBodyMedia').html(''); 2096 } else { 2097 $('#iframeBoletim').attr('src', ''); 2098 } 2099 $('#modal1').modal('hide'); 2100 $('#modal1').hide(); 2101 $('.modal-backdrop').remove(); 2102}); 2103 2104function baixarArquivoAluno(id, nomeArquivo) { 2105 window.open('/portal/documentoAlunoAvaliacao?idAvaliacaoAluno=' + id + '&nomeArquivo=' + nomeArquivo, '_self'); 2106} 2107 2108function baixarArquivoProfessor(id, nomeArquivo) { 2109 window.open('/portal/documentoProfessorAvaliacao?idAvaliacaoAluno=' + id + '&nomeArquivo=' + nomeArquivo, '_self'); 2110} 2111 2112function abrirAudio() { 2113 $('#modalTitleAudio').text(label19) 2114 $('#modalAudio').modal('show'); 2115} 2116 2117function prepararComentarios() { 2118 const comentarios = document.getElementById('comentarios'); 2119 2120 if (comentarios.classList.contains('mceEditorComentario')) { 2121 document.getElementById('comentarios').value = tinymce.get("comentarios").getContent(); 2122 } 2123} 2124 2125function salvarAvaliacaoCorrecaoRascunho() { 2126 if (!$("#correctForm").valid()) { 2127 return; 2128 } 2129 2130 prepararComentarios(); 2131 2132 $.post("/portal/salvarAvaliacaoCorrecaoRascunho", $("#correctForm").serialize(), function(data) { 2133 if (data.status == 0) { 2134 location.href = data.message; 2135 } else { 2136 alert(data.message); 2137 } 2138 }, 'json'); 2139} 2140 2141function salvarAvaliacaoCorrecao() { 2142 if (!$("#correctForm").valid()) { 2143 return false; 2144 } 2145 2146 prepararComentarios(); 2147 2148 $.post("/portal/salvarAvaliacaoCorrecao", $("#correctForm").serialize(), function(data) { 2149 if (data.status == 0) { 2150 location.href = data.message; 2151 } else { 2152 alert(data.message); 2153 } 2154 }, 'json'); 2155} 2156 2157 2158function removerArquivoAvaliacaoProfessor(id, nomeArquivo, item) { 2159 if (confirm('Deseja realmente excluir o arquivo ' + nomeArquivo + ' ?')) { 2160 $.post("/portal/removerArquivoAvaliacaoProfessor", { id: id, nomeArquivo: nomeArquivo }, function(data) { 2161 alert(data.message); 2162 if (data.status == 0) $(item).parent().remove(); 2163 }, 'json'); 2164 } 2165} 2166 2167function proximaPagina(form, pagina, indice) { 2168 pagina.val(indice); 2169 form.submit(); 2170} 2171
2172function salvarRespostaDuvida() { 2173 2174 if (!$("#inquiryForm").valid()) { 2175 return false; 2176 } 2177 2178 $.post("/portal/salvarRespostaDuvida", $("#inquiryForm").serialize(), function(data) { 2179 if (data.status == 0) { 2180 location.href = data.message; 2181 } else { 2182 alert(data.message); 2183 } 2184 }, 'json'); 2185} 2186 2187function loadTeacherReport(combo) { 2188 2189 var currentTime = new Date(); 2190 var month = currentTime.getMonth() + 1; 2191 var year = currentTime.getFullYear(); 2192 2193 2194 var dateNextMonth = new Date(); 2195 dateNextMonth.setMonth(dateNextMonth.getMonth() + 1); 2196 var monthNext = dateNextMonth.getMonth() + 1; 2197 var yearNext = dateNextMonth.getFullYear(); 2198 2199 monthNextString = monthNext; 2200 if (month < 10) monthNextString = '0' + monthNext; 2201 combo.append($("<option />").val(monthNextString + '/' + yearNext).text(monthNextString + '/' + yearNext)); 2202 2203 for (i = 1; i <= 12; i++) { 2204 monthString = month; 2205 if (month < 10) monthString = '0' + month; 2206 2207 combo.append($("<option />").val(monthString + '/' + year).text(monthString + '/' + year)); 2208 if ((month - 1) == 0) { 2209 month = 12; 2210 year = year - 1; 2211 } else { 2212 month--; 2213 } 2214 } 2215 combo.selectedIndex = 1; 2216 combo.find('option:eq(1)').prop('selected', true); 2217} 2218 2219 2220 2221function float2moeda2(num) { 2222 moeda = float2moeda(num); 2223 moeda = moeda.replace(",00", ""); 2224 return moeda; 2225} 2226function float2moeda(num) { 2227 x = 0; 2228 if (num < 0) { 2229 num = Math.abs(num); 2230 x = 1; 2231 } 2232 if (isNaN(num)) 2233 num = "0"; 2234 cents = Math.floor((num * 100 + 0.5) % 100); 2235 num = Math.floor((num * 100 + 0.5) / 100).toString(); 2236 if (cents < 10) 2237 cents = "0" + cents; 2238 for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) 2239 num = num.substring(0, num.length - (4 * i + 3)) + '.' 2240 + num.substring(num.length - (4 * i + 3)); 2241 ret = num + ',' + cents; 2242 if (x == 1) 2243 if (num != 0 || cents != '00') 2244 ret = ' -' + ret; 2245 return ret; 2246} 2247 2248function moeda2float(moeda) { 2249 moeda = moeda.replace(".", ""); 2250 moeda = moeda.replace(",", "."); 2251 return parseFloat(moeda); 2252} 2253 2254function documentoAlunoRequerimento(id, nomeArquivo) { 2255 window.open('/portal/documentoAlunoRequerimento?idRequerimento=' + id + '&nomeArquivo=' + nomeArquivo, '_self'); 2256} 2257function documentoRespostaRequerimento(id, nomeArquivo) { 2258 window.open('/portal/documentoRespostaRequerimento?idRequerimento=' + id + '&nomeArquivo=' + nomeArquivo, '_self'); 2259} 2260 2261function openURL(url, contentHTML, modalID) { 2262 $(modalID).modal('show'); 2263 $.ajax({ 2264 url: url, 2265 dataType: 'html', 2266 type: 'GET', 2267 async: true, 2268 success: function(data) { 2269 $(contentHTML).html(data); 2270 } 2271 }); 2272} 2273 2274function getAlunos() { 2275 if ($('#idCurso').val() != '') { 2276 $.getJSON("/portal/getAlunos", { format: "json", idCurso: $('#idCurso').val(), idAvaliacao: $('#idAvaliacao').val(), idDisciplina: $('#idDisciplina').val() }).done(function(data) { 2277 $("#tableAluno").empty(); 2278 for (var i = 0; i < data.length; i++) { 2279 var linha = "<tr><td>" + (i + 1); 2280 linha += "<input type=\"hidden\" name=\"itemAluno\" id=\"txtAluno" + data[i].pessoaTO.id + "\" size=\"10\" maxlength=\"10\" class=\"form-control\" value=\"" + data[i].pessoaTO.id + "\"></input>"; 2281 linha += "<input type=\"hidden\" name=\"itemContrato\" id=\"txtContrato" + data[i].pessoaTO.id + "\" size=\"10\" maxlength=\"10\" class=\"form-control\" value=\"" + data[i].idContrato + "\"></input>"; 2282 linha += "</td><td>" + data[i].matricula; 2283 linha += "</td><td>" + data[i].pessoaTO.nome; 2284 linha += "</td><td><input type=\"text\" name=\"itemNota\" id=\"txtNota" + data[i].pessoaTO.id + "\" size=\"10\" maxlength=\"10\" class=\"form-control\" value=\"" + data[i].notaFormatada + "\"></input>"; 2285 if (data[i].segundaChamada == 'S') { 2286 linha += "</td><td><input type=\"checkbox\" name=\"itemSegunda\" id=\"itemSegunda" + data[i].pessoaTO.id + "\" value=\"" + data[i].pessoaTO.id + "\" checked>"; 2287 } else { 2288 linha += "</td><td><input type=\"checkbox\" name=\"itemSegunda\" id=\"itemSegunda" + data[i].pessoaTO.id + "\" value=\"" + data[i].pessoaTO.id + "\">"; 2289 } 2290 linha += "</td></tr>"; 2291 $("#tableAluno").append(linha); 2292 } 2293 }); 2294 } 2295} 2296 2297function getCupons() { 2298 $.getJSON("/portal/getCupons", { format: "json", idProfessor: $('#
2298idProfessor').val() }).done(function(data) { 2299 $("#tableCupom").empty(); 2300 for (var i = 0; i < data.length; i++) { 2301 var linha = "<tr><td>" + (i + 1); 2302 linha += "<input type=\"hidden\" name=\"itemCupom\" id=\"txtCupom" + data[i].id + "\" size=\"10\" maxlength=\"10\" class=\"form-control\" value=\"" + data[i].id + "\"></input>"; 2303 linha += "</td><td>" + data[i].nomePessoa; 2304 linha += "</td><td>" + data[i].nomeCupom; 2305 linha += "</td><td>" + data[i].valorCupom; 2306 linha += "</td></tr>"; 2307 $("#tableCupom").append(linha); 2308 } 2309 }); 2310 2311} 2312 2313function salvarNotas() { 2314 var valores = ''; 2315 $("input[name='itemAluno']").each(function(i, v) { 2316 valores += this.value + ';' + $('#txtContrato' + this.value).val() + ';' + $('#txtNota' + this.value).val() + ';' + $('#itemSegunda' + this.value).is(':checked') + '|'; 2317 }); 2318 $('#valores').val(valores) 2319 2320 if (!$("#correctForm").valid()) { 2321 return; 2322 } 2323 $.post("/portal/salvarNota", $("#correctForm").serialize(), function(data) { 2324 if (data.status == 0) { 2325 location.href = data.message; 2326 } else { 2327 alert(data.message); 2328 } 2329 }, 'json'); 2330} 2331 2332 2333function setGosto() { 2334 if ($('#idCurso').val() != '') { 2335 $.getJSON("/portal/setGosto", { format: "json", idCurso: $('#tipoCurso').val() + '-' + $('#idCurso').val() }).done(function(data) { 2336 if (data.status == 0) { 2337 $('#iconeGosto').attr('class', 'far fa-thumbs-up'); 2338 $('#divGostoQuantidade').html(data.message); 2339 } else { 2340 $('#iconeGosto').attr('class', 'fas fa-thumbs-up'); 2341 $('#divGostoQuantidade').html(data.message); 2342 } 2343 }); 2344 } 2345} 2346 2347if ($('#divGostoQuantidade').length > 0) { 2348 if ($('#idCurso').val() != '') { 2349 $.getJSON("/portal/getGosto", { format: "json", idCurso: $('#tipoCurso').val() + '-' + $('#idCurso').val() }).done(function(data) { 2350 if (data.status == 0) { 2351 $('#iconeGosto').attr('class', 'far fa-thumbs-up'); 2352 $('#divGostoQuantidade').html(data.message); 2353 } else { 2354 $('#iconeGosto').attr('class', 'fas fa-thumbs-up'); 2355 $('#divGostoQuantidade').html(data.message); 2356 } 2357 }); 2358 } 2359} 2360 2361 2362function setFavorito() { 2363 if ($('#idCurso').val() != '') { 2364 $.getJSON("/portal/setFavorito", { format: "json", idCurso: $('#tipoCurso').val() + '-' + $('#idCurso').val() }).done(function(data) { 2365 if (data.status == 0) { 2366 $('#iconeFavorito').attr('class', 'far fa-star'); 2367 } else { 2368 $('#iconeFavorito').attr('class', 'fas fa-star'); 2369 } 2370 }); 2371 } 2372} 2373 2374if ($('#iconeFavorito').length > 0) { 2375 if ($('#idCurso').val() != '') { 2376 $.getJSON("/portal/getFavorito", { format: "json", idCurso: $('#tipoCurso').val() + '-' + $('#idCurso').val() }).done(function(data) { 2377 if (data.status == 0) { 2378 $('#iconeFavorito').attr('class', 'far fa-star'); 2379 } else { 2380 $('#iconeFavorito').attr('class', 'fas fa-star'); 2381 } 2382 }); 2383 } 2384} 2385 2386$('.btn-trocar').click(function() { 2387 $.getJSON("/portal/trocar-produto", { format: "json", idProduto: $(this).data('id') }).done(function(data) { 2388 if (data.status == 0) { 2389 alert(data.message); 2390 $('.btn-trocar').html(label22); 2391 } else { 2392 alert(data.message); 2393 } 2394 }); 2395}); 2396 2397$('#btnCopyLink').click(function() { 2398 var copyText = document.getElementById("productLink"); 2399 copyText.select(); 2400 document.execCommand("copy"); 2401}); 2402 2403 2404 2405$("#btnPrint").click(function() { 2406 var divToPrint = document.getElementById('dealPopupDescription'); 2407 newWin = window.open(""); 2408 newWin.document.write(divToPrint.outerHTML); 2409 newWin.print(); 2410 newWin.close(); 2411}); 2412 2413$("#btnConcordoContrato").click(function() { 2414 $.getJSON("/portal/setContratoPessoa", { format: "json", idContratoPadrao: $('#idContratoPadrao').val(), idAlunoMensalidade: $('#idContratoPadraoContrato').val() }).done(function(data) { 2415 $('#dealPopup').modal('hide'); 2416 }); 2417}); 2418 2419$('#btnTopico').click(function() { 2420 if ($('#divTopico').attr('class') == 'd-none') { 2421 $('#divTopico').removeClass('d-none') 2422 if ($('#divTopico').data('load') == 'N') { 2423 getTopicoPai(); 2424 $('#divTopico').data('load', 'S'); 2425 } 2426 } else { 2427 $('#divTopico').addClass('d-none') 2428 } 2429}); 2430 2431function getTopicoPai() { 2432 if ($('#divTopico').data('load') == 'N') { 2433 var contentHtml = $('#divTopico').html(); 2434 $('#divTopico').html($('#divTopico').html() + '<span class="badge badge-warning badge-media">
2434' + label01 + '...</span>'); 2435 $.getJSON("/portal/getTopicoPai", { format: "json", token: $("#token").val() }).done(function(data) { 2436 2437 contentHtml = contentHtml + '<div class="titulo"><h5 class="float-left">' + label23 + ':</h5><button type="button" class="close" id="btnCloseTopico" onclick="closeTopico()"><span aria-hidden="true">×</span></button></div>'; 2438 contentHtml = contentHtml + '<ul class="list-group list-grup-topics">'; 2439 for (var i = 0; i < data.listTopics.length; i++) { 2440 var comentario = ''; 2441 if (data.listTopics[i].comentario != null && data.listTopics[i].comentario.length > 0) { 2442 comentario = '<span class="badge badge-primary badge-media badge-media-' + data.tipo + '">' + data.listTopics[i].comentario + '</span>'; 2443 } 2444 contentHtml += '<li class="list-group-item item-tree clearfix" onclick="openTopic(event, this, \'' + data.token + '-' + data.listTopics[i].token + '\', \'I\', false)">' + data.listTopics[i].nome + '</li>'; 2445 } 2446 contentHtml += '</ul>'; 2447 2448 $('#divTopico').html(contentHtml); 2449 }); 2450 } 2451} 2452 2453function closeTopico() { 2454 $('#divTopico').addClass('d-none'); 2455} 2456 2457function openMediaProximo() { 2458 var url = '/portal/media?token=' + $('#chaveProximo').val(); 2459 $.ajax({ 2460 url: url, 2461 dataType: 'html', 2462 type: 'GET', 2463 async: true, 2464 success: function(data) { 2465 $('#modalBodyMedia').html(data); 2466 2467 if ($('.btnSidebarPrimaryPDFShowcaseClose').length) { 2468 $('.btnSidebarPrimaryPDFShowcaseClose').trigger('click'); 2469 $('.linkSidebarPrimaryClassListOpen').trigger('click'); 2470 } 2471 2472 } 2473 }); 2474} 2475 2476function openMediaAnterior() { 2477 var url = '/portal/media?token=' + $('#chaveAnterior').val(); 2478 $.ajax({ 2479 url: url, 2480 dataType: 'html', 2481 type: 'GET', 2482 async: true, 2483 success: function(data) { 2484 $('#modalBodyMedia').html(data); 2485 2486 if ($('.btnSidebarPrimaryPDFShowcaseClose').length) { 2487 $('.btnSidebarPrimaryPDFShowcaseClose').trigger('click'); 2488 $('.linkSidebarPrimaryClassListOpen').trigger('click'); 2489 } 2490 2491 } 2492 }); 2493} 2494$('#btnAvancar').click(function() { 2495 goNextClass(); 2496}); 2497 2498function goNextClass() { 2499 sincronizarMediaRotina(); 2500 openMediaProximo(); 2501} 2502 2503$('#btnRetroceder').click(function() { 2504 goPrevClass(); 2505}); 2506 2507function goPrevClass() { 2508 sincronizarMediaRotina(); 2509 openMediaAnterior(); 2510} 2511 2512$('#btnDuvida').click(function() { 2513 if ($('#divDuvida').attr('class') == 'd-none') { 2514 $('#divVideoMaterial').addClass('d-none'); 2515 $('#divVideoMaterial').removeClass('col-md-3'); 2516 $('#divVideoChat').addClass('d-none'); 2517 $('#divVideoChat').removeClass('col-md-3'); 2518 $('#divBlocoNota').addClass('d-none'); 2519 $('#divBlocoNota').removeClass('col-md-3'); 2520 $('#divDuvida').removeClass('d-none'); 2521 $('#divDuvida').addClass('col-md-3'); 2522 $('#divVideoVideo').removeClass('col-md-12'); 2523 $('#divVideoVideo').addClass('col-md-9'); 2524 } else { 2525 $('#divDuvida').addClass('d-none'); 2526 $('#divDuvida').removeClass('col-md-3'); 2527 $('#divVideoVideo').removeClass('col-md-9'); 2528 $('#divVideoVideo').addClass('col-md-12'); 2529 } 2530}); 2531 2532$('#btnAnotacoes').click(function() { 2533 if ($('#divBlocoNota').attr('class') == 'd-none') { 2534 $('#divVideoMaterial').addClass('d-none'); 2535 $('#divVideoMaterial').removeClass('col-md-3'); 2536 $('#divVideoChat').addClass('d-none'); 2537 $('#divVideoChat').removeClass('col-md-3'); 2538 $('#divDuvida').addClass('d-none'); 2539 $('#divDuvida').removeClass('col-md-3'); 2540 $('#divBlocoNota').removeClass('d-none'); 2541 $('#divBlocoNota').addClass('col-md-3'); 2542 $('#divVideoVideo').removeClass('col-md-12'); 2543 $('#divVideoVideo').addClass('col-md-9'); 2544 2545 getBlocoNotas(); 2546 $("#divBlocoNotaEnvio").hide(); 2547 $("#divBlocoNotaLista").show(); 2548 2549 } else { 2550 $('#divBlocoNota').addClass('d-none'); 2551 $('#divBlocoNota').removeClass('col-md-3'); 2552 $('#divVideoVideo').removeClass('col-md-9'); 2553 $('#divVideoVideo').addClass('col-md-12'); 2554 } 2555}); 2556 2557function salvarBlocoNotas() { 2558 if (!$("#formBlocoNota").valid()) { 2559 return; 2560 } 2561 2562 $("#idVideoBlocoNota").val($("#idVideo").val()); 2563 if (typeof tempo !== 'undefined') $("#tempoBlocoNota").val(tempo); 2564 2565 $.post("/portal/salvarBlocoNota", $("#formBlocoNota").serialize(), function(data) { 2566 if (data.status == 0) { 2567 $("#idBlocoNota").val(0); 2568 $("#idVideoBlocoNota").val(0); 2569 $("#tempoBlocoNota").val(0); 2570 $("#tituloBlocoNota").val(''); 2571 $("#descricaoBlocoNota").val(''); 2572 getBlocoNotas(); 2573 $("#divBlocoNotaEnvio").hide(); 2574 $("#divBlocoNotaLista").show(); 2575 } else { 2576 alert(data.message); 2577 } 2578 }, 'json'); 2579} 2580 2581function getBlocoNotas() { 2582 $.getJSON("/portal/getBlocoNotas", { format: "json", idVideoBlocoNota: $("#idVideo").val() }).done(function(data) { 2583 $("#ulListaBlocoNotas").empty(); 2584 for (var i = 0; i < data.length; i++) { 2585 var linha = '<li class="list-group-item">';
2586 linha += '<a href="javascript:getBlocoNota(' + data[i].id + ')" style="color:#000;text-decoration: none;"><b>' + data[i].titulo + '</b></a></br>'; 2587 linha += data[i].descricao; 2588 linha += "</li>"; 2589 $("#ulListaBlocoNotas").append(linha); 2590 } 2591 }); 2592} 2593 2594function showBlocoNotaLista() { 2595 $("#divBlocoNotaEnvio").hide(); 2596 $("#divBlocoNotaLista").show(); 2597} 2598 2599function showBlocoNotaIncluir() { 2600 $("#divBlocoNotaLista").hide(); 2601 $("#divBlocoNotaEnvio").show(); 2602} 2603 2604function getBlocoNota(id) { 2605 $.getJSON("/portal/getBlocoNota", { format: "json", id: id }).done(function(data) { 2606 $("#idBlocoNota").val(data.id); 2607 $("#idVideoBlocoNota").val(data.videoTO.id); 2608 $("#tempoBlocoNota").val(data.tempo); 2609 $("#tituloBlocoNota").val(data.titulo); 2610 $("#descricaoBlocoNota").val(data.descricao); 2611 showBlocoNotaIncluir(); 2612 }); 2613} 2614 2615function setMediaFavorito() { 2616 if ($('#tipo').val() == 'V') { 2617 if ($('#idVideo').val() != '') { 2618 $.getJSON("/portal/setVideoFavorito", { format: "json", idVideo: $('#idVideo').val(), token: $('#token').val() }).done(function(data) { 2619 if (data.status == 0) { 2620 if ($('#iconeMediaFavorito').length > 0) $('#iconeMediaFavorito').prop('class', 'far fa-star'); 2621 if ($('#iconeMediaFavorito4').length > 0) $('#iconeMediaFavorito4').removeAttr('checked'); 2622 if ($('#iconeMediaFavorito4').length > 0) $('#iiconeMediaFavorito4').css('color', '#dedee6'); 2623 if ($('#iconeMediaFavorito5').length > 0) $('#iconeMediaFavorito5').removeAttr('checked'); 2624 if ($('#iiconeMediaFavorito5').length > 0) $('#iiconeMediaFavorito5').css('color', '#dedee6'); 2625 if ($('#iconeMediaFavorito6').length > 0) $('#iconeMediaFavorito6').removeAttr('checked'); 2626 if ($('#iiconeMediaFavorito6').length > 0) $('#iiconeMediaFavorito6').css("font-weight", "lighter"); 2627 } else { 2628 if ($('#iconeMediaFavorito').length > 0) $('#iconeMediaFavorito').prop('class', 'fas fa-star'); 2629 if ($('#iconeMediaFavorito4').length > 0) $('#iconeMediaFavorito4').prop('checked', 'checked'); 2630 if ($('#iiconeMediaFavorito4').length > 0) $('#iiconeMediaFavorito4').css('color', '#fa0300'); 2631 if ($('#iconeMediaFavorito5').length > 0) $('#iconeMediaFavorito5').prop('checked', 'checked'); 2632 if ($('#iiconeMediaFavorito5').length > 0) $('#iiconeMediaFavorito5').css('color', '#fa0300'); 2633 if ($('#iconeMediaFavorito6').length > 0) $('#iconeMediaFavorito6').prop('checked', 'checked'); 2634 if ($('#iiconeMediaFavorito6').length > 0) $('#iiconeMediaFavorito6').css("font-weight", "bold"); 2635 2636 } 2637 }); 2638 } 2639 } else if ($('#tipo').val() == 'D') { 2640 if ($('#idDocumento').val() != '') { 2641 $.getJSON("/portal/setDocumentoFavorito", { format: "json", idDocumento: $('#idDocumento').val(), token: $('#token').val() }).done(function(data) { 2642 if (data.status == 0) { 2643 if ($('#iconeMediaFavorito').length > 0) $('#iconeMediaFavorito').attr('class', 'far fa-star'); 2644 if ($('#iconeMediaFavorito4').length > 0) $('#iconeMediaFavorito4').attr('checked', false); 2645 if ($('#iconeMediaFavorito6').length > 0) $('#iconeMediaFavorito6').attr('checked', false); 2646 if ($('#iiconeMediaFavorito6').length > 0) $('#iiconeMediaFavorito6').css("font-weight", "lighter"); 2647 } else { 2648 if ($('#iconeMediaFavorito').length > 0) $('#iconeMediaFavorito').attr('class', 'fas fa-star'); 2649 if ($('#iconeMediaFavorito4').length > 0) $('#iconeMediaFavorito4').attr('checked', true); 2650 if ($('#iconeMediaFavorito6').length > 0) $('#iconeMediaFavorito6').attr('checked', true); 2651 if ($('#iiconeMediaFavorito6').length > 0) $('#iiconeMediaFavorito6').css("font-weight", "bold"); 2652 } 2653 }); 2654 } 2655 } 2656} 2657 2658 2659$('#star-rating').on('mouseover', 'i.fas.fa-star', function(event) { 2660 $(this).removeClass('star-unchecked').addClass('star-checked'); 2661 $(this).prevAll().removeClass('star-unchecked').addClass('star-checked'); 2662 $(this).nextAll().removeClass('star-checked').addClass('star-unchecked'); 2663}); 2664 2665$('#star-rating').on('mouseleave', 'i.fas.fa-star', function(event) { 2666 active = $(this).parent().find('.selected'); 2667 if (active.length) { 2668 active.removeClass('star-unchecked').addClass('star-checked'); 2669 active.prevAll().removeClass('star-unchecked').addClass('star-checked'); 2670 active.nextAll().removeClass('star-checked ').addClass('star-unchecked'); 2671 } else { 2672 $('#star-rating').find('.fas.fa-star').removeClass('star-checked').addClass('star-unchecked'); 2673 } 2674}); 2675 2676$('#star-rating').on('click', 'i.fas.fa-star', function(event) { 2677 if ($(this).hasClass('selected')) { 2678 $(this).removeClass('selected'); 2679 registraRating(0); 2680 } else { 2681 $('#star-rating').find('i').removeClass('selected'); 2682 $(this).addClass('selected'); 2683 registraRating($(this).data('rating')); 2684 } 2685}); 2686 2687 2688function registraRating(classificacao) { 2689 2690 if (typeof classificacao === "undefined") { 2691 return; 2692 } 2693 if ($('#tipo').val() == 'V') { 2694 $.getJSON("/portal/setVideoClassificacao", { format: "json", idVideo: $('#idVideo').val(), classificacao: classificacao }).done(function(data) { }); 2695 } else if ($('#tipo').val() == 'D') { 2696 $.getJSON("/portal/setDocumentoClassificacao", { format: "json", idDocumento: $('#idDocumento').val(), classificacao: classificacao }).done(function(data) { }); 2697 } 2698} 2699 2700$("#palavraChaveCertificado").keyup(function() { 2701 $("#tableCertificate > tbody > tr").each(function() { 2702 if ($(this).text().toUpperCase().indexOf($('#palavraChaveCertificado').val().toUpperCase()) >= 0) { 2703 $(this).show(); 2704 } else { 2705 $(this).hide(); 2706 } 2707 if ($('#palavraChaveCertificado').val() == 0) { 2708 $(this).show(); 2709 } 2710 }); 2711}); 2712 2713function openPesquisaSatisfacao(url, chave, titulo) { 2714 $('#modalTitle').text(titulo) 2715 $('#modal1').modal('show'); 2716 2717 url = url + '?chave=' + chave; 2718 $.ajax({ 2719 url: url, 2720 dataType: 'html', 2721 type: 'GET', 2722 async: true, 2723 success: function(data) { 2724 $('#modalBodyMedia').html(data); 2725 } 2726 }); 2727} 2728 2729 2730function salvarPesquisa() { 2731 if (confirm(label37)) { 2732 $.post("/portal/salvarPesquisa", $("#pesquisaForm").serialize(), function(data) { 2733 alert('Obrigado por participar'); 2734 $('#modal1').modal('hide'); 2735 $('#modal1').hide(); 2736 $('.modal-backdrop').hide(); 2737 //location.reload(); 2738 }, 'html'); 2739 } 2740} 2741 2742function sairPesquisa() { 2743 if (confirm(label25)) { 2744 $('#modal1').modal('hide'); 2745 $('#modal1').hide(); 2746 $('.modal-backdrop').hide(); 2747 } 2748} 2749 2750$('[name="btnViewContrato"]').click(function() { 2751 var idAlunoMensalidade = $(this).data('value'); 2752 $.getJSON("/portal/getContratoPadrao", { format: "json", idAlunoMensalidade: idAlunoMensalidade }).done(function(data) { 2753 if (data == null) { 2754 alert(label26); 2755 return false;
2756 } 2757 2758 for (var i = 0; i < data.length; i++) { 2759 var url = '/portal/contrato-print?idTipoContrato=' + data[i] + '&idAlunoMensalidade=' + idAlunoMensalidade; 2760 window.open(url, 'contrato' + data[i]); 2761 } 2762 }); 2763}); 2764 2765 2766$('#btnAutorizacaoPagSeguro').click(function() { 2767 $.getJSON("/portal/getAutorizacao", { format: "json" }).done( 2768 function(data) { 2769 if (data != null && data.status == 0) { 2770 window.open(data.message, '_blank'); 2771 } else { 2772 alert(data.message); 2773 } 2774 }); 2775}); 2776 2777function closeWindow() { 2778 if ($('#modalBodyMedia').length > 0 && $('#modalBodyMedia').html() !== undefined && $('#modalBodyMedia').html().indexOf('iframeBoletim') == -1) { 2779 $('#modalBodyMedia').html(''); 2780 } else { 2781 $('#iframeBoletim').attr('src', ''); 2782 } 2783 $('#modal1').modal('hide'); 2784} 2785 2786function loadForum() { 2787 $('#modalFooter1').show(); 2788 $('#modalDialog1').width('100%'); 2789 $('#modalDialog1').height('auto'); 2790 $('#btnMaterial').hide(); 2791 $('#btnChat').hide(); 2792 $('#btnDownload').hide(); 2793 $('#btnDownloadTrilha').hide(); 2794 $('#divClassificacao').hide(); 2795 $('#divClassificacao').attr("style", "display: none !important"); 2796 $('#btnFavoritos').hide(); 2797 $('#btnAnotacoes').hide(); 2798 $('#btnAnotacoes').attr("style", "display: none !important"); 2799 $('#btnDuvida').hide(); 2800 $('#modalDialog1').css('max-width', '100%'); 2801 $('.modal-content').css('background-color', '#FFFFFF'); 2802 2803 var heightCompoment = $(window).height() - 110; 2804 if ($('#modalBodyMedia').height() < 100) { 2805 if ($('#modalContent').height() > 100) { 2806 heightCompoment = $('#modalContent').height(); 2807 } 2808 } else { 2809 heightCompoment = $('#modalBodyMedia').height(); 2810 } 2811 $('#modalBodyMedia').height(heightCompoment) 2812 $('#modalBodyMedia').css('overflowY', 'auto'); 2813} 2814 2815function calculaCriterio(id, valor) { 2816 var pontos = $('#pontoCriterioMax' + id).val(); 2817 $('#pontoCriterio' + id).val((pontos * valor) / 100); 2818 $('#badgePontos' + id).html(float2moeda2($('#pontoCriterio' + id).val()) + '/' + float2moeda2($('#pontoCriterioMax' + id).val())); 2819 2820 if (valor < 40) { 2821 $('#badgePontos' + id).attr('class', 'badge badge-pill badge-danger w-100 mt-2'); 2822 } else if (valor < 80) { 2823 $('#badgePontos' + id).attr('class', 'badge badge-pill badge-primary w-100 mt-2'); 2824 } else { 2825 $('#badgePontos' + id).attr('class', 'badge badge-pill badge-success w-100 mt-2'); 2826 } 2827 calculaCriterioTotal(); 2828} 2829 2830function calculaCriterioTotal() { 2831 var pontoCriterioMax = 0.0; 2832 $('[data-ponto-criterio-max="true"]').each(function(index) { 2833 if ($(this).val() != null && $(this).val().length > 0) { 2834 pontoCriterioMax += parseFloat($(this).val()); 2835 } 2836 }); 2837 var total = 0.0; 2838 $('[data-ponto-criterio="true"]').each(function(index) { 2839 if ($(this).val() != null && $(this).val().length > 0) { 2840 total += parseFloat($(this).val()); 2841 } 2842 }); 2843 var notaCorrecao = moeda2float($('#notaMax').val()) * (total / pontoCriterioMax); 2844 $('#notaCorrecao').val(float2moeda(notaCorrecao)); 2845} 2846 2847 2848$("#divDocument").dblclick(function(e) { 2849 e.preventDefault(); 2850 var x = e.pageX - $("#divDocument").offset().left; 2851 var y = e.pageY - $("#divDocument").offset().top - 10; 2852 $('#flagId').val(0); 2853 $('#flagTop').val(y); 2854 $('#flagLeft').val(x); 2855 tinymce.get("flagComentario").setContent(""); 2856 setTimeout(function() { 2857 tinymce.editors[0].focus(); 2858 }, 1000); 2859 $('#flagWidth').val(getWidth()); 2860 $('#flagHeight').val(getHeight()); 2861 criarIcone('0', y, x, getWidth(), getHeight(), '', getCor()); 2862 $('#modalComentario').modal({ backdrop: 'static', keyboard: false }); 2863}) 2864 2865function criarIcone(id, top, left, width, height, comentario, cor) { 2866 var icon = $('<i class="fas fa-circle flag-comentario"></i>'); 2867 icon.attr('id', 'flag' + id); 2868 icon.css('top', top); 2869 icon.css('left', left); 2870 icon.css('z-index', 10); 2871 icon.data('id', id); 2872 icon.data('flag', true); 2873 icon.data('comentario', comentario); 2874 icon.data('top', top); 2875 icon.data('left', left); 2876 icon.data('width', width); 2877 icon.data('height', height); 2878 icon.css('cursor', 'pointer'); 2879 icon.css('position', 'absolute'); 2880 icon.css('font-size', '19px'); 2881 icon.css('opacity', '0.5'); 2882 icon.css('color', cor); 2883 icon.appendTo('#divDocument'); 2884 2885 if (comentario != '') { 2886 icon.data('toggle', 'tooltip'); 2887 icon.data('placement', 'auto'); 2888 icon.attr('data-html', 'true'); 2889 icon.attr('title', comentario); 2890 icon.tooltip({ boundary: 'window'}); 2891 2892 $('#flag' + id).on('inserted.bs.tooltip', function() { 2893 document.querySelectorAll('.tooltip-inner').forEach((tooltip) => { 2894 tooltip.style.backgroundColor = "#fff"; 2895 tooltip.style.color = "#000"; 2896 tooltip.style.border = "2px solid #ccc"; 2897 tooltip.style.maxWidth = "900px"; 2898 }); 2899 }) 2900 } 2901 2902 2903 icon.click(function() { 2904 openComentarios($(this).data('id')); 2905 }); 2906} 2907 2908function openComentarios(id) { 2909 var icon = $('#flag' + id); 2910 $('#flagId').val(id); 2911 $('#flagTop').val(icon.data('top')); 2912 $('#flagLeft').val(icon.data('left')); 2913 $('#flagWidth').val(icon.data('width')); 2914 $('#flagHeight').val(icon.data('height')); 2915 if ($('#textoComentario').length > 0) $('#textoComentario').html(icon.data('comentario')); 2916 if (document.getElementById('flagComentario')) { 2917 tinymce.get('flagComentario').setContent(icon.data('comentario')); 2918 setTimeout(function() { 2919 tinymce.editors[0].focus(); 2920 }, 1000); 2921 } else { 2922 $('#flagComentario').val(icon.data('comentario')); 2923 } 2924 $('#modalComentario').modal('show'); 2925} 2926 2927function fecharModalComentario() { 2928 $('#modalComentario').modal('hide'); 2929} 2930 2931$('#btnSalvarFlag').click(function() { 2932 const content = tinymce.get("flagComentario").getContent(); 2933 2934 if (content.length == 0) { 2935 alert('Preencha um comentário.'); 2936 return; 2937 } 2938 2939 var cor = getCor(); 2940 2941 $.post("/portal/salvarFlagComentario", { 2942 id: $("#flagId").val(), 2943 idAvaliacaoAluno: $("#idAvaliacaoAluno").val(), 2944 comentario: content, 2945 topo: Math.round($("#flagTop").val()), 2946 esquerda: Math.round($("#flagLeft").val()), 2947 largura: Math.round($("#flagWidth").val()), 2948 altura: Math.round($("#flagHeight").val()), 2949 tipo: 1, 2950 topo2: 0, 2951 esquerda2: 0, 2952 cor: cor 2953 }, function(data) { 2954 if (data.status == 0) { 2955 if ($('#flag' + data.message).length == 0) { 2956 var icon = $('#flag0'); 2957 icon.attr('id', 'flag' + data.message); 2958 icon.data('original-title', content); 2959 icon.data('id', data.message); 2960 icon.data('comentario', content); 2961 icon.data('html', true); 2962 icon.data('toggle', 'tooltip'); 2963 icon.data('placement', 'auto'); 2964 icon.attr('data-html', 'true'); 2965 icon.attr('title', content); 2966 icon.tooltip({ boundary: 'window'}); 2967 2968 $('#flag' + data.message).on('inserted.bs.tooltip', function() { 2969 document.querySelectorAll('.tooltip-inner').forEach((tooltip) => { 2970 tooltip.style.backgroundColor = "#fff"; 2971 tooltip.style.color = "#000"; 2972 tooltip.style.border = "2px solid #ccc"; 2973 tooltip.style.maxWidth = "900px"; 2974 }); 2975 }) 2976 2977 } else { 2978 var icon = $('#flag' + data.message); 2979 icon.tooltip('dispose'); 2980 icon.attr('data-html', 'true'); 2981 icon.attr('data-original-title', content); 2982 icon.attr('title', content); 2983 icon.data('comentario', content) 2984 icon.tooltip(); 2985 } 2986 $('#flagId').val(0); 2987 $('#flagTop').val(''); 2988 $('#flagLeft').val(''); 2989 $('#flagWidth').val(''); 2990 $('#flagHeight').val(''); 2991 $('#flagComentario').val(''); 2992 } else { 2993 alert(data.message); 2994 } 2995 $('#modalComentario').modal('hide'); 2996 }, 'json'); 2997}); 2998 2999 3000$('#btnApagarFlag').click(function() { 3001 icon = $('#flag' + $('#flagId').val()); 3002 icon.remove(); 3003 if ($('#flagId').val() > 0) { 3004 $.post("/portal/apagarFlagComentario", { id: $("#flagId").val() }, function(data) { 3005 $('#modalComentario').modal('hide'); 3006 }, 'json'); 3007 } else { 3008 $('#modalComentario').modal('hide'); 3009 } 3010}); 3011 3012function paginationDocument(indice) { 3013 $('#indice').val(indice); 3014 $('#filterDocuments').click(); 3015} 3016 3017// Arguments : 3018// verb : 'GET'|'POST' 3019// target : an optional opening target (a name, or "_blank"), defaults to "_self" 3020window.io = { 3021 open: function(verb, url, data, target) { 3022 var form = document.createElement("form"); 3023 form.action = url; 3024 form.method = verb; 3025 form.target = target || "_self"; 3026 if (data) { 3027 for (var key in data) { 3028 var input = document.createElement("input"); 3029 input.name = key; 3030 input.value = typeof data[key] === "object" 3031 ? JSON.stringify(data[key]) 3032 : data[key]; 3033 form.appendChild(input); 3034 } 3035 } 3036 form.style.display = 'none'; 3037 document.body.appendChild(form); 3038 form.submit(); 3039 document.body.removeChild(form); 3040 } 3041}; 3042 3043 3044$('[name="btnAgendar"]').click(function() { 3045 var start = $(this).data('start'); 3046 var end = $(this).data('end'); 3047 var host = $(this).data('host'); 3048 var id = $(this).data('id'); 3049 var url = $(this).data('url'); 3050 3051 io.open('POST', url, { start: start, end: end, host: host, id: id }); 3052 3053}); 3054 3055function getContentTopic(event, id) { 3056 $.getJSON("/portal/getContentTopic", { format: "json", id: id }).done(function(data) { 3057 if (data != null && data.status == 0) { 3058 $('#modal2').modal('show'); 3059 $('#modalContentTopic').html(data.message); 3060 } else { 3061 alert(data.message); 3062 } 3063 }); 3064 event.stopPropagation(); 3065} 3066 3067function getCompleteDate() { 3068 var date = new Date(); 3069 return date.getFullYear() + ("0" + (date.getMonth() + 1)).slice(-2) + ("0" + date.getDate()).slice(-2) + ("0" + date.getHours()).slice(-2) + ("0" + date.getMinutes()).slice(-2) + ("0" + date.getSeconds()).slice(-2); 3070} 3071 3072function diffHours(hora1, hora2) { 3073 3074 if (hora1 == null || hora2 == null) return 0; 3075 3076 var min1 = hora1.substring(10, 12); 3077 var seg1 = hora1.substring(12, 14); 3078 3079 var min2 = hora2.substring(10, 12); 3080 var seg2 = hora2.substring(12, 14); 3081 3082 return ((min1 - min2) * 60) + (seg1 - seg2); 3083} 3084 3085function openStudos(titulo) { 3086 3087 var dialog = BootstrapDialog.show({ 3088 title: 'Aguarde...', 3089 message: 'Aguarde estamos abrindo a ' + titulo + '!', 3090 buttons: [ 3091 { 3092 id: 'btn-ok', 3093 icon: 'glyphicon glyphicon-check', 3094 label: 'Fechar', 3095 cssClass: 'btn-primary', 3096 data: { js: 'btn-confirm', 'user-id': '3' }, 3097 autospin: false, 3098 action: function(dialogRef) { dialogRef.close(); } 3099 }] 3100 }); 3101 3102 $.getJSON("/portal/studos", { format: "json" }).done(function(data) { 3103 if (data != null) { 3104 if (data.status == true && data.url != '') { 3105 var link = document.createElement('a'); 3106 link.target = '_blank'; 3107 link.href = data.url; 3108 document.body.appendChild(link); 3109 link.click(); 3110 setTimeout(BootstrapDialog.closeAll, 2000); 3111 } else { 3112 if (data.mensagem != '') { 3113 dialog.setMessage(data.mensagem); 3114 dialog.setTitle('Atenção!'); 3115 } 3116 } 3117 } else { 3118 dialog.setMessage('Erro ao abrir'); 3119 dialog.setTitle('Atenção!'); 3120 } 3121 }); 3122} 3123 3124 3125$('[name="btnIncluirDocumentoAluno"]').click(function() { 3126 $("#tipoDocumento").val(''); 3127 $("#tipoDocumento").prop('disabled', ''); 3128 $('#documentosPopup').modal('show'); 3129 $("#idDocumentoAluno").val(0); 3130}); 3131 3132$('[name="btnDownloadDocumentoAluno"]').click(function() {
3133 window.open('/portal/documento-aluno-download?id=' + $(this).data('value'), '_self'); 3134}); 3135 3136$('[name="btnAlterarDocumentoAluno"]').click(function() { 3137 $.getJSON("/portal/getDocumentoAluno", { format: "json", id: $(this).data('value') }).done(function(data) { 3138 if (data != null) { 3139 $("#idDocumentoAluno").val(data.idDocumentoAluno); 3140 $("#tipoDocumento").val(data.idTipoDocumento); 3141 $("#tipoDocumento").prop('disabled', 'disabled'); 3142 $("#tipoDocumento").val(data.idTipoDocumento); 3143 $('#documentosPopup').modal('show'); 3144 } 3145 }); 3146}); 3147 3148$('#fileUploadTipoDocumentoAluno').change(function(event) { 3149 var files = event.target.files; 3150 if ($("#btnSalvarDocumentoAluno").length) $('#btnSalvarDocumentoAluno').prop('disabled', true); 3151 receberVariosArquivos(files, $(this).data('type'), $(this).data('id'), $(this).data('directory'), null, false); 3152}); 3153 3154$('.fileUploadTipoDocumento').change(function(event) { 3155 var files = event.target.files; 3156 receberVariosArquivos(files, $(this).data('type'), $(this).data('id'), $(this).data('directory'), $(this).attr('name') + '_temp', false); 3157}); 3158 3159$('.fileUpload').change(function(event) { 3160 var files = event.target.files; 3161 receberVariosArquivos(files, $(this).data('type'), $(this).data('id'), $(this).data('directory'), null, $(this).data('delete')); 3162}); 3163 3164 3165$('#btnSalvarDocumentoAluno').click(function() { 3166 if ($("#tipoDocumento").val().length == 0) { 3167 alert('Preencha o Tipo de Documento.'); 3168 return; 3169 } 3170 $.post("/portal/salvarDocumentoAluno", { id: $("#idDocumentoAluno").val(), idTipoDocumento: $("#tipoDocumento").val() }, function(data) { 3171 if (data.status == 0) { 3172 alert(data.message); 3173 location.reload(); 3174 } else { 3175 alert(data.message); 3176 } 3177 }, 'json'); 3178}); 3179 3180$('[name="btnExcluirDocumentoAluno"]').click(function() { 3181 if (confirm(label27)) { 3182 $.post("/portal/excluirDocumentoAluno", { id: $(this).data('value') }, function(data) { 3183 if (data.status == 0) { 3184 alert(data.message); 3185 location.reload(); 3186 } else { 3187 alert(data.message); 3188 } 3189 }, 'json'); 3190 } 3191}); 3192 3193function openModalTeacher(opcao) { 3194 if (opcao == 1) { 3195 $('#iFrameDocument').addClass('d-none') 3196 $('#divDocument').addClass('d-none') 3197 $('#modalBodyMedia').removeClass('d-none'); 3198 } else { 3199 $('#modalBodyMedia').addClass('d-none') 3200 $('#iFrameDocument').removeClass('d-none'); 3201 $('#divDocument').removeClass('d-none'); 3202 } 3203} 3204 3205 3206$('[name="btnInscreveAlunos"]').click(function() { 3207 3208 var quantidade = $(this).data('quantidade'); 3209 var idContrato = $(this).data('contrato'); 3210 var idCurso = $(this).data('curso'); 3211 var tipoCurso = $(this).data('tipo'); 3212 3213 var conteudo = ''; 3214 conteudo += '<input type="hidden" name="idContrato" id="idContrato" value="' + idContrato + '">'; 3215 conteudo += '<input type="hidden" name="idCurso" id="idCurso" value="' + idCurso + '">'; 3216 conteudo += '<input type="hidden" name="tipoCurso" id="tipoCurso" value="' + tipoCurso + '">'; 3217 conteudo += '<input type="hidden" name="quantidade" id="quantidade" value="' + quantidade + '">'; 3218 3219 for (var i = 1; i <= quantidade; ++i) { 3220 conteudo += '<div class="row m-2">'; 3221 conteudo += '<div class="col-sm-12 col-md-6"><div class="form-group"><label class="control-label">Nome ' + i + '</label><input type="text" name="nome' + i + '" id="nome' + i + '" value="" maxlength="50" class="form-control" data-validation="required length" data-validation-length="max50"></div></div>'; 3222 conteudo += '<div class="col-sm-12 col-md-6"><div class="form-group"><label class="control-label">E-mail ' + i + '</label><input type="text" name="email' + i + '" id="email' + i + '" value="" maxlength="250" class="form-control" data-validation="required length email" data-validation-length="max250"></div></div>'; 3223 conteudo += '</div>'; 3224 } 3225 $('#inscreverAlunosForm').html(conteudo); 3226 $('#inscricaoPopup').modal('show'); 3227}); 3228 3229$('#btnSalvarInscrever').click(function() { 3230 if (!$("#inscreverAlunosForm").valid()) { 3231 return; 3232 } 3233 $.post("/portal/inscreverAlunosContrato", $("#inscreverAlunosForm").serialize(), function(data) { 3234 $('#inscricaoPopup').modal('hide'); 3235 location.reload(); 3236 }, 'json'); 3237}); 3238 3239function downloadArquivo(idButton) { 3240 3241 $('#' + idButton).prop("disabled", "true"); 3242 $("#modalLoading").modal({ 3243 backdrop: "static", 3244 keyboard: false, 3245 show: true 3246 }); 3247 var id = $('#' + idButton).data('value'); 3248 var token = $('#' + idButton).data('token'); 3249 3250 var path = $('#' + idButton).data('path'); 3251 var posicao = $('#' + idButton).data('posicao'); 3252 if (path.toLowerCase().substr(-3) != 'pdf') posicao = 0; 3253 3254 gerarPDFStamper(posicao, id, 'D', token, idButton, 'modalLoading', null, false); 3255} 3256 3257$('[name="btnContratoCancelamento"]').click(function() { 3258 3259 if (confirm(label28) == true) { 3260 var idContrato = $(this).data('contrato'); 3261 var url = '/portal/contrato-cancelamento?id=' + idContrato; 3262 $.getJSON(url, { format: "json" }).done(function(data) { 3263 if (data.status == 0) { 3264 alert(label29); 3265 location.reload(); 3266 } else { 3267 alert(data.message); 3268 } 3269 }); 3270 } 3271}); 3272 3273 3274$('[name="btnViewDeclaracao"]').click(function() { 3275 3276 $('#situacao').val($(this).data('situacao')); 3277 $('#token').val($(this).data('token')); 3278 3279 $.getJSON("/portal/getDeclaracoes", { format: "json", situacaoContrato: $(this).data('situacao'), idAlunoMensalidade: $(this).data('contrato') }).done(function(data) { 3280 3281 $('#listaDeclaracoes').html(''); 3282 linhaHtml = '<div class="row">'; 3283 for (var i = 0; i < data.length; i++) { 3284 if (data[i].liberadaPortal == 'S') { 3285 var url = '/portal/contratoPadrao?id=' + data[i].id;
3286 url += '&token=' + $('#token').val(); 3287 linhaHtml += '<div class="col-xs-12 col-sm-6 col-md-4"><div class="thumbnail">'; 3288 linhaHtml += ' <div class="caption text-center">'; 3289 linhaHtml += ' <p>' + data[i].nome + '</p>'; 3290 linhaHtml += ' <a href="javascript:window.open(\'' + url + '\',\'declaracao' + data[i].id + '\')" class="btn btn-primary center-block" role="button">' + label30 + '</a>'; 3291 linhaHtml += ' </div>'; 3292 linhaHtml += '</div></div>'; 3293 } 3294 } 3295 linhaHtml += '</div>'; 3296 $('#listaDeclaracoes').append(linhaHtml); 3297 3298 }); 3299 3300 $('#declaracaoPopup').modal('show'); 3301}); 3302 3303function rotate90deg() { 3304 $.ajax({ 3305 url: '/portal/rotacionarImagemAvaliacao', 3306 type: 'POST', 3307 dataType: 'json', 3308 data: { 3309 idAvaliacaoAluno: $('#idAvaliacaoAluno').val() 3310 }, 3311 beforeSend: function() { 3312 $('#btnRotacionar').prop('disabled', true); 3313 }, 3314 success: function(data) { 3315 if (data.status == 0) { 3316 var img = $('#img-viewer'); 3317 var srcAtual = img.attr('src'); 3318 3319 // Remove cache-bust anterior se existir, mantém parâmetros originais 3320 var srcLimpo = srcAtual.replace(/&t=\d+/, '').replace(/\?t=\d+/, ''); 3321 3322 // Adiciona novo cache-bust mantendo os parâmetros originais 3323 var separador = srcLimpo.indexOf('?') >= 0 ? '&' : '?'; 3324 img.attr('src', srcLimpo + separador + 't=' + new Date().getTime()); 3325 3326 img.off('load').on('load', function() { 3327 carregarCorrecao(); 3328 $('#btnRotacionar').prop('disabled', false); 3329 }); 3330 } else { 3331 alert(data.message); 3332 $('#btnRotacionar').prop('disabled', false); 3333 } 3334 }, 3335 error: function(xhr, status, error) { 3336 alert('Erro ao rotacionar a imagem: ' + error); 3337 $('#btnRotacionar').prop('disabled', false); 3338 } 3339 }); 3340} 3341 3342function zoom(e) { 3343 var zoomer = e.currentTarget; 3344 e.offsetX ? offsetX = e.offsetX : offsetX = e.touches[0].pageX 3345 e.offsetY ? offsetY = e.offsetY : offsetX = e.touches[0].pageX 3346 x = offsetX / zoomer.offsetWidth * 100 3347 y = offsetY / zoomer.offsetHeight * 100 3348 zoomer.style.backgroundPosition = x + '% ' + y + '%'; 3349} 3350 3351function previewImage() { 3352 const input = document.querySelector('#fileUpload'); 3353 const preview = document.querySelector('#preview'); 3354 3355 let divPreview = document.querySelector('#divPreview'); 3356 3357 if (input.files[0].type == "application/pdf") { 3358 if (!divPreview) { 3359 divPreview = document.createElement('div'); 3360 divPreview.setAttribute('id', 'divPreview'); 3361 } 3362 preview.src = ""; 3363 preview.insertAdjacentElement('afterend', divPreview); 3364 gerarPDF('divPreview', URL.createObjectURL(input.files[0]), 0, 0, null); 3365 } else { 3366 preview.style.display = ''; 3367 if (divPreview) divPreview.remove(); 3368 preview.src = URL.createObjectURL(input.files[0]); 3369 } 3370} 3371 3372function getMaxVistoFormatado(maxVistoFormatado, maxVisto) { 3373 if (maxVistoFormatado == 1) { 3374 return label34; 3375 } else if (maxVistoFormatado == 2) { 3376 return label33 + ": " + maxVisto + " " + label36; 3377 } else { 3378 return label32; 3379 } 3380} 3381 3382$(".collapse").on('show.bs.collapse', function(e) { 3383 if ($(this).is(e.target)) { 3384 getDiagrams($('#' + this.id).data('token')); 3385 } 3386}) 3387 3388function getDiagrams(tokenTopico) { 3389 if (tokenTopico == '' || tokenTopico == null) return; 3390 3391 $.post("/portal/getDiagrams", { tokenTopico: tokenTopico }, function(data) { 3392 $("#cardBody" + tokenTopico).html(''); 3393 var html = ''; 3394 for (var i = 0; i < data.length; i++) { 3395 html += '<li class="list-group-item">'; 3396 html += ' <i class="fas fa-project-diagram pr-2 media-class mouse-pointer" onclick="window.open(\'/portal/diagrama/' + data[i].token + '\', \'_self\')"></i>'; 3397 html += ' <span onclick="window.open(\'/portal/diagrama/' + data[i].tokenTopico + '/' + data[i].token + '\', \'_self\')" class="mouse-pointer">' + data[i].nome + '</span>'; 3398 if (data[i].delete == true) { 3399 html += '<i class="far fa-trash-alt float-right mouse-pointer pt-2 pr-3" onclick="deleteDiagram(\'' + data[i].token + '\', \'' + data[i].tokenTopico + '\');"></i>'; 3400 } 3401 html += '</li>'; 3402 } 3403 $("#cardBody" + tokenTopico).html(html); 3404 }, 'json'); 3405} 3406 3407function incluirNovoTopicoDiagram(tokenTopico) { 3408 window.open('/portal/diagrama/' + tokenTopico, '_self'); 3409 3410} 3411 3412function incluirNovoTopico() { 3413 3414 $('#modalDiagramsEdit').modal('show'); 3415} 3416 3417function salvarTopicoDiagrama() { 3418 $.post("/portal/salvarTopicoDiagram", { tokenTopico: $("#tokenTopico").val(), nome: $("#nomeTopico").val(), privacidade: $("#privacidade").val() }, function(data) { 3419 if (data != null) { 3420 window.location.reload(); 3421 } 3422 }, 'json'); 3423} 3424 3425function alterarTopicoDiagram(tokenTopico) { 3426 $.post("/portal/getTopicoDiagram", { tokenTopico: tokenTopico }, function(data) { 3427 $('#tokenTopico').val(data.token); 3428 $('#nomeTopico').val(data.nome); 3429 $('#privacidade').val(data.privacidade); 3430 }, 'json'); 3431 $('#modalDiagramsEdit').modal('show') 3432} 3433 3434function deleteTopicoDiagram(tokenTopico) { 3435 if (confirm('Tem certeza que deseja deletar o tópico e todos os seus diagramas?') == true) { 3436 $.post("/portal/deleteTopicoDiagram", { tokenTopico: tokenTopico }, function(data) { 3437 if (data != null) { 3438 window.location.reload(); 3439 } 3440 }, 'json'); 3441 } 3442} 3443 3444function deleteDiagram(tokenDiagrama, tokenTopico) { 3445 if (confirm('Tem certeza que deseja deletar o diagrama?') == true) { 3446 $.post("/portal/deleteDiagram", { tokenDiagrama: tokenDiagrama }, function(data) { 3447 if (data != null) { 3448 getDiagrams(tokenTopico); 3449 } 3450 }, 'json'); 3451 } 3452} 3453 3454function deleteTopicoFlashCard(tokenTopico) { 3455 if (confirm('Tem certeza que deseja deletar o tópico, todos os seus cards e ações?') == true) { 3456 $.post("/portal/deleteTopicoFlashCard", { tokenTopico: tokenTopico }, function(data) { 3457 if (data != null) { 3458 window.location.reload(); 3459 } 3460 }, 'json'); 3461 } 3462} 3463 3464// Variáveis globais para o desenho 3465var isDrawing = false;
3466var drawStartX = 0; 3467var drawStartY = 0; 3468var previewLineId = 'linha-preview'; 3469 3470// SUBSTITUA a função habilitarLinha() existente por esta: 3471function habilitarLinha() { 3472 if ($('#btnLinha').data('habilitado') == 1) { 3473 // Desabilitar 3474 $('#btnLinha').data('habilitado', 0); 3475 $('#btnLinha').css('background-color', 'unset'); 3476 $('#divDocument').css('cursor', 'default'); 3477 removerEventosDesenho(); 3478 removerLinhaPreview(); 3479 } else { 3480 // Habilitar 3481 $('#btnLinha').data('habilitado', 1); 3482 $('#btnLinha').css('background-color', '#CCCCCC'); 3483 $('#divDocument').css('cursor', 'crosshair'); 3484 configurarEventosDesenho(); 3485 } 3486} 3487 3488function criarLinha(id, x1, y1, x2, y2, color) { 3489 3490 if ($('#svglinha').length == 0) { 3491 var svg = '<svg xmlns="http://www.w3.org/2000/svg" id="svglinha" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="' + getWidth() + '" height="' + getHeight() + '" style="position: absolute;top: 0;"></svg>'; 3492 if ($('#divDocument img').length > 0) { 3493 $('#divDocument').append(svg); 3494 } else { 3495 $('#divDocument2').append(svg); 3496 } 3497 } 3498 3499 var newLine = document.createElementNS('http://www.w3.org/2000/svg', 'line'); 3500 newLine.setAttribute('id', 'linha' + id); 3501 newLine.setAttribute('x1', x1); 3502 newLine.setAttribute('y1', y1); 3503 newLine.setAttribute('x2', x2); 3504 newLine.setAttribute('y2', y2); 3505 newLine.setAttribute('stroke-linecap', "round"); 3506 newLine.setAttribute('stroke-opacity', "0.7"); 3507 newLine.setAttribute('stroke-width', "8"); 3508 newLine.setAttribute('stroke', color); 3509 newLine.setAttribute('class', "linhaCorrecao"); 3510 $("#svglinha").append(newLine); 3511} 3512 3513function getCor() { 3514 const rgb2hex = (rgba) => `#${rgba.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)$/).slice(1).map((n, i) => (i === 3 ? Math.round(parseFloat(n) * 255) : parseFloat(n)).toString(16).padStart(2, '0').replace('NaN', '')).join('')}`; 3515 3516 for (var i = 1; i <= 5; i++) { 3517 if ($('#btnCor' + i).data('marcado') == 1) { 3518 return rgb2hex($('#btnCor' + i).css("background-color")); 3519 } 3520 } 3521} 3522 3523function habilitarCor(indice) { 3524 for (var i = 1; i <= 5; i++) { 3525 $('#btnCor' + i).data('marcado', '0'); 3526 $('#btnCor' + i).css("color", '#FFFFFF'); 3527 } 3528 $('#btnCor' + indice).data('marcado', '1'); 3529 $('#btnCor' + indice).css("color", '#000000'); 3530} 3531 3532function magnify(imgID, zoom, create) { 3533 3534 if (create) { 3535 var img, glass, w, h, bw; 3536 img = document.getElementById(imgID); 3537 3538 glass = document.createElement("DIV"); 3539 glass.setAttribute("class", "img-magnifier-glass"); 3540 3541 img.parentElement.insertBefore(glass, img); 3542 3543 glass.style.backgroundImage = "url('" + img.src + "')"; 3544 glass.style.backgroundRepeat = "no-repeat"; 3545 glass.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px"; 3546 glass.style.zIndex = "5"; 3547 bw = 3; 3548 w = glass.offsetWidth / 2; 3549 h = glass.offsetHeight / 2; 3550 3551 glass.addEventListener("mousemove", moveMagnifier1); 3552 img.addEventListener("mousemove", moveMagnifier1); 3553 3554 glass.addEventListener("touchmove", moveMagnifier1); 3555 img.addEventListener("touchmove", moveMagnifier1); 3556 function moveMagnifier1(e) { 3557 var pos, x, y; 3558 e.preventDefault(); 3559 pos = getCursorPos1(e); 3560 x = pos.x; 3561 y = pos.y; 3562 if (x > img.width - (w / zoom)) { x = img.width - (w / zoom); } 3563 if (x < w / zoom) { x = w / zoom; } 3564 if (y > img.height - (h / zoom)) { y = img.height - (h / zoom); } 3565 if (y < h / zoom) { y = h / zoom; } 3566 glass.style.left = (x - w) + "px"; 3567 glass.style.top = (y - h) + "px"; 3568 glass.style.backgroundPosition = "-" + ((x * zoom) - w + bw) + "px -" + ((y * zoom) - h + bw) + "px"; 3569 } 3570 3571 function getCursorPos1(e) { 3572 var a, x = 0, y = 0; 3573 e = e || window.event; 3574 a = img.getBoundingClientRect(); 3575 x = e.pageX - a.left; 3576 y = e.pageY - a.top; 3577 x = x - window.pageXOffset; 3578 y = y - window.pageYOffset; 3579 return { x: x, y: y }; 3580 } 3581 } else { 3582 document.querySelector('.img-magnifier-glass').remove(); 3583 } 3584} 3585 3586function magnifyDiv(containerID, zoom, create) { 3587 if (create) { 3588 var container = document.getElementById(containerID); 3589 var wrapper = container.parentElement; 3590 3591 // Cria a lupa 3592 var glass = document.createElement("DIV"); 3593 glass.setAttribute("class", "img-magnifier-glass2"); 3594 wrapper.appendChild(glass); 3595 var w = 120; // Largura da lupa 3596 var h = 120; // Altura da lupa 3597 glass.style.width = w + "px"; 3598 glass.style.height = h + "px"; 3599 3600 function moveMagnifier(e) { 3601 e.preventDefault(); 3602
3603 // Obtém as coordenadas do cursor relativas ao contêiner 3604 var rect = container.getBoundingClientRect(); 3605 var x = e.clientX - rect.left; 3606 var y = e.clientY - rect.top; 3607 3608 // Limita o cursor dentro dos limites do contêiner 3609 x = Math.max(0, Math.min(x, container.offsetWidth)); 3610 y = Math.max(0, Math.min(y, container.offsetHeight)); 3611 3612 // Ajusta a posição da lupa 3613 glass.style.left = (x - w / 2) + "px"; 3614 glass.style.top = (y - h / 2) + "px"; 3615 3616 // Captura o conteúdo atual do contêiner em um canvas temporário 3617 var dataUrl = getCanvasDataURL(container); 3618 glass.style.backgroundImage = "url('" + dataUrl + "')"; 3619 3620 // Define o tamanho do background ampliado 3621 var bgWidth = container.offsetWidth * zoom; 3622 var bgHeight = container.offsetHeight * zoom; 3623 glass.style.backgroundSize = bgWidth + "px " + bgHeight + "px"; 3624 3625 // Calcula a posição do background dentro da lupa 3626 var offsetX = x * zoom * 1; 3627 var offsetY = y * zoom * 1; 3628 3629 // Centraliza o conteúdo da lupa 3630 var centerOffsetX = w / 2; 3631 var centerOffsetY = h / 2; 3632 3633 // Define a posição do background 3634 glass.style.backgroundPosition = "-" + (offsetX - centerOffsetX) + "px -" + 3635 (offsetY - centerOffsetY) + "px"; 3636 } 3637 3638 function getCanvasDataURL(container) { 3639 var tempCanvas = document.createElement("canvas"); 3640 tempCanvas.width = container.offsetWidth * 1.4; 3641 tempCanvas.height = container.offsetHeight * 1.4; 3642 var ctx = tempCanvas.getContext("2d"); 3643 3644 // Desenha todos os canvases no canvas temporário 3645 var canvases = container.querySelectorAll("canvas"); 3646 canvases.forEach(canvas => { 3647 ctx.drawImage(canvas, canvas.offsetLeft, canvas.offsetTop * 1.4, 3648 canvas.width, canvas.height); 3649 }); 3650 3651 return tempCanvas.toDataURL(); 3652 } 3653 3654 // Adiciona os eventos de movimento 3655 container.addEventListener("mousemove", moveMagnifier); 3656 container.addEventListener("touchmove", moveMagnifier); 3657 3658 } else { 3659 var glass = document.querySelector('.img-magnifier-glass2'); 3660 if (glass) { 3661 glass.remove(); 3662 } 3663 } 3664} 3665function toggleLupa() { 3666 const lupa = document.getElementById('lupa'); 3667 if (lupa.classList.contains('ativada')) { 3668 lupa.classList.remove('ativada'); 3669 3670 if ($('#img-viewer').length == 0) { 3671 magnifyDiv("divDocument2", 2, false); 3672 } else { 3673 magnify("img-viewer", 2, false); 3674 } 3675 } else { 3676 lupa.classList.add('ativada'); 3677 if ($('#img-viewer').length == 0) { 3678 magnifyDiv("divDocument2", 2, true); 3679 } else { 3680 magnify("img-viewer", 2, true); 3681 } 3682 } 3683} 3684 3685 3686function getWidth() { 3687 if ($("#divDocument img").length > 0) { 3688 return Math.round($("#divDocument img").width()); 3689 } else if ($("#divDocument canvas").length > 0) { 3690 return Math.round($('#divDocument canvas').width()); 3691 } 3692} 3693 3694function getHeight() { 3695 if ($("#divDocument img").length > 0) { 3696 return Math.round($("#divDocument img").height()); 3697 } else if ($("#divDocument canvas").length > 0) { 3698 return Math.round($('#divDocument canvas').height()); 3699 } 3700} 3701 3702 3703function addOption(theSel, theText, theValue) { 3704 var newOpt = new Option(theText, theValue); 3705 var selLength = theSel.length; 3706 theSel.options[selLength] = newOpt; 3707} 3708 3709function deleteOption(theSel, theIndex) { 3710 var selLength = theSel.length; 3711 if (selLength > 0) { 3712 theSel.options[theIndex] = null; 3713 } 3714} 3715 3716function moveOptions(theSelFrom, theSelTo) { 3717 3718 var selLength = theSelFrom.length; 3719 var selectedText = new Array(); 3720 var selectedValues = new Array(); 3721 var selectedCount = 0; 3722 3723 var i; 3724 3725 for (i = selLength - 1; i >= 0; i--) { 3726 if (theSelFrom.options[i].selected) { 3727 selectedText[selectedCount] = theSelFrom.options[i].text; 3728 selectedValues[selectedCount] = theSelFrom.options[i].value; 3729 deleteOption(theSelFrom, i); 3730 selectedCount++; 3731 } 3732 } 3733 3734 for (i = selectedCount - 1; i >= 0; i--) { 3735 addOption(theSelTo, selectedText[i], selectedValues[i]); 3736 } 3737} 3738 3739// Seleciona todos os itens de uma lista 3740function SelecionarTodosItens(Lista) { 3741 for (var i = 0; i < Lista.options.length; i = i + 1) { 3742 Lista.options[i].selected = true; 3743 } 3744} 3745 3746function verifyOne(theSelFrom, theSelTo) { 3747 var selLength = theSelTo.length; 3748 var index = -1; 3749 for (i = selLength - 1; i >= 0; i--) { 3750 if (theSelTo.options[i].value.substring(0, 1) == 1) { 3751 index = i; 3752 } 3753 } 3754 3755 if (index >= 0) { 3756 var selectedText = new Array(); 3757 var selectedValues = new Array(); 3758 var selectedCount = 0; 3759 3760 for (i = selLength - 1; i >= 0; i--) { 3761 if (index != i) { 3762 selectedText[selectedCount] = theSelTo.options[i].text; 3763 selectedValues[selectedCount] = theSelTo.options[i].value; 3764 deleteOption(theSelTo, i); 3765 selectedCount++; 3766 } 3767 } 3768 for (i = selectedCount - 1; i >= 0; i--) { 3769 addOption(theSelFrom, selectedText[i], selectedValues[i]); 3770 } 3771 } 3772} 3773 3774function checkCursosPlanoEstudo(valueCheckBox) { 3775 3776 if (!$("#planoEstudoForm").valid()) { 3777 return; 3778 } 3779 3780 var checkedBoxes = document.querySelectorAll('input[type=checkbox]:checked'); 3781 var valueCheckBox = ""; 3782 3783 for (const item of checkedBoxes) { 3784 valueCheckBox = valueCheckBox + item.value + '-'; 3785 } 3786
3787 var inputCheck = document.getElementById("valueCheckBox"); 3788 inputCheck.value = valueCheckBox; 3789 3790 var cursos = document.getElementById('idCursoSelecionada').options; 3791 var idCursos = ""; 3792 3793 for (const item2 of cursos) { 3794 idCursos = idCursos + item2.value + '-'; 3795 } 3796 var inputCursos = document.getElementById("valueCurso"); 3797 inputCursos.value = idCursos; 3798 3799 var inputData = document.getElementById("valueDate"); 3800 inputData.value = document.getElementById("datepicker").value 3801 3802 SelecionarTodosItens(document.getElementById('idCursoSelecionada')); 3803 3804 $.post("/portal/enviarCursosPlanoEstudo", $("#planoEstudoForm").serialize(), function(data) { 3805 3806 var idPE = document.getElementById("idPlanoEstudo"); 3807 3808 select = document.getElementById('idTopicoNaoSelecionada'); 3809 removeOptions(select); 3810 removeOptions(document.getElementById('idTopicoSelecionada')); 3811 3812 for (const item of data) { 3813 idPE.value = item.idPlanoEstudo; 3814 if (item.nome != null) { 3815 for (const item2 of item.listaTopico) { 3816 var opt = document.createElement('option'); 3817 opt.value = item2.id; 3818 opt.innerHTML = item.nome + ' | ' + item2.nome; 3819 select.appendChild(opt); 3820 } 3821 } 3822 } 3823 returnTab(3); 3824 }, 'json'); 3825}; 3826 3827function checkTopicosPlanoEstudo() { 3828 3829 if (!$("#planoEstudoForm").valid()) { 3830 return; 3831 } 3832 3833 var numTo = document.getElementById('nroTopicos'); 3834 var numAu = document.getElementById('nroAulas'); 3835 3836 var inputTo = document.getElementById("nrTopicos") 3837 var inputAu = document.getElementById("nrAulas") 3838 3839 numTo.value = inputTo.value 3840 numAu.value = inputAu.value 3841 3842 var topicos = document.getElementById('idTopicoSelecionada').options; 3843 var idTopicos = ""; 3844 3845 for (const item2 of topicos) { 3846 idTopicos = idTopicos + item2.value + '-'; 3847 } 3848 var inputTopicos = document.getElementById("valueTopico"); 3849 inputTopicos.value = idTopicos; 3850 3851 SelecionarTodosItens(document.getElementById('idTopicoSelecionada')); 3852 3853 $.post("/portal/enviarTopicosPlanoEstudo", $("#planoEstudoForm").serialize(), function() { 3854 window.location.replace("agenda") 3855 }, 'json'); 3856}; 3857 3858function removeOptions(selectElement) { 3859 var i, L = selectElement.options.length - 1; 3860 for (i = L; i >= 0; i--) { 3861 selectElement.remove(i); 3862 } 3863} 3864 3865function returnTab(index) { 3866 3867 var tab1 = document.getElementById("disponibilidade"); 3868 var tab2 = document.getElementById("cursos"); 3869 var tab3 = document.getElementById("topicos"); 3870 3871 if (index == 1) { 3872 tab1.style.display = 'block'; 3873 tab2.style.display = 'none'; 3874 tab3.style.display = 'none'; 3875 document.getElementsByClassName("nav-link")[0].className = "nav-link active"; 3876 document.getElementsByClassName("nav-link")[1].className = "nav-link"; 3877 document.getElementsByClassName("nav-link")[2].className = "nav-link"; 3878 3879 } 3880 if (index == 2) { 3881 tab1.style.display = 'none'; 3882 tab2.style.display = 'block'; 3883 tab3.style.display = 'none'; 3884 document.getElementsByClassName("nav-link")[0].className = "nav-link"; 3885 document.getElementsByClassName("nav-link")[1].className = "nav-link active"; 3886 document.getElementsByClassName("nav-link")[2].className = "nav-link"; 3887 } 3888 if (index == 3) { 3889 tab1.style.display = 'none'; 3890 tab2.style.display = 'none'; 3891 tab3.style.display = 'block'; 3892 document.getElementsByClassName("nav-link")[0].className = "nav-link"; 3893 document.getElementsByClassName("nav-link")[1].className = "nav-link"; 3894 document.getElementsByClassName("nav-link")[2].className = "nav-link active"; 3895 } 3896} 3897 3898$(".test-comentado-video .nav-tabs a[data-toggle=tab]").on("click", function(e) { 3899 $('#modalBodyMedia').html(''); 3900 if ($(this).data('video') == 'S') { 3901 $('#divQuestao1').attr("class", "col-md-6"); 3902 $('#divQuestao2').attr("class", "col-md-6"); 3903 openMedia(null, $(this).attr('id'), '', 'V'); 3904 } else { 3905 $('#divQuestao1').attr("class", "col-md-12"); 3906 $('#divQuestao2').attr("class", "d-none"); 3907 } 3908 return true; 3909}); 3910 3911function configurarModalQuestaoOcorrencia(tpOcorrencia) { 3912 var tipoOcorrencia = parseInt(tpOcorrencia, 10); 3913 if (isNaN(tipoOcorrencia)) { 3914 tipoOcorrencia = 1; 3915 } 3916 3917 var ehRecurso = tipoOcorrencia == 2; 3918 var campoDescricao = $('#descricaoErro'); 3919 var validator = $("#QuestaoErroForm").data('validator'); 3920 3921 if ($('#tituloModalFrame2').length > 0) { 3922 $('#tituloModalFrame2').text(ehRecurso ? 'Marcar questão para recurso' : 'Reportar erro da questão'); 3923 } 3924 if ($('#textoModalQuestaoErro').length > 0) { 3925 $('#textoModalQuestaoErro').text(ehRecurso ? 'Use esta área para marcar a questão como passível de recurso. Você pode informar uma justificativa, se desejar.' : 'Esta área é exclusiva para reportar erros técnicos ou problemas na questão. Para esclarecimento de dúvidas sobre o conteúdo, utilize os canais de dúvidas.'); 3926 } 3927 if ($('#labelDescricaoQuestaoErro').length > 0) { 3928 $('#labelDescricaoQuestaoErro').text(ehRecurso ? 'Justificativa (opcional):' : 'Descrição do problema:'); 3929 } 3930 if ($('#btnQuestaoErroSend').length > 0) { 3931 $('#btnQuestaoErroSend').text(ehRecurso ? 'Marcar recurso' : 'Enviar'); 3932 } 3933 3934 if (ehRecurso) { 3935 campoDescricao.removeAttr('required'); 3936 campoDescricao.removeAttr('data-rule-required'); 3937 campoDescricao.attr('placeholder', 'Se quiser, descreva resumidamente o motivo do recurso.'); 3938 } else { 3939 campoDescricao.attr('required', 'required'); 3940 campoDescricao.attr('data-rule-required', 'true'); 3941 campoDescricao.attr('placeholder', 'Descreva o erro encontrado na questão.'); 3942 } 3943 3944 if ($('#tpOcorrenciaErro').length > 0) { 3945 $('#tpOcorrenciaErro').val(tipoOcorrencia); 3946 } 3947 if (validator) { 3948 validator.resetForm(); 3949 } 3950 campoDescricao.removeClass('error'); 3951} 3952 3953function abrirQuestaoOcorrencia(idQuestao, tpOcorrencia) { 3954 $('#idQuestaoErro').val(idQuestao);
3955 $('#idAlunoMensalidadeErro').val($('#idAlunoMensalidade').val()); 3956 $('#idAvaliacaoErro').val($('#idAvaliacao').val()); 3957 $('#idCursoErro').val($('#idCurso').val()); 3958 $('#tipoCursoErro').val($('#tipoCurso').val()); 3959 $('#descricaoErro').val(''); 3960 configurarModalQuestaoOcorrencia(tpOcorrencia); 3961 $('#modalErro').modal('show'); 3962} 3963 3964function abrirQuestaoErro(idQuestao) { 3965 abrirQuestaoOcorrencia(idQuestao, 1); 3966} 3967 3968$(document).on("click", '#btnQuestaoErroSend', function() { 3969 3970 if (!$("#QuestaoErroForm").valid()) { 3971 return; 3972 } 3973 3974 $.post("/portal/salvarQuestaoErro", $("#QuestaoErroForm").serialize(), function(data) { 3975 if (data.status == 0) { 3976 $('#descricaoErro').val(''); 3977 $('#modalErro').modal('hide'); 3978 } else { 3979 alert(data.message); 3980 } 3981 }, 'json'); 3982}); 3983 3984 3985 3986 3987 3988function setTestAgendamento(idAvaliacao, token) { 3989 3990 if (!$("#TestAgendamentoForm").valid()) { 3991 return; 3992 } 3993 3994 $.post("/portal/setTestAgendamento", { dataAgendamento: $("#dataAgendamento").val(), turnoAgendamento: $("#turnoAgendamento").val(), token: token, idAvaliacao: idAvaliacao }, function(data) { 3995 if (data.message.length > 0) { 3996 alert(data.message); 3997 $("#modal1").modal("hide"); 3998 } 3999 }, 'json'); 4000} 4001 4002function documentoAlunoDuvida(id, nomeArquivo) { 4003 window.open('/portal/documentoAlunoDuvida?idDuvida=' + id + '&nomeArquivo=' + nomeArquivo, '_self'); 4004} 4005 4006 4007function documentoProfessorDuvida(id, nomeArquivo) { 4008 window.open('/portal/documentoProfessorDuvida?idDuvida=' + id + '&nomeArquivo=' + nomeArquivo, '_self'); 4009} 4010 4011function editText(id) { 4012 const textElement = document.getElementById(`titulo-${id}`); 4013 const descElement = document.getElementById(`desc-${id}`); 4014 const editIcon = document.getElementById(`icon-${id}`); 4015 4016 // Verifica se o texto esta em modo de edicao 4017 if (textElement.contentEditable === 'true') { 4018 // Desabilita a edicao 4019 textElement.contentEditable = 'false'; 4020 descElement.contentEditable = 'false'; 4021 editIcon.className = 'fas fa-pencil-alt'; 4022 // Aqui voce pode salvar o novo texto em algum lugar, como em uma base de dados, se necessario 4023 const newTitulo = textElement.innerText; 4024 const newDesc = descElement.innerText; 4025 4026 textElement.classList.remove('edit-text'); 4027 descElement.classList.remove('edit-text'); 4028 4029 $.post("/portal/atualizarAnotacao", { titulo: newTitulo, descricao: newDesc, id: id }, function() { 4030 }, 'json'); 4031 4032 4033 4034 } else { 4035 textElement.classList.add('edit-text'); 4036 descElement.classList.add('edit-text'); 4037 textElement.contentEditable = 'true'; 4038 descElement.contentEditable = 'true'; 4039 editIcon.className = 'fas fa-save'; 4040 } 4041} 4042 4043 4044function deleteBloco(id) { 4045 var confirmDelete = confirm("Tem certeza que deseja excluir?"); 4046 4047 if (confirmDelete) { 4048 $.post("/portal/deletarAnotacao", { id: id }, function() { 4049 }, 'json'); 4050 document.location.reload(true); 4051 document.location.reload(true); 4052 } 4053} 4054 4055function imprimirTela() { 4056 window.print(); 4057} 4058 4059function toExcel() { 4060 $.post("/portal/BlocoNotaToExcel", function(data) { 4061 const wb = XLSX.utils.book_new(); 4062 4063 const ws = XLSX.utils.json_to_sheet(data); 4064 4065 XLSX.utils.book_append_sheet(wb, ws, "Dados"); 4066 4067 const excelBuffer = XLSX.write(wb, { bookType: "xlsx", type: "array" }); 4068 4069 const blob = new Blob([excelBuffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }); 4070 4071 const url = URL.createObjectURL(blob); 4072 4073 const downloadLink = document.createElement("a"); 4074 downloadLink.href = url; 4075 downloadLink.download = "dados.xlsx"; 4076 downloadLink.textContent = "Baixar Excel"; 4077 4078 document.body.appendChild(downloadLink); 4079 downloadLink.click(); 4080 URL.revokeObjectURL(url); 4081 }, 'json'); 4082} 4083 4084 4085function cancelarAtendimento(id) { 4086 var confirmDelete = confirm("Tem certeza que deseja cancelar?"); 4087 4088 if (confirmDelete) { 4089 $.post("/portal/cancelarAtendimento", { id: id }, function() { 4090 }, 'json'); 4091 document.location.reload(true); document.location.reload(true); 4092 } 4093} 4094 4095 4096function select2String(id) { 4097 var selectElement = document.getElementById(id); 4098 var selectedValues = []; 4099 4100 for (var i = 0; i < selectElement.options.length; i++) { 4101 selectedValues.push(selectElement.options[i].value); 4102 } 4103 4104 return selectedValues.join(","); 4105} 4106 4107 4108function arquivarAvaliacaoBaseQuestao(event, token) { 4109 4110 if (confirm($("#btnArquivar" + token).data("msgconfirm")) == true) { 4111 $.getJSON("/portal/arquivarAvaliacaoBaseQuestao", { format: "json", token: token }).done(function(data) { 4112 if (data.status == 0) { 4113 alert($("#btnArquivar" + token).data("msgsucess")); 4114 $("#li-" + token).remove(); 4115 } 4116 if (data == null || data.message.length > 0) { 4117 alert($("#btnArquivar" + token).data("msgerror") + " " + data.message); 4118 } 4119 }); 4120 } 4121} 4122 4123function deletaLinhas(tabela) { 4124 for (var i = tabela.rows.length - 1; i >= 1; i--) { 4125 tabela.deleteRow(i); 4126 } 4127} 4128 4129function reiniciaEditor() { 4130 tinymce.remove('.mceEditorAlternativa'); 4131 4132 tinymce.init({ 4133 editor_selector: 'mceEditorAlternativa', 4134 mode: "specific_textareas", 4135 height: 100, 4136 menubar: false, 4137 browser_spellcheck: true, 4138 language: 'pt_BR', 4139 branding: false, 4140 plugins: [ 4141 'advlist autolink lists link image charmap print preview anchor', 4142 'searchreplace visualblocks fullscreen', 4143 'insertdatetime media wordcount textcolor emoticons' 4144 ], 4145 toolbar: 'forecolor backcolor bold italic underline | alignleft aligncenter alignright al
4145ignjustify | removeformat | subscript superscript | charmap emoticons' 4146 }); 4147 4148} 4149 4150 4151function loadFormulario() { 4152 $('#modalFooter1').show(); 4153 $('#modalDialog1').width('100%'); 4154 $('#modalDialog1').height('auto'); 4155 $('#btnMaterial').hide(); 4156 $('#btnChat').hide(); 4157 $('#btnDownload').hide(); 4158 $('#btnDownloadTrilha').hide(); 4159 $('#divClassificacao').hide(); 4160 $('#divClassificacao').attr("style", "display: none !important"); 4161 $('#btnFavoritos').hide(); 4162 $('#btnAnotacoes').hide(); 4163 $('#btnAnotacoes').attr("style", "display: none !important"); 4164 $('#btnDuvida').hide(); 4165 $('#modalDialog1').css('max-width', '100%'); 4166 $('.modal-content').css('background-color', '#FFFFFF'); 4167 4168 var heightCompoment = $(window).height() - 110; 4169 if ($('#modalBodyMedia').height() < 100) { 4170 if ($('#modalContent').height() > 100) { 4171 heightCompoment = $('#modalContent').height(); 4172 } 4173 } else { 4174 heightCompoment = $('#modalBodyMedia').height(); 4175 } 4176 $('#modalBodyMedia').height(heightCompoment) 4177 $('#modalBodyMedia').css('overflowY', 'auto'); 4178 4179 4180 $('#btnEnviarFormularioDinamico').click(function() { 4181 4182 if ($("#formularioDinamico").valid() == false) { 4183 alert("Existem erros no formulário. Por favor, corrija-os."); 4184 return false; 4185 } 4186 4187 $.post("/portal/enviarFormularioDinamico", $("#formularioDinamico").serialize(), function(data) { 4188 if (data.status == 0) { 4189 alert('Dados enviados com sucesso!'); 4190 4191 fecharModalFormulario(); 4192 window.parent.fecharModalFormulario(); 4193 4194 } else { 4195 alert(data.message); 4196 } 4197 }, 'json'); 4198 }); 4199} 4200 4201function fecharModalFormulario() { 4202 var modais = $(".modalFormulario"); 4203 modais.each(function() { 4204 $(this).modal('hide'); 4205 $(this).hide(); 4206 $('.modal-backdrop').remove(); 4207 }); 4208 4209 var modais = $("#modal1"); 4210 modais.each(function() { 4211 $(this).modal('hide'); 4212 $(this).hide(); 4213 $('.modal-backdrop').remove(); 4214 }); 4215} 4216 4217 function generatePDF() { 4218 const element = document.getElementById('content'); 4219 4220 const options = { 4221 margin: 10, 4222 filename: 'notas.pdf', 4223 image: { type: 'jpeg', quality: 0.98 }, 4224 html2canvas: { scale: 2 }, 4225 jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } 4226 }; 4227 4228 html2pdf(element, options); 4229 } 4230 4231function ehNumero(s) { 4232 var i; 4233 var dif = 0; 4234 for (i = 0; i < s.length; i = i + 1) { 4235 var c = s.charAt(i); 4236 if (!((c >= "0") && (c <= "9"))) { 4237 dif = 1; 4238 } 4239 } 4240 if (dif == 1) { 4241 return false; 4242 } 4243 return true; 4244} 4245 4246$(document).on("click", '[name="btnTranscricaoDownload"]', function() { 4247 $('#btnTranscricaoDownload' + $(this).data('value')).prop("disabled", "true"); 4248 $("#modalLoading").modal({ 4249 backdrop: "static", 4250 keyboard: false, 4251 show: true 4252 }); 4253 var token = $(this).data('token'); 4254 4255 window.open('/portal/trascricao-download/' + token); 4256 4257}); 4258 4259$(document).on("click", '[name="btnEbookDownload"]', function() { 4260 $('#btnEbookDownload' + $(this).data('value')).prop("disabled", "true"); 4261 $("#modalLoading").modal({ 4262 backdrop: "static", 4263 keyboard: false, 4264 show: true 4265 }); 4266 var token = $(this).data('token'); 4267 4268 window.open('/portal/ebook-ai-download/' + token); 4269 4270}); 4271 4272 4273function carregaTranscricao(token, divTranscricao) { 4274 4275 $.getJSON("/portal/getTranscricao", { format: "json", token: token }).done(function(transcricao) { 4276 4277 var bodyTranscription = $('#' + divTranscricao); 4278 4279 if (transcricao == null) { 4280 var bloco = '<div class="bloco palavra">'; 4281 bloco += 'Este vídeo não tem legenda, contacte nossa equipe!'; 4282 bloco += '</div>'; 4283 bodyTranscription.html(bloco); 4284 4285 return; 4286 } 4287 4288 bodyTranscription.html(''); 4289 for (var i = 0; i < transcricao.transcripts.length; i++) { 4290 var bloco = '<div class="bloco" data-confidence="' + transcricao.transcripts[i].confidence + '">'; 4291 for (var j = 0; j < transcricao.transcripts[i].words.length; j++) { 4292 var classe = ""; 4293 for (var k = transcricao.transcripts[i].words[j].startInt; k <= transcricao.transcripts[i].words[j].endInt; k++) { 4294 classe += ' t-' + k; 4295 } 4296 bloco += '<span class="palavra ' + classe + '" data-inicio="' + transcricao.transcripts[i].words[j].start + '" data-fim="' + transcricao.transcripts[i].words[j].end + '"><span data-texto="true">' + transcricao.transcripts[i].words[j].word + '</span></span>'; 4297 bloco += '<span class="espaco t-' + transcricao.transcripts[i].words[j].endInt + '"> </span>'; 4298 } 4299 bloco += '</div>'; 4300 bodyTranscription.append(bloco); 4301 } 4302 }); 4303} 4304 4305function abrirModal(url) { 4306 $('#modalFormularioFrame').attr('src', url); 4307 $('#modalFormulario').modal('show'); 4308} 4309 4310function goBack() { 4311 if (document.referrer) { 4312 window.location.href = document.referrer; 4313 } else { 4314 history.back(); 4315 } 4316} 4317 4318function getURLIntegracao(token){ 4319 $.ajax({ 4320 url: "/portal/getURLIntegracao?token=" + token, 4321 dataType: 'html', 4322 type: 'GET', 4323 async: true, 4324 success: function(data) { 4325 if (data == null) {
4326 alert('Não foi possível abrir o link deste produto, contate o suporte.'); 4327 } 4328 window.open(data, '_blank'); 4329 } 4330 }); 4331} 4332 4333function truncateToOneDecimal(number) { 4334 return Math.floor(number * 10) / 10; 4335} 4336 4337function converterDataSimples(dataStr) { 4338 var partes = dataStr.split('/'); 4339 return partes[2] + '-' + partes[1] + '-' + partes[0]; 4340} 4341 4342function converterDataSimples2(dataStr) { 4343 var partes = dataStr.split('-'); 4344 return partes[2] + '/' + partes[1] + '/' + partes[0]; 4345} 4346 4347function formatTime(totalSeconds) { 4348 totalSeconds = Math.max(0, Math.floor(totalSeconds)); 4349 4350 const hours = Math.floor(totalSeconds / 3600); 4351 const remainingSecondsAfterHours = totalSeconds % 3600; 4352 const minutes = Math.floor(remainingSecondsAfterHours / 60); 4353 const seconds = remainingSecondsAfterHours % 60; 4354 4355 const parts = []; 4356 if (hours > 0) { 4357 parts.push(hours === 1 ? '1 hora' : `${hours} horas`); 4358 } 4359 if (minutes > 0) { 4360 parts.push(`${minutes} min`); 4361 } 4362 if (seconds > 0 || parts.length === 0) { 4363 parts.push(`${seconds}s`); 4364 } 4365 4366 if (parts.length > 1) { 4367 return parts.slice(0, -1).join(' ') + ' e ' + parts[parts.length -1]; 4368 } else { 4369 return parts[0]; 4370 } 4371} 4372 4373function criarEventoApagarLinha(id) { 4374 $("#linha" + id).click(function() { 4375 if ($('#btnLinha').length > 0) { 4376 if (confirm('Deseja remover a linha?')) { 4377 4378 $.post("/portal/apagarFlagComentario", { id: id}, function(data) { 4379 $("#linha" + id).remove(); 4380 }, 'json'); 4381 4382 4383 } 4384 } 4385 }); 4386} 4387 4388$('[name="btnBoletoOnline"]').click(function() { 4389 var id = $(this).data('value'); 4390 var tipo = $(this).data('tipo'); 4391 var url = ''; 4392 if (tipo == 'V') { 4393 PagSeguroDirectPayment.onSenderHashReady(function(response) { 4394 if (response.status == 'error') { 4395 return false; 4396 } 4397 url = '/portal/boleto-online?id=' + id + "&userHash=" + response.senderHash; 4398 4399 $.getJSON(url, { format: "json" }).done(function(data) { 4400 if (data.status == 0) { 4401 $('#pixPopupDescription').hide(); 4402 $('#boletoPopupDescription').show(); 4403 $("#aBoletoDownload").prop("href", data.message); 4404 $("#divBoletoDownload").html(data.message); 4405 $('#boletoPopupTitle').text('Boleto'); 4406 $('#boletoPopup').modal('show'); 4407 } else { 4408 alert(data.message); 4409 } 4410 }); 4411 }); 4412 } else { 4413 url = '/portal/boleto-online?id=' + id; 4414 $.getJSON(url, { format: "json" }).done(function(data) { 4415 if (data.status == 0) { 4416 $('#pixPopupDescription').hide(); 4417 $('#boletoPopupDescription').show(); 4418 $("#aBoletoDownload").prop("href", data.message); 4419 $("#divBoletoDownload").html(data.message); 4420 $('#boletoPopupTitle').text('Boleto'); 4421 $('#boletoPopup').modal('show'); 4422 } else { 4423 alert(data.message); 4424 } 4425 }); 4426 } 4427}); 4428 4429function copyDownloadButton(tokenButton) { 4430 4431 var $link = $('#btnMaterialDownload' + tokenButton); 4432 var $target = $('#btnDownloadDownloadFrame'); 4433 4434 $target.data('path', $link.data('path')); 4435 $target.data('posicao', $link.data('posicao')); 4436 $target.data('token', $link.data('token')); 4437 $target.data('value', $link.data('value')); 4438 $target.data('tipo', $link.data('tipo')); 4439 4440} 4441 4442$('[name="btnPix"]').click(function() { 4443 var id = $(this).data('value'); 4444 var url = ''; 4445 url = '/portal/pix-online?id=' + id; 4446 $.getJSON(url, { format: "json" }).done(function(data) { 4447 if (data.status == 0) { 4448 $('#pixPopupDescription').show(); 4449 $('#boletoPopupDescription').hide(); 4450 $("#qrcode").data("url", data.message); 4451 $("#copyLinkPix").val(data.message); 4452 4453 $("#qrcode").empty(); 4454 4455 var qrcode = new QRCode(document.getElementById("qrcode"), { 4456 text: $("#qrcode").data("url"), 4457 width: 250, 4458 height: 250, 4459 colorDark: "#000000", 4460 colorLight: "#ffffff", 4461 correctLevel: QRCode.CorrectLevel.H 4462 }); 4463 $('#boletoPopupTitle').text('Pix'); 4464 $('#boletoPopup').modal('show'); 4465 } else { 4466 alert(data.message); 4467 } 4468 }); 4469}); 4470 4471 4472function openTopicoFlashcard(tokenFlash, whereDiv) { 4473 4474 var token = 'flash-' + $('#token').val() + "-" + tokenFlash; 4475 4476 var url = '/portal/media?token=' + token; 4477 $.ajax({ 4478 url: url, 4479 dataType: 'html', 4480 type: 'GET', 4481 async: true, 4482 success: function(data) { 4483 $(whereDiv).html(data); 4484 } 4485 }); 4486} 4487 4488function carregaEbookAI(token, divEbook) { 4489
4490 var url = '/portal/getEbookAI?token=' + token; 4491 4492 $.ajax({ 4493 url: url, 4494 dataType: 'html', 4495 type: 'GET', 4496 async: true, 4497 success: function(data) { 4498 $('#' + divEbook).html(data); 4499 } 4500 }); 4501} 4502 4503function configurarEventosDesenho() { 4504 var $doc = $('#divDocument'); 4505 4506 // Remover eventos antigos primeiro 4507 removerEventosDesenho(); 4508 4509 // Criar SVG se não existir 4510 criarSVGSeNecessario(); 4511 4512 // Mouse down - iniciar linha 4513 $doc.on('mousedown.desenho', function(e) { 4514 if ($('#btnLinha').data('habilitado') != 1) return; 4515 if ($(e.target).hasClass('flag-comentario')) return; 4516 if ($(e.target).closest('.linhaCorrecao').length > 0) return; 4517 4518 e.preventDefault(); 4519 e.stopPropagation(); 4520 4521 isDrawing = true; 4522 4523 var offset = getDocumentOffset(); 4524 drawStartX = e.pageX - offset.left; 4525 drawStartY = e.pageY - offset.top; 4526 4527 criarLinhaPreview(drawStartX, drawStartY); 4528 }); 4529 4530 // Mouse move - atualizar preview 4531 $doc.on('mousemove.desenho', function(e) { 4532 if (!isDrawing) return; 4533 4534 e.preventDefault(); 4535 4536 var offset = getDocumentOffset(); 4537 var currentX = e.pageX - offset.left; 4538 var currentY = e.pageY - offset.top; 4539 4540 currentX = Math.max(0, Math.min(currentX, getWidth())); 4541 currentY = Math.max(0, Math.min(currentY, getHeight())); 4542 4543 atualizarLinhaPreview(currentX, currentY); 4544 }); 4545 4546 // Mouse up - finalizar linha 4547 $doc.on('mouseup.desenho', function(e) { 4548 if (!isDrawing) return; 4549 4550 isDrawing = false; 4551 4552 var offset = getDocumentOffset(); 4553 var endX = e.pageX - offset.left; 4554 var endY = e.pageY - offset.top; 4555 4556 endX = Math.max(0, Math.min(endX, getWidth())); 4557 endY = Math.max(0, Math.min(endY, getHeight())); 4558 4559 // Verificar tamanho mínimo (evitar cliques acidentais) 4560 var distancia = Math.sqrt(Math.pow(endX - drawStartX, 2) + Math.pow(endY - drawStartY, 2)); 4561 4562 if (distancia < 10) { 4563 removerLinhaPreview(); 4564 return; 4565 } 4566 4567 removerLinhaPreview(); 4568 salvarLinhaDesenho(drawStartX, drawStartY, endX, endY); 4569 }); 4570 4571 // Mouse leave - cancelar se sair da área 4572 $doc.on('mouseleave.desenho', function(e) { 4573 if (isDrawing) { 4574 isDrawing = false; 4575 removerLinhaPreview(); 4576 } 4577 }); 4578} 4579 4580function removerEventosDesenho() { 4581 $('#divDocument').off('mousedown.desenho'); 4582 $('#divDocument').off('mousemove.desenho'); 4583 $('#divDocument').off('mouseup.desenho'); 4584 $('#divDocument').off('mouseleave.desenho'); 4585} 4586 4587function getDocumentOffset() { 4588 if ($('#divDocument img').length > 0) { 4589 return $('#divDocument img').offset(); 4590 } else if ($('#divDocument canvas').length > 0) { 4591 return $('#divDocument canvas').first().offset(); 4592 } 4593 return $('#divDocument').offset(); 4594} 4595 4596function criarSVGSeNecessario() { 4597 if ($('#svglinha').length == 0) { 4598 var svg = '<svg xmlns="http://www.w3.org/2000/svg" id="svglinha" version="1.1" ' + 4599 'width="' + getWidth() + '" height="' + getHeight() + '" ' + 4600 'style="position: absolute; top: 0; left: 0;"></svg>'; 4601 4602 if ($('#divDocument img').length > 0) { 4603 $('#divDocument').append(svg); 4604 } else { 4605 $('#divDocument2').append(svg); 4606 } 4607 } 4608} 4609 4610function criarLinhaPreview(x, y) { 4611 criarSVGSeNecessario(); 4612 removerLinhaPreview(); 4613 4614 var cor = getCor(); 4615 4616 var newLine = document.createElementNS('http://www.w3.org/2000/svg', 'line'); 4617 newLine.setAttribute('id', previewLineId); 4618 newLine.setAttribute('x1', x); 4619 newLine.setAttribute('y1', y); 4620 newLine.setAttribute('x2', x); 4621 newLine.setAttribute('y2', y); 4622 newLine.setAttribute('stroke-linecap', 'round'); 4623 newLine.setAttribute('stroke-opacity', '0.5'); 4624 newLine.setAttribute('stroke-width', '8'); 4625 newLine.setAttribute('stroke', cor); 4626 newLine.setAttribute('stroke-dasharray', '5,5'); 4627 newLine.style.pointerEvents = 'none'; 4628 4629 $('#svglinha').append(newLine); 4630} 4631 4632function atualizarLinhaPreview(x, y) { 4633 var preview = document.getElementById(previewLineId); 4634 if (preview) { 4635 preview.setAttribute('x2', x); 4636 preview.setAttribute('y2', y); 4637 } 4638} 4639 4640function removerLinhaPreview() { 4641 $('#' + previewLineId).remove(); 4642} 4643 4644function salvarLinhaDesenho(x1, y1, x2, y2) { 4645 var cor = getCor(); 4646 var idTemp = 'temp-' + parseInt(Math.random() * 10000); 4647 4648 // Criar linha visual imediatamente 4649 criarLinha(idTemp, x1, y1, x2, y2, cor); 4650 4651 // Salvar no servidor 4652 $.post("/portal/salvarFlagComentario", { 4653 id: 0, 4654 idAvaliacaoAluno: $("#idAvaliacaoAluno").val(), 4655 comentario: '', 4656 topo: Math.round(y1), 4657 esquerda: Math.round(x1), 4658 largura: getWidth(), 4659 altura: getHeight(), 4660 tipo: 2, 4661 topo2: Math.round(y2), 4662 esquerda2: Math.round(x2), 4663 cor: cor 4664 }, function(data) { 4665 if (data.status == 0) { 4666 var novoId = data.message; 4667 $('#linha' + idTemp).attr('id', 'linha' + novoId); 4668 criarEventoApagarLinha(novoId); 4669 } else { 4670 alert(data.message); 4671 $('#linha' + idTemp).remove(); 4672 } 4673 }, 'json').fail(function() { 4674 alert('Erro ao salvar a linha'); 4675 $('#linha' + idTemp).remove(); 4676 }); 4677}
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.