/** * */ var caminhoUrl = location.protocol + "//" + location.host+"/"; /*var loadingMask = function () { var loading = function () { this.show = function() { $( 'body' ).loading({ message: 'Por favor Aguarde...' }); }; this.hide = function() { $( 'body' ).loading('stop'); }; }; return new loading(); };*/ function loading( mostra = true ) { if ( mostra ) { $( 'body' ).loading( { message: 'Por favor Aguarde...' }); } else { $( 'body' ).loading( 'stop' ); } }; function findPos(obj) { var curleft = 0; var curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft curtop = obj.offsetTop while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } } return [curleft,curtop]; } function centDiv(id) { var div = document.getElementById(id); var altTela = Math.floor(document.body.offsetHeight); var largTela = Math.floor(document.body.offsetWidth); div.style.left = ((largTela/2)-(div.offsetWidth/2))+"px"; var vScrollY = 0; if (document.all){ if (!document.documentElement.scrollTop){ vScrollY = document.body.scrollTop; }else{ vScrollY = document.documentElement.scrollTop; } }else{ vScrollY = window.pageYOffset; } if (window.innerHeight) { altura = window.innerHeight; } else if (window.document.body.clientHeight) { altura = window.document.body.clientHeight; } else { altura = Math.floor(document.body.offsetHeight); } div.style.top=((altura/2) + vScrollY - (parseInt(div.offsetHeight)/2))+"px"; } function Mascara(objeto, evt, mask) { var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZÇ'; var LetrasL = 'abcdefghijklmnopqrstuvwxyzç'; var Letras = 'ABCDEFGHIJKLMNOPQRSTUVWXYZÇabcdefghijklmnopqrstuvwxyzç'; var Numeros = "0123456789%&´.'("; var Fixos = "().-:/¹²³£¢¬ªº'"; var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZÇ[\]^_/`abcdefghijklmnopqrstuvwxyzç{|}~"; evt = (evt) ? evt : (window.event) ? window.event : ""; var value = objeto.value; if (evt) { var ntecla = (evt.which) ? evt.which : evt.keyCode; tecla = Charset.substr(ntecla - 32, 1); if(parseInt(ntecla) == 8){ return true; } if (parseInt(ntecla) < 32 || parseInt(ntecla) > 127){ return false; } var tamanho = value.length; if (tamanho >= mask.length) return false; var pos = mask.substr(tamanho,1); while (Fixos.indexOf(pos) != -1) { value += pos; tamanho = value.length; if (tamanho >= mask.length) return false; pos = mask.substr(tamanho,1); } switch (pos) { case '#' : if (Numeros.indexOf(tecla) == -1) return false; break; case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break; case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break; case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break; case '*' : objeto.value = value; return true; break; default : return false; break; } } objeto.value = value; return true; } //formata float para moeda function float2moeda(num, params, data) { x = 0; if(num<0) { num = Math.abs(num); x = 1; } if(isNaN(num)) num = "0"; cents = Math.floor((num*100+0.5)%100); num = Math.floor((num*100+0.5)/100).toString(); if(cents < 10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+'.' +num.substring(num.length-(4*i+3)); ret = num + ',' + cents; if (x == 1) ret = ' - ' + ret;return ret; } function FormataReais(fld, milSep, decSep, e) { var sep = 0; var key = ''; var i = j = 0; var len = len2 = 0; var strCheck = '0123456789'; var aux = aux2 = ''; var whichCode = (navigator.appName == 'Microsoft Internet Explorer') ? e.keyCode : e.which; if (whichCode == 13 || whichCode == 0 || whichCode == 8) return true; key = String.fromCharCode(whichCode); // Valor para o c�digo da Chave if (strCheck.indexOf(key) == -1) return false; // Chave inv�lida len = fld.value.length; for(i = 0; i < len; i++) if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; aux = ''; for(; i < len; i++) if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt (i); aux += key; len = aux.length; if (len == 0) fld.value = ''; if (len == 1) fld.value = '0'+ decSep + '0' + aux; if (len == 2) fld.value = '0'+ decSep + aux; if (len > 2) { aux2 = ''; for (j = 0, i = len - 3; i >= 0; i--) { if (j == 3) { aux2 += milSep; j = 0; } aux2 += aux.charAt(i); j++; } fld.value = ''; len2 = aux2.length; for (i = len2 - 1; i >= 0; i--) fld.value += aux2.charAt(i); fld.value += decSep + aux.substr(len - 2, len); } return false; }