http://www.ikbc.in/my-profile $.each(timestamps, function(key, time){ str += '

'+key+":"+time+'

'; }); log(str); data = { action: 'get', lastMessageTimestamps: timestamps }; ajaxim_bindInProcess = true; $.ajax({ url: bindUrl, type: 'POST', data: data, success: function(data){ if (typeof data.presenceList != 'undefined' && data.presenceList.length > 0) { $.each(data.presenceList, function(){ if ( this.type == 'offline' ) { contactManager.deleteRoster( this.node ); } if ( this.type == 'online' ) { contactManager.add( this ); } } ); } if (data.messageListLength > 0) { $.each(data.messageList, function(){ handleMessage( this ); } ); } ajaxim_bindInProcess = false; }, error: function(){ log('bind error occured'); ajaxim_bindInProcess = false; }, complete: function() { ajaxim_bindInProcess = false; }, dataType: 'json' }); } } function handleMessage(new_message) { if( typeof new_message.message != 'undefined' ){ var box; // Message to my other resources if( new_message.from == my.node ){ if ( new_message.timestamp == contactManager.contacts[new_message.to].last_message_timestamp ) { return; } box = talkBoxManager.get(new_message.to); if ( !box.isOpened ) { box.showTab(1); OW.bind(new_message.to+'_tabOpened', function(){ OW.bind(new_message.to+'_isLogLoaded', function(){ log(new_message.to+'_isLogLoaded', 1); box.show(); box.writeTimeDelimiter(); //new_message.message += '_isLogLoaded'; box.write(new_message); OW.unbind(new_message.to+'_isLogLoaded'); }); OW.unbind(new_message.to+'_tabOpened'); }); } else { if (!box.isActive) { log('!box.isActive', 1); box.show(); } box.writeTimeDelimiter(); //new_message.message += 'box.isActive'; box.write(new_message); } } else{ // Message to other contact if ( new_message.timestamp == contactManager.contacts[new_message.from].last_message_timestamp ) { return; } box = talkBoxManager.get(new_message.from); if( !box.isOpened ) { box.showTab(1); OW.bind(new_message.from+'_tabOpened', function(){ OW.bind(new_message.from+'_isLogLoaded', function(){ log(new_message.from+'_isLogLoaded', 1); box.write(new_message).setOnline().notifyOnNewMessage() OW.unbind(new_message.from+'_isLogLoaded'); }); OW.unbind(new_message.from+'_tabOpened'); }); } else { box.writeTimeDelimiter(); box.write(new_message); if (!box.isActive) { log('!box.isActive', 1); box.notifyOnNewMessage(); } } } } } /* DEBUG MODE */ //log = function(message){}; function log(message, append){ /* if (append) { $("#server_msg_container2").append('

'+message+'

'); } else { $("#server_msg_container").html('

'+message+'

'); } */ } http://www.ikbc.in/admin $(function(){ var im_console = document.getElementById('im_console'); var main_im_tab = document.getElementById('main_im_tab'); if ( typeof im_console == 'undefined' || im_console == null || typeof main_im_tab == 'undefined' || main_im_tab == null ) return; $('#main_im_tab').parent().attr('id', 'main_im_tab_container'); // main_im_tab.parentNode.setAttribute('id', 'main_im_tab_container'); main_im_tab.parentNode.appendChild(im_console.parentNode.removeChild(im_console)); ajaxim_bindInProcess = false; ajaxim_onlineNowClickInProcess = [];