(function(){ // Conector, Xtools , Janelas var _conn = new IMConnector(path_im); var _xtools = new XTools(path_im); var _im_content = top.document.getElementById('instant_messenger_content'); var _window = new Windows(_xtools, _im_content); var _cookies = new IMCookies; var Timeout = ""; function _config(pObj, pEvent, pHandler) { if ( typeof pObj == 'object' ) { if ( pEvent.substring(0, 2) == 'on' ) pEvent = pEvent.substring(2, pEvent.length); if ( pObj.addEventListener ) pObj.addEventListener(pEvent, pHandler, false); else if ( pObj.attachEvent ) pObj.attachEvent('on' + pEvent, pHandler); } } function _load_window() { var _win_preferences = ""; _win_preferences = _window.load('preferences_window'); _win_preferences.title('.:: Expresso Messenger - ' + imGetLang('Preferences') + ' ::.'); _win_preferences.size(400, 350); _win_preferences.position(150, 70, false); _win_preferences.icon(im_console_prefs.src); _win_preferences.bz.style.display = 'none'; _win_preferences.bx.style.display = 'none'; _win_preferences.wc.style.padding = '5px'; var _params = { 'lang1':imGetLang('Options'), 'lang2':imGetLang('Show users offline'), 'lang3':imGetLang('Away'), 'lang4':imGetLang('Ficar ausente depois de'), 'lang5':imGetLang('Minutes'), 'lang6':imGetLang('Ativar aviso de mensagem recebida'), 'lang7':imGetLang('Normal'), 'lang8':imGetLang('Treme Tela'), 'lang9':imGetLang('Save'), 'lang10':imGetLang('Close') }; _win_preferences.content(_xtools.parse(_xtools.xml('settings'), 'mysettings.xsl', _params)); _config(_win_preferences.wc.childNodes[2], 'onclick', setPreferences); _config(_win_preferences.wc.childNodes[3], 'onclick', function() { _win_preferences.button(_win_preferences.bc); } ); // Carrega as preferências; getPreferences(); } function focus_select() { arguments[0].focus(); arguments[0].select(); } function _preferences() { _cookies.set('preferences_im', arguments[0]); var preferences = arguments[0].split(';'); preferences.pop(); for(var i in preferences) { var field = preferences[i].substring(0,preferences[i].indexOf(':')); var value = preferences[i].substring(preferences[i].indexOf(':') + 1, preferences[i].length); if( value === 'true' || value === 'false') { if(top.document.getElementById(field)) top.document.getElementById(field).checked = eval(value); else if( field === 'ch_offline') if(eval(value)) _cookies.set('IM_unavailable', 'show'); else _cookies.set('IM_unavailable', 'hidden'); } else { Timeout = ( parseInt(value) > 0 ) ? value : "1"; if( top.document.getElementById(field) ) top.document.getElementById(field).value = Timeout; } } } function getPreferences() { var preferences = ""; if((preferences = _cookies.get('preferences_im'))) _preferences(preferences); else _conn.go('$this.db_im.get_preferences', _preferences); } function setPreferences() { _win_preferences = _window.get('preferences_window'); var preferences = ""; var numbers = /^\d+$/; // Offline if (top.document.getElementById('ch_offline').checked) { preferences = 'ch_offline:true;'; _cookies.set('IM_unavailable', 'show'); } else { preferences = 'ch_offline:false;'; _cookies.set('IM_unavailable', 'hidden'); } // TimeOut if(numbers.test(top.document.getElementById('time_xa_im').value) && top.document.getElementById('time_xa_im').value != "0") { preferences += "time_xa_im:" + top.document.getElementById('time_xa_im').value + ";"; Timeout = top.document.getElementById('time_xa_im').value; } else { preferences += "time_xa_im:1;"; Timeout = 1; } // New Message /* if(top.document.getElementById('rd_nm').checked) { preferences += 'rd_nm:true;'; _cookies.set('IM_screen','nm'); } else preferences += 'rd_nm:false;'; if(top.document.getElementById('rd_ch').checked) { preferences += 'rd_ch:true;'; _cookies.set('IM_screen','rd'); } else preferences += 'rd_ch:false;'; */ // Write Cookie _cookies.set('preferences_im', preferences ); _conn.go('$this.db_im.set_preferences', function(dataString) { if( !eval(dataString)) alert('Erro : Preferências não foram salvas !'); }, 'preferences='+preferences ); if ( _win_preferences ) _win_preferences.button(_win_preferences.bc); } var _changed = false; var _id_timeout = ""; function _setTimeOut() { _changed = true; InstantMessengerPresence('auto'); } function _timeOut() { if ( _id_timeout ) clearTimeout(_id_timeout); if ( _changed ) { _changed = false; InstantMessengerPresence(); } _id_timeout = setTimeout(_setTimeOut, parseInt(Timeout) * 60000); } function _show_hidden_group() { if ( !(arguments[0]) ) return false; var show = 'block'; if ( !(arguments[0].checked) ) show = 'none'; var el = top.document.getElementById('im_contact_list'); if ( el && (el = el.firstChild) ) while ( el ) { // it is a contact if ( (el.nodeName.toLowerCase() == 'div') && el.getAttribute('jid') ) if ( el.style.backgroundImage.indexOf('unavailable') > -1 ) el.style.display = show; el = el.nextSibling; } } function Preferences() { getPreferences(); //_timeOut(); } Preferences.prototype._setTimeOut = _setTimeOut; Preferences.prototype.timeOut = _timeOut; Preferences.prototype.load = _load_window; Preferences.prototype.getfocus = focus_select; Preferences.prototype.showHiddenGroup = _show_hidden_group; top.window.im_preferences = new Preferences; //_config(top.window.document, 'onmousemove', _timeOut); })();