/** * Arquivo para controlar o TimeOut de sessao * Autor: leandro1.lima@saude.gov.br */ var min, sec; function Minutes(data) { for (var i = 0; i < data.length; i++) if (data.substring(i, i + 1) == ":") break; return (data.substring(0, i)); } function Seconds(data) { for (var i = 0; i < data.length; i++) if (data.substring(i, i + 1) == ":") break; return (data.substring(i + 1, data.length)); } function Down() { sec--; if (sec == -1) { sec = 59; min--; } if (document.location.href.indexOf("timeout") < 0 && document.location.href.indexOf("parametro") < 0) { if (min == 3 && sec == 0) { var d = new Date(); var hours = d.getHours(); var minutes = d.getMinutes(); if (minutes < 10) { minutes = "0" + minutes; } //alert('Mensagem da Aplicação em '+hours+':'+minutes+'\n\nVocê esta inativo por algum tempo.\nEm aproximadamente 1 minuto(s) sua sessão será finalizada.'); showDialog(); } if (sec == 59) { var minutes = min + 1; console.log("Minutos restantes para timeout: " + minutes); } if (min < 3) { var elem = (!isIE() ? document.getElementById("timeleft") : document.getElementById("timeleft2")); elem.innerHTML = getTimeLeft(); console.log("Tempo restante para timeout: " + getTimeLeft()); } if (min == 0 && sec == 0) { window.status = "Sua sessão foi finalizada."; document.location.href = "timeout.do"; } else { setTimeout("Down()", 1000); } } } function getTimeLeft() { var sMin = min; var sSec = sec; if (sMin < 10) sMin = "0" + sMin; if (sSec < 10) sSec = "0" + sSec; return sMin + ":" + sSec; } /* * Chame essa funcao para disparar o contador */ function timeIt() { var timeout = "10:00" min = 1 * Minutes(timeout); sec = 0 + Seconds(timeout); Down(); } function isIE() { var myNav = navigator.userAgent.toLowerCase(); return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false; } function showDialog() { if (!isIE()) { document.location.href = "#openModal"; } var el = (!isIE() ? document.getElementById("openModal") : document.getElementById("openModal2")); el.style.visibility = "visible"; } function hideDialog() { if (!isIE()) { document.location.href = "#openModal"; } var el = (!isIE() ? document.getElementById("openModal") : document.getElementById("openModal2")); el.style.visibility = "hidden"; } function configure() { if (isIE()) { //var myElement = document.getElementById("openModal2"); //myElement.style.backgroundColor = "#D93600"; //myElement.style.className = "transparent"; document.getElementById("dialogContent").style.backgroundColor = "#dddddd"; } } window.setTimeout(function () { var Hwindow = $(window).height(), Hbody = $("body").height(), Hbarra =$("#barra-brasil").height(), Htopo = $("#topo").height(), Hconteudo = $("#corpo_menuhorizontal").height(), Hfooter = $("footer .ms-footer").height(), Hsection = Hwindow - Hbarra - Htopo - Hfooter - 2; if (Hwindow >= Hbody) { $("#corpo_menuhorizontal").css("min-height", Hsection); $(window).resize(function () { var Hwindow = $(window).height(), Hbody = $("body").height(), Hbarra =$("#barra-brasil").height(), Htopo = $("#topo").height(), Hconteudo = $("#corpo_menuhorizontal").height(), Hfooter = $("footer .ms-footer").height(), Hsection = Hwindow - Hbarra - Htopo - Hfooter - 2; $("#corpo_menuhorizontal").css("min-height", Hsection); }); } }, 100);