Ignore:
Timestamp:
06/20/08 15:16:25 (16 years ago)
Author:
niltonneto
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/js/preferences.js

    r318 r323  
    77        var     _window         = new Windows(_xtools, _im_content); 
    88        var _cookies    = new IMCookies; 
    9         var idTimeout   = ""; 
    109        var Timeout             = ""; 
    1110 
     
    3736                _win_preferences.bx.style.display = 'none'; 
    3837                _win_preferences.wc.style.padding = '5px'; 
    39                  
     38 
    4039                var _params = { 
    4140                        'lang1':imGetLang('Options'), 
     
    7675                var preferences = arguments[0].split(';'); 
    7776                        preferences.pop(); 
    78                  
     77 
    7978                for(var i in preferences) 
    8079                { 
     
    9493                        else 
    9594                        { 
    96                                 Timeout = ( parseInt(value) > 0 ) ? value : "1";  
     95                                Timeout = ( parseInt(value) > 0 ) ? value : "1"; 
    9796                                if( top.document.getElementById(field) ) 
    9897                                        top.document.getElementById(field).value = Timeout; 
     
    104103        { 
    105104                var preferences = ""; 
    106                  
     105 
    107106                if((preferences = _cookies.get('preferences_im'))) 
    108107                        _preferences(preferences); 
     
    114113        { 
    115114                _win_preferences = _window.get('preferences_window'); 
    116          
     115 
    117116                var preferences = ""; 
    118117                var numbers = /^\d+$/; 
    119                  
     118 
    120119                // Offline 
    121120        if (top.document.getElementById('ch_offline').checked) 
     
    129128                        _cookies.set('IM_unavailable', 'hidden'); 
    130129                } 
    131          
     130 
    132131                // TimeOut 
    133132                if(numbers.test(top.document.getElementById('time_xa_im').value) && top.document.getElementById('time_xa_im').value != "0") 
     
    141140                        Timeout = 1; 
    142141                } 
    143         
     142 
    144143                // New Message 
    145144                if(top.document.getElementById('rd_nm').checked) 
     
    150149                else 
    151150                        preferences += 'rd_nm:false;'; 
    152          
     151 
    153152                if(top.document.getElementById('rd_ch').checked) 
    154153                { 
     
    175174        } 
    176175 
    177         function _setPresence() 
    178         { 
    179                 var _presence = false; 
    180                 var _pPresence; 
    181                 if ( arguments.length == 0 ) 
    182                 { 
    183                         if ( !(_pPresence = _cookies.get('IM_presence')) ) 
    184                                 _pPresence = 'available'; 
    185                 } 
    186                 else 
    187                         _pPresence = arguments[0]; 
    188  
    189                 _cookies.set('IM_presence', _pPresence); 
    190  
    191                 switch ( _pPresence ) 
    192                 { 
    193                         case 'away': 
    194                         case 'dnd': 
    195                         case 'xa': 
    196                                 _presence = 'show=' + _pPresence; 
    197                         break; 
    198                         case 'available': 
    199                         case 'unavailable': 
    200                                 _presence = 'type=' + _pPresence; 
    201                         break; 
    202                 } 
    203  
    204                 if ( _presence ) 
    205                 { 
    206                         var _img_status = eval('im_' + _pPresence + '.src'); 
    207  
    208                         var _status = top.document.getElementById('im_status'); 
    209                         if ( _status ) 
    210                                 _status.style.backgroundImage = 'url(' + _img_status + ')'; 
    211  
    212                         var _win_contacts = _window.get('contact_list'); 
    213                         if ( _win_contacts ) 
    214                                 _win_contacts.icon(_img_status); 
    215  
    216                         _conn.go('$this.Ujabber.setPresence', _presence); 
    217                 } 
    218         } 
    219  
     176        var _changed = false; 
     177        var _id_timeout = ""; 
    220178        function _setTimeOut() 
    221179        { 
    222                 _setPresence('xa'); 
    223                 idTimeout = setTimeout('top.window.im_preferences.timeOut();', parseInt(Timeout) * 60000); 
     180                _changed = true; 
     181                InstantMessengerPresence('auto'); 
    224182        } 
    225183 
    226184        function _timeOut() 
    227185        { 
    228                 if(idTimeout) 
    229                 { 
    230                         clearTimeout(idTimeout); 
    231                         var _status = ''; 
    232                  
    233                         if((_status = _cookies.get('IM_presence')) === 'xa') 
    234                                 _setPresence('available'); 
    235                 } 
    236                  
    237                 idTimeout = setTimeout('top.window.im_preferences._setTimeOut("xa");', parseInt(Timeout) * 60000); 
     186                if ( _id_timeout ) 
     187                        clearTimeout(_id_timeout); 
     188 
     189                if ( _changed ) 
     190                { 
     191                        _changed = false; 
     192                        InstantMessengerPresence(); 
     193                } 
     194 
     195                _id_timeout = setTimeout(_setTimeOut, parseInt(Timeout) * 60000); 
    238196        } 
    239197 
     
    243201                _timeOut(); 
    244202        } 
    245          
     203 
    246204        Preferences.prototype._setTimeOut        = _setTimeOut; 
    247205        Preferences.prototype.timeOut            = _timeOut; 
     
    249207        Preferences.prototype.getfocus           = focus_select; 
    250208        top.window.im_preferences                        = new Preferences; 
    251         top.window.document.onmousemove          = _timeOut; 
     209        _config(top.window.document, 'onmousemove', _timeOut); 
    252210 
    253211})(); 
Note: See TracChangeset for help on using the changeset viewer.