function loadHora(){ jQuery.ajax({url : 'webservices/ws_servertime.php', success : function (data) { jQuery('#clock').html(data); } }); } function createObject() { var request_type; var browser = navigator.appName; if(browser == 'Microsoft Internet Explorer'){ request_type = new ActiveXObject('Microsoft.XMLHTTP'); } else { request_type = new XMLHttpRequest(); } return request_type; } var http = createObject(); var nocache = 0; function login(dist) { document.getElementById('login_response').innerHTML = ""; document.getElementById('login_response').style.visibility='visible'; document.getElementById('login_response').style.display='block'; var user = encodeURI(document.getElementById('userLogin').value); var pass = encodeURI(document.getElementById('passLogin').value); var dist = dist; nocache = Math.random(); http.open('get', 'webservices/ws_login.php?user='+user+'&pass='+pass+'&dist='+dist+'&nocache='+nocache); http.onreadystatechange = loginReply; http.send(null); } function loginReply() { if(http.readyState === 4){ var response = http.responseText; var conf = { frequency: 5000, spread: 5, duration: 500 }; if(response === 0 || response == 0 ){ // login falhou document.getElementById('login_response').innerHTML = "Utilizador ou Senha não válidos!"; } else { // login com sucesso var sURL = '?session=entrar'; window.location.replace( sURL ); } } } // Altera a firma corrente function alterafirma(firma){ $('#page_effect').show(); nocache = Math.random(); http.open('get', 'webservices/ws_login.php?firma='+firma+'&nocache = '+nocache); http.onreadystatechange = alterafirmaReply; http.send(null); } function alterafirmaReply(){ if(http.readyState === 4){ var response = http.responseText; if(response === 0){ alerta('Não tem permissões'); var sURL = "?"; window.location.replace( sURL ); } else { // sucesso var sURL = '?session=entrar'; window.location.replace( sURL ); } } } // Chamar ajaxLoader dependente de string inserida em formulário function enviarVarsForm(id,url,loadto) { var strget = encodeURI(document.getElementById('strget').value); var loadto = encodeURI(document.getElementById('loadto').value); var url = encodeURI(document.getElementById('url').value); ajaxLoader(url+strget,loadto); } function janelaOculta(button,tohide,width,height,buttons) { $('#'+tohide).dialog({ autoOpen: false, width: width, height: height, buttons: buttons, modal: true, overlay: {opacity: 0.95,background:'black'} }); $('#'+button).mouseover(function(){ $('#'+button).css('cursor','pointer'); }); $('#'+button).click(function(){ $('#'+tohide).dialog('open'); return false; }); }; function encerrarSessao(){ jQuery('#divalerta').html("

Tem a certeza que pretende encerrar a sua sessão?

"); jQuery('#divalerta').dialog({ autoOpen: false, width: 200, height: 180, modal: true, buttons: { 'Sair': function() { var sURL = '?session=sair'; window.location.replace( sURL ); }, 'Cancelar': function() { $(this).dialog('close'); } }, overlay: {opacity: 0.95,background: 'black'} }); jQuery('#divalerta').dialog( 'option', 'dialogClass', 'alert' ); jQuery('#divalerta').dialog('open'); } function alerta(texto,width,height){ if(!width){ width=300; height=300; } $('#divalerta').html(texto); $('#divalerta').dialog({ autoOpen: false, width: width, height: height, modal: true, buttons: { 'Ok': function() { $(this).dialog('close'); } }, overlay: {opacity: 0.95,background: 'black'} }); $('#divalerta').dialog('open'); } function post(URL, PARAMS) { var temp=document.createElement('form'); temp.action=URL; temp.method='POST'; temp.style.display='none'; for(var x in PARAMS) { var opt=document.createElement('textarea'); opt.name=x; opt.value=PARAMS[x]; temp.appendChild(opt); } document.body.appendChild(temp); temp.submit(); return temp; } function print_r(arr){ alerta('
'+dump(arr)+'
'); }