Changeset 2618 for trunk/phpgwapi


Ignore:
Timestamp:
04/22/10 16:37:22 (14 years ago)
Author:
amuller
Message:

Ticket #911 - Usando xconnector e transformando lang para API

Location:
trunk/phpgwapi/js/expressoAjax
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/js/expressoAjax/dom.js

    r2617 r2618  
    4646} 
    4747 
    48  
    49 /* Make decimal round, using in size message 
    50 function round(value, decimal){ 
    51         var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal ); 
    52         return( return_value ); 
    53 }*/ 
    54  
    5548function removeAll(id){ 
    5649        do 
     
    9689   } 
    9790   while (retValue.indexOf("  ") != -1) { 
    98           retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);  
     91          retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
    9992   } 
    10093   return retValue; 
     
    165158        } 
    166159} 
     160 
     161// Translate words and phrases using user language from eGroupware. 
     162function get_lang(_key) { 
     163        try 
     164        { 
     165                var key = _key.toLowerCase(); 
     166                if(array_lang[key]) 
     167                        var _value = array_lang[key]; 
     168                else 
     169                        var _value = _key+"*"; 
     170 
     171                if(arguments.length > 1) 
     172                        for(j = 1; typeof(arguments[j]) != 'undefined'; j++) 
     173                                _value = _value.replace("%"+j,arguments[j]); 
     174                return _value; 
     175        } 
     176        catch ( e ) 
     177        { 
     178                return _key+"*"; 
     179        } 
     180} 
     181 
    167182 
    168183function showBar(){ 
     
    175190        but.style.top = "55px"; 
    176191        but.style.left = "2px"; 
    177         title = "{hide_bar_txt}"; 
     192        title = get_lang('hide_bar_txt'); 
    178193        extra = document.getElementById("extraButton"); 
    179194        extra.style.visibility = "hidden"; 
     
    191206        but = document.getElementById("hiddenButton"); 
    192207        but.style.visibility = "hidden"; 
    193         title = "{show_bar_txt}"; 
     208        title = get_lang('show_bar_txt'); 
    194209        extra = document.getElementById("extraButton"); 
    195         extra.style.visibility = "" 
    196                 extra.style.top = "-11px"; 
     210        extra.style.visibility = ""; 
     211        extra.style.top = "-11px"; 
    197212        extra.style.left = "-10px"; 
    198213        var neverExpires = new Date("January 01, 2100 00:00:00"); 
  • trunk/phpgwapi/js/expressoAjax/expressoAjax.js

    r2537 r2618  
    288288        }; 
    289289 
    290         //Create XMLHTTP object Method 
    291         cConnector.prototype.createXMLHTTP = function () 
    292         { 
    293                 try 
    294                 { 
    295                         this.oxmlhttp = new XMLHttpRequest(); 
    296                         this.oxmlhttp.overrideMimeType('text/xml'); 
    297                 } 
    298                 catch (e) 
    299                 { 
    300                         try 
    301                         { 
    302                                 this.oxmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); 
    303                         } 
    304                         catch (e1) 
    305                         { 
    306                                 try 
    307                                 { 
    308                                         this.oxmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); 
    309                                 } 
    310                                 catch (e2) 
    311                                 { 
    312                                         this.oxmlhttp = null; 
    313                                 }; 
    314                         }; 
    315                 }; 
    316  
    317         }; 
    318  
    319290        // Request Constructor Connector 
    320291        cConnector.prototype.newRequest = function (id, target, method, handler, data) 
    321292        { 
    322                 this.tid = id; 
    323                 if (this.requests[id]) { 
    324                         return false; 
    325                 } 
    326  
    327                 this.createXMLHTTP(); 
    328                 var oxmlhttp = this.oxmlhttp; 
    329                 var _thisObject = this; 
    330  
    331                 if (! oxmlhttp) 
    332                         return false; 
    333  
    334                 this.requests[id] = oxmlhttp; 
    335                 this.buildBar(); 
    336                 this.showProgressBar(); 
    337  
    338                 var sub_handler = function () 
    339                 { 
    340                         try 
     293                _connector.go( { 
     294                        "access" : target, 
     295                        "handler" : function( data ) 
    341296                        { 
    342                                 if (oxmlhttp.readyState == 4 ) 
    343                                 { 
    344  
    345                                         switch (oxmlhttp.status) 
    346                                         { 
    347  
    348                                                 case 200: 
    349                                                         if (typeof(handler) == 'function') 
    350                                                         { 
    351                                                                 _thisObject.hideProgressBar(); 
    352                                                                 var data = _thisObject.unserialize(oxmlhttp.responseText); 
    353                                                                 if ( typeof data == 'undefined' ) 
    354                                                                         data = oxmlhttp.responseText; 
    355                                                                 // Verify user session 
    356                                                                 if(!_thisObject.verify_session(data)){ 
    357                                                                         delete _thisObject.requests[id]; 
    358                                                                         _thisObject.requests[id] = null; 
    359                                                                         return false; 
    360                                                                 } 
    361                                                                 if(debug_controller) { 
    362                                                                         document.getElementById("debug_controller").innerHTML += oxmlhttp.responseText; 
    363                                                                         document.getElementById("debug_controller").innerHTML += "<br>-------------------------------------------------------------------------------------<br>"; 
    364                                                                 } 
    365                                                                 handler(data); 
    366                                                                 _thisObject.addToCache(data?id+"&"+data:id,data); 
    367                                                                 delete _thisObject.requests[id]; 
    368                                                                 _thisObject.requests[id] = null; 
    369                                                         } 
    370  
    371                                                         break; 
    372  
    373                                                 case 404: 
    374  
    375                                                         alert(get_lang('Page Not Found!')); 
    376                                                         break; 
    377  
    378                                                 default: 
    379                                         }; 
    380                                 } 
     297                                handler( expresso.connector.unserialize( data ) ); 
    381298                        } 
    382                         catch (e) 
    383                         { 
    384                                 _thisObject.hideProgressBar(); 
    385                                 if(debug_controller) 
    386                                         alert(e+"\n"+oxmlhttp.responseText); 
    387                                 // View Exception in Javascript Console 
    388                                 throw(e); 
    389                         }; 
    390  
    391                 }; 
    392  
    393                 try 
    394                 { 
    395  
    396                         if (method == '' || method == 'GET') 
    397                         { 
    398                                 oxmlhttp.open("GET",target,true); 
    399                                 if (typeof(handler) == 'function') 
    400                                 { 
    401                                         oxmlhttp.onreadystatechange =  sub_handler; 
    402                                         oxmlhttp.send(null); 
    403                                 } 
    404  
    405                         } 
    406                         else if (method == 'POST') 
    407                         { 
    408                                 oxmlhttp.open("POST",target, true); 
    409                                 oxmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
    410                                 if (typeof(handler) == 'function') 
    411                                 { 
    412                                         oxmlhttp.onreadystatechange = sub_handler; 
    413                                         oxmlhttp.send(data); 
    414                                 } 
    415  
    416                         } 
    417                 } 
    418                 catch(e) 
    419                 { 
    420                         _thisObject.hideProgressBar(); 
    421                         if(debug_controller) 
    422                                 alert(e); 
    423                         // View Exception in Javascript Console 
    424                         throw(e); 
    425                 }; 
    426  
    427                 return true; 
     299                } ); 
    428300        }; 
    429301        // Cancel Request Connector 
    430302        cConnector.prototype.cancelRequest = function (){ 
    431                 if (!this.requests[this.tid]){ 
    432                         return false; 
    433                 } 
    434                 this.oxmlhttp.onreadystatechange = null; 
    435                 this.requests[this.tid].abort(); 
    436                 this.hideProgressBar(); 
     303                return false; 
    437304        }; 
    438305//------------------------------------  END: Functions for Connector HTTPRequest  -------------------------------------------------// 
     
    486353//------------------------------------  END: Functions for Progress Bar  -------------------------------------------------// 
    487354        // Default Controller File 
    488         var URL_DEFAULT = URL_SERVER+'/controller.php?action='; 
     355        var URL_DEFAULT = URL_SERVER + "/controller.php?menuaction="; 
    489356        // connector object 
    490357        var _onmouseup = document.onmouseup; 
     
    561428                        return; 
    562429                } 
    563                 url = URL_DEFAULT + url; 
     430                //url = URL_DEFAULT + url; 
    564431 
    565432                if (expresso.connector.queryConnectorCache(params?url+"&"+params:url,handler)) 
     
    623490                }; 
    624491                divUpload.innerHTML= "<iframe onload=\"cExecute('expressoMail1_2.functions.getReturnExecuteForm',"+form_handler+");\"  style='display:"+(debug_controller ? "" : "none")+";width:"+(debug_controller ? 400 : 0)+";height:"+(debug_controller ? 400 : 0)+";' name='uploadFile'></iframe>"; 
    625                 form.action = URL_SERVER + "/controller.php"; 
     492                form.action = URL_DEFAULT + url; 
    626493                form.target ="uploadFile"; 
    627494                form.submit(); 
Note: See TracChangeset for help on using the changeset viewer.