Changeset 164 for trunk/instant_messenger/js
- Timestamp:
- 02/01/08 10:48:43 (17 years ago)
- Location:
- trunk/instant_messenger/js
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/js/client.js
r151 r164 1 1 var con = new Connector; 2 var disconnected = false; 3 2 4 function client() 3 5 { … … 5 7 var buffer = ''; 6 8 var xtools = new XTools; 7 var disconnected = false; 9 8 10 function request(data) 9 11 { … … 27 29 im_window.elementC('_contacts_im_').innerHTML = xtools.parse(XmlDoc,'disconnected.xsl'); 28 30 func.byId('img_status_im').src = im_unavailable.src; 31 im.status = 'type=unavailable'; 32 im.statusFlag = 'unavailable'; 33 34 //im_window.visible('_contacts_im_','block'); 29 35 } 30 36 else if ( data.lastIndexOf('>') == data.length - 1) … … 53 59 54 60 var node = xmlDoc.documentElement.firstChild; 61 55 62 while ( node ) 63 { 56 64 with ( node ) 57 65 { 58 66 jabber.doIt(nodeName, node); 59 node = nextSibling;67 //node = nextSibling; 60 68 } 69 node = node.nextSibling; 70 } 61 71 } 62 72 else -
trunk/instant_messenger/js/images.js
r151 r164 24 24 im_photo.src = path_im + 'templates/default/images/photo.png'; 25 25 26 var im_photo_1 = new Image(); 27 im_photo_1.src = path_im + 'templates/default/images/photo_1.png'; 28 26 29 var im_group_open = new Image(); 27 30 im_group_open.src = path_im + 'templates/default/images/group_open.gif'; -
trunk/instant_messenger/js/jabber.js
r157 r164 44 44 { 45 45 var XmlDoc = "<layer>" + 46 "<lang1>" + im.get_lang("Nickname") + "</lang1>" +46 "<lang1>" + im.get_lang("Nickname") + "</lang1>" + 47 47 "<lang2>" + im.get_lang("Add Contact") + "</lang2>" + 48 48 "<lang3>" + im.get_lang("Preferences") + "</lang3>" + 49 "<nickname>" + im.get_lang("Username") + "</nickname>" +50 "<path>" +path_im+"</path>" +49 "<nickname>" + im.get_lang("Username") + "</nickname>" + 50 "<path>" + path_im + "</path>" + 51 51 "</layer>"; 52 52 53 im_window.load('_contacts_im_','instant_messenger_content','<title>.::Expresso Messenger::.</title>','window.xsl','',true,true,false); 53 54 im_window.elementC('_contacts_im_').innerHTML = _this.xtools.parse(XmlDoc,'layer.xsl'); 54 55 im_window.elementC('_contacts_im_').innerHTML += _this.xtools.parse(pContacts, 'contacts.xsl'); 55 56 56 57 var element = func.byId('im_contact_list').firstChild; 57 58 … … 67 68 } 68 69 69 if( im.nickname == null)70 { 71 im.request_vcard('this', 'layer');70 if(func.byId('im_avatar').src === im_photo.src) 71 { 72 im.request_vcard('this',false); 72 73 im.ldap_photo('im_avatar'); 73 74 } 74 else75 func.byId('im_layer_nickname').innerHTML = im.nickname;76 75 } 77 76 … … 81 80 { 82 81 case 'contacts' : readContacts(pIq); break; 83 case 'vCard' : readVcard(pIq); break; 82 case 'vCard' : 83 case 'vCard_user' : 84 readVcard(pIq); 85 break; 84 86 } 85 87 } … … 93 95 from = from.substr(0,from.indexOf('/')); 94 96 97 if(func.byId('iframe_' + from) != null) 98 func.byId('iframe_' + from).parentNode.removeChild(func.byId('iframe_' + from)); 99 95 100 var win; 96 if ( !(win = im_window.elementC(from)) ) 97 { 98 im_window.load(from, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl', '310', true, true, true); 99 func.byId(from + '_avatar').src = path_im + "/templates/default/images/photo.png"; 100 101 102 function include_iframe() 103 { 101 104 win = im_window.elementC(from); 102 105 103 106 var iframe = document.createElement('iframe'); 104 107 iframe.id = 'iframe_' + from; … … 108 111 iframe.style.margin = '0'; 109 112 iframe.style.padding = '0' 110 113 111 114 var _messages_ = win.firstChild.firstChild.nextSibling.nextSibling; 112 115 _messages_.appendChild(iframe); 113 116 114 117 iframe.contentWindow.document.write('<html><body id="' + from + '" style="margin:0px;padding:0px"></body></html>'); 115 118 iframe.contentWindow.document.close(); 116 119 iframe.contentWindow.document.designMode = "On"; 117 120 iframe.contentWindow.focus(); 118 121 119 122 function keypress_handler(e) 120 123 { … … 163 166 obj.attachEvent('onkeyup', keyup_handler); 164 167 } 165 }else 168 } 169 170 if ( !(win = im_window.elementC(from)) ) 171 { 172 im_window.load(from, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl', '310', true, true, true); 173 //im_window.visible(from,'block'); 174 func.byId(from + '_avatar').src = path_im + "/templates/default/images/photo.png"; 175 include_iframe(); 176 } 177 else 178 { 166 179 im_window.load(from, '', '', '', '', true, true, true); 180 //im_window.visible(from,'block'); 181 include_iframe(); 182 } 167 183 168 184 if ( win ) 169 185 { 170 186 if(!(im.nickname_contacts[from])) 171 im.request_vcard(from, 'nickname');187 im.request_vcard(from, false); 172 188 173 189 win = win.firstChild.firstChild; … … 183 199 function readPresence(pPresence) 184 200 { 185 var jidFrom = pPresence.getAttribute('from'); 186 jidFrom = jidFrom.substr(0,jidFrom.indexOf('/')); 187 188 if(pPresence.getAttribute('type')) 189 { 190 switch(pPresence.getAttribute('type')) 191 { 192 case 'subscribe' : 193 if(!func.byId(pPresence.getAttribute('from'))) 201 //@TODO: presenca antes da lista ocasiona erros 202 //verificar e retirar o controle de erros abaixo 203 try 204 { 205 var jidFrom = pPresence.getAttribute('from'); 206 jidFrom = jidFrom.substr(0,jidFrom.indexOf('/')); 207 208 if(pPresence.getAttribute('type')) 209 { 210 switch(pPresence.getAttribute('type')) 211 { 212 case 'subscribe' : 213 if(func.byId(pPresence.getAttribute('from'))) 214 { 215 if(confirm('Autorizar o usuário ' + pPresence.getAttribute('from') + '?')) 216 im.subscription(pPresence.getAttribute('from'),'subscribed'); 217 else 218 im.subscription(pPresence.getAttribute('from'),'unsubscribe'); 219 } 220 else 221 { 222 if(!func.byId(pPresence.getAttribute('from'))) 223 { 224 if(confirm('O usuário ' + pPresence.getAttribute('from') + ' quer adicioná-lo ?')) 225 { 226 im.addrequest(pPresence.getAttribute('from')); 227 im.subscription(pPresence.getAttribute('from'),'subscribed'); 228 } 229 else 230 im.subscription(pPresence.getAttribute('from'),'unsubscribe'); 231 }else 232 im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 233 } 234 break; 235 case 'subscribed' : 236 im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 237 break; 238 case 'unsubscribed' : 239 //alert('O usuário ' + pPresence.getAttribute('from') + ' não quer mais papo !'); 240 break; 241 case 'unsubscribe' : 242 alert('O usuário ' + pPresence.getAttribute('from') + ' negou seu pedido !'); 243 break; 244 case 'unavailable' : 245 func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 246 func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:none;"); 247 break; 248 case 'available' : 249 func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 250 func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;"); 251 break; 252 } 253 } 254 else 255 { 256 var node = pPresence.firstChild; 257 while( node ) 258 { 259 if(node.hasChildNodes()) 260 { 261 switch(node.nodeName) 194 262 { 195 if(confirm('O usuario ' + pPresence.getAttribute('from') + ' quer adicioná-lo ?')) 196 im.addrequest(pPresence.getAttribute('from')); 197 else 198 im.subscription(pPresence.getAttribute('from'),'unsubscribe'); 199 }else 200 im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 201 break; 202 case 'subscribed' : 203 im.subscription(pPresence.getAttribute('from'),pPresence.getAttribute('type')); 204 break; 205 case 'unsubscribed' : 206 //alert('O usuário ' + pPresence.getAttribute('from') + ' não quer mais papo !'); 207 break; 208 case 'unsubscribe' : 209 alert('O usuário ' + pPresence.getAttribute('from') + ' negou seu pedido !'); 210 break; 211 case 'unavailable' : 212 func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 213 func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:none;"); 214 break; 215 case 'available' : 216 func.byId('img_' + jidFrom).src = eval('im_' + pPresence.getAttribute('type') + '.src'); 217 break; 218 } 219 } 220 else 221 { 222 var node = pPresence.firstChild; 223 while( node ) 224 { 225 if(node.hasChildNodes()) 226 { 227 switch(node.nodeName) 228 { 229 case "show" : 230 func.byId('img_' + jidFrom).src = eval('im_' + node.firstChild.nodeValue + '.src'); 231 func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;"); 232 func.byId('status_' + jidFrom).innerHTML = " "; 233 func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 234 break; 235 case "status" : 236 func.byId('status_' + jidFrom).innerHTML = ( node.firstChild.nodeValue ) ? node.firstChild.nodeValue : "" ; 237 func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:block;"); 238 break; 239 default : 240 func.byId('img_' + jidFrom).src = im_available.src; 241 func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;"); 242 func.byId('status_' + jidFrom).innerHTML = " "; 243 func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 244 break; 263 case "show" : 264 func.byId('img_' + jidFrom).src = eval('im_' + node.firstChild.nodeValue + '.src'); 265 func.confEl(func.byId(jidFrom),"style","margin-left:15px;cursor:pointer;display:block;"); 266 func.byId('status_' + jidFrom).innerHTML = " "; 267 func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 268 break; 269 case "status" : 270 func.byId('status_' + jidFrom).innerHTML = ( node.firstChild.nodeValue ) ? node.firstChild.nodeValue : "" ; 271 func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:block;"); 272 break; 273 default : 274 func.byId('img_' + jidFrom).src = im_available.src; 275 func.byId('status_' + jidFrom).innerHTML = " "; 276 func.confEl(func.byId('status_' + jidFrom), "style", "font-size:8pt; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; display:none;"); 277 break; 278 } 245 279 } 246 } 247 node = node.nextSibling; 248 } 249 250 /*if(!im.contacts_off_line) 251 setTimeout("im.off_line('none')",2000);*/ 280 node = node.nextSibling; 281 } 282 283 if(!im.contacts_off_line) 284 setTimeout("im.off_line()",3000); 285 } 286 } 287 catch(e) 288 { 252 289 } 253 290 } … … 255 292 function readVcard(pVcard) 256 293 { 257 switch(im.vcard) 258 { 259 case "layer" : 294 switch(pVcard.getAttribute('id')) 295 { 296 case "vCard_user" : 297 260 298 var vcard = pVcard.firstChild; 261 299 var cc = vcard.firstChild; 262 263 300 while( cc ) 264 301 { 265 302 if(cc.nodeName == "NICKNAME" || cc.nodeName == "nickname") 266 303 { 267 func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue;268 im.nickname = " ";269 304 if(cc.firstChild.nodeValue) 270 im.nickname = cc.firstChild.nodeValue;305 func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue; 271 306 } 272 273 307 cc = cc.nextSibling; 274 308 } 275 309 if( im.vcard ) 310 templates.vcard_user(pVcard); 276 311 break; 277 312 278 case "user" : 279 templates.vcard_user(pVcard); 280 im.vcard = "layer"; 281 break; 282 283 case "contact" : 284 templates.vcard_contact(pVcard); 285 im.vcard = "layer"; 286 break; 287 288 case "nickname" : 313 case "vCard" : 314 289 315 var vcard = _this.xtools.parse(pVcard,'nickname.xsl'); 290 im.vcard = "layer"; 291 im.nickname_contacts[vcard.substr(0,vcard.indexOf(','))] = vcard.substr(vcard.indexOf(',')+1); 316 im.nickname_contacts[vcard.substr(0,vcard.indexOf(','))] = ( vcard.substr(vcard.indexOf(',')+1) ) ? vcard.substr(vcard.indexOf(',')+1) : vcard.substr(0,vcard.indexOf(',')) ; 317 if( im.vcard ) 318 templates.vcard_contact(pVcard); 292 319 break; 293 320 } -
trunk/instant_messenger/js/load.js
r151 r164 17 17 }; 18 18 19 function load_im_contacts() 20 { 21 im_window.load('_contacts_im_','instant_messenger_content', '<title>Expresso Messenger</title>', 'window.xsl','',true,true,true); 22 //im_window.visible('_contacts_im_','block'); 23 } 24 19 25 function shortcut_im() 20 26 { … … 22 28 if((local = func.byId('user_info')) && !(func.byId('instant_messenger_content'))) 23 29 { 24 local.innerHTML = '<img src="' + im_fast_menu.src + '" onclick="javascript:templates.fast_menu();"/>' + 25 '<img id="im_status_src" src="' + im_available.src + '" onclick="javascript:im_window.load(\'_contacts_im_\', \'instant_messenger_content\', \'<title>Expresso Messenger</title>\', \'window.xsl\',\'\',true,true,true);"/>' + 26 local.innerHTML + '<div id="instant_messenger_content"><span id="fast_menu_im"/></div>'; 30 var local_old = local.innerHTML ; 31 local.innerHTML = '<img src="' + im_fast_menu.src + '" onclick="javascript:templates.fast_menu();">'; 32 local.innerHTML += '<img id="im_status_src" src="' + im_available.src + '" onclick="javascript:load_im_contacts();"/>'; 33 local.innerHTML += local_old; 34 local.innerHTML += '<div id="instant_messenger_content"></div><span id="fast_menu_im"/>'; 27 35 } 36 28 37 // Carregando Preferências do usuário 29 38 im.get_preferences(); -
trunk/instant_messenger/js/templates.js
r151 r164 26 26 im_window.elementC('add_user_im').innerHTML = this.xtools.parse(XmlDoc,'add_user.xsl'); 27 27 im.ldap(); 28 //im_window.visible('add_user_im','block'); 28 29 }, 29 30 … … 90 91 im_window.elementC('my_settings_im').innerHTML = this.xtools.parse(XmlDoc,'mysettings.xsl'); 91 92 im.get_preferences(); 93 //im_window.visible('my_settings_im','block'); 92 94 }, 93 95 … … 121 123 122 124 if(!(im.nickname_contacts[pJid])) 123 im.request_vcard(pJid, 'nickname');125 im.request_vcard(pJid, false); 124 126 125 127 if(func.byId('img_' + pJid).src != im_unavailable.src ) 126 128 { 127 129 im_window.load(pJid, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl','310',true,true,true); 130 //im_window.visible(pJid,'block'); 128 131 func.byId(pJid + '_avatar').src = path_im + "/templates/default/images/photo.png"; 132 133 if(func.byId('iframe_' + pJid) != null) 134 func.byId('iframe_' + pJid).parentNode.removeChild(func.byId('iframe_' + pJid)); 129 135 130 136 var win = im_window.elementC(pJid); … … 204 210 "<lang2>" + im.get_lang("Group") + "</lang2>" + 205 211 "<lang3>" + im.get_lang("Remove") + "</lang3>" + 206 "<lang4> (Re)-requisitar Autorização</lang4>" +212 "<lang4>" + im.get_lang("It requisition permission")+ "</lang4>" + 207 213 "<lang5>" + im.get_lang("See Info") + "</lang5>" + 208 214 "<jid>" + pJid + "</jid>" + 209 215 "<path>" + path_im + "</path>" + 210 216 "</options>"; 211 menu_action.menu('sub_' + pJid, this.xtools.parse(XmlDoc,'options.xsl')); 212 func.byId('sub_' + pJid).style.zIndex = '99999'; 213 func.byId('sub_' + pJid).style.left = parseInt(func.byId('sub_' + pJid).style.left) - 5; 214 func.byId('sub_' + pJid).style.position = 'absolute'; 215 217 218 var posX = parseInt(func.byId('sub_' + pJid).offsetLeft) - parseInt(func.byId('sub_' + pJid).parentNode.scrollLeft); 219 var posY = parseInt(func.byId('sub_' + pJid).offsetTop) - parseInt(func.byId('sub_' + pJid).parentNode.scrollTop); 220 221 menu_action.menu('im_sub_menu', this.xtools.parse(XmlDoc,'options.xsl')); 222 func.byId('im_sub_menu').style.zIndex = '99999'; 223 func.byId('im_sub_menu').style.top = posY; 224 func.byId('im_sub_menu').style.left = posX + 20; 225 func.byId('im_sub_menu').style.position = 'absolute'; 216 226 }, 217 227 … … 224 234 "<function2>templates.remove_user();</function2>" + 225 235 "<lang3>" + im.get_lang("Vcard") +"</lang3>" + 226 "<function3>im.request_vcard('this', 'user')</function3>" +236 "<function3>im.request_vcard('this',true)</function3>" + 227 237 "<lang4>" + im.get_lang("Preferences") + "</lang4>" + 228 238 "<function4>templates.mysettings()</function4>" + … … 246 256 im_window.elementC('remove_user_im').innerHTML = this.xtools.parse(XmlDoc,'remove_user.xsl'); 247 257 im.get_contacts(); 258 //im_window.visible('remove_user_im','block'); 248 259 }, 249 260 … … 264 275 "vcard_contact" : function(pXml) 265 276 { 277 im.vcard = false; 266 278 var title = "Informações do Contato - Expresso"; 267 279 var XmlDoc = "<vcard_contact>" + … … 279 291 im_window.load('vcard_contact_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','390',true,true,true); 280 292 im_window.elementC('vcard_contact_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_contacts.xsl'); 293 //im_window.visible('vcard_contact_im','block'); 281 294 }, 282 295 283 296 "vcard_user" : function(pXml) 284 297 { 298 im.vcard = false; 285 299 var title = "Informações Pessoais - Expresso"; 286 300 var XmlDoc = "<vcard_user>" + … … 298 312 im_window.load('vcard_user_im','instant_messenger_content','<title>.:: ' + title +' ::.</title>','window.xsl','470',true,true,true); 299 313 im_window.elementC('vcard_user_im').innerHTML = this.xtools.parse(XmlDoc,'vcard_user.xsl'); 314 //im_window.visible('vcard_user_im','block'); 300 315 } 301 316 }
Note: See TracChangeset
for help on using the changeset viewer.