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