[55] | 1 | function IM() |
---|
| 2 | { |
---|
| 3 | this.vcards = false; |
---|
| 4 | this.statusvcard = false; |
---|
| 5 | this.UsersNot = []; |
---|
| 6 | this.userPrefe = false; |
---|
[68] | 7 | this.count_Vcard = 0; |
---|
[76] | 8 | this._listen = ""; |
---|
| 9 | this.custom_message = ""; |
---|
| 10 | this.timeout_composing = ""; |
---|
[55] | 11 | } |
---|
[64] | 12 | |
---|
[55] | 13 | IM.prototype.load_im = function() |
---|
| 14 | { |
---|
[68] | 15 | this.listen(); |
---|
| 16 | this.requireContacts(); |
---|
| 17 | this.atalho(); |
---|
[64] | 18 | |
---|
[55] | 19 | var handler_Status = function(XmlData) |
---|
| 20 | { |
---|
| 21 | var data = XmlData.getElementsByTagName('retorno').item(0); |
---|
| 22 | data = data.firstChild.nodeValue; |
---|
| 23 | if( data ) |
---|
[57] | 24 | { |
---|
[76] | 25 | if(data == 'available' || data == 'xa') |
---|
| 26 | awayFlag = true; |
---|
[57] | 27 | statusFlag = data; |
---|
[55] | 28 | setTimeout('IM.ImgStatus("'+data+'")',4000); |
---|
[57] | 29 | } |
---|
[55] | 30 | }; |
---|
| 31 | XMLTools.request('$this.Ujabber.MyPresence', 'GET', handler_Status); |
---|
| 32 | }; |
---|
[64] | 33 | |
---|
[55] | 34 | IM.prototype.listen = function() |
---|
| 35 | { |
---|
| 36 | var _this = this; |
---|
[72] | 37 | var handler = function(XMLdata) |
---|
[55] | 38 | { |
---|
| 39 | try |
---|
[44] | 40 | { |
---|
[73] | 41 | var data = XMLdata.documentElement; |
---|
| 42 | if ( data.hasChildNodes() ) |
---|
| 43 | { |
---|
| 44 | data = data.firstChild; |
---|
| 45 | if ( data.nodeType == 3 && data.nodeValue == 'disconnected' ) |
---|
| 46 | { |
---|
| 47 | document.getElementById('div_contacts').innerHTML = '<a href="javascript:void(0);" onclick="javascript:IM.reconnect();">'+_this.get_lang("Re-connect Expresso Messenger ?")+'</a>'; |
---|
| 48 | _this.ImgStatus('unavailable'); |
---|
| 49 | statusFlag = 'unavailable'; |
---|
| 50 | clearTimeout(_awayTimer); |
---|
| 51 | return false; |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
[55] | 55 | if( !_this.userPrefe ) |
---|
| 56 | { |
---|
| 57 | if(window.IM_Preferences) |
---|
| 58 | IM_Preferences.GetYourPreferences(); |
---|
| 59 | } |
---|
[64] | 60 | |
---|
[72] | 61 | _this.getContacts(XMLdata); |
---|
| 62 | _this.getPresence(XMLdata); |
---|
| 63 | _this.getComposing(XMLdata); |
---|
| 64 | _this.getMessages(XMLdata); |
---|
| 65 | _this.getVcard(XMLdata); |
---|
[64] | 66 | |
---|
[55] | 67 | if(!_this.vcards) |
---|
| 68 | { |
---|
[68] | 69 | _this.Vcard(); |
---|
[55] | 70 | _this.vcards = true; |
---|
| 71 | } |
---|
[72] | 72 | |
---|
[65] | 73 | }catch(e){} |
---|
| 74 | |
---|
[76] | 75 | _this._listen = setTimeout('IM.listen()', 3000); |
---|
[55] | 76 | }; |
---|
[76] | 77 | |
---|
[55] | 78 | XMLTools.__RETURN_MODE__ = 'XML'; |
---|
| 79 | XMLTools.request('$this.Ujabber.listen', 'GET', handler); |
---|
| 80 | }; |
---|
[73] | 81 | |
---|
| 82 | IM.prototype.reconnect = function() |
---|
| 83 | { |
---|
| 84 | var _this = this; |
---|
| 85 | var handler_reconnect = function(XMLdata) |
---|
| 86 | { |
---|
| 87 | if ( XMLdata.documentElement.firstChild.nodeValue == 'true' ) |
---|
| 88 | { |
---|
| 89 | document.getElementById('div_contacts').innerHTML = '<div><img src="' + img_wait.src + '" width="25px" heigth="25px" style="float:left;margin:3px "/>'; |
---|
| 90 | document.getElementById('div_contacts').innerHTML += '<font style="color:#0000FF;float:left;margin:9px 5px">' + _this.get_lang("Wait a moment !!") + '</font></div>'; |
---|
[77] | 91 | setTimeout('IM.load_im()',2000); |
---|
[73] | 92 | _this.count_Vcard = 0; |
---|
| 93 | _this.ImgStatus('available'); |
---|
| 94 | statusFlag = 'available'; |
---|
| 95 | _awayTimer = setTimeout("IM.setAway()", parseInt(IM_Preferences.im_timer_xa) * 60000 ); |
---|
| 96 | }else{ |
---|
| 97 | document.getElementById('div_contacts').innerHTML = '<a href="javascript:void(0);" onclick="javascript:IM.reconnect();">'+_this.get_lang("Re-connect Expresso Messenger ?")+'</a>'; |
---|
| 98 | _this.ImgStatus('unavailable'); |
---|
| 99 | statusFlag = 'unavailable'; |
---|
| 100 | return false; |
---|
| 101 | } |
---|
| 102 | }; |
---|
| 103 | XMLTools.__RETURN_MODE__ = 'XML'; |
---|
| 104 | XMLTools.request('$this.Ujabber.reconnect', 'GET', handler_reconnect); |
---|
| 105 | }; |
---|
[20] | 106 | |
---|
[64] | 107 | /* |
---|
[55] | 108 | * Contacts |
---|
[33] | 109 | */ |
---|
[64] | 110 | |
---|
[55] | 111 | IM.prototype.requireContacts = function() |
---|
[33] | 112 | { |
---|
[55] | 113 | var handler = function(data) |
---|
| 114 | { |
---|
| 115 | }; |
---|
| 116 | XMLTools.request('$this.Ujabber.requireContacts', 'GET', handler); |
---|
| 117 | }; |
---|
[20] | 118 | |
---|
[55] | 119 | IM.prototype.getContacts = function(data) |
---|
| 120 | { |
---|
| 121 | try |
---|
| 122 | { |
---|
| 123 | if ( data.getElementsByTagName('contacts').length > 0 ) |
---|
| 124 | { |
---|
| 125 | var node = data.documentElement.firstChild; |
---|
| 126 | while ( node.nodeName != 'contacts' ) |
---|
| 127 | node = node.nextSibling; |
---|
[20] | 128 | |
---|
[55] | 129 | var div = document.getElementById("div_contacts"); |
---|
| 130 | var xsl = XMLTools.load(im_path + 'xsl/contacts.xsl?' + Date.parse(new Date)); |
---|
| 131 | var img = document.createElement('img'); |
---|
| 132 | img.id = 'img_all_groups'; |
---|
| 133 | img.src = img_group_open.src; |
---|
| 134 | img.onclick = function(){IM.visible_group("all_groups")}; |
---|
[20] | 135 | |
---|
[55] | 136 | var a = document.createElement('div'); |
---|
| 137 | a.innerHTML = XMLTools.transform(node, xsl); |
---|
[64] | 138 | |
---|
[55] | 139 | div.innerHTML = ''; |
---|
| 140 | div.appendChild(img); |
---|
| 141 | div.appendChild(document.createTextNode(this.get_lang('List of Contacts'))); |
---|
| 142 | div.appendChild(a); |
---|
[64] | 143 | |
---|
[55] | 144 | var group = func.byId("all_groups").firstChild; |
---|
| 145 | while ( group ) |
---|
| 146 | { |
---|
| 147 | var contact = group.firstChild.nextSibling; |
---|
| 148 | while ( contact = contact.nextSibling ) |
---|
| 149 | { |
---|
| 150 | var img = func.newEl('img'); |
---|
| 151 | img.src = img_unavailable.src; |
---|
[27] | 152 | |
---|
[55] | 153 | func.insElB(img, func.byId(contact.id).firstChild); |
---|
| 154 | } |
---|
[20] | 155 | |
---|
[55] | 156 | try |
---|
| 157 | { |
---|
| 158 | var img = document.createElement('img'); |
---|
| 159 | img.src = img_group_open.src; |
---|
| 160 | img.id = "img_" + group.id; |
---|
| 161 | var el_parent = group; |
---|
[64] | 162 | |
---|
[55] | 163 | el_parent.insertBefore(img,el_parent.firstChild); |
---|
[64] | 164 | |
---|
[55] | 165 | } catch(e){} |
---|
| 166 | group = group.nextSibling; |
---|
| 167 | } |
---|
| 168 | } |
---|
[65] | 169 | }catch(e){} |
---|
[64] | 170 | |
---|
[55] | 171 | }; |
---|
[33] | 172 | |
---|
[64] | 173 | /* |
---|
[55] | 174 | * Visible / Unvisible |
---|
[20] | 175 | */ |
---|
| 176 | |
---|
| 177 | IM.prototype.visible_group = function(el) |
---|
| 178 | { |
---|
| 179 | var _this = this; |
---|
[55] | 180 | var divParent = document.getElementById(el); |
---|
| 181 | divParent.style.display = "none"; |
---|
[20] | 182 | var img = document.getElementById("img_" + el); |
---|
| 183 | img.onclick = function(){_this.unvisible_group(el)}; |
---|
| 184 | img.src = img_group_close.src; |
---|
| 185 | } |
---|
[64] | 186 | |
---|
[20] | 187 | IM.prototype.unvisible_group = function(el) |
---|
| 188 | { |
---|
| 189 | var _this = this; |
---|
| 190 | var div = document.getElementById(el); |
---|
| 191 | div.style.display = ""; |
---|
| 192 | var img = document.getElementById("img_" + el); |
---|
| 193 | img.onclick = function(){_this.visible_group(el)}; |
---|
| 194 | img.src = img_group_open.src; |
---|
[55] | 195 | } |
---|
[64] | 196 | |
---|
[20] | 197 | /* |
---|
[55] | 198 | * Presence |
---|
[20] | 199 | */ |
---|
[64] | 200 | |
---|
[55] | 201 | IM.prototype.getPresence = function(data) |
---|
[20] | 202 | { |
---|
[55] | 203 | try |
---|
| 204 | { |
---|
| 205 | var presence = data.documentElement.firstChild; |
---|
| 206 | var _this = this; |
---|
| 207 | while ( presence ) |
---|
| 208 | { |
---|
| 209 | if ( presence.nodeName != 'presence' ) |
---|
| 210 | { |
---|
| 211 | presence = presence.nextSibling; |
---|
| 212 | continue; |
---|
| 213 | } |
---|
[20] | 214 | |
---|
[55] | 215 | var from = presence.getAttribute('from'); |
---|
| 216 | var type = presence.getAttribute('type'); |
---|
| 217 | if ( presence.hasChildNodes() ) |
---|
| 218 | var status_message = presence.firstChild.nodeValue; |
---|
| 219 | else |
---|
| 220 | var status_message = false; |
---|
[20] | 221 | |
---|
[55] | 222 | if( from ) |
---|
| 223 | { |
---|
| 224 | switch ( type ) |
---|
| 225 | { |
---|
| 226 | case 'subscribe' : |
---|
| 227 | if ( !func.byId(from) ) |
---|
| 228 | _this.UsersNot[_this.UsersNot.length] = from; |
---|
| 229 | else |
---|
| 230 | { |
---|
| 231 | Subscription.subscribed(from); |
---|
| 232 | this.setStatus(statusFlag); |
---|
| 233 | } |
---|
| 234 | break; |
---|
| 235 | case 'subscribed' : |
---|
| 236 | // |
---|
| 237 | break; |
---|
[64] | 238 | case 'unsubscribe' : |
---|
[55] | 239 | Subscription.unsubscribe(from); |
---|
| 240 | type = 'unavailable'; |
---|
| 241 | func.byId(from).firstChild.src = eval('img_' + type + '.src'); |
---|
| 242 | break; |
---|
[64] | 243 | case 'unsubscribed' : |
---|
[55] | 244 | Subscription.unsubscribed(from); |
---|
| 245 | type = 'unavailable'; |
---|
| 246 | func.byId(from).firstChild.src = eval('img_' + type + '.src'); |
---|
| 247 | break; |
---|
| 248 | default : |
---|
| 249 | if ( func.byId(from) ) |
---|
| 250 | { |
---|
| 251 | func.byId(from).firstChild.src = eval('img_' + type + '.src'); |
---|
| 252 | var status; |
---|
| 253 | |
---|
| 254 | if ( (status = func.byId(from + '_im_window')) ) |
---|
| 255 | { |
---|
| 256 | status.firstChild.style.background = 'url('+func.byId(from).firstChild.src+')'; |
---|
| 257 | status = func.byId(from + '_im_window_message'); |
---|
| 258 | if( status_message && status_message != "available" ) |
---|
| 259 | status.innerHTML = from.substr(0, from.indexOf('@')) + ' : ' + status_message; |
---|
| 260 | else |
---|
| 261 | status.innerHTML = ''; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | if( document.getElementById('status_message_' + from) == null) |
---|
| 265 | { |
---|
| 266 | var lbl = document.createElement('label'); |
---|
| 267 | lbl.id = 'status_message_' + from; |
---|
| 268 | if(!status_message) |
---|
| 269 | lbl.innerHTML = ""; |
---|
| 270 | else |
---|
| 271 | if( status_message != "available" ) |
---|
| 272 | lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>"; |
---|
[64] | 273 | func.byId(from).appendChild(lbl); |
---|
[55] | 274 | }else{ |
---|
| 275 | var lbl = document.getElementById('status_message_' + from); |
---|
| 276 | if(!status_message) |
---|
| 277 | lbl.innerHTML = ""; |
---|
| 278 | else |
---|
| 279 | if( status_message != "available" ) |
---|
| 280 | lbl.innerHTML = "<span style='margin-left:10px'><br/> ( " + status_message + " )</span>"; |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | if( _this.UsersNot.length > 0 ) |
---|
| 286 | Templates.Users_Not_Auth(_this.UsersNot); |
---|
| 287 | presence = presence.nextSibling; |
---|
| 288 | } |
---|
| 289 | _this.Contacts_Offline(); |
---|
[65] | 290 | }catch(e){} |
---|
[55] | 291 | }; |
---|
[64] | 292 | |
---|
[55] | 293 | /* |
---|
| 294 | * Contatos - Offline |
---|
| 295 | */ |
---|
[64] | 296 | |
---|
[55] | 297 | IM.prototype.Contacts_Offline = function() |
---|
| 298 | { |
---|
| 299 | var offline = true; |
---|
| 300 | if(IM.userPrefe) |
---|
| 301 | offline = eval(IM_Preferences.LoadPreferences('ch_offline')); |
---|
| 302 | else |
---|
| 303 | offline = eval(IM_Preferences.LoadPreferences('ch_offline')); |
---|
[67] | 304 | |
---|
[55] | 305 | var group = func.byId("all_groups").firstChild; |
---|
| 306 | while ( group ) |
---|
| 307 | { |
---|
[67] | 308 | var contact = group.firstChild; |
---|
| 309 | while ( contact ) |
---|
[55] | 310 | { |
---|
[67] | 311 | if(contact.tagName == "DIV") |
---|
[55] | 312 | { |
---|
[67] | 313 | var childF = contact.firstChild; |
---|
| 314 | if( childF.src == img_unavailable.src && !offline) |
---|
[55] | 315 | func.byId(contact.id).style.display = "none"; |
---|
| 316 | else |
---|
| 317 | func.byId(contact.id).style.display = "block"; |
---|
| 318 | } |
---|
[67] | 319 | contact = contact.nextSibling; |
---|
[55] | 320 | } |
---|
| 321 | group = group.nextSibling; |
---|
| 322 | } |
---|
[20] | 323 | } |
---|
[64] | 324 | |
---|
[55] | 325 | /* |
---|
| 326 | * Get / Send - Messages |
---|
| 327 | */ |
---|
[64] | 328 | |
---|
[55] | 329 | IM.prototype.getMessages = function(data) |
---|
| 330 | { |
---|
| 331 | try |
---|
| 332 | { |
---|
| 333 | data = data.documentElement; |
---|
| 334 | if ( data.childNodes.length > 0 ) |
---|
| 335 | { |
---|
| 336 | var message = data.firstChild; |
---|
| 337 | while ( message ) |
---|
| 338 | { |
---|
| 339 | if ( message.tagName == 'messages' ) |
---|
| 340 | { |
---|
| 341 | var from = message.getAttribute('from'); |
---|
| 342 | with ( from ) |
---|
| 343 | from = substr(0, indexOf('/')) |
---|
[20] | 344 | |
---|
[55] | 345 | if( document.getElementById('vcard_' + from) != null) |
---|
| 346 | { |
---|
[57] | 347 | var vcards = IM_Preferences.vCardLoad(from); |
---|
| 348 | var nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length); |
---|
| 349 | nickname = nickname.substr(0,nickname.indexOf('|')); |
---|
| 350 | nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length); |
---|
[68] | 351 | nickname = ( func.trim(nickname) != "" ) ? nickname : from ; |
---|
[55] | 352 | } |
---|
[65] | 353 | else |
---|
| 354 | var nickname = from; |
---|
[64] | 355 | |
---|
[55] | 356 | var win = document.getElementById(from + '_chatMessages'); |
---|
| 357 | if ( !win ) |
---|
| 358 | { |
---|
| 359 | im_win.open_chat(from); |
---|
| 360 | win = document.getElementById(from + '_chatMessages'); |
---|
| 361 | } |
---|
[64] | 362 | |
---|
[55] | 363 | var el = message.firstChild; |
---|
| 364 | while ( el ) |
---|
| 365 | { |
---|
| 366 | var xsl = XMLTools.load(im_path + 'xsl/message.xsl?' + Date.parse(new Date)); |
---|
| 367 | var next = el.nextSibling; |
---|
[64] | 368 | |
---|
[55] | 369 | var label = document.createElement('strong'); |
---|
[65] | 370 | label.appendChild(document.createTextNode(nickname)); |
---|
| 371 | |
---|
[55] | 372 | win.appendChild(label); |
---|
| 373 | win.appendChild(document.createElement('br')); |
---|
[65] | 374 | var msg = XMLTools.transform(el, xsl); |
---|
| 375 | win.innerHTML += this.emotions_icons(msg); |
---|
[55] | 376 | win.appendChild(document.createElement('br')); |
---|
| 377 | win.appendChild(document.createElement('br')); |
---|
| 378 | win.scrollTop = win.scrollHeight; |
---|
| 379 | im_win.newMessageNotification(); |
---|
[64] | 380 | |
---|
[55] | 381 | el = next; |
---|
| 382 | } |
---|
| 383 | } |
---|
[20] | 384 | |
---|
[55] | 385 | if ( (composing = func.byId(from + '_composing')) ) |
---|
| 386 | if ( composing.style.display = 'block' ) |
---|
| 387 | composing.style.display = 'none'; |
---|
| 388 | |
---|
| 389 | message = message.nextSibling; |
---|
| 390 | } |
---|
| 391 | } |
---|
[65] | 392 | }catch(e){} |
---|
[20] | 393 | } |
---|
[64] | 394 | |
---|
[55] | 395 | IM.prototype.sendMessage = function (pJID) |
---|
[20] | 396 | { |
---|
[55] | 397 | var _this = this; |
---|
| 398 | var name_document = document.getElementById(pJID + '_edita'); |
---|
| 399 | var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0); |
---|
[20] | 400 | |
---|
[65] | 401 | var imgs = envio.getElementsByTagName('img'); |
---|
| 402 | var cod; |
---|
| 403 | var emotion_regexp; |
---|
[20] | 404 | |
---|
[65] | 405 | for ( i = imgs.length - 1; i > -1; i--) |
---|
| 406 | { |
---|
| 407 | if ( (cod = imgs[i].getAttribute('emotion')) ) |
---|
| 408 | { |
---|
| 409 | emotion_regexp = new RegExp('<img[^>]*?emotion="' + cod_emotions[cod][1] + '"[^>]*?>', "i"); |
---|
| 410 | envio.innerHTML = envio.innerHTML.replace(emotion_regexp, cod); |
---|
| 411 | } |
---|
| 412 | else |
---|
| 413 | imgs[i].parentNode.removeChild(imgs[i]); |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | envio.innerHTML = func.trim(envio.innerHTML); |
---|
[68] | 417 | envio.innerHTML = envio.innerHTML.replace(/ | +/gi, ' '); |
---|
| 418 | envio.innerHTML = envio.innerHTML.replace(/<br[^>]*>/gi, '<br />'); |
---|
[65] | 419 | |
---|
[55] | 420 | if ( envio.innerHTML != "" ) |
---|
| 421 | { |
---|
| 422 | var message_text = "<div style='"; |
---|
| 423 | message_text += (envio.style.fontFamily != "") ? "font-family:"+envio.style.fontFamily+";" : ""; |
---|
| 424 | message_text += (envio.style.fontSize != "") ? "font-size:"+envio.style.fontSize+";" : "" ; |
---|
| 425 | message_text += (envio.style.fontWeight != "") ? "font-weight:"+envio.style.fontWeight+";": ""; |
---|
| 426 | message_text += (envio.style.fontStyle != "" ) ? "font-style:"+envio.style.fontStyle+";" : ""; |
---|
| 427 | message_text += (envio.style.color != "") ? "color:"+envio.style.color+";" : "color:black"; |
---|
| 428 | message_text += "'>"; |
---|
| 429 | message_text += envio.innerHTML + "</div>"; |
---|
| 430 | |
---|
[68] | 431 | message_text = message_text.replace(/ | +/gi, ' '); |
---|
| 432 | message_text = message_text.replace(/<br[^>]*>/gi, '<br />'); |
---|
| 433 | |
---|
[55] | 434 | envio.innerHTML = ''; |
---|
[64] | 435 | |
---|
[55] | 436 | var message_element = document.getElementById(pJID + '_chatMessages'); |
---|
[57] | 437 | var nickname = "me "; |
---|
| 438 | if( IM_Preferences.jid ) |
---|
| 439 | { |
---|
| 440 | var vcards = IM_Preferences.vCardLoad(IM_Preferences.jid); |
---|
| 441 | nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length); |
---|
| 442 | nickname = nickname.substr(0,nickname.indexOf('|')); |
---|
| 443 | nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length); |
---|
[68] | 444 | nickname = (func.trim(nickname) != "") ? nickname : IM_Preferences.jid; |
---|
[57] | 445 | } |
---|
[64] | 446 | |
---|
[57] | 447 | message_element.innerHTML += '<strong>' + nickname + ' '; |
---|
[65] | 448 | message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br />'; |
---|
| 449 | message_element.innerHTML += this.emotions_icons(message_text) + '<br />'; |
---|
[55] | 450 | message_element.scrollTop = message_element.scrollHeight; |
---|
[64] | 451 | |
---|
[55] | 452 | var handler_sendMessage = function(data) |
---|
| 453 | { |
---|
| 454 | var data = func.interface(data); |
---|
| 455 | if(!data) |
---|
| 456 | alert(data); |
---|
| 457 | } |
---|
| 458 | XMLTools.request('$this.Ujabber.SendMessage','POST',handler_sendMessage,"to="+pJID+"&body="+escape(message_text)); |
---|
| 459 | } |
---|
| 460 | }; |
---|
[76] | 461 | |
---|
| 462 | /* |
---|
| 463 | * Composing / GetComposing / Paused Message |
---|
| 464 | */ |
---|
[64] | 465 | |
---|
[55] | 466 | IM.prototype.getComposing = function(data) |
---|
[20] | 467 | { |
---|
[55] | 468 | if ( data.hasChildNodes() ) |
---|
| 469 | { |
---|
| 470 | var node = data.documentElement.firstChild; |
---|
| 471 | while ( node ) |
---|
| 472 | { |
---|
| 473 | var composing; |
---|
| 474 | if ( node.nodeName == 'composing' ) |
---|
| 475 | if ( (composing = func.byId(node.getAttribute('from') + '_composing')) ) |
---|
| 476 | if ( composing.style.display = 'none' ) |
---|
| 477 | composing.style.display = 'block'; |
---|
[64] | 478 | |
---|
[55] | 479 | if ( node.nodeName == 'paused' ) |
---|
| 480 | if ( (composing = func.byId(node.getAttribute('from') + '_composing')) ) |
---|
| 481 | if ( composing.style.display = 'block' ) |
---|
| 482 | composing.style.display = 'none'; |
---|
| 483 | |
---|
| 484 | node = node.nextSibling; |
---|
[20] | 485 | } |
---|
| 486 | } |
---|
[55] | 487 | }; |
---|
[76] | 488 | |
---|
| 489 | IM.prototype.composingMessage = function(pId) |
---|
| 490 | { |
---|
| 491 | if( IM.timeout_composing ) |
---|
| 492 | { |
---|
| 493 | clearTimeout(IM.timeout_composing); |
---|
| 494 | IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)'); |
---|
| 495 | } |
---|
| 496 | else |
---|
| 497 | { |
---|
| 498 | IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)'); |
---|
| 499 | var handler_composingMessage = function(data) |
---|
| 500 | { |
---|
| 501 | }; |
---|
| 502 | XMLTools.request('$this.Ujabber.composingMessage', 'POST', handler_composingMessage,"to="+pId); |
---|
| 503 | } |
---|
| 504 | }; |
---|
| 505 | |
---|
| 506 | IM.prototype.pausedMessage = function(pId) |
---|
| 507 | { |
---|
| 508 | clearTimeout(IM.timeout_composing); |
---|
| 509 | IM.timeout_composing = ""; |
---|
| 510 | var handler_pausedMessage = function(data) |
---|
| 511 | { |
---|
| 512 | }; |
---|
| 513 | XMLTools.request('$this.Ujabber.pausedMessage','POST',handler_pausedMessage,"to="+pId); |
---|
| 514 | }; |
---|
[64] | 515 | |
---|
[20] | 516 | /* |
---|
[55] | 517 | * Get_lang |
---|
[20] | 518 | */ |
---|
[64] | 519 | |
---|
[55] | 520 | IM.prototype.get_lang = function(_key, _arg1, _arg2, _arg3, _arg4) |
---|
[20] | 521 | { |
---|
[55] | 522 | var _value = ""; |
---|
[64] | 523 | |
---|
[55] | 524 | if ( !lang_im[_key.toLowerCase()] ) |
---|
| 525 | return _key + "*"; |
---|
[64] | 526 | |
---|
[55] | 527 | _value = lang_im[_key.toLowerCase()]; |
---|
[64] | 528 | |
---|
[55] | 529 | if ( _arg1 || _arg2 ||_arg3 || _arg4 ) |
---|
| 530 | { |
---|
| 531 | for (j = 1; j <= 4; j++ ) |
---|
| 532 | if( eval("_arg"+j) ) |
---|
| 533 | { |
---|
| 534 | var regExp = new RegExp("%" + j + ""); |
---|
| 535 | _value = _value.replace(regExp, eval("_arg"+j)); |
---|
| 536 | } |
---|
| 537 | } |
---|
[64] | 538 | |
---|
[55] | 539 | return _value; |
---|
| 540 | }; |
---|
[64] | 541 | |
---|
[55] | 542 | IM.prototype.getWinContactsState = function() |
---|
| 543 | { |
---|
| 544 | try |
---|
| 545 | { |
---|
| 546 | var win_state = false; |
---|
| 547 | win_state = ( windowItems['contacts'].state == WINDOW_STATE_REGULAR ) ? true : false; |
---|
| 548 | win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false; |
---|
| 549 | return win_state; |
---|
[64] | 550 | |
---|
[55] | 551 | }catch(e){} |
---|
| 552 | }; |
---|
[64] | 553 | |
---|
[55] | 554 | IM.prototype.showContacts = function() |
---|
| 555 | { |
---|
| 556 | if ( this.getWinContactsState() ) |
---|
| 557 | im_win.windowClose('contacts_im'); |
---|
| 558 | else |
---|
| 559 | { |
---|
| 560 | im_win.windowMaximizeRestore('contacts_im'); |
---|
| 561 | } |
---|
| 562 | }; |
---|
[64] | 563 | |
---|
[24] | 564 | /* |
---|
[55] | 565 | * Smiles |
---|
| 566 | */ |
---|
[20] | 567 | |
---|
[55] | 568 | IM.prototype.emotions_icons = function(pEmotion) |
---|
| 569 | { |
---|
[65] | 570 | var emotion_regexp; |
---|
| 571 | for ( i in cod_emotions ) |
---|
[55] | 572 | { |
---|
[65] | 573 | try |
---|
| 574 | { |
---|
| 575 | emotion_regexp = new RegExp(cod_emotions[i][1], 'gi'); |
---|
| 576 | if ( emotion_regexp.test(pEmotion) ) |
---|
| 577 | { |
---|
| 578 | var image = eval('smile_' + cod_emotions[i][0] + '.src.substr(smile_' +cod_emotions[i][0] + '.src.indexOf(im_path))'); |
---|
| 579 | emotion_regexp = new RegExp(cod_emotions[i][1], 'gi'); |
---|
| 580 | pEmotion = pEmotion.replace(emotion_regexp, '<img emotion="' + i + '" src="' + image + '">'); |
---|
| 581 | } |
---|
[75] | 582 | }catch(e){} |
---|
[55] | 583 | } |
---|
| 584 | return pEmotion; |
---|
| 585 | } |
---|
[64] | 586 | |
---|
[55] | 587 | IM.prototype.atalho = function() |
---|
| 588 | { |
---|
| 589 | if ( (local = func.byId('user_info')) && !(func.byId('myStatus')) ) |
---|
| 590 | { |
---|
[20] | 591 | var aux = new Array(); |
---|
| 592 | var _mix = func.newEl('a', 'a', 'img', 'img', 'dl'); |
---|
| 593 | |
---|
| 594 | var fast_menu_link = _mix[0]; |
---|
| 595 | var contacts_link = _mix[1]; |
---|
| 596 | var fast_menu_image = _mix[2]; |
---|
| 597 | var contacts_image = _mix[3]; |
---|
| 598 | var im_fast_menu = _mix[4]; |
---|
| 599 | |
---|
| 600 | fast_menu_link.onclick = function(){IM.showFastMenu();}; |
---|
| 601 | contacts_link.onclick = function(){IM.showContacts();}; |
---|
| 602 | |
---|
| 603 | aux['fast_menu_image'] = new Array(); |
---|
| 604 | aux['fast_menu_image']['element'] = fast_menu_image; |
---|
| 605 | aux['fast_menu_image']['style'] = 'width:9px;height:9px'; |
---|
| 606 | aux['fast_menu_image']['src'] = im_path + 'templates/default/images/menuarwopen.gif'; |
---|
| 607 | |
---|
| 608 | aux['im_fast_menu'] = new Array(); |
---|
| 609 | aux['im_fast_menu']['element'] = im_fast_menu; |
---|
| 610 | aux['im_fast_menu']['id'] = 'fast_menu_im'; |
---|
| 611 | aux['im_fast_menu']['class'] = 'menu_im'; |
---|
| 612 | |
---|
| 613 | aux['contacts_image'] = new Array(); |
---|
| 614 | aux['contacts_image']['element'] = contacts_image; |
---|
[55] | 615 | aux['contacts_image']['id'] = 'myStatus'; |
---|
| 616 | aux['contacts_image']['src'] = eval('img_' + statusFlag + '.src'); |
---|
[20] | 617 | aux['contacts_image']['style'] = 'width:15px;height:15px'; |
---|
| 618 | func.confEl(aux); |
---|
| 619 | |
---|
| 620 | func.insEl(fast_menu_image, fast_menu_link); |
---|
| 621 | func.insEl(contacts_image, contacts_link); |
---|
| 622 | func.insElB(fast_menu_link, contacts_link, im_fast_menu, document.createTextNode(' '), local.firstChild); |
---|
[55] | 623 | } |
---|
| 624 | else |
---|
| 625 | setTimeout('IM.atalho()', 5000); |
---|
| 626 | }; |
---|
[20] | 627 | |
---|
[55] | 628 | /* |
---|
| 629 | * Vcard |
---|
| 630 | */ |
---|
[64] | 631 | |
---|
[68] | 632 | IM.prototype.Vcard = function() |
---|
[55] | 633 | { |
---|
| 634 | var _this = this; |
---|
[70] | 635 | if( _this.count_Vcard < 4) |
---|
[55] | 636 | { |
---|
[68] | 637 | var handler_getVcard = function(_XMLdata) |
---|
| 638 | { |
---|
| 639 | var data = _XMLdata.getElementsByTagName('retorno').item(0); |
---|
| 640 | data = eval(data.firstChild.nodeValue); |
---|
| 641 | if(!data) |
---|
| 642 | setTimeout("IM.Vcard()",2000); |
---|
| 643 | _this.count_Vcard++; |
---|
| 644 | }; |
---|
| 645 | XMLTools.request('$this.Ujabber.Vcard','GET',handler_getVcard); |
---|
| 646 | }else{ |
---|
| 647 | var handler_getVcardUser = function(XMLdata) |
---|
| 648 | { |
---|
| 649 | }; |
---|
| 650 | XMLTools.request('$this.Ujabber.VcardUser','GET',handler_getVcardUser); |
---|
| 651 | } |
---|
[64] | 652 | |
---|
[68] | 653 | }; |
---|
| 654 | |
---|
[55] | 655 | IM.prototype.getVcard = function(data) |
---|
| 656 | { |
---|
| 657 | var _this = this; |
---|
| 658 | try |
---|
[64] | 659 | { |
---|
[55] | 660 | if ( data.getElementsByTagName('vcard').length > 0 && !_this.statusvcard ) |
---|
| 661 | { |
---|
| 662 | var div = document.getElementById("im_vcard_contacts"); |
---|
| 663 | var xsl = XMLTools.load(im_path + 'xsl/vcard_contacts.xsl?' + Date.parse(new Date)); |
---|
| 664 | _this.statusvcard = true; |
---|
[64] | 665 | |
---|
[55] | 666 | div.innerHTML = ""; |
---|
| 667 | div.innerHTML += XMLTools.transform(data, xsl); |
---|
[68] | 668 | IM_Preferences.vCardInit(); |
---|
[55] | 669 | } |
---|
[20] | 670 | |
---|
[68] | 671 | |
---|
[55] | 672 | }catch(e){} |
---|
| 673 | }; |
---|
[64] | 674 | |
---|
[55] | 675 | IM.prototype.open_chat = function(pJID) |
---|
| 676 | { |
---|
| 677 | im_win.open_chat(pJID); |
---|
| 678 | }; |
---|
[64] | 679 | |
---|
[55] | 680 | IM.prototype.action_button = function(pEv, pJid) |
---|
| 681 | { |
---|
| 682 | try |
---|
| 683 | { |
---|
| 684 | if ( pEv.button > 1 ) |
---|
| 685 | { |
---|
| 686 | var posx = 0; |
---|
| 687 | var posy = 0; |
---|
| 688 | if (pEv.pageX || pEv.pageY) |
---|
| 689 | { |
---|
| 690 | posx = pEv.pageX; |
---|
| 691 | posy = pEv.pageY; |
---|
| 692 | } |
---|
| 693 | else if (pEv.clientX || pEv.clientY) |
---|
| 694 | { |
---|
| 695 | posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; |
---|
| 696 | posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop; |
---|
| 697 | } |
---|
| 698 | this.menu_button_right(pJid, posx, posy); |
---|
| 699 | document.oncontextmenu = new Function("return false"); |
---|
| 700 | } |
---|
| 701 | else |
---|
| 702 | if ( func.byId(pJid).firstChild.src != img_unavailable.src ) |
---|
| 703 | this.open_chat(pJid); |
---|
[65] | 704 | }catch(e){} |
---|
[55] | 705 | }; |
---|
[64] | 706 | |
---|
[55] | 707 | IM.prototype.menu_button_right = function(pElement, pX, pY) |
---|
| 708 | { |
---|
| 709 | var form_menu_button_right = '<dl style="z-index:99999">'+ |
---|
| 710 | '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.Update_NickName(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Nick') + '</a>'+ |
---|
| 711 | '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.Update_Group(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Group') + '</a>'+ |
---|
| 712 | '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.RemoveContact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Delete') + '</a>'+ |
---|
| 713 | '<dt><a href="javascript:void(0);" onclick="javascript:Subscription.RequestAutorization(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('(Re)-requisitar Autorização') + '</a>' + |
---|
| 714 | '<dt><a href="javascript:void(0);" onclick="javascript:IM_Preferences.vCardLoad_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('See Info') + '</a>'+ |
---|
| 715 | '</dl>'; |
---|
| 716 | im_menu_action.menu('menu_contato', form_menu_button_right); |
---|
| 717 | func.byId('menu_contato').style.top = pY-10; |
---|
| 718 | func.byId('menu_contato').style.left = pX-10; |
---|
| 719 | func.byId('menu_contato').style.zIndex = zValue + 10; |
---|
| 720 | }; |
---|
[20] | 721 | |
---|
[55] | 722 | /* |
---|
| 723 | * Menu |
---|
[64] | 724 | */ |
---|
[20] | 725 | |
---|
[55] | 726 | IM.prototype.menu_preferences = function() |
---|
| 727 | { |
---|
| 728 | var posx = 0; |
---|
| 729 | var posy = 0; |
---|
| 730 | var pEv = arguments[0]; |
---|
[64] | 731 | |
---|
[55] | 732 | if (pEv.pageX || pEv.pageY) |
---|
| 733 | { |
---|
| 734 | posx = pEv.pageX; |
---|
| 735 | posy = pEv.pageY; |
---|
| 736 | } |
---|
| 737 | else if (pEv.clientX || pEv.clientY) |
---|
| 738 | { |
---|
| 739 | posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; |
---|
| 740 | posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop; |
---|
| 741 | } |
---|
[64] | 742 | |
---|
[55] | 743 | var p_element = document.getElementById(arguments[1]); |
---|
[64] | 744 | var _xmlDoc = ""; |
---|
[55] | 745 | var _this = this; |
---|
[20] | 746 | |
---|
[64] | 747 | _xmlDoc = '<menu>' + |
---|
| 748 | '<item function="IM_Preferences.Add_userLoad()" lang="'+IM.get_lang('Add Contact')+'"/>' + |
---|
[55] | 749 | '<item function="IM_Preferences.Remove_userLoad()" lang="'+IM.get_lang('Remove Contact')+'"/>' + |
---|
[67] | 750 | '<item function="IM_Preferences.vCard()" lang="'+IM.get_lang('Vcard')+'"/>' + |
---|
[55] | 751 | '<item function="IM_Preferences.yourPreferences()" lang="'+IM.get_lang('preferences')+'"/>' + |
---|
| 752 | '</menu>'; |
---|
[64] | 753 | |
---|
[55] | 754 | im_menu_action.menu(p_element.id,parse_XmlXsl(_xmlDoc,'menu_preferences.xsl')); |
---|
| 755 | func.byId(p_element).style.top = posy; |
---|
| 756 | func.byId(p_element).style.left = posx; |
---|
| 757 | func.byId(p_element).style.zIndex = zValue + 10; |
---|
[20] | 758 | |
---|
[55] | 759 | _this.Load_Images_menu(); |
---|
| 760 | } |
---|
[64] | 761 | |
---|
[55] | 762 | IM.prototype.Load_Images_menu = function(Element) |
---|
| 763 | { |
---|
| 764 | try |
---|
| 765 | { |
---|
| 766 | var group = document.getElementById("dl_im_menu_preferences"); |
---|
| 767 | var Child = group.childNodes; |
---|
[64] | 768 | |
---|
[55] | 769 | for(var i = 0; i < Child.length; i++) |
---|
| 770 | { |
---|
| 771 | var img = document.createElement('img'); |
---|
| 772 | img.src = img_menu.src; |
---|
| 773 | Child[i].firstChild.insertBefore(img, Child[i].firstChild.firstChild); |
---|
| 774 | } |
---|
[65] | 775 | }catch(e){} |
---|
[55] | 776 | } |
---|
[64] | 777 | |
---|
[55] | 778 | /* |
---|
| 779 | * Função Provisória - By AlC |
---|
| 780 | */ |
---|
[20] | 781 | |
---|
[55] | 782 | function parse_XmlXsl(_xmlDoc, form_xsl) |
---|
| 783 | { |
---|
[64] | 784 | var xslWin = false; |
---|
| 785 | |
---|
[55] | 786 | if ( !xslWin ) xslWin = XMLTools.load(im_path + 'xsl/' + form_xsl + '?' + Date.parse(new Date)); |
---|
[64] | 787 | |
---|
[55] | 788 | a = document.createElement('div'); |
---|
| 789 | if (window.ActiveXObject) |
---|
| 790 | { |
---|
| 791 | var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); |
---|
| 792 | xmlDoc.async = "false"; |
---|
| 793 | xmlDoc.loadXML(_xmlDoc); |
---|
| 794 | } |
---|
| 795 | else |
---|
| 796 | { |
---|
| 797 | var parser = new DOMParser(); |
---|
| 798 | var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml"); |
---|
| 799 | } |
---|
| 800 | a.innerHTML = XMLTools.transform(xmlDoc, xslWin); |
---|
[64] | 801 | |
---|
[55] | 802 | return a; |
---|
[64] | 803 | |
---|
[55] | 804 | } |
---|
[20] | 805 | |
---|
[55] | 806 | IM.prototype.showFastMenu = function() |
---|
| 807 | { |
---|
| 808 | var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt'); |
---|
| 809 | var _a = func.newEl('a', 'a', 'a', 'a', 'a'); |
---|
[64] | 810 | |
---|
[55] | 811 | for ( var i in _dt ) |
---|
| 812 | { |
---|
| 813 | if ( typeof _dt[i] == 'function' ) |
---|
| 814 | continue; |
---|
| 815 | eval('var option' + (parseInt(i)+1) + ' = _dt[' + i + '];'); |
---|
| 816 | eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];'); |
---|
| 817 | } |
---|
[64] | 818 | |
---|
[55] | 819 | var _img = func.newEl('img', 'img', 'img', 'img','img'); |
---|
[64] | 820 | |
---|
[55] | 821 | for ( var i in _img ) |
---|
| 822 | { |
---|
| 823 | if ( typeof _dt[i] == 'function' ) |
---|
| 824 | continue; |
---|
| 825 | eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];'); |
---|
| 826 | } |
---|
[76] | 827 | |
---|
[55] | 828 | option1_link.onclick = function(){statusFlag = 'available'; IM.setStatus('available');}; |
---|
[76] | 829 | option2_link.onclick = function(){statusFlag = 'xa'; awayFlag = false; IM.setStatus('xa');}; |
---|
[55] | 830 | option3_link.onclick = function(){statusFlag = 'dnd'; IM.setStatus('dnd');}; |
---|
| 831 | option4_link.onclick = function(){statusFlag = 'unavailable'; IM.setStatus('unavailable');}; |
---|
| 832 | option5_link.onclick = function(){IM.setStatus('custom')}; |
---|
[64] | 833 | |
---|
[55] | 834 | func.confEl(option1_image, 'src', img_available.src); |
---|
[63] | 835 | func.confEl(option1_image, 'style', 'width:16px;height:16px;cursor:pointer;'); |
---|
[55] | 836 | func.confEl(option2_image, 'src', img_xa.src); |
---|
[63] | 837 | func.confEl(option2_image, 'style', 'width:16px;height:16px;cursor:pointer;'); |
---|
[55] | 838 | func.confEl(option3_image, 'src', img_dnd.src); |
---|
[63] | 839 | func.confEl(option3_image, 'style', 'width:16px;height:16px;cursor:pointer;'); |
---|
[55] | 840 | func.confEl(option4_image, 'src', img_unavailable.src); |
---|
[63] | 841 | func.confEl(option4_image, 'style', 'width:16px;height:16px;cursor:pointer;'); |
---|
[55] | 842 | func.confEl(option5_image, 'src', img_edit.src); |
---|
[63] | 843 | func.confEl(option5_image, 'style', 'width:16px;height:16px;cursor:pointer;'); |
---|
[64] | 844 | |
---|
[55] | 845 | func.insEl(option1_image, IM.get_lang('online'), option1_link); |
---|
[63] | 846 | func.confEl(option1_link, 'style','cursor:pointer;'); |
---|
[55] | 847 | func.insEl(option1_link, option1); |
---|
[63] | 848 | |
---|
[55] | 849 | func.insEl(option2_image, IM.get_lang('away'), option2_link); |
---|
[63] | 850 | func.confEl(option2_link, 'style','cursor:pointer;'); |
---|
[55] | 851 | func.insEl(option2_link, option2); |
---|
[63] | 852 | |
---|
[55] | 853 | func.insEl(option3_image, IM.get_lang('busy'), option3_link); |
---|
[63] | 854 | func.confEl(option3_link, 'style','cursor:pointer;'); |
---|
[55] | 855 | func.insEl(option3_link, option3); |
---|
[63] | 856 | |
---|
[55] | 857 | func.insEl(option4_image, IM.get_lang('offline'), option4_link); |
---|
[63] | 858 | func.confEl(option4_link, 'style','cursor:pointer;'); |
---|
[55] | 859 | func.insEl(option4_link, option4); |
---|
[63] | 860 | |
---|
[55] | 861 | func.insEl(option5_image, IM.get_lang('Custom message...'), option5_link); |
---|
[63] | 862 | func.confEl(option5_link, 'style','cursor:pointer;'); |
---|
[55] | 863 | func.insEl(option5_link, option5); |
---|
[64] | 864 | |
---|
[55] | 865 | im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5); |
---|
| 866 | }; |
---|
[20] | 867 | |
---|
[72] | 868 | IM.prototype.setStatus = function(pStatus) |
---|
| 869 | { |
---|
| 870 | try |
---|
| 871 | { |
---|
| 872 | var handler = function() |
---|
| 873 | { |
---|
| 874 | }; |
---|
[20] | 875 | |
---|
[72] | 876 | if ( func.byId('fast_menu_im').style.display == 'block' ) |
---|
| 877 | im_menu_action.menu('fast_menu_im', null); |
---|
| 878 | |
---|
| 879 | if ( pStatus == 'custom' ) |
---|
| 880 | { |
---|
[76] | 881 | pStatus = prompt('Personalize seu Status : ', this.custom_message); |
---|
[72] | 882 | pStatus = 'show=' + statusFlag + '&status=' + pStatus; |
---|
| 883 | } |
---|
| 884 | else |
---|
| 885 | { |
---|
| 886 | if ( pStatus == 'unavailable' ) |
---|
| 887 | { |
---|
| 888 | this.ImgStatus(pStatus); |
---|
| 889 | pStatus = 'type=' + pStatus; |
---|
| 890 | } |
---|
| 891 | else |
---|
| 892 | { |
---|
| 893 | try |
---|
| 894 | { |
---|
| 895 | this.ImgStatus(pStatus); |
---|
| 896 | pStatus = 'show=' + pStatus; |
---|
[75] | 897 | }catch(e){} |
---|
[72] | 898 | } |
---|
| 899 | } |
---|
| 900 | XMLTools.request('$this.Ujabber.setPresence', 'POST', handler, pStatus); |
---|
[75] | 901 | }catch(e){} |
---|
[72] | 902 | }; |
---|
[64] | 903 | |
---|
[55] | 904 | IM.prototype.ImgStatus = function(pStatus) |
---|
[20] | 905 | { |
---|
[55] | 906 | var myStatus; |
---|
| 907 | if ( (myStatus = func.byId('myStatus')) ) |
---|
| 908 | myStatus.src = eval('img_' + pStatus + '.src'); |
---|
| 909 | }; |
---|
[20] | 910 | |
---|
[55] | 911 | IM.prototype.setAway = function() |
---|
[20] | 912 | { |
---|
[76] | 913 | if(statusFlag != 'dnd' && statusFlag != 'unavailable') |
---|
[20] | 914 | { |
---|
[76] | 915 | if ( awayFlag ) |
---|
| 916 | { |
---|
| 917 | this.setStatus('available'); |
---|
| 918 | statusFlag = 'available'; |
---|
| 919 | awayFlag = false; |
---|
| 920 | } |
---|
| 921 | else |
---|
| 922 | { |
---|
| 923 | this.setStatus('xa'); |
---|
| 924 | statusFlag = 'xa'; |
---|
| 925 | awayFlag = true; |
---|
| 926 | } |
---|
[20] | 927 | } |
---|
[55] | 928 | }; |
---|
[64] | 929 | |
---|
[72] | 930 | IM.prototype.infoContact = function(pUid) |
---|
| 931 | { |
---|
| 932 | try |
---|
| 933 | { |
---|
| 934 | var info = false; |
---|
| 935 | var div_allg = document.getElementById('all_groups'); |
---|
| 936 | var elements = div_allg.firstChild; |
---|
| 937 | while ( elements ) |
---|
| 938 | { |
---|
| 939 | var childs = elements.firstChild; |
---|
| 940 | while( childs ) |
---|
| 941 | { |
---|
| 942 | if(childs.tagName == "DIV" && childs.id.indexOf(pUid) === 0 ) |
---|
| 943 | { |
---|
| 944 | info = {'jid':childs.id, 'src':childs.firstChild.src}; |
---|
| 945 | break; |
---|
| 946 | } |
---|
| 947 | childs = childs.nextSibling; |
---|
| 948 | } |
---|
| 949 | if ( !info ) |
---|
| 950 | elements = elements.nextSibling; |
---|
| 951 | else |
---|
| 952 | break; |
---|
| 953 | } |
---|
| 954 | return info; |
---|
[75] | 955 | }catch(e){return false;} |
---|
[72] | 956 | }; |
---|
[20] | 957 | |
---|
[75] | 958 | var IM = new IM(); |
---|