[2397] | 1 | (function() |
---|
| 2 | { |
---|
| 3 | var fullName = ""; |
---|
| 4 | var path = ""; |
---|
| 5 | var addUser = null; |
---|
[2437] | 6 | var conn = null; |
---|
| 7 | var selectEditable = null; |
---|
[2397] | 8 | var showhidden = null; |
---|
[2599] | 9 | var timeoutId = null |
---|
[2437] | 10 | var userCurrent = null; |
---|
[2397] | 11 | var Xtools = null; |
---|
| 12 | var zIndex = 9001; |
---|
| 13 | |
---|
| 14 | // Images |
---|
| 15 | var add_user = new Image(); |
---|
| 16 | add_user.src = path_jabberit + 'templates/default/images/adduser_azul.png'; |
---|
| 17 | |
---|
| 18 | var arrow_down = new Image(); |
---|
| 19 | arrow_down.src = path_jabberit + 'templates/default/images/arrow_down.gif'; |
---|
| 20 | |
---|
| 21 | var arrow_right = new Image(); |
---|
| 22 | arrow_right.src = path_jabberit + 'templates/default/images/arrow_right.gif'; |
---|
| 23 | |
---|
| 24 | function actionButton() |
---|
| 25 | { |
---|
| 26 | if( arguments.length > 0 ) |
---|
| 27 | { |
---|
[2471] | 28 | var e = arguments[0]; |
---|
| 29 | var jid = arguments[1]; |
---|
| 30 | var index = arguments[2]; |
---|
[2577] | 31 | var coord = null; |
---|
[2397] | 32 | |
---|
| 33 | if ( !e ) |
---|
[2626] | 34 | e = window.event; |
---|
[2577] | 35 | |
---|
| 36 | var _X = e.clientX + document.body.scrollLeft - document.body.clientLeft; |
---|
| 37 | var _Y = e.clientY + document.body.scrollTop - document.body.clientTop; |
---|
| 38 | |
---|
| 39 | coord = { X : _X, Y : _Y }; |
---|
[2397] | 40 | |
---|
[2577] | 41 | window.document.oncontextmenu = function() |
---|
[2397] | 42 | { |
---|
| 43 | return false; |
---|
| 44 | }; |
---|
[2626] | 45 | |
---|
| 46 | if( e.button ) |
---|
[2577] | 47 | { |
---|
[2626] | 48 | if( e.button > 1 ) |
---|
| 49 | optionsItensContact( jid, index, coord ); |
---|
| 50 | else |
---|
| 51 | TrophyIM.rosterClick(jid); |
---|
| 52 | } |
---|
| 53 | else if( e.which ) |
---|
[2491] | 54 | { |
---|
[2626] | 55 | if( e.which > 1 ) |
---|
| 56 | optionsItensContact( jid, index, coord ); |
---|
| 57 | else |
---|
| 58 | if( e.target.id ) |
---|
| 59 | TrophyIM.rosterClick(jid); |
---|
[2491] | 60 | } |
---|
[2397] | 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
[2437] | 64 | function addContact() |
---|
[2397] | 65 | { |
---|
[2421] | 66 | if( arguments.length > 0 ) |
---|
| 67 | addUser.add(); |
---|
| 68 | else |
---|
| 69 | addUser.show(); |
---|
[2397] | 70 | } |
---|
| 71 | |
---|
| 72 | function addIcon() |
---|
| 73 | { |
---|
| 74 | var StatusBar = getElement('divStatusBar'); |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | * @quando estiver habilitada a opção fora de escritório nos filtros. |
---|
| 78 | */ |
---|
| 79 | |
---|
| 80 | if( div_write_msg = getElement('em_div_write_msg') ) |
---|
| 81 | { |
---|
| 82 | var StatusBarIM = getElement('JabberMessenger'); |
---|
| 83 | StatusBarIM.style.paddingLeft = '33px'; |
---|
| 84 | |
---|
| 85 | div_write_msg.parentNode.insertBefore( StatusBarIM, div_write_msg ); |
---|
| 86 | |
---|
| 87 | return; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | if( StatusBar ) |
---|
| 91 | { |
---|
| 92 | StatusBar.style.paddingLeft = '33px'; |
---|
| 93 | |
---|
| 94 | var _div = document.createElement('div'); |
---|
| 95 | _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); |
---|
| 96 | |
---|
| 97 | StatusBar.parentNode.insertBefore( _div, StatusBar); |
---|
| 98 | |
---|
| 99 | var divJabber = document.createElement('div'); |
---|
| 100 | divJabber.setAttribute('id', 'JabberMessenger'); |
---|
| 101 | |
---|
| 102 | var _fastMenu = top.document.createElement('div'); |
---|
| 103 | _fastMenu.setAttribute('id', 'fast_menu_jabber_expresso'); |
---|
| 104 | _fastMenu.style.background = 'no-repeat'; |
---|
| 105 | _fastMenu.style.backgroundImage = 'url(' + arrow_down.src + ')'; |
---|
| 106 | _fastMenu.style.float = 'left'; |
---|
| 107 | _fastMenu.style.height = '15px'; |
---|
| 108 | _fastMenu.style.left = '7px'; |
---|
| 109 | _fastMenu.style.margin = '8 0 0 10px'; |
---|
| 110 | _fastMenu.style.padding = '0px'; |
---|
| 111 | _fastMenu.style.position = 'absolute'; |
---|
| 112 | _fastMenu.style.width = '15px'; |
---|
| 113 | _fastMenu.style.cursor = 'pointer'; |
---|
| 114 | |
---|
| 115 | divJabber.insertBefore( _fastMenu, divJabber.firstChild ); |
---|
| 116 | |
---|
| 117 | // Add event onclick element _fastMenu |
---|
| 118 | configEvents( _fastMenu, 'onclick', function(){ fastMenu(_fastMenu); }); |
---|
| 119 | |
---|
| 120 | var _statusJabber = top.document.createElement('div'); |
---|
| 121 | _statusJabber.setAttribute('id','status_jabber_expresso'); |
---|
| 122 | _statusJabber.style.background = 'no-repeat'; |
---|
| 123 | _statusJabber.style.backgroundImage = 'url(' + add_user.src +')'; |
---|
| 124 | _statusJabber.style.float = 'left'; |
---|
| 125 | _statusJabber.style.height = '18px'; |
---|
| 126 | _statusJabber.style.left = '19px'; |
---|
| 127 | _statusJabber.style.margin = '0 0 0 10px'; |
---|
| 128 | _statusJabber.style.padding = '0px'; |
---|
| 129 | _statusJabber.style.position = 'absolute'; |
---|
| 130 | _statusJabber.style.width = '18px'; |
---|
| 131 | _statusJabber.style.cursor = 'pointer'; |
---|
| 132 | _statusJabber.style.zindex = '999999'; |
---|
| 133 | |
---|
| 134 | divJabber.insertBefore( _statusJabber, divJabber.firstChild ); |
---|
| 135 | |
---|
| 136 | StatusBar.insertBefore( divJabber, StatusBar.firstChild ); |
---|
| 137 | |
---|
| 138 | // Add event onclick element _statusJabber |
---|
| 139 | configEvents( _statusJabber, 'onclick', function(){ TrophyIM.load();}); |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | |
---|
[2620] | 143 | function clrAllContacts() |
---|
| 144 | { |
---|
| 145 | getElement("JabberIMRoster").innerHTML = ""; |
---|
| 146 | } |
---|
| 147 | |
---|
[2397] | 148 | function configEvents(pObj, pEvent, pHandler) |
---|
| 149 | { |
---|
| 150 | if ( typeof pObj == 'object' ) |
---|
| 151 | { |
---|
| 152 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
| 153 | pEvent = pEvent.substring(2, pEvent.length); |
---|
| 154 | |
---|
| 155 | if ( pObj.addEventListener ) |
---|
| 156 | pObj.addEventListener(pEvent, pHandler, false); |
---|
| 157 | else if ( pObj.attachEvent ) |
---|
| 158 | pObj.attachEvent('on' + pEvent, pHandler); |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | function fastMenu() |
---|
| 163 | { |
---|
| 164 | if( arguments.length > 0 ) |
---|
| 165 | { |
---|
| 166 | var element = arguments[0]; |
---|
[2626] | 167 | |
---|
[2397] | 168 | if( showhidden == null ) |
---|
| 169 | showhidden = new ShowHidden(300); |
---|
| 170 | |
---|
| 171 | var _options = [ |
---|
[2437] | 172 | ['Adicionar Contato', 'loadIM.addContact();' ], |
---|
[2397] | 173 | ['Ajuda', 'alert("2")' ], |
---|
| 174 | ['Preferências', 'alert("3")'], |
---|
| 175 | ]; |
---|
| 176 | |
---|
| 177 | var _itens = ""; |
---|
| 178 | |
---|
| 179 | for( var i in _options ) |
---|
| 180 | { |
---|
[2626] | 181 | if( typeof(_options) == "object" ) |
---|
| 182 | { |
---|
| 183 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
| 184 | _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>'; |
---|
| 185 | _itens += _options[i][0] + '</span><br/>'; |
---|
| 186 | } |
---|
[2397] | 187 | } |
---|
| 188 | |
---|
| 189 | var _optionsItens = document.createElement("div"); |
---|
[2626] | 190 | _optionsItens.style.marginTop = "19px"; |
---|
| 191 | _optionsItens.style.marginLeft = "-8px"; |
---|
[2397] | 192 | _optionsItens.className = "x-menu"; |
---|
[2511] | 193 | _optionsItens.style.zIndex = '999999'; |
---|
[2397] | 194 | _optionsItens.innerHTML = _itens; |
---|
| 195 | |
---|
| 196 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
| 197 | |
---|
| 198 | element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
| 199 | element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
| 200 | element.parentNode.appendChild( _optionsItens ); |
---|
| 201 | |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | function getElement( elementId ) |
---|
| 206 | { |
---|
| 207 | return document.getElementById( elementId ); |
---|
| 208 | } |
---|
| 209 | |
---|
[2511] | 210 | function getPhotoUser( jid ) |
---|
| 211 | { |
---|
| 212 | var _divPhoto = getElement( jid + '__photo' ); |
---|
| 213 | |
---|
| 214 | if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) |
---|
| 215 | { |
---|
| 216 | var _imgUser = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); |
---|
| 217 | _imgUser += '&photo_ldap=' + jid; |
---|
| 218 | |
---|
| 219 | _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; |
---|
| 220 | } |
---|
| 221 | } |
---|
| 222 | |
---|
[2397] | 223 | function getUserCurrent() |
---|
| 224 | { |
---|
| 225 | return userCurrent; |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | function getZindex() |
---|
| 229 | { |
---|
| 230 | return zIndex++; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | function groupsHidden() |
---|
| 234 | { |
---|
| 235 | if( arguments.length > 0 ) |
---|
| 236 | { |
---|
| 237 | var _element = arguments[0]; |
---|
[2626] | 238 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left"; |
---|
[2397] | 239 | _element.onclick = function(){ groupsVisible(_element);}; |
---|
| 240 | |
---|
| 241 | // Hidden all |
---|
| 242 | var _elementNext = _element.nextSibling; |
---|
| 243 | |
---|
| 244 | while( _elementNext ) |
---|
| 245 | { |
---|
[2626] | 246 | if( _elementNext.nodeType == 1 ) |
---|
| 247 | _elementNext.style.display = "none"; |
---|
| 248 | |
---|
[2397] | 249 | _elementNext = _elementNext.nextSibling; |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | function groupsVisible() |
---|
| 255 | { |
---|
| 256 | if( arguments.length > 0 ) |
---|
| 257 | { |
---|
| 258 | var _element = arguments[0]; |
---|
[2626] | 259 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left"; |
---|
[2397] | 260 | _element.onclick = function(){ groupsHidden(_element);}; |
---|
| 261 | |
---|
| 262 | // Display all |
---|
| 263 | var _elementNext = _element.nextSibling; |
---|
| 264 | |
---|
| 265 | while( _elementNext ) |
---|
| 266 | { |
---|
[2626] | 267 | if( _elementNext.nodeType == 1 ) |
---|
| 268 | _elementNext.style.display = "block"; |
---|
| 269 | |
---|
[2397] | 270 | _elementNext = _elementNext.nextSibling; |
---|
| 271 | } |
---|
| 272 | } |
---|
| 273 | } |
---|
| 274 | |
---|
[2411] | 275 | function keyPressSearch() |
---|
| 276 | { |
---|
| 277 | if( arguments.length > 0 ) |
---|
| 278 | { |
---|
| 279 | var ev = arguments[0]; |
---|
| 280 | var element = arguments[1]; |
---|
| 281 | |
---|
| 282 | if ( ev.keyCode == 13 ) |
---|
[2471] | 283 | if( element.value.length >= 3 ) |
---|
[2411] | 284 | searchUser( element.value ); |
---|
| 285 | else |
---|
[2471] | 286 | alert('Your search argument must be longer than 3 characters.'); |
---|
[2411] | 287 | } |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | |
---|
[2397] | 291 | function loginPage() |
---|
| 292 | { |
---|
| 293 | var winLoginPage = |
---|
| 294 | { |
---|
| 295 | id_window : "window_login_page", |
---|
| 296 | width : 260, |
---|
| 297 | height : 150, |
---|
| 298 | top : 100, |
---|
| 299 | left : 400, |
---|
| 300 | draggable : true, |
---|
| 301 | visible : "display", |
---|
| 302 | resizable : true, |
---|
| 303 | zindex : zIndex++, |
---|
| 304 | title : "Login - Expresso Messenger", |
---|
| 305 | closeAction : "remove", |
---|
| 306 | content : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl") |
---|
| 307 | }; |
---|
| 308 | |
---|
| 309 | _winBuild( winLoginPage ); |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | function loadScripts(pFiles) |
---|
| 313 | { |
---|
| 314 | // Load JavaScript |
---|
| 315 | var loadJavaScript = function(pJs) |
---|
| 316 | { |
---|
| 317 | var newScript = document.createElement("script"); |
---|
| 318 | newScript.setAttribute("type", "text/javascript"); |
---|
| 319 | newScript.setAttribute("src", pJs ); |
---|
| 320 | |
---|
| 321 | return newScript; |
---|
| 322 | }; |
---|
| 323 | |
---|
| 324 | // Load CSS |
---|
| 325 | var loadStyleSheet = function(pCss) |
---|
| 326 | { |
---|
| 327 | var newStyle = document.createElement("link"); |
---|
| 328 | newStyle.setAttribute("rel", "stylesheet"); |
---|
| 329 | newStyle.setAttribute("type", "text/css"); |
---|
| 330 | newStyle.setAttribute("href", pCss); |
---|
| 331 | |
---|
| 332 | return newStyle; |
---|
| 333 | }; |
---|
| 334 | |
---|
| 335 | for(var i = 0; i < pFiles.length; i++) |
---|
| 336 | { |
---|
| 337 | if( pFiles[i].indexOf(".js") > -1 ) |
---|
| 338 | document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i])); |
---|
| 339 | |
---|
| 340 | if( pFiles[i].indexOf(".css") > -1 ) |
---|
| 341 | document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i])); |
---|
| 342 | } |
---|
| 343 | } |
---|
[2599] | 344 | |
---|
| 345 | function notificationNewMessage() |
---|
| 346 | { |
---|
| 347 | var oldTitle = document.title; |
---|
| 348 | var newTitle = " ## NOVA MENSAGEM ## "; |
---|
| 349 | var idWindow = arguments[1]; |
---|
| 350 | |
---|
| 351 | if( timeoutId == null) |
---|
| 352 | { |
---|
| 353 | timeoutId = setInterval(function() |
---|
| 354 | { |
---|
| 355 | document.title = document.title == newTitle ? ' ' : newTitle; |
---|
| 356 | |
---|
| 357 | }, 1000); |
---|
| 358 | |
---|
| 359 | configEvents( window, 'onclick', function() |
---|
| 360 | { |
---|
| 361 | clearInterval(timeoutId); |
---|
| 362 | document.title = oldTitle; |
---|
| 363 | timeoutId = null; |
---|
| 364 | }); |
---|
[2620] | 365 | |
---|
| 366 | configEvents( window, 'onkeypress', function() |
---|
| 367 | { |
---|
| 368 | clearInterval(timeoutId); |
---|
| 369 | document.title = oldTitle; |
---|
| 370 | timeoutId = null; |
---|
| 371 | }); |
---|
[2599] | 372 | } |
---|
| 373 | } |
---|
[2397] | 374 | |
---|
| 375 | function optionsItensContact() |
---|
| 376 | { |
---|
| 377 | if( arguments.length > 0 ) |
---|
| 378 | { |
---|
[2471] | 379 | var jid = arguments[0]; |
---|
| 380 | var index = arguments[1]; |
---|
[2577] | 381 | var coord = arguments[2]; |
---|
| 382 | var element = getElement('itenContact_' + jid + '_' + index ); |
---|
[2620] | 383 | var action = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar"; |
---|
[2397] | 384 | |
---|
| 385 | if( showhidden == null ) |
---|
| 386 | showhidden = new ShowHidden(300); |
---|
| 387 | |
---|
| 388 | var _options = [ |
---|
[2620] | 389 | [ action , 'loadIM.setAutorization(\''+jid+'\',\''+index+'\')'], |
---|
| 390 | ['Remover' , 'loadIM.removeContact(\''+jid+'\',\''+index+'\')'], |
---|
| 391 | ['Renomear' , 'loadIM.renameContact(\''+jid+'\',\''+index+'\')'], |
---|
| 392 | ['Trocar grupo' , 'loadIM.renameGroup(\''+jid+'\',\''+index+'\')'] |
---|
[2397] | 393 | ]; |
---|
| 394 | |
---|
| 395 | var _itens = ""; |
---|
| 396 | |
---|
| 397 | for( var i in _options ) |
---|
| 398 | { |
---|
[2626] | 399 | if( typeof(_options[i]) == "object") |
---|
| 400 | { |
---|
| 401 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
| 402 | _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>'; |
---|
| 403 | _itens += _options[i][0] + '</span><br/>'; |
---|
| 404 | } |
---|
[2397] | 405 | } |
---|
| 406 | |
---|
| 407 | var _optionsItens = document.createElement("div"); |
---|
| 408 | _optionsItens.className = "x-menu"; |
---|
[2577] | 409 | _optionsItens.style.top = coord.Y; |
---|
| 410 | _optionsItens.style.left = ( coord.X - element.offsetLeft ); |
---|
| 411 | _optionsItens.style.zIndex = getZindex(); |
---|
[2397] | 412 | _optionsItens.innerHTML = _itens; |
---|
[2577] | 413 | _optionsItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
[2491] | 414 | _optionsItens.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
| 415 | _optionsItens.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
[2471] | 416 | |
---|
[2397] | 417 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
| 418 | |
---|
[2577] | 419 | window.document.body.appendChild(_optionsItens); |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | setTimeout(function() |
---|
| 423 | { |
---|
| 424 | window.document.oncontextmenu = function() |
---|
| 425 | { |
---|
| 426 | return true; |
---|
| 427 | }; |
---|
| 428 | |
---|
| 429 | },500); |
---|
[2397] | 430 | } |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | function parse() |
---|
| 434 | { |
---|
| 435 | if( arguments.length == 2 ) |
---|
| 436 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] ); |
---|
| 437 | |
---|
| 438 | if( arguments.length === 3 ) |
---|
| 439 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); |
---|
| 440 | } |
---|
| 441 | |
---|
[2491] | 442 | function removeContact(jid, index) |
---|
[2437] | 443 | { |
---|
[2471] | 444 | setTimeout(function() |
---|
| 445 | { |
---|
[2491] | 446 | TrophyIM.removeContact(jid, index); |
---|
[2471] | 447 | |
---|
[2491] | 448 | },300); |
---|
[2437] | 449 | } |
---|
| 450 | |
---|
[2577] | 451 | function removeElement( ) |
---|
| 452 | { |
---|
| 453 | if( arguments.length > 0 ) |
---|
| 454 | { |
---|
| 455 | var _element = arguments[0] |
---|
| 456 | var _parent = _element.parentNode; |
---|
| 457 | |
---|
| 458 | _parent.removeChild( _element ); |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | |
---|
[2471] | 462 | function removeGroup() |
---|
| 463 | { |
---|
| 464 | var _parent = arguments[0]; |
---|
| 465 | |
---|
| 466 | if( _parent.childNodes.length <= 2 ) |
---|
| 467 | _parent.parentNode.removeChild(_parent); |
---|
| 468 | } |
---|
| 469 | |
---|
[2584] | 470 | function renameContact() |
---|
[2577] | 471 | { |
---|
[2584] | 472 | if( arguments.length > 0 ) |
---|
| 473 | { |
---|
| 474 | var _jid = arguments[0]; |
---|
| 475 | var _index = arguments[1]; |
---|
| 476 | |
---|
| 477 | TrophyIM.renameContact( _jid, _index ); |
---|
| 478 | } |
---|
[2577] | 479 | } |
---|
| 480 | |
---|
[2584] | 481 | function renameGroup() |
---|
| 482 | { |
---|
| 483 | if( arguments.length > 0 ) |
---|
| 484 | { |
---|
| 485 | var _jid = arguments[0]; |
---|
| 486 | var _index = arguments[1]; |
---|
| 487 | |
---|
| 488 | TrophyIM.renameGroup( _jid , _index ); |
---|
| 489 | } |
---|
| 490 | } |
---|
| 491 | |
---|
[2397] | 492 | function rosterDiv() |
---|
| 493 | { |
---|
| 494 | var paramListContact = |
---|
| 495 | { |
---|
[2607] | 496 | 'idUser' : Base64.decode(getUserCurrent().jid), |
---|
[2511] | 497 | 'full_name' : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), |
---|
[2397] | 498 | 'path_jabberit' : path_jabberit, |
---|
[2511] | 499 | 'zIndex_' : zIndex++ |
---|
[2397] | 500 | }; |
---|
| 501 | |
---|
| 502 | var winRosterDiv = |
---|
| 503 | { |
---|
| 504 | id_window : "window_Roster_im", |
---|
| 505 | width : 250, |
---|
| 506 | height : 410, |
---|
| 507 | top : 50, |
---|
| 508 | left : 50, |
---|
| 509 | draggable : true, |
---|
| 510 | visible : "display", |
---|
| 511 | resizable : true, |
---|
| 512 | zindex : zIndex++, |
---|
| 513 | title : "Contatos - Expresso Messenger", |
---|
| 514 | closeAction : "hidden", |
---|
| 515 | content : Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact) |
---|
| 516 | }; |
---|
| 517 | |
---|
| 518 | _winBuild( winRosterDiv ); |
---|
[2511] | 519 | |
---|
| 520 | // Photo User |
---|
[2607] | 521 | getPhotoUser(Base64.decode(getUserCurrent().jid)); |
---|
[2397] | 522 | } |
---|
| 523 | |
---|
[2411] | 524 | function searchUser() |
---|
| 525 | { |
---|
[2577] | 526 | var _input = getElement('search_user_jabber'); |
---|
[2421] | 527 | |
---|
| 528 | if( _input.value.length >= 3 ) |
---|
| 529 | addUser.search(); |
---|
| 530 | else |
---|
| 531 | alert('Your search argument must be longer than 3 characters.'); |
---|
[2411] | 532 | } |
---|
| 533 | |
---|
[2491] | 534 | function setAutorization(jidTo, indexTo) |
---|
[2437] | 535 | { |
---|
[2491] | 536 | var divItenContact = null; |
---|
| 537 | |
---|
[2577] | 538 | if( ( divItenContact = getElement('itenContact_' + jidTo + '_' + indexTo ))) |
---|
[2491] | 539 | { |
---|
| 540 | var subscription = divItenContact.getAttribute('subscription'); |
---|
| 541 | |
---|
| 542 | switch(subscription) |
---|
| 543 | { |
---|
| 544 | case 'from': |
---|
[2577] | 545 | |
---|
[2607] | 546 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
[2577] | 547 | break; |
---|
| 548 | |
---|
| 549 | case 'none' : |
---|
| 550 | |
---|
[2607] | 551 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
| 552 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
[2577] | 553 | |
---|
| 554 | break; |
---|
| 555 | |
---|
[2491] | 556 | case 'not-in-roster': |
---|
[2577] | 557 | |
---|
| 558 | setTimeout(function() |
---|
| 559 | { |
---|
| 560 | var _add = ""; |
---|
| 561 | |
---|
| 562 | if( ( _add = confirm("Deseja adicionar o usuario!")) ) |
---|
| 563 | { |
---|
| 564 | addUser.add( jidTo, indexTo ); |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | },100); |
---|
| 568 | |
---|
[2491] | 569 | break; |
---|
[2577] | 570 | |
---|
[2491] | 571 | case 'to' : |
---|
[2577] | 572 | |
---|
[2607] | 573 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
[2577] | 574 | |
---|
| 575 | case 'subscribe' : |
---|
| 576 | |
---|
[2607] | 577 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
[2577] | 578 | |
---|
| 579 | break; |
---|
[2491] | 580 | } |
---|
| 581 | } |
---|
[2437] | 582 | } |
---|
| 583 | |
---|
[2397] | 584 | function setPresence() |
---|
| 585 | { |
---|
| 586 | if( arguments.length > 0 ) |
---|
| 587 | { |
---|
| 588 | var element = arguments[0]; |
---|
| 589 | |
---|
| 590 | if( showhidden == null ) |
---|
| 591 | showhidden = new ShowHidden(300); |
---|
| 592 | |
---|
| 593 | var _status = [ |
---|
| 594 | ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'], |
---|
| 595 | ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'], |
---|
| 596 | ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'], |
---|
| 597 | ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], |
---|
| 598 | ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], |
---|
[2620] | 599 | ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'], |
---|
[2626] | 600 | ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'], |
---|
[2397] | 601 | ]; |
---|
| 602 | |
---|
| 603 | var _itens = ""; |
---|
| 604 | |
---|
| 605 | for( var i in _status ) |
---|
| 606 | { |
---|
[2626] | 607 | if( typeof( _status[i]) == "object" ) |
---|
| 608 | { |
---|
| 609 | _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadIM.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">'; |
---|
| 610 | _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>"; |
---|
| 611 | } |
---|
[2397] | 612 | } |
---|
| 613 | |
---|
| 614 | var _statusItens = document.createElement("div"); |
---|
[2626] | 615 | _statusItens.style.marginTop = "65px"; |
---|
| 616 | _statusItens.style.marginLeft = "67px"; |
---|
| 617 | _statusItens.className = "x-menu"; |
---|
| 618 | _statusItens.style.zIndex = '99999'; |
---|
| 619 | _statusItens.innerHTML = _itens; |
---|
| 620 | _statusItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
[2397] | 621 | |
---|
| 622 | showhidden.action('onmouseover', 'onmouseout', _statusItens); |
---|
| 623 | |
---|
| 624 | element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
| 625 | element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
| 626 | element.parentNode.appendChild(_statusItens); |
---|
| 627 | } |
---|
| 628 | } |
---|
[2491] | 629 | |
---|
| 630 | function setSelectEditable(element) |
---|
| 631 | { |
---|
[2577] | 632 | if( getElement('selectBox0') == null ) |
---|
[2491] | 633 | selectEditable.create(element); |
---|
| 634 | } |
---|
| 635 | |
---|
[2397] | 636 | function setStatusJabber() |
---|
| 637 | { |
---|
| 638 | if( arguments.length > 0 ) |
---|
| 639 | { |
---|
[2511] | 640 | if( arguments[1] != 'status' ) |
---|
| 641 | { |
---|
| 642 | var _text = arguments[0]; |
---|
| 643 | var _img = arguments[1]; |
---|
[2626] | 644 | |
---|
| 645 | getElement('statusJabberText').innerHTML = _text; |
---|
| 646 | getElement('statusJabberImg').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')"; |
---|
[2511] | 647 | getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; |
---|
| 648 | } |
---|
[2397] | 649 | } |
---|
| 650 | } |
---|
[2607] | 651 | |
---|
| 652 | function teste_meu(_jid, _password ) |
---|
[2397] | 653 | { |
---|
| 654 | userCurrent = |
---|
| 655 | { |
---|
[2607] | 656 | 'jid' : _jid.substring(11, _jid.length), |
---|
| 657 | 'password' : _password.substring(11, _password.length) |
---|
| 658 | } |
---|
[2397] | 659 | } |
---|
[2607] | 660 | |
---|
| 661 | function setUserCurrent() |
---|
| 662 | { |
---|
| 663 | conn.go('p.ff.data_0', |
---|
| 664 | function(_User) |
---|
| 665 | { |
---|
| 666 | var _user = _User; |
---|
| 667 | |
---|
| 668 | conn.go('p.ff.data_1', |
---|
| 669 | function(_pass) |
---|
| 670 | { |
---|
| 671 | teste_meu( _user, _pass ); |
---|
| 672 | }); |
---|
| 673 | }); |
---|
| 674 | } |
---|
[2411] | 675 | |
---|
[2397] | 676 | function loadIM() |
---|
| 677 | { |
---|
| 678 | if( arguments.length > 0 ) |
---|
| 679 | { |
---|
| 680 | var files = [ |
---|
[2411] | 681 | path_jabberit + 'js/connector.js', |
---|
[2397] | 682 | path_jabberit + 'js/xtools.js', |
---|
| 683 | path_jabberit + 'js/dragdrop.js', |
---|
| 684 | path_jabberit + 'js/makeW.js', |
---|
| 685 | path_jabberit + 'js/show_hidden.js', |
---|
| 686 | path_jabberit + 'js/trophyim.js', |
---|
| 687 | path_jabberit + 'js/AddUser.js', |
---|
[2437] | 688 | path_jabberit + 'js/SelectEditable.js', |
---|
[2421] | 689 | path_jabberit + 'templates/default/css/button.css', |
---|
| 690 | path_jabberit + 'templates/default/css/common.css', |
---|
[2437] | 691 | path_jabberit + 'templates/default/css/selectEditableStyle.css', |
---|
[2397] | 692 | path_jabberit + 'templates/default/css/' + theme_jabberit |
---|
| 693 | ]; |
---|
[2411] | 694 | // FullName |
---|
[2397] | 695 | fullName = arguments[0]; |
---|
| 696 | |
---|
| 697 | loadScripts(files); |
---|
| 698 | |
---|
[2411] | 699 | setTimeout(function() |
---|
| 700 | { |
---|
| 701 | // Object Xtools |
---|
| 702 | if( Xtools == null ) |
---|
| 703 | Xtools = new xtools(path_jabberit); |
---|
| 704 | |
---|
| 705 | // Object Conector |
---|
| 706 | if( conn == null ) |
---|
| 707 | conn = new AjaxConnector(path_jabberit); |
---|
| 708 | |
---|
| 709 | // Object Add User |
---|
| 710 | if( addUser == null ) |
---|
| 711 | addUser = new addUserIM(Xtools, conn); |
---|
| 712 | |
---|
[2437] | 713 | |
---|
| 714 | // Object SelectEditable |
---|
| 715 | if( selectEditable == null ) |
---|
| 716 | selectEditable = new SelectEditable(); |
---|
| 717 | |
---|
[2411] | 718 | // Add Jabber in StatusBar; |
---|
| 719 | addIcon(); |
---|
| 720 | |
---|
| 721 | }, 1000); |
---|
[2397] | 722 | } |
---|
| 723 | } |
---|
| 724 | |
---|
[2599] | 725 | loadIM.prototype.addIcon = addIcon; |
---|
[2397] | 726 | loadIM.prototype.actionButton = actionButton; |
---|
[2437] | 727 | loadIM.prototype.addContact = addContact; |
---|
[2620] | 728 | loadIM.prototype.clrAllContacts = clrAllContacts; |
---|
[2397] | 729 | loadIM.prototype.configEvents = configEvents; |
---|
[2511] | 730 | loadIM.prototype.getPhotoUser = getPhotoUser; |
---|
[2397] | 731 | loadIM.prototype.getUserCurrent = getUserCurrent; |
---|
| 732 | loadIM.prototype.getZIndex = getZindex; |
---|
| 733 | loadIM.prototype.groupsHidden = groupsHidden; |
---|
| 734 | loadIM.prototype.groupsVisible = groupsVisible; |
---|
[2411] | 735 | loadIM.prototype.keyPressSearch = keyPressSearch; |
---|
[2397] | 736 | loadIM.prototype.loginPage = loginPage; |
---|
[2599] | 737 | loadIM.prototype.notification = notificationNewMessage; |
---|
[2397] | 738 | loadIM.prototype.parse = parse; |
---|
[2437] | 739 | loadIM.prototype.searchUser = searchUser |
---|
[2491] | 740 | loadIM.prototype.setAutorization = setAutorization; |
---|
[2397] | 741 | loadIM.prototype.setPresence = setPresence; |
---|
| 742 | loadIM.prototype.setStatusJabber = setStatusJabber; |
---|
[2437] | 743 | loadIM.prototype.setSelectEditable = setSelectEditable; |
---|
[2607] | 744 | loadIM.prototype.setUserCurrent = setUserCurrent; |
---|
[2437] | 745 | loadIM.prototype.removeContact = removeContact; |
---|
[2577] | 746 | loadIM.prototype.removeElement = removeElement; |
---|
[2471] | 747 | loadIM.prototype.removeGroup = removeGroup; |
---|
[2584] | 748 | loadIM.prototype.renameContact = renameContact; |
---|
| 749 | loadIM.prototype.renameGroup = renameGroup; |
---|
[2397] | 750 | loadIM.prototype.rosterDiv = rosterDiv; |
---|
| 751 | |
---|
[2621] | 752 | window.LoadIM = loadIM; |
---|
[2397] | 753 | |
---|
| 754 | })(); |
---|