$(() => { //alert(window.innerWidth + " | " + $('form').width()) resizeForms() $('.tabela').removeAttr('border') $('#form1 br').remove() }) function resizeForms(){ const elements = ['form', '#view'] elements.forEach(e => { if($(e).length){ window.resizeTo($(e).width() + 100, $(e).height() + 100); return; } }) } //DETECTA O TIPO DE BROWSER PARA FAZER O TRATAMENTO DAS TELAS function browser() { var agt = navigator.userAgent.toLowerCase(); if (agt.indexOf("opera") != -1) return 'Opera'; if (agt.indexOf("staroffice") != -1) return 'Star Office'; if (agt.indexOf("webtv") != -1) return 'WebTV'; if (agt.indexOf("beonex") != -1) return 'Beonex'; if (agt.indexOf("chimera") != -1) return 'Chimera'; if (agt.indexOf("netpositive") != -1) return 'NetPositive'; if (agt.indexOf("phoenix") != -1) return 'Phoenix'; if (agt.indexOf("firefox") != -1) return 'Firefox'; if (agt.indexOf("safari") != -1) return 'Safari'; if (agt.indexOf("skipstone") != -1) return 'SkipStone'; if (agt.indexOf("msie") != -1) return 'Internet Explorer'; if (agt.indexOf("netscape") != -1) return 'Netscape'; if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla'; if (agt.indexOf('\/') != -1) { if (agt.substr(0, agt.indexOf('\/')) != 'mozilla') { return navigator.userAgent.substr(0, agt.indexOf('\/')); } else return 'Netscape'; } else if (agt.indexOf(' ') != -1) return navigator.userAgent.substr(0, agt.indexOf(' ')); else return navigator.userAgent; } function MM_goToURL(url) { //v3.0 eval("window.location='" + url + "'"); } //FUNÇÃO PARA FECHAR AS JANELAS ABERTAS DENTRO DO SISTEMA function fecha_popup(openForm, url) { if ((typeof url !== 'undefined') && (url)) { window.close(); window.opener.ConsultaRamal(url, 0); } else { window.close(); // if (typeof url === 'undefined') // { // window.opener.ResetForm(); // } } } //FUNC�O PARA ABRIR AS JANELAS USADAS PARA O CADASTRO DO SISTEMA function abre_janela(largura, altura, url, resize) { largura = largura > 800 ? largura : 800; altura = altura > 600 ? altura : 600; var $resize = resize ? resize : 'resizable=1, scrollbars=1'; var nomeJanela = 'janPopup_' + new Date().getTime(); NovaJanela(url, nomeJanela, largura, altura, $resize); } //FUNC�O UTILIZADA PARA ABRIR PROMPT DE EXLUS�O DE REGISTROS function excluir(codigo, nome, mensagem, endereco, tipo) { var msg = mensagem ? mensagem : "O resgistro selecionado será excluido, deseja continuar?"; if (confirm(msg)) { window.location = endereco; } } function _excluir(codigo, nome, mensagem, endereco, tipo) { $.blockUI({message: $('#mensagem'), width: 330 }); document.getElementById("mens").value = mensagem; $('#todos').click(function () { // update the block message if (endereco != 'digivoice.php?acao=restart') { $.blockUI({message: "

Exluindo o " + tipo + " : " + nome + "

"}); } else { $.blockUI({message: "

REINICIANDO O SERVICO!

"}); } $.ajax({ url: endereco, cache: false, complete: function () { window.parent.location.reload(); $.unblockUI(); } }); }); $('#cancela').click(function () { $.unblockUI(); return false; }); } //FUNC�O DE ALERTA DE EXISTENCIA DE REGISTROS NA INCLUS�O function alerta_existe(mensagem) { $.blockUI({message: $('#alerta'), css: {width: '275px', left: '20%', top: '20%' } }); window.mens2.value = mensagem; $('#volta').click(function () { $.unblockUI(); history.back(); return false; }); } var HttpReq = null; var dest_combo = null; var dest_combo2 = null; function ajaxComboBox3(url, comboBox, origem) { dest_combo2 = comboBox; orig_combo = origem; var indice = document.getElementById(orig_combo).selectedIndex; var sigla = document.getElementById(orig_combo).options[indice].getAttribute('value'); url = url + '&tipo=' + sigla; if (document.getElementById) { //Verifica se o Browser suporta DHTML. if (window.XMLHttpRequest) { let HttpReq = new XMLHttpRequest(); HttpReq.onreadystatechange = XMLHttpRequestChange_; HttpReq.open("GET", url, true); HttpReq.send(); } else if (window.ActiveXObject) { HttpReq = new ActiveXObject("Microsoft.XMLHTTP"); if (HttpReq) { HttpReq.onreadystatechange = XMLHttpRequestChange_; HttpReq.open("GET", url, true); HttpReq.send(); } } } } function ajaxComboBox4(url, origem) { let indice = document.getElementById(origem).selectedIndex; let sigla = document.getElementById(origem).options[indice].getAttribute('value'); url = url + '&tipo=' + sigla; if (document.getElementById) { //Verifica se o Browser suporta DHTML. if (window.XMLHttpRequest) { let HttpReq = new XMLHttpRequest(); HttpReq.onreadystatechange = XMLHttpRequestChange_; HttpReq.open("GET", url, true); HttpReq.send(null); } else if (window.ActiveXObject) { HttpReq = new ActiveXObject("Microsoft.XMLHTTP"); if (HttpReq) { HttpReq.onreadystatechange = XMLHttpRequestChange_; HttpReq.open("GET", url, true); HttpReq.send(); } } } } //FUNC�O PARA TRATAR A POPULA��O DAS COMBOBOX //GRUPO COM 4 FUN��ES function ajaxComboBox(url, comboBox, origem) { dest_combo = comboBox; orig_combo = origem; var indice = document.getElementById(orig_combo).selectedIndex; var sigla = document.getElementById(orig_combo).options[indice].getAttribute('value'); url = url + '&tipo=' + sigla; if (document.getElementById) { //Verifica se o Browser suporta DHTML. if (window.XMLHttpRequest) { HttpReq = new XMLHttpRequest(); HttpReq.onreadystatechange = XMLHttpRequestChange; HttpReq.open("GET", url, true); HttpReq.send(null); } else if (window.ActiveXObject) { HttpReq = new ActiveXObject("Microsoft.XMLHTTP"); if (HttpReq) { HttpReq.onreadystatechange = XMLHttpRequestChange; HttpReq.open("GET", url, true); HttpReq.send(); } } } } function ajaxComboBox2(url, comboBox, origem) { dest_combo = comboBox; orig_combo = origem; var indice = document.getElementById(orig_combo).selectedIndex; var sigla = document.getElementById(orig_combo).options[indice].getAttribute('value'); url = url + '&tipo=' + sigla; if (document.getElementById) { //Verifica se o Browser suporta DHTML. if (window.XMLHttpRequest) { HttpReq = new XMLHttpRequest(); HttpReq.onreadystatechange = XMLHttpRequestChange; HttpReq.open("GET", url, true); HttpReq.send(null); } else if (window.ActiveXObject) { HttpReq = new ActiveXObject("Microsoft.XMLHTTP"); if (HttpReq) { HttpReq.onreadystatechange = XMLHttpRequestChange; HttpReq.open("GET", url, true); HttpReq.send(); } } } } function ajaxComboBox4(url, combobx, origem){ var indice = document.getElementById(origem).selectedIndex; var sigla = document.getElementById(origem).options[indice].getAttribute('value'); var comboBox = combobx url = url + '&tipo=' + sigla; if (document.getElementById) { //Verifica se o Browser suporta DHTML. if (window.XMLHttpRequest) { let HttpReq = new XMLHttpRequest(); HttpReq.onreadystatechange = function (combo) { if (this.readyState == 4 && this.status == 200) { var result = this.responseXML; var cidades = result.getElementsByTagName("nome"); var padrao = result.getElementsByTagName("valor1"); document.getElementById(comboBox).innerHTML = ""; var valor1 = padrao[0].getAttribute("id"); for (var i = 0; i < cidades.length; i++) { new_opcao = create_opcao(cidades[i]); document.getElementById(comboBox).appendChild(new_opcao); if (valor1 == document.getElementById(comboBox).options[i].value) { document.getElementById(comboBox).options[i].selected = true; } } } } HttpReq.open("GET", url, true); HttpReq.send(null); } else if (window.ActiveXObject) { HttpReq = new ActiveXObject("Microsoft.XMLHTTP"); if (HttpReq) { HttpReq.onreadystatechange = function (comboBox) { if (this.readyState == 4 && this.status == 200) { var result = this.responseXML; var cidades = result.getElementsByTagName("nome"); var padrao = result.getElementsByTagName("valor1"); document.getElementById(comboBox).innerHTML = ""; var valor1 = padrao[0].getAttribute("id"); for (var i = 0; i < cidades.length; i++) { new_opcao = create_opcao(cidades[i]); document.getElementById(comboBox).appendChild(new_opcao); if (valor1 == document.getElementById(comboBox).options[i].value) { document.getElementById(comboBox).options[i].selected = true; } } } } HttpReq.open("GET", url, true); HttpReq.send(); } } } } function XMLHttpRequestChange() { if (HttpReq.readyState == 4 && HttpReq.status == 200) { var result = HttpReq.responseXML; var cidades = result.getElementsByTagName("nome"); var padrao = result.getElementsByTagName("valor1"); document.getElementById(dest_combo).innerHTML = ""; var valor1 = padrao[0].getAttribute("id"); for (var i = 0; i < cidades.length; i++) { new_opcao = create_opcao(cidades[i]); document.getElementById(dest_combo).appendChild(new_opcao); if (valor1 == document.getElementById(dest_combo).options[i].value) { document.getElementById(dest_combo).options[i].selected = true; } } } } function XMLHttpRequestChange_() { if (HttpReq.readyState == 4 && HttpReq.status == 200) { var result = HttpReq.responseXML; var cidades = result.getElementsByTagName("nome"); var padrao = result.getElementsByTagName("valor1"); document.getElementById(dest_combo2).innerHTML = ""; var valor1 = padrao[0].getAttribute("id"); for (var i = 0; i < cidades.length; i++) { new_opcao = create_opcao(cidades[i]); document.getElementById(dest_combo2).appendChild(new_opcao); if (valor1 == document.getElementById(dest_combo2).options[i].value) { document.getElementById(dest_combo2).options[i].selected = true; } } } } function create_opcao(cidade) { var new_opcao = document.createElement("option"); var texto = document.createTextNode(cidade.childNodes[0].data); new_opcao.setAttribute("value", cidade.getAttribute("id")); new_opcao.appendChild(texto); //Adiciona o texto a OPTION. return new_opcao; // Retorna a nova OPTION. } function marca_selecao(origem, destino) { var j = document.getElementById(destino).length; for (var i = 0; i < j; i++) { if (origem == document.getElementById(destino).options[i].value) { document.getElementById(destino).options[i].selected = true; } } } function formataHora(campo, teclapres) { var tecla = teclapres.keyCode; campo.value = filtraCampo(campo); vr = campo.value; vr = vr.replace(".", ""); vr = vr.replace(":", ""); vr = vr.replace(":", ""); tam = vr.length + 1; if (tecla != 9 && tecla != 8) { if (tam > 2 && tam < 5) campo.value = vr.substr(0, tam - 2) + ':' + vr.substr(tam - 2, tam); } } function RemoveSpace(comp) { var nome = document.getElementById(comp).value; var newNome = ''; for (var i = 0; i < nome.length; i++) { if (!(nome.substr(i, 1) == ' ')) newNome += nome.substr(i, 1); } document.getElementById(comp).value = newNome; } function RangeRamais(comp) { var nome = document.getElementById(comp).value; var newNome = ''; for (var i = 0; i < nome.length; i++) { if ((soNumero(nome.substr(i, 1))) || (nome.substr(i, 1) == '.') || (nome.substr(i, 1) == '-') || (nome.substr(i, 1) == '[') || (nome.substr(i, 1) == ']') || (nome.substr(i, 1).toUpperCase() == 'X') || (nome.substr(i, 1).toUpperCase() == 'N') || (nome.substr(i, 1).toUpperCase() == 'Z') ) newNome += nome.substr(i, 1); } document.getElementById(comp).value = newNome; } function soNumero(str) { var s = ""; // var charValido = new Array('0','1','2','3','4','5','6','7','8','9', ' '); var vr = str; tam = vr.length; for (i = 0; i < tam; i++) { if ((vr.substr(i, 1) == '0') || (vr.substr(i, 1) == '1') || (vr.substr(i, 1) == '2') || (vr.substr(i, 1) == '3') || (vr.substr(i, 1) == '4') || (vr.substr(i, 1) == '5') || (vr.substr(i, 1) == '6') || (vr.substr(i, 1) == '7') || (vr.substr(i, 1) == '8') || (vr.substr(i, 1) == '9') ) s += vr.substr(i, 1); } return s; } var win; function NovaJanela(pagina, nome, w, h, add_atributos) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; //Atributos var settings = 'height=' + h + ','; settings += 'width=' + w + ','; settings += 'top=' + wint + ','; settings += 'left=' + winl; if (!add_atributos) settings += 'resizable=yes,location=no'; if (add_atributos != "") { settings += ',' + add_atributos; } win = window.open(pagina, nome, settings); //Correção para outros navegadores if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } function ConsultaRamal(url, teclapres) { if (teclapres) { var tecla = teclapres.keyCode; if (tecla == 13) { var ramais = document.getElementById("numRamal").value; window.location.href = url + '&pesquisa=1&numRamal=' + ramais; } } else { var ramais = document.getElementById("numRamal").value; window.location.href = url + '&pesquisa=1&numRamal=' + ramais; } } function FiltraRamalRotaSaida(tipo, id) { var filtro = document.getElementById('filtro').value; var url = 'index.php?idProg=177' url = url + '&filtro=' + filtro + '&tipo=' + tipo + '&id=' + id; if (document.getElementById) { //Verifica se o Browser suporta DHTML. if (window.XMLHttpRequest) { HttpReq = new XMLHttpRequest(); HttpReq.onreadystatechange = GetRamalRotaSaida; HttpReq.open("GET", url, true); HttpReq.send(null); } else if (window.ActiveXObject) { HttpReq = new ActiveXObject("Microsoft.XMLHTTP"); if (HttpReq) { HttpReq.onreadystatechange = GetRamalRotaSaida; HttpReq.open("GET", url, true); HttpReq.send(); } } } } function GetRamalRotaSaida() { if (HttpReq.readyState == 4 && HttpReq.status == 200) { var ret = HttpReq.responseText.split('@'); if (ret[0] == 'ERRO') { alert(ret[1]); } else { document.getElementById('contentFiltro').innerHTML = ret[1]; } } }