[3102] | 1 | (function() |
---|
| 2 | { |
---|
| 3 | var _autoStatus; |
---|
| 4 | var _autoStatusTime = 60000; // 1 minuto |
---|
| 5 | var addUser = null; |
---|
| 6 | var conn = null; |
---|
| 7 | var fullName = ""; |
---|
| 8 | var path = ""; |
---|
| 9 | var _preferencesIM = ""; |
---|
| 10 | var selectEditable = null; |
---|
| 11 | var showhidden = null; |
---|
| 12 | var statusUserIM = ""; |
---|
| 13 | var _statusMessage = ""; |
---|
| 14 | var timeoutId = null; |
---|
| 15 | var userCurrent = null; |
---|
| 16 | var _timeOutNotification = ""; |
---|
| 17 | var Xtools = null; |
---|
| 18 | var zIndex = 9001; |
---|
| 19 | var windowPopUp = []; |
---|
| 20 | |
---|
| 21 | // Images |
---|
| 22 | var add_user = new Image(); |
---|
| 23 | add_user.src = path_jabberit + 'templates/default/images/adduser_azul.png'; |
---|
| 24 | |
---|
| 25 | var arrow_down = new Image(); |
---|
| 26 | arrow_down.src = path_jabberit + 'templates/default/images/arrow_down.gif'; |
---|
| 27 | |
---|
| 28 | var arrow_right = new Image(); |
---|
| 29 | arrow_right.src = path_jabberit + 'templates/default/images/arrow_right.gif'; |
---|
| 30 | |
---|
| 31 | function actionButton() |
---|
| 32 | { |
---|
| 33 | if( arguments.length > 0 ) |
---|
| 34 | { |
---|
| 35 | var e = arguments[0]; |
---|
| 36 | var _element = ( e.target ) ? e.target : e.srcElement; |
---|
| 37 | var jid = arguments[1]; |
---|
| 38 | var coord = null; |
---|
| 39 | |
---|
| 40 | if ( !e ) |
---|
| 41 | e = window.event; |
---|
| 42 | |
---|
| 43 | var _X = e.clientX + document.body.scrollLeft - document.body.clientLeft; |
---|
| 44 | var _Y = e.clientY + document.body.scrollTop - document.body.clientTop; |
---|
| 45 | |
---|
| 46 | coord = { X : _X, Y : _Y }; |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | var _onContextMenu = function() |
---|
| 50 | { |
---|
| 51 | return false; |
---|
| 52 | }; |
---|
| 53 | |
---|
| 54 | window.document.oncontextmenu = _onContextMenu; |
---|
| 55 | |
---|
| 56 | if( e.button ) |
---|
| 57 | { |
---|
| 58 | if( e.button > 1 ) |
---|
| 59 | optionsItensContact( jid, coord ); |
---|
| 60 | else |
---|
| 61 | TrophyIM.rosterClick(jid); |
---|
| 62 | } |
---|
| 63 | else if( e.which ) |
---|
| 64 | { |
---|
| 65 | if( e.which > 1 ) |
---|
| 66 | optionsItensContact( jid, coord ); |
---|
| 67 | else |
---|
| 68 | if( e.target.id ) |
---|
| 69 | TrophyIM.rosterClick(jid); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | setTimeout(function() |
---|
| 73 | { |
---|
| 74 | window.document.oncontextmenu = function() |
---|
| 75 | { |
---|
| 76 | return true; |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | },500); |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | function addContact() |
---|
| 84 | { |
---|
| 85 | if( arguments.length > 0 ) |
---|
| 86 | addUser.add(); |
---|
| 87 | else |
---|
| 88 | addUser.show(); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | function addIcon() |
---|
| 92 | { |
---|
| 93 | |
---|
| 94 | var div_write_msg = ( getElement('em_div_write_msg') != null ) ? getElement('em_div_write_msg') : null ; |
---|
| 95 | var StatusBar = ( getElement('divStatusBar') != null ) ? getElement('divStatusBar') : null ; |
---|
| 96 | var StatusBarIM = ( getElement('JabberMessenger') != null ) ? getElement('JabberMessenger') : null; |
---|
| 97 | |
---|
| 98 | /************************************************************************** |
---|
| 99 | * |
---|
| 100 | * Quando estiver habilitada a opção fora de escritório nos filtros. |
---|
| 101 | * |
---|
| 102 | */ |
---|
| 103 | |
---|
| 104 | if( ( div_write_msg && StatusBarIM ) != null ) |
---|
| 105 | { |
---|
| 106 | div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg); |
---|
| 107 | StatusBarIM.style.paddingLeft = '33px'; |
---|
| 108 | return; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | /**************************************************************************/ |
---|
| 112 | |
---|
| 113 | if ( !StatusBarIM ) |
---|
| 114 | { |
---|
| 115 | StatusBarIM = document.createElement('div'); |
---|
| 116 | StatusBarIM.setAttribute('id', 'JabberMessenger'); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | if( StatusBar ) |
---|
| 120 | { |
---|
| 121 | StatusBar.style.paddingLeft = '33px'; |
---|
| 122 | |
---|
| 123 | var _div = document.createElement('div'); |
---|
| 124 | _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); |
---|
| 125 | |
---|
| 126 | StatusBar.parentNode.insertBefore( _div, StatusBar); |
---|
| 127 | |
---|
| 128 | var _fastMenu = top.document.createElement('div'); |
---|
| 129 | _fastMenu.setAttribute('id', 'fast_menu_jabber_expresso'); |
---|
| 130 | _fastMenu.style.background = 'no-repeat'; |
---|
| 131 | _fastMenu.style.backgroundImage = 'url(' + arrow_down.src + ')'; |
---|
| 132 | _fastMenu.style.float = 'left'; |
---|
| 133 | _fastMenu.style.height = '15px'; |
---|
| 134 | _fastMenu.style.left = '7px'; |
---|
| 135 | _fastMenu.style.margin = '8 0 0 10px'; |
---|
| 136 | _fastMenu.style.padding = '0px'; |
---|
| 137 | _fastMenu.style.position = 'absolute'; |
---|
| 138 | _fastMenu.style.width = '15px'; |
---|
| 139 | _fastMenu.style.cursor = 'pointer'; |
---|
| 140 | |
---|
| 141 | StatusBarIM.insertBefore( _fastMenu, StatusBarIM.firstChild ); |
---|
| 142 | |
---|
| 143 | // Add event onclick element _fastMenu |
---|
| 144 | configEvents( _fastMenu, 'onclick', function(){ fastMenu(_fastMenu); }); |
---|
| 145 | |
---|
| 146 | var _statusJabber = top.document.createElement('div'); |
---|
| 147 | _statusJabber.setAttribute('id','status_jabber_expresso'); |
---|
| 148 | _statusJabber.style.background = 'no-repeat'; |
---|
| 149 | _statusJabber.style.backgroundImage = 'url(' + add_user.src +')'; |
---|
| 150 | _statusJabber.style.float = 'left'; |
---|
| 151 | _statusJabber.style.height = '18px'; |
---|
| 152 | _statusJabber.style.left = '19px'; |
---|
| 153 | _statusJabber.style.margin = '0 0 0 10px'; |
---|
| 154 | _statusJabber.style.padding = '0px'; |
---|
| 155 | _statusJabber.style.position = 'absolute'; |
---|
| 156 | _statusJabber.style.width = '18px'; |
---|
| 157 | _statusJabber.style.cursor = 'pointer'; |
---|
| 158 | _statusJabber.style.zindex = '999999'; |
---|
| 159 | |
---|
| 160 | StatusBarIM.insertBefore( _statusJabber, StatusBarIM.firstChild ); |
---|
| 161 | |
---|
| 162 | StatusBar.insertBefore( StatusBarIM, StatusBar.firstChild ); |
---|
| 163 | |
---|
| 164 | // Add event onclick element _statusJabber |
---|
| 165 | if( _preferencesIM[0] == "openWindowJabberit:true" ) |
---|
| 166 | { |
---|
| 167 | configEvents( _statusJabber, 'onclick', function(){ rosterDiv(); }); |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | configEvents( _statusJabber, 'onclick', function(){ TrophyIM.load(); }); |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | function addNewUser() |
---|
| 177 | { |
---|
| 178 | addUser.newUser(); |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | function autoStatus() |
---|
| 182 | { |
---|
| 183 | var _div_status = ( getElement('status_jabber_expresso') != null ) ? getElement('status_jabber_expresso') : null; |
---|
| 184 | |
---|
| 185 | if ( _autoStatus ) |
---|
| 186 | clearTimeout(_autoStatus); |
---|
| 187 | |
---|
| 188 | if ( _div_status != null ) |
---|
| 189 | { |
---|
| 190 | var _status = _div_status.style.backgroundImage; |
---|
| 191 | _status = _status.substr(_status.lastIndexOf('/') + 1); |
---|
| 192 | _status = _status.substr(0, _status.indexOf('.')); |
---|
| 193 | |
---|
| 194 | if( _status == "xa" && _div_status.getAttribute('autoStatus') ) |
---|
| 195 | { |
---|
| 196 | if( getStatusMessage() != "") |
---|
| 197 | TrophyIM.setPresence("available", getStatusMessage()); |
---|
| 198 | else |
---|
| 199 | TrophyIM.setPresence("available"); |
---|
| 200 | |
---|
| 201 | _div_status.removeAttribute('autoStatus'); |
---|
| 202 | loadscript.setStatusJabber("Disponível","available"); |
---|
| 203 | } |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | var TimeStatus = _preferencesIM[2].split(':'); |
---|
| 207 | |
---|
| 208 | if( TimeStatus[1] ) |
---|
| 209 | _autoStatus = setTimeout( function(){ autoStatusHandler();}, parseInt(TimeStatus[1]) * _autoStatusTime ); |
---|
| 210 | else |
---|
| 211 | _autoStatus = setTimeout( function(){ autoStatusHandler();}, parseInt(_autoStatusTime)); |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | function autoStatusHandler() |
---|
| 215 | { |
---|
| 216 | var _div_status = ( getElement('status_jabber_expresso') != null ) ? getElement('status_jabber_expresso') : null; |
---|
| 217 | |
---|
| 218 | if ( _div_status != null ) |
---|
| 219 | { |
---|
| 220 | var _status = _div_status.style.backgroundImage; |
---|
| 221 | _status = _status.substr(_status.lastIndexOf('/') + 1); |
---|
| 222 | _status = _status.substr(0, _status.indexOf('.')); |
---|
| 223 | |
---|
| 224 | if( _status == "available" ) |
---|
| 225 | { |
---|
| 226 | if(getStatusMessage() != "") |
---|
| 227 | TrophyIM.setPresence("xa", getStatusMessage()); |
---|
| 228 | else |
---|
| 229 | TrophyIM.setPresence("xa"); |
---|
| 230 | |
---|
| 231 | _div_status.setAttribute('autoStatus','true'); |
---|
| 232 | |
---|
| 233 | loadscript.setStatusJabber("Não Disponível","xa"); |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | function clrAllContacts() |
---|
| 239 | { |
---|
| 240 | getElement("JabberIMRoster").innerHTML = ""; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | function configEvents(pObj, pEvent, pHandler) |
---|
| 244 | { |
---|
| 245 | if ( typeof pObj == 'object' ) |
---|
| 246 | { |
---|
| 247 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
| 248 | pEvent = pEvent.substring(2, pEvent.length ); |
---|
| 249 | |
---|
| 250 | if ( arguments.length == 3 ) |
---|
| 251 | { |
---|
| 252 | if ( pObj.addEventListener ) |
---|
| 253 | pObj.addEventListener(pEvent, pHandler, false ); |
---|
| 254 | else if ( pObj.attachEvent ) |
---|
| 255 | pObj.attachEvent( 'on' + pEvent, pHandler ); |
---|
| 256 | } |
---|
| 257 | else if ( arguments.length == 4 ) |
---|
| 258 | { |
---|
| 259 | if ( pObj.removeEventListener ) |
---|
| 260 | pObj.removeEventListener( pEvent, pHandler, false ); |
---|
| 261 | else if ( pObj.detachEvent ) |
---|
| 262 | pObj.detachEvent( 'on' + pEvent, pHandler ); |
---|
| 263 | } |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | function disabledNotificationNewUsers() |
---|
| 268 | { |
---|
| 269 | var _notification = getElement('notification_new_users_jabber') ; |
---|
| 270 | var _statusJabber = getElement('status_jabber_expresso'); |
---|
| 271 | |
---|
| 272 | _notification.style.display = 'none'; |
---|
| 273 | |
---|
| 274 | _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; |
---|
| 275 | |
---|
| 276 | if( _timeOutNotification ) |
---|
| 277 | clearTimeout(_timeOutNotification ); |
---|
| 278 | |
---|
| 279 | TrophyIM.controll.notificationNewUsers = 0; |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | function enabledNotificationNewUsers() |
---|
| 283 | { |
---|
| 284 | var _notification = getElement('notification_new_users_jabber') ; |
---|
| 285 | var _statusJabber = getElement('status_jabber_expresso'); |
---|
| 286 | |
---|
| 287 | if( _notification && _statusJabber ) |
---|
| 288 | { |
---|
| 289 | if ( _notification.style.display == 'none' ) |
---|
| 290 | { |
---|
| 291 | _notification.style.display = 'block'; |
---|
| 292 | |
---|
| 293 | _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat"; |
---|
| 294 | |
---|
| 295 | if( _timeOutNotification ) |
---|
| 296 | clearTimeout(_timeOutNotification ); |
---|
| 297 | |
---|
| 298 | _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 2000 ); |
---|
| 299 | } |
---|
| 300 | else |
---|
| 301 | { |
---|
| 302 | _notification.style.display = 'none'; |
---|
| 303 | |
---|
| 304 | _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; |
---|
| 305 | |
---|
| 306 | if( _timeOutNotification ) |
---|
| 307 | clearTimeout(_timeOutNotification ); |
---|
| 308 | |
---|
| 309 | _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 800 ); |
---|
| 310 | } |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | function fastMenu() |
---|
| 315 | { |
---|
| 316 | if( arguments.length > 0 ) |
---|
| 317 | { |
---|
| 318 | var element = arguments[0]; |
---|
| 319 | |
---|
| 320 | if( showhidden == null ) |
---|
| 321 | showhidden = new ShowHidden(300); |
---|
| 322 | |
---|
[3680] | 323 | var _options = [ |
---|
| 324 | ['Adicionar Contato', 'loadscript.addContact();' ], |
---|
| 325 | ['Preferências', 'loadscript.preferences();'] |
---|
| 326 | ]; |
---|
[3102] | 327 | |
---|
[3680] | 328 | if( im_chatroom == "false" ) |
---|
| 329 | { |
---|
| 330 | _options[2] = [ 'Sala(s) de Bate-Papo','loadscript.getListRooms();']; |
---|
| 331 | } |
---|
| 332 | |
---|
[3102] | 333 | var _itens = ""; |
---|
| 334 | |
---|
| 335 | for( var i in _options ) |
---|
| 336 | { |
---|
| 337 | if( _options[i].constructor == Function ) |
---|
| 338 | continue; |
---|
| 339 | |
---|
| 340 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
| 341 | _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>'; |
---|
| 342 | _itens += _options[i][0] + '</span><br/>'; |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | var _optionsItens = document.createElement("div"); |
---|
| 346 | _optionsItens.id = "fastMenu_Jabber"; |
---|
| 347 | _optionsItens.style.marginTop = "19px"; |
---|
| 348 | _optionsItens.style.marginLeft = "-8px"; |
---|
| 349 | _optionsItens.className = "x-menu"; |
---|
| 350 | _optionsItens.style.zIndex = '999999'; |
---|
| 351 | _optionsItens.innerHTML = _itens; |
---|
| 352 | _optionsItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
| 353 | _optionsItens.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
| 354 | _optionsItens.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
| 355 | |
---|
| 356 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
| 357 | |
---|
| 358 | element.parentNode.appendChild( _optionsItens ); |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | function getElement( elementId ) |
---|
| 363 | { |
---|
| 364 | return document.getElementById( elementId ); |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | function getIsIE() |
---|
| 368 | { |
---|
[3228] | 369 | return SnifferBrowser.isCompatible('is_ie'); |
---|
[3102] | 370 | } |
---|
| 371 | |
---|
| 372 | function getPhotoUser( jid ) |
---|
| 373 | { |
---|
| 374 | try |
---|
| 375 | { |
---|
[3308] | 376 | var _divPhoto = getElement( jid + '__photo' ); |
---|
| 377 | |
---|
| 378 | if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) |
---|
| 379 | { |
---|
| 380 | var _imgUser = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); |
---|
| 381 | _imgUser += '&photo_ldap=' + jid; |
---|
| 382 | |
---|
| 383 | _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; |
---|
| 384 | } |
---|
| 385 | }catch(e){} |
---|
[3102] | 386 | } |
---|
| 387 | |
---|
| 388 | function getShowContactsOffline() |
---|
| 389 | { |
---|
| 390 | if( _preferencesIM[3] ) |
---|
| 391 | { |
---|
| 392 | var showOffline = _preferencesIM[3].split(":"); |
---|
| 393 | |
---|
| 394 | if( showOffline[1] === "true") |
---|
| 395 | return true; |
---|
| 396 | else |
---|
| 397 | return false; |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | return true; |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | function getSmiles( String ) |
---|
| 404 | { |
---|
| 405 | String = String.replace( /:\)|:-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/1.gif'/> "); |
---|
| 406 | String = String.replace( /:-D/g , " <img src='"+path_jabberit+"templates/default/images/smiles/2.gif'/> "); |
---|
| 407 | String = String.replace( /;-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/3.gif'/> "); |
---|
| 408 | String = String.replace( /=-O/g , " <img src='"+path_jabberit+"templates/default/images/smiles/4.gif'/> "); |
---|
| 409 | String = String.replace( /:P/g , " <img src='"+path_jabberit+"templates/default/images/smiles/5.gif'/> "); |
---|
| 410 | String = String.replace( /8-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/6.gif'/> "); |
---|
| 411 | String = String.replace( /\>:o/g , " <img src='"+path_jabberit+"templates/default/images/smiles/7.gif'/> "); |
---|
| 412 | String = String.replace( /:-\$/g , " <img src='"+path_jabberit+"templates/default/images/smiles/8.gif'/> "); |
---|
| 413 | String = String.replace( /:s|:-X/g , " <img src='"+path_jabberit+"templates/default/images/smiles/9.gif'/> "); |
---|
| 414 | String = String.replace( /:-\(/g , " <img src='"+path_jabberit+"templates/default/images/smiles/10.gif'/> "); |
---|
| 415 | String = String.replace( /:\'\(/g , " <img src='"+path_jabberit+"templates/default/images/smiles/11.gif'/> "); |
---|
| 416 | String = String.replace( /:\|/g , " <img src='"+path_jabberit+"templates/default/images/smiles/12.gif'/> "); |
---|
| 417 | String = String.replace( /O:-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/13.gif'/> "); |
---|
| 418 | String = String.replace( /\*\*@#%/g , " <img src='"+path_jabberit+"templates/default/images/smiles/14.gif'/> "); |
---|
| 419 | String = String.replace( /\(I\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/15.gif'/> "); |
---|
[3308] | 420 | String = String.replace( /C28I/g , " <img src='"+path_jabberit+"templates/default/images/smiles/16.gif'/> "); |
---|
[3320] | 421 | String = String.replace( /CS2A/g , " <img src='"+path_jabberit+"templates/default/images/smiles/17.gif' style='width:42px;height:36px;'/> "); |
---|
[4341] | 422 | String = String.replace( /\(CzzzzI\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/18.gif'/> "); |
---|
[3102] | 423 | |
---|
| 424 | return String; |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | function getStatusUserIM() |
---|
| 428 | { |
---|
| 429 | return statusUserIM; |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | function getStatusMessage() |
---|
| 433 | { |
---|
| 434 | return _statusMessage; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | function getUserCurrent() |
---|
| 438 | { |
---|
| 439 | return userCurrent; |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | function getZindex() |
---|
| 443 | { |
---|
| 444 | return zIndex++; |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | function groupsHidden() |
---|
| 448 | { |
---|
| 449 | if( arguments.length > 0 ) |
---|
| 450 | { |
---|
| 451 | var _element = arguments[0]; |
---|
| 452 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left"; |
---|
| 453 | _element.onclick = function(){ groupsVisible(_element);}; |
---|
| 454 | |
---|
| 455 | // Hidden all |
---|
| 456 | var _elementNext = _element.nextSibling; |
---|
| 457 | |
---|
| 458 | while( _elementNext ) |
---|
| 459 | { |
---|
| 460 | if( _elementNext.nodeType == 1 ) |
---|
| 461 | _elementNext.style.display = "none"; |
---|
| 462 | |
---|
| 463 | _elementNext = _elementNext.nextSibling; |
---|
| 464 | } |
---|
| 465 | } |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | function groupsVisible() |
---|
| 469 | { |
---|
| 470 | if( arguments.length > 0 ) |
---|
| 471 | { |
---|
| 472 | var _element = arguments[0]; |
---|
| 473 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left"; |
---|
| 474 | _element.onclick = function(){ groupsHidden(_element);}; |
---|
| 475 | |
---|
| 476 | // Display all |
---|
| 477 | var _elementNext = _element.nextSibling; |
---|
| 478 | |
---|
| 479 | while( _elementNext ) |
---|
| 480 | { |
---|
| 481 | if( _elementNext.nodeType == 1 && _elementNext.nodeName.toLowerCase() == "div" ) |
---|
| 482 | { |
---|
| 483 | var is_off = _elementNext.style.backgroundImage.indexOf("unavailable"); |
---|
| 484 | |
---|
| 485 | if( is_off > 0 && !getShowContactsOffline()) |
---|
| 486 | { |
---|
| 487 | _elementNext.style.display = "none"; |
---|
| 488 | getElement("span_show_" + _elementNext.id ).style.display = "none"; |
---|
| 489 | |
---|
| 490 | } |
---|
| 491 | else |
---|
| 492 | { |
---|
| 493 | _elementNext.style.display = "block"; |
---|
| 494 | getElement("span_show_" + _elementNext.id ).style.display = "block"; |
---|
| 495 | } |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | _elementNext = _elementNext.nextSibling; |
---|
| 499 | } |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | function keyPressSearch() |
---|
| 504 | { |
---|
| 505 | if( arguments.length > 0 ) |
---|
| 506 | { |
---|
| 507 | var ev = arguments[0]; |
---|
| 508 | var element = arguments[1]; |
---|
| 509 | |
---|
| 510 | if ( ev.keyCode == 13 ) |
---|
| 511 | if( element.value.length >= 3 ) |
---|
| 512 | searchUser( element.value ); |
---|
| 513 | else |
---|
[3308] | 514 | alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); |
---|
[3102] | 515 | } |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | |
---|
| 519 | function loginPage() |
---|
| 520 | { |
---|
| 521 | var paramsLoginPage = |
---|
| 522 | { |
---|
| 523 | 'username' : ((( Base64.decode(getUserCurrent().jid) )) ? Base64.decode(getUserCurrent().jid) : ""), |
---|
| 524 | 'password' : ((( Base64.decode(getUserCurrent().password) )) ? Base64.decode(getUserCurrent().password) : "") |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | var winLoginPage = |
---|
| 528 | { |
---|
| 529 | id_window : "window_login_page", |
---|
| 530 | width : 260, |
---|
| 531 | height : 120, |
---|
| 532 | top : 100, |
---|
| 533 | left : 400, |
---|
| 534 | draggable : true, |
---|
| 535 | visible : "display", |
---|
| 536 | resizable : true, |
---|
| 537 | zindex : zIndex++, |
---|
| 538 | title : "Expresso Messenger - Login", |
---|
| 539 | closeAction : "remove", |
---|
| 540 | content : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl", paramsLoginPage) |
---|
| 541 | }; |
---|
| 542 | |
---|
| 543 | _winBuild( winLoginPage ); |
---|
| 544 | } |
---|
| 545 | |
---|
| 546 | function loadScripts(pFiles) |
---|
| 547 | { |
---|
| 548 | // Load JavaScript |
---|
| 549 | var loadJavaScript = function(pJs) |
---|
| 550 | { |
---|
| 551 | var newScript = document.createElement("script"); |
---|
| 552 | newScript.setAttribute("type", "text/javascript"); |
---|
| 553 | newScript.setAttribute("src", pJs ); |
---|
| 554 | |
---|
| 555 | return newScript; |
---|
| 556 | }; |
---|
| 557 | |
---|
| 558 | // Load CSS |
---|
| 559 | var loadStyleSheet = function(pCss) |
---|
| 560 | { |
---|
| 561 | var newStyle = document.createElement("link"); |
---|
| 562 | newStyle.setAttribute("rel", "stylesheet"); |
---|
| 563 | newStyle.setAttribute("type", "text/css"); |
---|
| 564 | newStyle.setAttribute("href", pCss); |
---|
| 565 | |
---|
| 566 | return newStyle; |
---|
| 567 | }; |
---|
| 568 | |
---|
| 569 | for(var i = 0; i < pFiles.length; i++) |
---|
| 570 | { |
---|
| 571 | if( pFiles[i].indexOf(".js") > -1 ) |
---|
| 572 | document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i])); |
---|
| 573 | |
---|
| 574 | if( pFiles[i].indexOf(".css") > -1 ) |
---|
| 575 | document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i])); |
---|
| 576 | } |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | function notificationNewMessage() |
---|
| 580 | { |
---|
| 581 | var _doc = document; |
---|
| 582 | var _id = arguments[0]; |
---|
| 583 | var _win_name = _id.replace( /\W/g, '' ); |
---|
| 584 | |
---|
| 585 | if ( windowPOPUP( _id ) ) |
---|
| 586 | { |
---|
| 587 | _doc = windowPopUp[_win_name].document; |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | var oldTitle = _doc.title; |
---|
| 591 | var newTitle = "## NOVA MENSAGEM ##"; |
---|
| 592 | |
---|
| 593 | if( timeoutId == null ) |
---|
| 594 | { |
---|
| 595 | timeoutId = setInterval(function() |
---|
| 596 | { |
---|
| 597 | _doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle; |
---|
| 598 | }, 1000); |
---|
| 599 | |
---|
| 600 | configEvents( _doc, 'onclick', function() |
---|
| 601 | { |
---|
| 602 | clearInterval(timeoutId); |
---|
| 603 | _doc.title = oldTitle; |
---|
| 604 | timeoutId = null; |
---|
| 605 | }); |
---|
| 606 | |
---|
| 607 | configEvents( _doc, 'onkeypress', function() |
---|
| 608 | { |
---|
| 609 | clearInterval(timeoutId); |
---|
| 610 | _doc.title = oldTitle; |
---|
| 611 | timeoutId = null; |
---|
| 612 | }); |
---|
| 613 | } |
---|
| 614 | } |
---|
| 615 | |
---|
| 616 | function optionsItensContact() |
---|
| 617 | { |
---|
| 618 | if( arguments.length > 0 ) |
---|
| 619 | { |
---|
| 620 | var jid = arguments[0]; |
---|
| 621 | var coord = arguments[1]; |
---|
| 622 | var element = getElement('itenContact_' + jid ); |
---|
| 623 | var action = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar"; |
---|
| 624 | |
---|
| 625 | if( showhidden == null ) |
---|
| 626 | showhidden = new ShowHidden(300); |
---|
| 627 | |
---|
| 628 | var _options = [ |
---|
| 629 | [ action , 'loadscript.setAutorization(\''+jid+'\')'], |
---|
| 630 | ['Remover' , 'loadscript.removeContact(\''+jid+'\')'], |
---|
| 631 | ['Renomear' , 'loadscript.renameContact(\''+jid+'\')'], |
---|
| 632 | ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')'] |
---|
| 633 | ]; |
---|
| 634 | |
---|
| 635 | var _itens = ""; |
---|
| 636 | |
---|
| 637 | for( var i in _options ) |
---|
| 638 | { |
---|
| 639 | if( typeof(_options[i]) == "object") |
---|
| 640 | { |
---|
| 641 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
| 642 | _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>'; |
---|
| 643 | _itens += _options[i][0] + '</span><br/>'; |
---|
| 644 | } |
---|
| 645 | } |
---|
| 646 | |
---|
| 647 | var _optionsItens = document.createElement("div"); |
---|
| 648 | _optionsItens.className = "x-menu"; |
---|
| 649 | _optionsItens.style.top = coord.Y; |
---|
| 650 | _optionsItens.style.left = ( coord.X - element.offsetLeft ); |
---|
| 651 | _optionsItens.style.zIndex = getZindex(); |
---|
| 652 | _optionsItens.innerHTML = _itens; |
---|
| 653 | _optionsItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
| 654 | _optionsItens.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
| 655 | _optionsItens.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
| 656 | |
---|
| 657 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
| 658 | |
---|
| 659 | window.document.body.appendChild(_optionsItens); |
---|
| 660 | } |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | function parse() |
---|
| 664 | { |
---|
| 665 | if( arguments.length == 2 ) |
---|
| 666 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] ); |
---|
| 667 | |
---|
| 668 | if( arguments.length === 3 ) |
---|
| 669 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); |
---|
| 670 | } |
---|
| 671 | |
---|
| 672 | function preferences() |
---|
| 673 | { |
---|
| 674 | var paramPreferences = |
---|
| 675 | { |
---|
| 676 | 'path' : path, |
---|
| 677 | 'lang1' : 'Suas Preferências', |
---|
| 678 | 'lang2' : 'Conexão', |
---|
| 679 | 'lang3' : 'Conectar Automaticamente o IM', |
---|
| 680 | 'lang4' : 'Usuários OffLine', |
---|
| 681 | 'lang5' : 'Exibir amigos Offline', |
---|
| 682 | 'lang6' : 'Salvar', |
---|
| 683 | 'lang7' : 'Cancelar', |
---|
| 684 | 'lang8' : 'Janela de Contatos', |
---|
| 685 | 'lang9' : 'Abrir janela como Pop-up', |
---|
| 686 | 'lang10' : 'Ausente', |
---|
| 687 | 'lang11' : 'Definir status de ausente depois de', |
---|
| 688 | 'lang12' : 'minutos', |
---|
| 689 | 'lang13' : 'Mostrar Contatos', |
---|
| 690 | 'lang14' : 'Mostrar contatos desconectados', |
---|
| 691 | 'langYes': 'Sim', |
---|
| 692 | 'langNo' : 'Não' |
---|
| 693 | }; |
---|
| 694 | |
---|
| 695 | |
---|
| 696 | var _win_preferences = |
---|
| 697 | { |
---|
| 698 | id_window : "jabberit_preferences", |
---|
| 699 | width : 430, |
---|
| 700 | height : 350, |
---|
| 701 | top : 150, |
---|
| 702 | left : 100, |
---|
| 703 | draggable : true, |
---|
| 704 | visible : "display", |
---|
| 705 | resizable : true, |
---|
| 706 | zindex : zIndex++, |
---|
| 707 | title : 'Expresso Messenger - Preferências', |
---|
| 708 | closeAction : "remove", |
---|
| 709 | content : Xtools.parse(Xtools.xml('preferences'), 'preferences.xsl', paramPreferences) |
---|
| 710 | }; |
---|
| 711 | |
---|
| 712 | _winBuild(_win_preferences); |
---|
| 713 | |
---|
| 714 | |
---|
| 715 | var _pButtons = { |
---|
| 716 | 'lang1' : 'Salvar', |
---|
| 717 | 'lang2' : 'Fechar', |
---|
| 718 | 'onclickClose' : '_winBuild("jabberit_preferences","remove");', |
---|
| 719 | 'onclickSubmit' : 'javascript:loadscript.setPreferences();' |
---|
| 720 | }; |
---|
| 721 | |
---|
| 722 | document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); |
---|
| 723 | |
---|
| 724 | // Element openWindowJabberit |
---|
| 725 | var value1 = _preferencesIM[0].split(':'); |
---|
| 726 | var element1 = document.getElementById(value1[0]); |
---|
| 727 | var valueSelect1 = value1[1]; |
---|
| 728 | |
---|
| 729 | for(var i = 0; i < element1.options.length; i++) |
---|
| 730 | if( element1.options[i].value == valueSelect1 ) |
---|
| 731 | element1.options[i].selected = true; |
---|
| 732 | |
---|
| 733 | // Element openWindowJabberitPopUp |
---|
| 734 | var value2 = _preferencesIM[1].split(':'); |
---|
| 735 | |
---|
| 736 | // Element flagAwayIM |
---|
| 737 | var value3 = _preferencesIM[2].split(':'); |
---|
| 738 | var element3 = document.getElementById(value3[0]); |
---|
| 739 | element3.value = value3[1]; |
---|
| 740 | |
---|
| 741 | // Element showContactsOfflineJabberit |
---|
| 742 | var value4 = _preferencesIM[3].split(':'); |
---|
| 743 | var element4 = document.getElementById(value4[0]); |
---|
| 744 | var valueSelect4 = value4[1]; |
---|
| 745 | for(var i = 0; i < element4.options.length; i++) |
---|
| 746 | if( element4.options[i].value == valueSelect4 ) |
---|
| 747 | element4.options[i].selected = true; |
---|
| 748 | } |
---|
| 749 | |
---|
| 750 | function removeContact( jid ) |
---|
| 751 | { |
---|
| 752 | TrophyIM.removeContact( jid ); |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | function removeElement( ) |
---|
| 756 | { |
---|
| 757 | if( arguments.length > 0 ) |
---|
| 758 | { |
---|
| 759 | var _element = arguments[0] |
---|
| 760 | |
---|
| 761 | if( _element != null ) |
---|
| 762 | { |
---|
| 763 | _element.parentNode.removeChild( _element ); |
---|
| 764 | } |
---|
| 765 | } |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | function removeGroup() |
---|
| 769 | { |
---|
| 770 | var _parent = arguments[0]; |
---|
| 771 | |
---|
| 772 | if( _parent.childNodes.length <= 2 ) |
---|
| 773 | _parent.parentNode.removeChild(_parent); |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | function renameContact() |
---|
| 777 | { |
---|
| 778 | if( arguments.length > 0 ) |
---|
| 779 | { |
---|
| 780 | var _jid = arguments[0]; |
---|
| 781 | |
---|
| 782 | TrophyIM.renameContact( _jid ); |
---|
| 783 | } |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | function renameGroup() |
---|
| 787 | { |
---|
| 788 | if( arguments.length > 0 ) |
---|
| 789 | { |
---|
| 790 | var _jid = arguments[0]; |
---|
| 791 | |
---|
| 792 | TrophyIM.renameGroup( _jid ); |
---|
| 793 | } |
---|
| 794 | } |
---|
| 795 | |
---|
| 796 | function rosterDiv() |
---|
| 797 | { |
---|
| 798 | var _rosterDiv = function() |
---|
| 799 | { |
---|
[3228] | 800 | |
---|
[3102] | 801 | var winRosterDiv = |
---|
| 802 | { |
---|
| 803 | id_window : "window_Roster_im", |
---|
| 804 | width : 250, |
---|
| 805 | height : 410, |
---|
| 806 | top : 50, |
---|
| 807 | left : -1500, |
---|
| 808 | leftOld : 50, |
---|
| 809 | draggable : true, |
---|
| 810 | visible : "display", |
---|
| 811 | resizable : true, |
---|
| 812 | zindex : zIndex++, |
---|
| 813 | title : "Expresso Messenger - Contatos", |
---|
| 814 | closeAction : "hidden", |
---|
[3228] | 815 | content : "" |
---|
[3102] | 816 | }; |
---|
[3228] | 817 | |
---|
[3102] | 818 | if( _preferencesIM[0] == "openWindowJabberit:false" ) |
---|
| 819 | { |
---|
| 820 | winRosterDiv.left = 50; |
---|
| 821 | winRosterDiv.leftOld = -1500; |
---|
| 822 | } |
---|
[3228] | 823 | |
---|
| 824 | if( SnifferBrowser.isCompatible('ie8','firefox3','epiphany2','iceweasel3') ) |
---|
| 825 | { |
---|
| 826 | var _idUser = Base64.decode(getUserCurrent().jid); |
---|
[3102] | 827 | |
---|
[3228] | 828 | var paramListContact = |
---|
| 829 | { |
---|
| 830 | 'idUser' : _idUser, |
---|
| 831 | 'full_name' : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), |
---|
| 832 | 'path_jabberit' : path_jabberit, |
---|
| 833 | 'help_expresso' : help_expresso, |
---|
| 834 | 'zIndex_' : zIndex++ |
---|
| 835 | }; |
---|
| 836 | |
---|
| 837 | winRosterDiv.content = Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact) |
---|
| 838 | |
---|
| 839 | } |
---|
| 840 | else |
---|
| 841 | { |
---|
| 842 | var paramList = |
---|
| 843 | { |
---|
| 844 | 'path_jabberit' : path_jabberit |
---|
| 845 | }; |
---|
| 846 | |
---|
| 847 | winRosterDiv.width = 280; |
---|
| 848 | winRosterDiv.height = 430; |
---|
| 849 | winRosterDiv.content = Xtools.parse(Xtools.xml("navigator"),"navigatorCompatible.xsl", paramList); |
---|
| 850 | } |
---|
[3102] | 851 | |
---|
[3228] | 852 | _winBuild( winRosterDiv ); |
---|
| 853 | |
---|
[3102] | 854 | // Photo User |
---|
| 855 | getPhotoUser(_idUser); |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | setTimeout( function(){ _rosterDiv(); }, 200 ); |
---|
| 859 | } |
---|
| 860 | |
---|
| 861 | function searchUser() |
---|
| 862 | { |
---|
| 863 | var _input = getElement('search_user_jabber'); |
---|
| 864 | |
---|
| 865 | if( _input.value.length >= 3 ) |
---|
| 866 | addUser.search(); |
---|
| 867 | else |
---|
| 868 | alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | function setAutorization() |
---|
| 872 | { |
---|
| 873 | var divItenContact = null; |
---|
| 874 | |
---|
| 875 | if( arguments.length > 0 ) |
---|
| 876 | { |
---|
| 877 | var jidTo = arguments[0]; |
---|
| 878 | |
---|
| 879 | if( getElement('itenContact_' + jidTo) ) |
---|
| 880 | divItenContact = getElement('itenContact_' + jidTo ); |
---|
| 881 | } |
---|
| 882 | |
---|
| 883 | if( divItenContact ) |
---|
| 884 | { |
---|
| 885 | var subscription = divItenContact.getAttribute('subscription'); |
---|
| 886 | |
---|
| 887 | switch(subscription) |
---|
| 888 | { |
---|
| 889 | case 'from': |
---|
| 890 | |
---|
[3308] | 891 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe'); |
---|
[3102] | 892 | break; |
---|
| 893 | |
---|
| 894 | case 'subscribe' : |
---|
| 895 | |
---|
[3308] | 896 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed'); |
---|
[3102] | 897 | break; |
---|
| 898 | |
---|
| 899 | case 'none' : |
---|
| 900 | |
---|
[3308] | 901 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe'); |
---|
[3102] | 902 | break; |
---|
| 903 | |
---|
| 904 | case 'to' : |
---|
| 905 | |
---|
[3308] | 906 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed'); |
---|
[3102] | 907 | removeElement( getElement('itenContactNotification_' + jidTo ) ); |
---|
| 908 | break; |
---|
| 909 | |
---|
| 910 | case 'not-in-roster': |
---|
| 911 | |
---|
[3308] | 912 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
[3102] | 913 | addUser.add( jidTo ); |
---|
| 914 | break; |
---|
| 915 | } |
---|
| 916 | } |
---|
| 917 | } |
---|
| 918 | |
---|
| 919 | function setMessageStatus() |
---|
| 920 | { |
---|
| 921 | if( arguments.length > 0 ) |
---|
| 922 | { |
---|
| 923 | var _element = arguments[0]; |
---|
| 924 | var _parent = _element.parentNode; |
---|
| 925 | |
---|
| 926 | if( _element.nodeName.toLowerCase() == "label") |
---|
| 927 | { |
---|
| 928 | var _input = document.createElement("input"); |
---|
| 929 | _input.size = "35"; |
---|
| 930 | _input.maxlength = "35"; |
---|
| 931 | _input.style.border = "0"; |
---|
| 932 | _input.value = _element.innerHTML; |
---|
| 933 | |
---|
| 934 | // OnkeyUp |
---|
| 935 | configEvents( _input, "onkeyup", function(e) |
---|
| 936 | { |
---|
| 937 | if( e.keyCode == 13 ) loadscript.setMessageStatus(_input, _element); |
---|
| 938 | } |
---|
| 939 | ); |
---|
| 940 | |
---|
| 941 | // Onblur |
---|
| 942 | configEvents(_input, "onblur", function(){ loadscript.setMessageStatus(_input, _element)}); |
---|
| 943 | |
---|
| 944 | |
---|
| 945 | if( _parent != null ) |
---|
| 946 | { |
---|
| 947 | // Remove label |
---|
| 948 | if( _element != null ) |
---|
| 949 | _parent.removeChild( _element ); |
---|
| 950 | |
---|
| 951 | // Add Input |
---|
| 952 | if( _input != null ) |
---|
| 953 | _parent.appendChild( _input ); |
---|
| 954 | } |
---|
| 955 | |
---|
| 956 | _input.focus(); |
---|
| 957 | _input.select(); |
---|
| 958 | } |
---|
| 959 | else |
---|
| 960 | { |
---|
| 961 | var _label = arguments[1]; |
---|
| 962 | _statusMessage = _element.value.replace(/^\(+|\)+$/g,""); |
---|
| 963 | |
---|
| 964 | if( ( _statusMessage = _statusMessage.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") |
---|
| 965 | _label.innerHTML = "( " + _statusMessage + " )"; |
---|
| 966 | else |
---|
| 967 | _label.innerHTML = "( " + i18n.TYPE_YOUR_MESSAGE_HERE_STATUS + " )"; |
---|
| 968 | |
---|
| 969 | if( _parent != null ) |
---|
| 970 | { |
---|
| 971 | // Remove Input |
---|
| 972 | if( _element != null ) |
---|
| 973 | _parent.removeChild( _element ); |
---|
| 974 | |
---|
| 975 | // Add Label |
---|
| 976 | if( _label != null ) |
---|
| 977 | _parent.appendChild( _label ); |
---|
| 978 | } |
---|
| 979 | |
---|
| 980 | // Send Status Message |
---|
| 981 | _statusMessage = ( ( _statusMessage != i18n.TYPE_YOUR_MESSAGE_HERE_STATUS ) ? _statusMessage : "" ); |
---|
| 982 | |
---|
| 983 | TrophyIM.setPresence("status", _statusMessage ); |
---|
| 984 | } |
---|
| 985 | } |
---|
| 986 | } |
---|
| 987 | |
---|
| 988 | function setPreferences() |
---|
| 989 | { |
---|
| 990 | // Element openWindowJabberit |
---|
| 991 | var elementOpenW = document.getElementById('openWindowJabberit'); |
---|
| 992 | var value = ''; |
---|
| 993 | |
---|
| 994 | for(var i = 0 ; i < elementOpenW.options.length; i++) |
---|
| 995 | if( elementOpenW.options[i].selected == true) |
---|
| 996 | { |
---|
| 997 | value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value; |
---|
| 998 | _preferencesIM[0] = 'openWindowJabberit:' + elementOpenW.options[i].value; |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | // Element openWindowJabberitPopUp |
---|
| 1002 | value += '&preferences2=openWindowJabberitPopUp:false'; |
---|
| 1003 | _preferencesIM[1] = 'openWindowJabberitPopUp:false'; |
---|
| 1004 | |
---|
| 1005 | // Element flagAwayIM |
---|
| 1006 | var elementFlagIM = document.getElementById('flagAwayIM'); |
---|
| 1007 | |
---|
| 1008 | if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 ) |
---|
| 1009 | { |
---|
| 1010 | _preferencesIM[2] = 'flagAwayIM:' + elementFlagIM.value; |
---|
| 1011 | value += '&preferences3=flagAwayIM:' + elementFlagIM.value; |
---|
| 1012 | } |
---|
| 1013 | else |
---|
| 1014 | { |
---|
| 1015 | alert('Informe um valor igual ou maior que 1!'); |
---|
| 1016 | return false; |
---|
| 1017 | } |
---|
| 1018 | |
---|
| 1019 | // Element showContactsOfflineJabberit |
---|
| 1020 | var elementShowOffline = document.getElementById('showContactsOfflineJabberit'); |
---|
| 1021 | |
---|
| 1022 | for(var i = 0 ; i < elementShowOffline.options.length; i++) |
---|
| 1023 | if( elementShowOffline.options[i].selected == true) |
---|
| 1024 | { |
---|
| 1025 | _preferencesIM[3] = 'showContactsOfflineJabberit:' + elementShowOffline.options[i].value; |
---|
| 1026 | value += '&preferences4=showContactsOfflineJabberit:' + elementShowOffline.options[i].value; |
---|
| 1027 | } |
---|
| 1028 | |
---|
| 1029 | // Save Preferences |
---|
| 1030 | conn.go('p.pf.setPreferences', |
---|
| 1031 | function(data) |
---|
| 1032 | { |
---|
| 1033 | if( data == 'false' ) |
---|
| 1034 | { |
---|
| 1035 | alert('Erro salvando suas preferências!'); |
---|
| 1036 | } |
---|
| 1037 | |
---|
| 1038 | _winBuild('jabberit_preferences', 'remove'); |
---|
| 1039 | }, |
---|
| 1040 | value); |
---|
| 1041 | } |
---|
| 1042 | |
---|
| 1043 | function setPresence() |
---|
| 1044 | { |
---|
| 1045 | if( arguments.length > 0 ) |
---|
| 1046 | { |
---|
| 1047 | var element = arguments[0]; |
---|
| 1048 | |
---|
| 1049 | if( showhidden == null ) |
---|
| 1050 | showhidden = new ShowHidden(300); |
---|
| 1051 | |
---|
| 1052 | var _status = [ |
---|
| 1053 | ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'], |
---|
| 1054 | ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'], |
---|
| 1055 | ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'], |
---|
| 1056 | ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], |
---|
| 1057 | ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], |
---|
| 1058 | ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'], |
---|
| 1059 | ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'], |
---|
| 1060 | ]; |
---|
| 1061 | |
---|
| 1062 | var _itens = ""; |
---|
| 1063 | |
---|
| 1064 | for( var i in _status ) |
---|
| 1065 | { |
---|
| 1066 | if( typeof( _status[i]) == "object" ) |
---|
| 1067 | { |
---|
| 1068 | _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadscript.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">'; |
---|
| 1069 | _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>"; |
---|
| 1070 | } |
---|
| 1071 | } |
---|
| 1072 | |
---|
| 1073 | var _statusItens = document.createElement("div"); |
---|
| 1074 | _statusItens.style.marginTop = "65px"; |
---|
| 1075 | _statusItens.style.marginLeft = "67px"; |
---|
| 1076 | _statusItens.className = "x-menu"; |
---|
| 1077 | _statusItens.style.zIndex = '99999'; |
---|
| 1078 | _statusItens.innerHTML = _itens; |
---|
| 1079 | _statusItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
| 1080 | |
---|
| 1081 | showhidden.action('onmouseover', 'onmouseout', _statusItens); |
---|
| 1082 | |
---|
| 1083 | element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
| 1084 | element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
| 1085 | element.parentNode.appendChild(_statusItens); |
---|
| 1086 | } |
---|
| 1087 | } |
---|
| 1088 | |
---|
| 1089 | function setSelectEditable(element, top, left ) |
---|
| 1090 | { |
---|
| 1091 | if( getElement('selectBox0') == null ) |
---|
| 1092 | selectEditable.create(element, top, left ); |
---|
| 1093 | } |
---|
| 1094 | |
---|
| 1095 | function setStatusJabber() |
---|
| 1096 | { |
---|
| 1097 | if( arguments.length > 0 ) |
---|
| 1098 | { |
---|
| 1099 | if( arguments[1] != 'status' ) |
---|
| 1100 | { |
---|
| 1101 | var _text = arguments[0]; |
---|
| 1102 | var _img = statusUserIM = arguments[1]; |
---|
| 1103 | |
---|
| 1104 | getElement('statusJabberText').innerHTML = _text; |
---|
| 1105 | getElement('statusJabberImg').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')"; |
---|
| 1106 | getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; |
---|
| 1107 | } |
---|
| 1108 | } |
---|
| 1109 | } |
---|
| 1110 | |
---|
| 1111 | function _setUserCurrent( _user ) |
---|
| 1112 | { |
---|
| 1113 | userCurrent = |
---|
| 1114 | { |
---|
| 1115 | 'jid' : _user.jid.substring(11, _user.jid.length), |
---|
| 1116 | 'password' : _user.password.substring(11, _user.password.length) |
---|
| 1117 | } |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | function setUserCurrent() |
---|
| 1121 | { |
---|
| 1122 | if( getUserCurrent() == null ) |
---|
| 1123 | { |
---|
| 1124 | conn.go('p.ff.data_0', |
---|
| 1125 | function(_User) |
---|
| 1126 | { |
---|
| 1127 | conn.go('p.ff.data_1', |
---|
| 1128 | function(_pass) |
---|
| 1129 | { |
---|
| 1130 | _setUserCurrent( { jid : _User, password : _pass } ); |
---|
| 1131 | }); |
---|
| 1132 | }); |
---|
| 1133 | } |
---|
| 1134 | } |
---|
| 1135 | |
---|
| 1136 | var _stylesheets = [ ]; |
---|
| 1137 | var _links = document.getElementsByTagName( 'link' ); |
---|
| 1138 | |
---|
| 1139 | for ( var i = 0; i < _links.length; i++ ) |
---|
| 1140 | if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' ) |
---|
| 1141 | _stylesheets[ _stylesheets.length ] = _links.item( i ); |
---|
| 1142 | |
---|
| 1143 | function windowPOPUP() |
---|
| 1144 | { |
---|
| 1145 | var _id = arguments[0]; |
---|
| 1146 | var _win_name = _id.replace( /\W/g, '' ); |
---|
| 1147 | |
---|
| 1148 | if ( arguments.length == 1 ) |
---|
| 1149 | { |
---|
| 1150 | if ( windowPopUp[_win_name] ) |
---|
| 1151 | return true; |
---|
| 1152 | else |
---|
| 1153 | return false; |
---|
| 1154 | } |
---|
| 1155 | |
---|
| 1156 | if( arguments.length == 2 ) |
---|
| 1157 | { |
---|
| 1158 | if( !windowPopUp[_win_name] ) |
---|
| 1159 | { |
---|
| 1160 | windowPopUp[_win_name] = window.open( '', _win_name + '__popup', 'height=355,width=380,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,titlebar=no'); |
---|
| 1161 | var tmp = windowPopUp[_win_name].document; |
---|
| 1162 | |
---|
| 1163 | tmp.write('<html><head>'); |
---|
| 1164 | tmp.write('</head><body>'); |
---|
| 1165 | tmp.write('</body></html>'); |
---|
| 1166 | tmp.close(); |
---|
| 1167 | |
---|
| 1168 | for ( var i = 0; i < _stylesheets.length; i++ ) |
---|
| 1169 | tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) ); |
---|
| 1170 | |
---|
| 1171 | var divPOP = getElement( _id + "__popUp" ); |
---|
| 1172 | divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat"; |
---|
| 1173 | divPOP.innerHTML = "PopIn"; |
---|
| 1174 | |
---|
| 1175 | function _close( ) |
---|
| 1176 | { |
---|
| 1177 | windowPopUp[_win_name].close(); |
---|
| 1178 | configEvents( divPOP ,'onclick', _close, true ); |
---|
| 1179 | } |
---|
| 1180 | |
---|
| 1181 | configEvents( divPOP ,'onclick', _close ); |
---|
| 1182 | |
---|
| 1183 | var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode ); |
---|
| 1184 | |
---|
| 1185 | _content.firstChild.scrollTop = _content.firstChild.scrollHeight; |
---|
| 1186 | |
---|
| 1187 | configEvents( windowPopUp[_win_name] ,'onbeforeunload', function() |
---|
| 1188 | { |
---|
| 1189 | delete windowPopUp[_win_name]; |
---|
| 1190 | divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat"; |
---|
| 1191 | divPOP.innerHTML = "PopUp"; |
---|
| 1192 | divPOP.onclick = function(){ loadscript.windowPOPUP( _id , true ); }; |
---|
| 1193 | _winBuild( 'window_chat_area_' + _id, "display" ).content( true ); |
---|
| 1194 | }); |
---|
| 1195 | |
---|
| 1196 | _winBuild( 'window_chat_area_' + _id, 'hidden' ); |
---|
| 1197 | } |
---|
| 1198 | } |
---|
| 1199 | } |
---|
| 1200 | |
---|
| 1201 | function windowNotificationNewUsers() |
---|
| 1202 | { |
---|
| 1203 | var _users = Xtools.xml('notification_new_users'); |
---|
| 1204 | |
---|
| 1205 | for( var user in TrophyIM.rosterObj.roster ) |
---|
| 1206 | { |
---|
| 1207 | if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) |
---|
| 1208 | continue; |
---|
| 1209 | |
---|
| 1210 | if( TrophyIM.rosterObj.roster[ user ].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) |
---|
| 1211 | { |
---|
| 1212 | var _subscription = TrophyIM.rosterObj.roster[user].contact.subscription; |
---|
| 1213 | |
---|
| 1214 | if ( _subscription == 'to' || _subscription == 'not-in-roster' ) |
---|
| 1215 | { |
---|
| 1216 | var _user = _users.createElement('user'); |
---|
| 1217 | var _jid = _users.createElement('jid'); |
---|
| 1218 | var _status = _users.createElement('status'); |
---|
| 1219 | _jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) ); |
---|
| 1220 | _status.appendChild( _users.createTextNode( _subscription ) ); |
---|
| 1221 | _user.appendChild( _jid ); |
---|
| 1222 | _user.appendChild( _status ); |
---|
| 1223 | _users.documentElement.appendChild( _user ); |
---|
| 1224 | } |
---|
| 1225 | } |
---|
| 1226 | } |
---|
| 1227 | |
---|
| 1228 | var paramsNotification = |
---|
| 1229 | { |
---|
| 1230 | 'lang_1' : "Notificação", |
---|
| 1231 | 'lang_2' : "O(s) usuário(s) abaixo pedem sua autorização.", |
---|
| 1232 | 'lang_3' : "Autorizar", |
---|
| 1233 | 'lang_4' : "Remover" |
---|
| 1234 | }; |
---|
| 1235 | |
---|
| 1236 | var winNotification = |
---|
| 1237 | { |
---|
| 1238 | id_window : "window_notification_new_users", |
---|
| 1239 | width : 400, |
---|
| 1240 | height : 300, |
---|
| 1241 | top : 100, |
---|
| 1242 | left : 400, |
---|
| 1243 | draggable : true, |
---|
| 1244 | visible : "display", |
---|
| 1245 | resizable : true, |
---|
| 1246 | zindex : zIndex++, |
---|
| 1247 | title : "Expresso Messenger - Notificação de Novos Usuários", |
---|
| 1248 | closeAction : "remove", |
---|
| 1249 | content : Xtools.parse( _users , "notificationNewUsers.xsl", paramsNotification ) |
---|
| 1250 | }; |
---|
| 1251 | |
---|
| 1252 | _winBuild( winNotification ); |
---|
| 1253 | } |
---|
| 1254 | |
---|
| 1255 | function createChatRooms() |
---|
| 1256 | { |
---|
[3129] | 1257 | _winBuild("window_List_Rooms_jabberit_messenger","remove"); |
---|
| 1258 | |
---|
| 1259 | var paramCreateChatRoom = |
---|
[3102] | 1260 | { |
---|
| 1261 | 'lang_nameChatRoom' : "Nome da Sala", |
---|
| 1262 | 'lang_nickName' : "Apelido" |
---|
| 1263 | }; |
---|
| 1264 | |
---|
| 1265 | var winCreateChatRooms = |
---|
| 1266 | { |
---|
| 1267 | id_window : "window_create_chat_rooms", |
---|
| 1268 | width : 360, |
---|
| 1269 | height : 160, |
---|
| 1270 | top : 100, |
---|
| 1271 | left : 410, |
---|
| 1272 | draggable : true, |
---|
| 1273 | visible : "display", |
---|
| 1274 | resizable : true, |
---|
| 1275 | zindex : loadscript.getZIndex(), |
---|
| 1276 | title : "Expresso Messenger - Criar Sala de Bate Papo", |
---|
| 1277 | closeAction : "remove", |
---|
| 1278 | content : Xtools.parse( Xtools.xml("create_chat_room"), "createChatRoom.xsl", paramCreateChatRoom ) |
---|
| 1279 | }; |
---|
| 1280 | |
---|
| 1281 | _winBuild( winCreateChatRooms ); |
---|
| 1282 | |
---|
| 1283 | var _pButtons = |
---|
| 1284 | { |
---|
| 1285 | 'lang1' : 'Ingressar', |
---|
| 1286 | 'lang2' : 'Fechar', |
---|
| 1287 | 'onclickClose' : '_winBuild("window_create_chat_rooms","remove");', |
---|
| 1288 | 'onclickSubmit' : 'TrophyIM.createChatRooms(); _winBuild("window_create_chat_rooms","remove");' |
---|
| 1289 | }; |
---|
| 1290 | |
---|
| 1291 | // Add Buttons |
---|
| 1292 | document.getElementById('buttons_createChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); |
---|
| 1293 | |
---|
| 1294 | } |
---|
| 1295 | |
---|
| 1296 | function listRooms( element ) |
---|
| 1297 | { |
---|
| 1298 | element = element.getElementsByTagName( 'item' ); |
---|
| 1299 | |
---|
| 1300 | var _roomsCount = 0; |
---|
| 1301 | var _xml = Xtools.xml('listRooms'); |
---|
| 1302 | var _listRooms = _xml.documentElement; |
---|
| 1303 | |
---|
| 1304 | var show = function( ) |
---|
| 1305 | { |
---|
| 1306 | if ( _roomsCount != element.length ) |
---|
| 1307 | return false; |
---|
| 1308 | |
---|
| 1309 | var paramsListRooms = |
---|
| 1310 | { |
---|
| 1311 | "path_jabberit" : path_jabberit |
---|
| 1312 | }; |
---|
| 1313 | |
---|
| 1314 | var winListRooms = |
---|
| 1315 | { |
---|
[3129] | 1316 | id_window : "window_List_Rooms_jabberit_messenger", |
---|
[3102] | 1317 | width : 450, |
---|
| 1318 | height : 300, |
---|
| 1319 | top : 100, |
---|
| 1320 | left : 400, |
---|
| 1321 | draggable : true, |
---|
| 1322 | visible : "display", |
---|
| 1323 | resizable : true, |
---|
| 1324 | zindex : loadscript.getZIndex(), |
---|
| 1325 | title : "Expresso Messenger - Salas de Bate Papo", |
---|
| 1326 | closeAction : "remove", |
---|
| 1327 | content : Xtools.parse( _xml, "listRooms.xsl", paramsListRooms ) |
---|
| 1328 | }; |
---|
| 1329 | |
---|
| 1330 | _winBuild( winListRooms ); |
---|
| 1331 | |
---|
| 1332 | var _pButtons = |
---|
| 1333 | { |
---|
| 1334 | 'lang1' : 'Criar Nova Sala', |
---|
| 1335 | 'lang2' : 'Fechar', |
---|
[3129] | 1336 | 'onclickClose' : '_winBuild("window_List_Rooms_jabberit_messenger","remove");', |
---|
[3102] | 1337 | 'onclickSubmit' : 'loadscript.createChatRooms();' |
---|
| 1338 | }; |
---|
| 1339 | |
---|
| 1340 | // Add Buttons |
---|
| 1341 | document.getElementById('buttons_addChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); |
---|
| 1342 | }; |
---|
| 1343 | |
---|
| 1344 | var _add_room = function( _room ) |
---|
| 1345 | { |
---|
| 1346 | _roomsCount++; |
---|
| 1347 | |
---|
[3680] | 1348 | var _ROOM = _xml.createElement('room'); |
---|
| 1349 | var _JIDROOM = _xml.createElement('jidRoom'); |
---|
[3102] | 1350 | var nameRoom = _room.getAttribute( 'from' ); |
---|
[3177] | 1351 | |
---|
[3264] | 1352 | _ROOM.setAttribute( 'nameRoom', unescape((nameRoom.substring(0, nameRoom.indexOf("@"))).toUpperCase()) ); |
---|
[3102] | 1353 | _JIDROOM.appendChild( _xml.createTextNode(nameRoom) ); |
---|
| 1354 | _ROOM.appendChild( _JIDROOM ); |
---|
[3177] | 1355 | |
---|
[3102] | 1356 | // Get fields elements; |
---|
| 1357 | var _fields = _room.getElementsByTagName( 'field' ); |
---|
[3177] | 1358 | |
---|
[3102] | 1359 | for ( var f = 0; f < _fields.length; f++ ) |
---|
| 1360 | { |
---|
[3177] | 1361 | if ( _fields[ f ].getAttribute( 'var' ) ) |
---|
[3102] | 1362 | { |
---|
| 1363 | if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_description' ) |
---|
| 1364 | { |
---|
| 1365 | var _description = _xml.createElement("description"); |
---|
| 1366 | _description.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue ) ); |
---|
| 1367 | _ROOM.appendChild( _description ); |
---|
| 1368 | } |
---|
| 1369 | |
---|
| 1370 | if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_occupants' ) |
---|
| 1371 | { |
---|
| 1372 | var _occupants = _xml.createElement("occupants") |
---|
| 1373 | _occupants.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue) ); |
---|
| 1374 | _ROOM.appendChild( _occupants ); |
---|
| 1375 | } |
---|
| 1376 | } |
---|
| 1377 | } |
---|
| 1378 | |
---|
| 1379 | // Get feature elements; |
---|
| 1380 | var _feature = _room.getElementsByTagName( 'feature' ); |
---|
| 1381 | |
---|
| 1382 | for( var f = 0 ; f < _feature.length; f++ ) |
---|
| 1383 | { |
---|
[3177] | 1384 | if ( _feature[ f ].getAttribute( 'var' ) ) |
---|
[3102] | 1385 | { |
---|
| 1386 | if( _feature[ f ].getAttribute( 'var' ) == 'muc_unsecured' ) |
---|
| 1387 | { |
---|
| 1388 | var _password = _xml.createElement("password"); |
---|
| 1389 | _password.appendChild( _xml.createTextNode("false") ); |
---|
| 1390 | _ROOM.appendChild( _password ); |
---|
| 1391 | } |
---|
| 1392 | else if( _feature[ f ].getAttribute( 'var' ) == 'muc_passwordprotected' ) |
---|
| 1393 | { |
---|
| 1394 | var _password = _xml.createElement("password"); |
---|
| 1395 | _password.appendChild( _xml.createTextNode("true") ); |
---|
| 1396 | _ROOM.appendChild( _password ); |
---|
| 1397 | } |
---|
| 1398 | } |
---|
| 1399 | } |
---|
| 1400 | |
---|
| 1401 | _listRooms.appendChild( _ROOM ); |
---|
| 1402 | |
---|
| 1403 | show( ); |
---|
| 1404 | }; |
---|
| 1405 | |
---|
| 1406 | var _get_room_info = function( _room ) |
---|
| 1407 | { |
---|
| 1408 | TrophyIM.connection.sendIQ( |
---|
| 1409 | $iq( { "to" : _room, "type" : "get" } ).c( "query",{xmlns: Strophe.NS.DISCO_INFO } ), |
---|
| 1410 | _add_room, |
---|
| 1411 | function( a ) |
---|
| 1412 | { |
---|
| 1413 | _roomsCount++; |
---|
| 1414 | |
---|
| 1415 | show( ); |
---|
[3124] | 1416 | |
---|
| 1417 | }, 500 ); |
---|
[3102] | 1418 | }; |
---|
| 1419 | |
---|
[3124] | 1420 | if( element.length > 0 ) |
---|
[3102] | 1421 | { |
---|
[3124] | 1422 | for ( var i = 0; i < element.length; i++ ) |
---|
| 1423 | { |
---|
| 1424 | _get_room_info( element[ i ].getAttribute( 'jid' ) ); |
---|
| 1425 | } |
---|
[3102] | 1426 | } |
---|
[3124] | 1427 | else |
---|
| 1428 | { |
---|
| 1429 | show(); |
---|
| 1430 | } |
---|
[3102] | 1431 | } |
---|
| 1432 | |
---|
| 1433 | function getListRooms() |
---|
| 1434 | { |
---|
| 1435 | TrophyIM.getListRooms(); |
---|
| 1436 | } |
---|
| 1437 | |
---|
| 1438 | function joinRoom( jidRoom, nameRoom ) |
---|
| 1439 | { |
---|
[3115] | 1440 | var append_nick = function( room, nick ) |
---|
[3102] | 1441 | { |
---|
| 1442 | var room_nick = room; |
---|
| 1443 | |
---|
| 1444 | if ( nick ) |
---|
| 1445 | { |
---|
| 1446 | room_nick += "/" + nick; |
---|
| 1447 | } |
---|
| 1448 | |
---|
| 1449 | return room_nick; |
---|
| 1450 | } |
---|
| 1451 | |
---|
| 1452 | if( document.getElementById( 'window_chat_room_' + jidRoom + '__main' ) != null ) |
---|
| 1453 | { |
---|
| 1454 | _winBuild('window_chat_room_' + jidRoom, 'display'); |
---|
| 1455 | } |
---|
| 1456 | else |
---|
| 1457 | { |
---|
| 1458 | var nickName = Base64.decode( loadscript.getUserCurrent().jid ); |
---|
| 1459 | nickName = nickName.substring(0, nickName.indexOf('@')); |
---|
| 1460 | |
---|
| 1461 | var _prompt = prompt("Deseja informar um Apelido ?", nickName ); |
---|
| 1462 | |
---|
| 1463 | if( _prompt ) |
---|
| 1464 | { |
---|
| 1465 | _prompt = _prompt.replace(/^\s+|\s+$|^\n|\n$/g,""); |
---|
| 1466 | |
---|
[3320] | 1467 | var room_nick = append_nick( jidRoom, nickName ); |
---|
| 1468 | |
---|
| 1469 | var nickChat = nickName.toString(); |
---|
[3102] | 1470 | |
---|
| 1471 | if( _prompt && _prompt != "" ) |
---|
| 1472 | { |
---|
[3320] | 1473 | nickChat = _prompt.toString(); |
---|
| 1474 | var room_nick = append_nick( jidRoom, _prompt ); |
---|
[3102] | 1475 | } |
---|
| 1476 | |
---|
| 1477 | TrophyIM.makeChatRoom( jidRoom , nameRoom ); |
---|
[3122] | 1478 | |
---|
| 1479 | TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = room_nick; |
---|
[3102] | 1480 | |
---|
| 1481 | TrophyIM.joinChatRoom( room_nick); |
---|
[3320] | 1482 | |
---|
| 1483 | setTimeout(function() |
---|
| 1484 | { |
---|
| 1485 | var _message = nickName.toUpperCase() + " entrou como : " + nickChat; |
---|
| 1486 | |
---|
| 1487 | TrophyIM.sendMessageChatRoom( jidRoom , _message ); |
---|
| 1488 | |
---|
| 1489 | }, 500); |
---|
| 1490 | |
---|
[3102] | 1491 | } |
---|
| 1492 | } |
---|
[3129] | 1493 | |
---|
| 1494 | _winBuild("window_List_Rooms_jabberit_messenger","remove"); |
---|
[3102] | 1495 | } |
---|
| 1496 | |
---|
| 1497 | function loadIM() |
---|
| 1498 | { |
---|
| 1499 | if( arguments.length > 0 ) |
---|
| 1500 | { |
---|
| 1501 | var files = [ |
---|
| 1502 | path_jabberit + 'templates/default/css/button.css', |
---|
| 1503 | path_jabberit + 'templates/default/css/common.css', |
---|
| 1504 | path_jabberit + 'templates/default/css/selectEditableStyle.css', |
---|
| 1505 | path_jabberit + 'templates/default/css/' + theme_jabberit |
---|
| 1506 | ]; |
---|
| 1507 | // FullName |
---|
| 1508 | fullName = arguments[0]; |
---|
| 1509 | |
---|
| 1510 | // Preferences |
---|
| 1511 | _preferencesIM = arguments[1].split(";"); |
---|
| 1512 | |
---|
| 1513 | if( !_preferencesIM[3] ) _preferencesIM[3] = "showContactsOfflineJabberit:true"; |
---|
| 1514 | |
---|
| 1515 | loadScripts(files); |
---|
| 1516 | |
---|
| 1517 | setTimeout(function() |
---|
| 1518 | { |
---|
| 1519 | // Object Xtools |
---|
| 1520 | if( Xtools == null ) |
---|
| 1521 | Xtools = new xtools(path_jabberit); |
---|
| 1522 | |
---|
| 1523 | // Object Conector |
---|
| 1524 | if( conn == null ) |
---|
| 1525 | conn = new AjaxConnector(path_jabberit); |
---|
| 1526 | |
---|
| 1527 | // Object Add User |
---|
| 1528 | if( addUser == null ) |
---|
| 1529 | addUser = new addUserIM(Xtools, conn); |
---|
| 1530 | |
---|
| 1531 | |
---|
| 1532 | // Object SelectEditable |
---|
| 1533 | if( selectEditable == null ) |
---|
| 1534 | selectEditable = new SelectEditable(); |
---|
| 1535 | |
---|
| 1536 | // Add Jabber in StatusBar; |
---|
| 1537 | addIcon(); |
---|
[3228] | 1538 | |
---|
[3102] | 1539 | // Auto Connect |
---|
| 1540 | setTimeout(function() |
---|
| 1541 | { |
---|
| 1542 | if( _preferencesIM[0] === 'openWindowJabberit:true' ) |
---|
| 1543 | { |
---|
[4341] | 1544 | if( SnifferBrowser.isCompatible('ie8','firefox3','firefox4','epiphany2','iceweasel3') ) |
---|
[3228] | 1545 | TrophyIM.load(); |
---|
[3102] | 1546 | } |
---|
| 1547 | |
---|
| 1548 | },1500); |
---|
| 1549 | |
---|
| 1550 | // Auto Status |
---|
| 1551 | autoStatus(); |
---|
| 1552 | configEvents( document, 'onmousemove', autoStatus ); |
---|
| 1553 | configEvents( document, 'onkeypress', autoStatus ); |
---|
| 1554 | |
---|
| 1555 | }, 2000); |
---|
| 1556 | } |
---|
| 1557 | } |
---|
| 1558 | |
---|
| 1559 | loadIM.prototype.adIcon = addIcon; |
---|
| 1560 | loadIM.prototype.actionButton = actionButton; |
---|
| 1561 | loadIM.prototype.addContact = addContact; |
---|
| 1562 | loadIM.prototype.addNewUser = addNewUser; |
---|
| 1563 | loadIM.prototype.clrAllContacts = clrAllContacts; |
---|
| 1564 | loadIM.prototype.configEvents = configEvents; |
---|
| 1565 | loadIM.prototype.createChatRooms = createChatRooms; |
---|
| 1566 | loadIM.prototype.disabledNotificationNewUsers = disabledNotificationNewUsers; |
---|
| 1567 | loadIM.prototype.enabledNotificationNewUsers = enabledNotificationNewUsers; |
---|
| 1568 | loadIM.prototype.getListRooms = getListRooms; |
---|
| 1569 | loadIM.prototype.getIsIE = getIsIE; |
---|
| 1570 | loadIM.prototype.getPhotoUser = getPhotoUser; |
---|
| 1571 | loadIM.prototype.getSmiles = getSmiles; |
---|
| 1572 | loadIM.prototype.getStatusUserIM = getStatusUserIM; |
---|
| 1573 | loadIM.prototype.getStatusMessage = getStatusMessage; |
---|
| 1574 | loadIM.prototype.getShowContactsOffline = getShowContactsOffline; |
---|
| 1575 | loadIM.prototype.getUserCurrent = getUserCurrent; |
---|
| 1576 | loadIM.prototype.getZIndex = getZindex; |
---|
| 1577 | loadIM.prototype.groupsHidden = groupsHidden; |
---|
| 1578 | loadIM.prototype.groupsVisible = groupsVisible; |
---|
| 1579 | loadIM.prototype.joinRoom = joinRoom; |
---|
| 1580 | loadIM.prototype.keyPressSearch = keyPressSearch; |
---|
| 1581 | loadIM.prototype.listRooms = listRooms; |
---|
| 1582 | loadIM.prototype.loginPage = loginPage; |
---|
| 1583 | loadIM.prototype.notification = notificationNewMessage; |
---|
| 1584 | loadIM.prototype.parse = parse; |
---|
| 1585 | loadIM.prototype.preferences = preferences; |
---|
| 1586 | loadIM.prototype.searchUser = searchUser |
---|
| 1587 | loadIM.prototype.setAutorization = setAutorization; |
---|
| 1588 | loadIM.prototype.setMessageStatus = setMessageStatus; |
---|
| 1589 | loadIM.prototype.setPreferences = setPreferences; |
---|
| 1590 | loadIM.prototype.setPresence = setPresence; |
---|
| 1591 | loadIM.prototype.setStatusJabber = setStatusJabber; |
---|
| 1592 | loadIM.prototype.setSelectEditable = setSelectEditable; |
---|
| 1593 | loadIM.prototype.setUserCurrent = setUserCurrent; |
---|
| 1594 | loadIM.prototype.removeContact = removeContact; |
---|
| 1595 | loadIM.prototype.removeElement = removeElement; |
---|
| 1596 | loadIM.prototype.removeGroup = removeGroup; |
---|
| 1597 | loadIM.prototype.renameContact = renameContact; |
---|
| 1598 | loadIM.prototype.renameGroup = renameGroup; |
---|
| 1599 | loadIM.prototype.rosterDiv = rosterDiv; |
---|
| 1600 | loadIM.prototype.windowNotificationNewUsers = windowNotificationNewUsers; |
---|
| 1601 | loadIM.prototype.windowPOPUP = windowPOPUP; |
---|
| 1602 | |
---|
| 1603 | window.LoadIM = loadIM; |
---|
| 1604 | |
---|
| 1605 | // Necessário para não ocasionar problema no ExpressoMail |
---|
| 1606 | // quando os itens abaixo não são criados pelo próprio ExpressoMail |
---|
[3228] | 1607 | if( SnifferBrowser.isCompatible('is_ie') ) |
---|
[3102] | 1608 | { |
---|
| 1609 | configEvents( window, 'onload', function( ) |
---|
| 1610 | { |
---|
| 1611 | if ( ! document.getElementById( 'cc_msg_err_serialize_data_unknown' ) ) |
---|
| 1612 | { |
---|
| 1613 | var fix = document.createElement('input'); |
---|
| 1614 | fix.type = 'hidden'; |
---|
| 1615 | fix.id = 'cc_msg_err_serialize_data_unknown'; |
---|
| 1616 | |
---|
| 1617 | document.appendChild( fix ); |
---|
| 1618 | } |
---|
| 1619 | if ( ! window.showMessage ) |
---|
| 1620 | window.showMessage = function(){}; |
---|
| 1621 | }); |
---|
| 1622 | } |
---|
| 1623 | |
---|
| 1624 | })(); |
---|