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

Ticket #911 - Aproveitamento de funções comuns do expressoMail

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/jscode/common_functions.js

    r2579 r2616  
    2020 
    2121window.onresize = resizeWindow; 
    22  
    23 function config_events(pObj, pEvent, pHandler) 
    24 { 
    25     if( typeof pObj == 'object') 
    26     { 
    27         if( pEvent.substring(0, 2) == 'on') 
    28             pEvent = pEvent.substring(2, pEvent.length); 
    29  
    30         if ( pObj.addEventListener ) 
    31             pObj.addEventListener(pEvent, pHandler, false); 
    32         else if( pObj.attachEvent ) 
    33             pObj.attachEvent('on' + pEvent, pHandler ); 
    34     } 
    35 } 
    3622 
    3723function resizeWindow(){ 
     
    10995                return _key+"*"; 
    11096        } 
    111 } 
    112  
    113 // Make decimal round, using in size message 
    114 function round(value, decimal){ 
    115         var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal ); 
    116         return( return_value ); 
    11797} 
    11898 
     
    156136} 
    157137 
    158 function removeAll(id){ 
    159         do 
    160         { 
    161                 if (typeof(Element(id)) == 'undefined') 
    162                         break; 
    163                 Element(id).parentNode.removeChild(Element(id)); 
    164         } 
    165         while(Element(id)); 
    166 } 
    167138 
    168139function get_current_folder(){ 
     
    437408} 
    438409 
    439 function validateEmail(email){ 
    440         if (typeof(email) != 'string') 
    441                 return false; 
    442         var validName = /^[a-z][a-z-_0-9\.]*/i; 
    443         emailParts = email.split('@'); 
    444         return (validName.test(emailParts[0]) && validateDomain(emailParts[1])); 
    445 } 
    446 function validateDomain(domain){ 
    447         var domainReg = /^(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/i; 
    448         return (domainReg.test(domain)); 
    449 } 
    450  
    451 function validateUrl(url){ 
    452         var urlReg = /([A-Za-z]{2,7}:\/\/)(.*)/i; 
    453         urlParts = url.split(urlReg); 
    454         return (urlParts[1].length > 4 &&  validateDomain(urlParts[2])); 
    455 } 
    456410function emQuickSearch(emailList, field, ID){ 
    457411        var quickSearchKeyBegin; 
     
    561515} 
    562516 
    563 function url_encode(str){ 
    564     var hex_chars = "0123456789ABCDEF";  
    565     var noEncode = /^([a-zA-Z0-9\_\-\.])$/;  
    566     var n, strCode, hex1, hex2, strEncode = "";  
    567  
    568     for(n = 0; n < str.length; n++) {  
    569         if (noEncode.test(str.charAt(n))) {  
    570             strEncode += str.charAt(n);  
    571         } else {  
    572             strCode = str.charCodeAt(n);  
    573             hex1 = hex_chars.charAt(Math.floor(strCode / 16));  
    574             hex2 = hex_chars.charAt(strCode % 16);  
    575             strEncode += "%" + (hex1 + hex2);  
    576         }  
    577     }  
    578     return strEncode;  
    579  
    580  
    581 function url_decode(str) {  
    582  
    583         var n, strCode, strDecode = "";  
    584         for (n = 0; n < str.length; n++) {  
    585             if (str.charAt(n) == "%") {  
    586                 strCode = str.charAt(n + 1) + str.charAt(n + 2);  
    587                 strDecode += String.fromCharCode(parseInt(strCode, 16));  
    588                 n += 2;  
    589             } else {  
    590                 strDecode += str.charAt(n);  
    591             }  
    592         }  
    593         return strDecode;  
    594  
    595  
    596517function Element (el) { 
    597518        return  document.getElementById(el); 
     
    626547                return rb; 
    627548        } 
    628 } 
    629  
    630 function borkb(size){ 
    631         kbyte = 1024; 
    632         mbyte = kbyte*1024; 
    633         gbyte = mbyte*1024; 
    634         if (!size) 
    635                 size = 0; 
    636         if (size < kbyte) 
    637                 return size + 'B'; 
    638         else if (size < mbyte) 
    639                 return parseInt(size/kbyte) + 'KB'; 
    640         else if (size < gbyte) 
    641                 if (size/mbyte > 100) 
    642                         return (size/mbyte).toFixed(0) + 'MB'; 
    643                 else 
    644                         return (size/mbyte).toFixed(1) + 'MB'; 
    645         else 
    646                 return parseInt(size/gbyte).toFixed(1) + 'GB'; 
    647 } 
    648  
    649 function trim(inputString) { 
    650    if (typeof inputString != "string")  
    651         return inputString; 
    652        
    653    var retValue = inputString; 
    654    var ch = retValue.substring(0, 1); 
    655    while (ch == " ") {  
    656           retValue = retValue.substring(1, retValue.length); 
    657           ch = retValue.substring(0, 1); 
    658    } 
    659    ch = retValue.substring(retValue.length-1, retValue.length); 
    660    while (ch == " ") {  
    661           retValue = retValue.substring(0, retValue.length-1); 
    662           ch = retValue.substring(retValue.length-1, retValue.length); 
    663    } 
    664    while (retValue.indexOf("  ") != -1) {  
    665           retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);  
    666    } 
    667    return retValue;  
    668 } 
     549}; 
    669550 
    670551function increment_folder_unseen(){ 
     
    772653} 
    773654 
    774 function LTrim(value){ 
    775         var w_space = String.fromCharCode(32); 
    776         var strTemp = ""; 
    777         var iTemp = 0; 
    778  
    779         var v_length = value ? value.length : 0; 
    780         if(v_length < 1) 
    781                 return ""; 
    782  
    783         while(iTemp < v_length){ 
    784                 if(value && value.charAt(iTemp) != w_space){ 
    785                         strTemp = value.substring(iTemp,v_length); 
    786                         break; 
    787                 } 
    788                 iTemp++; 
    789         } 
    790         return strTemp; 
    791 } 
    792  
    793655//changes MENU background color. 
    794656function set_menu_bg(menu) 
     
    824686} 
    825687 
    826 function add_className(obj, className){ 
    827         if (obj && !exist_className(obj, className)) 
    828                 obj.className = obj.className + ' ' + className; 
    829 } 
    830  
    831 function remove_className(obj, className){ 
    832         var re = new RegExp("\\s*"+className); 
    833         if (obj) 
    834                 obj.className = obj.className.replace(re, ' '); 
    835 } 
    836  
    837 function exist_className(obj, className){ 
    838         return ( obj && obj.className.indexOf(className) != -1 ); 
    839 } 
    840  
    841688function select_all_messages(select) 
    842689{ 
     
    861708                } 
    862709        } 
    863 } 
    864  
    865 function validate_date(date){ 
    866     if (date.match(/^[0-3][0-9]\/[0-1][0-9]\/\d{4,4}$/)) 
    867     { 
    868         tmp = date.split('/'); 
    869  
    870         day = new Number(tmp[0]); 
    871         month = new Number(tmp[1]); 
    872         year = new Number(tmp[2]); 
    873         if (month >= 1 && month <= 12 && day >= 1 && day <= 31) 
    874         { 
    875             if (month == 02 && day <= 29) 
    876             { 
    877                 return true; 
    878             } 
    879             return true; 
    880         } 
    881         else 
    882             { 
    883                 return false; 
    884             } 
    885     } 
    886     else 
    887         { 
    888             return false; 
    889         } 
    890710}; 
Note: See TracChangeset for help on using the changeset viewer.