[382] | 1 | (function() |
---|
| 2 | { |
---|
[697] | 3 | var _autoStatusTime = 60000; // 1 minuto |
---|
| 4 | var _autoStatus; |
---|
[1530] | 5 | var _conn = new JITConnector(path_jabberit); |
---|
| 6 | var Xtools = new JITXtools(path_jabberit); |
---|
[751] | 7 | var _showhidden = new ShowHidden(300); |
---|
[1530] | 8 | var _win_contacts = null; |
---|
[382] | 9 | var myWindow = ''; |
---|
| 10 | var flagMouseOver = ''; |
---|
[417] | 11 | var flagOpenIM = ''; |
---|
[622] | 12 | var flagOpenPopup = ''; |
---|
[697] | 13 | var flagAwayIM = ''; |
---|
[751] | 14 | var itensSubMenu = []; |
---|
[382] | 15 | |
---|
[417] | 16 | // Sniffer Browser |
---|
[1530] | 17 | var agt = navigator.userAgent.toLowerCase(); |
---|
[382] | 18 | var is_major = parseInt(navigator.appVersion); |
---|
| 19 | var is_minor = parseFloat(navigator.appVersion); |
---|
| 20 | var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) |
---|
| 21 | && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) |
---|
| 22 | && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); |
---|
| 23 | var is_gecko = (agt.indexOf('gecko') != -1); |
---|
| 24 | var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1); |
---|
| 25 | var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); |
---|
| 26 | var is_ie3 = (is_ie && (is_major < 4)); |
---|
| 27 | var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) ); |
---|
| 28 | var is_ie4up = (is_ie && (is_major >= 4)); |
---|
| 29 | var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); |
---|
| 30 | var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1)); |
---|
| 31 | var is_ie5up = (is_ie && !is_ie3 && !is_ie4); |
---|
| 32 | var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5); |
---|
| 33 | var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) ); |
---|
| 34 | var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); |
---|
| 35 | var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); |
---|
| 36 | |
---|
[1530] | 37 | var _ldap = new JITLdap( _conn, Xtools, is_ie ); |
---|
[382] | 38 | |
---|
[697] | 39 | function addContacts() |
---|
| 40 | { |
---|
[1530] | 41 | _ldap.load(myWindow); |
---|
[697] | 42 | } |
---|
| 43 | |
---|
[382] | 44 | function addIcon() |
---|
| 45 | { |
---|
[622] | 46 | |
---|
| 47 | var StatusBar = document.getElementById('divStatusBar'); |
---|
| 48 | |
---|
[439] | 49 | /** |
---|
[622] | 50 | * @quando estiver habilitada a opção fora de escritório nos filtros. |
---|
[439] | 51 | */ |
---|
| 52 | |
---|
[622] | 53 | if( div_write_msg = document.getElementById('em_div_write_msg') ) |
---|
| 54 | { |
---|
| 55 | var StatusBarIM = document.getElementById('JabberMessenger'); |
---|
| 56 | div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg); |
---|
| 57 | StatusBarIM.style.paddingLeft = '33px'; |
---|
| 58 | return; |
---|
| 59 | } |
---|
[439] | 60 | |
---|
[622] | 61 | if( StatusBar ) |
---|
[382] | 62 | { |
---|
| 63 | StatusBar.style.paddingLeft = '33px'; |
---|
[439] | 64 | |
---|
[622] | 65 | var _div = document.createElement('div'); |
---|
| 66 | _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); |
---|
| 67 | StatusBar.parentNode.insertBefore(_div,StatusBar); |
---|
| 68 | |
---|
[439] | 69 | var divJabber = document.createElement('div'); |
---|
| 70 | divJabber.setAttribute('id', 'JabberMessenger'); |
---|
| 71 | |
---|
[382] | 72 | var _status = top.document.createElement('div'); |
---|
[439] | 73 | _status.setAttribute('id', 'jabberit_login'); |
---|
[382] | 74 | _status.style.background = 'no-repeat'; |
---|
| 75 | _status.style.backgroundImage = 'url(' + jabberit_group_open.src + ')'; |
---|
| 76 | _status.style.float = 'left'; |
---|
| 77 | _status.style.height = '15px'; |
---|
| 78 | _status.style.left = '7px'; |
---|
| 79 | _status.style.margin = '8 0 0 10px'; |
---|
| 80 | _status.style.padding = '0px'; |
---|
| 81 | _status.style.position = 'absolute'; |
---|
| 82 | _status.style.width = '15px'; |
---|
| 83 | _status.style.cursor = 'pointer'; |
---|
| 84 | |
---|
[439] | 85 | divJabber.insertBefore(_status,divJabber.firstChild); |
---|
[382] | 86 | |
---|
| 87 | var _menu; |
---|
[697] | 88 | _menu = top.document.createElement('div'); |
---|
[382] | 89 | _menu.setAttribute('id','fast_menu_jabberit'); |
---|
[1530] | 90 | _menu.className = "x-menu"; |
---|
[382] | 91 | _menu.style.zIndex = '99999'; |
---|
[697] | 92 | _menu.onmouseout = function(){ _showhidden.hiddenObject(false); }; |
---|
| 93 | _menu.onmouseover = function(){ _showhidden.hiddenObject(true); }; |
---|
[439] | 94 | |
---|
| 95 | divJabber.insertBefore(_menu, divJabber.firstChild); |
---|
[382] | 96 | |
---|
| 97 | var _menu_div = top.document.createElement('div'); |
---|
[622] | 98 | _menu_div.setAttribute('id','status_Jabber_Expresso'); |
---|
[382] | 99 | _menu_div.style.background = 'no-repeat'; |
---|
| 100 | _menu_div.style.backgroundImage = 'url(' + jabberit_add_user.src + ')'; |
---|
| 101 | _menu_div.style.float = 'left'; |
---|
| 102 | _menu_div.style.height = '18px'; |
---|
| 103 | _menu_div.style.left = '19px'; |
---|
| 104 | _menu_div.style.margin = '0 0 0 10px'; |
---|
| 105 | _menu_div.style.padding = '0px'; |
---|
| 106 | _menu_div.style.position = 'absolute'; |
---|
| 107 | _menu_div.style.width = '18px'; |
---|
| 108 | _menu_div.style.cursor = 'pointer'; |
---|
[1569] | 109 | _menu_div.style.zindex = '999999'; |
---|
[382] | 110 | |
---|
[622] | 111 | statusJabberExpresso = _menu_div; |
---|
| 112 | |
---|
[439] | 113 | divJabber.insertBefore(_menu_div, divJabber.firstChild); |
---|
| 114 | StatusBar.insertBefore(divJabber, StatusBar.firstChild); |
---|
[382] | 115 | |
---|
[1530] | 116 | configEvents(_menu_div,'onclick', windowShow); |
---|
[382] | 117 | |
---|
| 118 | configEvents( |
---|
| 119 | _status, |
---|
| 120 | 'onclick', |
---|
| 121 | function() |
---|
| 122 | { |
---|
| 123 | var _options = [ |
---|
[1530] | 124 | ['Add Contact', addContacts], |
---|
| 125 | ['Help', helpJabberit], |
---|
[697] | 126 | ['Preferences', preferences], |
---|
| 127 | ['Change Status', subMenuChangeStatus] |
---|
[382] | 128 | ]; |
---|
| 129 | |
---|
[1530] | 130 | var _style_text = 'cursor: pointer;' + |
---|
| 131 | 'padding:2px 2px 2px 15px;' + |
---|
| 132 | 'background: no-repeat url(' + jabberit_group_close.src + ');'; |
---|
[382] | 133 | |
---|
[1530] | 134 | var _xml = Xtools.xml('menu'); |
---|
[382] | 135 | var _option; |
---|
| 136 | var _item; |
---|
| 137 | var _action; |
---|
| 138 | var _style; |
---|
| 139 | |
---|
| 140 | for ( var i in _options ) |
---|
| 141 | { |
---|
| 142 | _option = _xml.createElement('option'); |
---|
| 143 | |
---|
| 144 | _item = _xml.createElement('item'); |
---|
| 145 | _item.appendChild(_xml.createTextNode(jabberitGetLang(_options[i][0]))); |
---|
| 146 | |
---|
| 147 | _style = _xml.createElement('style'); |
---|
| 148 | _style.appendChild(_xml.createTextNode(_style_text)); |
---|
| 149 | |
---|
| 150 | _option.appendChild(_item); |
---|
| 151 | _option.appendChild(_style); |
---|
| 152 | |
---|
| 153 | _xml.documentElement.appendChild(_option); |
---|
| 154 | } |
---|
| 155 | |
---|
[1530] | 156 | _menu.innerHTML = Xtools.parse(_xml, 'options.xsl'); |
---|
[382] | 157 | _showhidden.action('onmouseover', 'onmouseout', _menu); |
---|
| 158 | |
---|
| 159 | _item = _menu.firstChild; |
---|
| 160 | |
---|
| 161 | for ( var i in _options ) |
---|
| 162 | { |
---|
| 163 | _item.childNodes[i].setAttribute('presence', _options[i]); |
---|
[1530] | 164 | configEvents( _item.childNodes[i], 'onclick', _options[i][1] ); |
---|
[382] | 165 | } |
---|
[697] | 166 | }); |
---|
| 167 | } |
---|
| 168 | } |
---|
[622] | 169 | |
---|
[1530] | 170 | function addUser() |
---|
| 171 | { |
---|
| 172 | _ldap.addUser(); |
---|
| 173 | } |
---|
| 174 | |
---|
[697] | 175 | function autoStatus() |
---|
| 176 | { |
---|
| 177 | if ( _autoStatus ) |
---|
| 178 | clearTimeout(_autoStatus); |
---|
[622] | 179 | |
---|
[697] | 180 | var _div_status = document.getElementById('status_Jabber_Expresso'); |
---|
| 181 | if ( _div_status ) |
---|
| 182 | { |
---|
| 183 | var _status = _div_status.style.backgroundImage; |
---|
| 184 | _status = _status.substr(_status.lastIndexOf('/') + 1); |
---|
| 185 | _status = _status.substr(0, _status.indexOf('.')); |
---|
| 186 | if ( _status == 'xa' && _div_status.getAttribute('autoStatus') ) |
---|
| 187 | { |
---|
| 188 | _div_status.removeAttribute('autoStatus'); |
---|
| 189 | changeStatusJava("2"); |
---|
| 190 | } |
---|
| 191 | } |
---|
[622] | 192 | |
---|
[697] | 193 | var TimeStatus = flagAwayIM.split(':'); |
---|
| 194 | |
---|
| 195 | if( TimeStatus[1] ) |
---|
| 196 | _autoStatus = setTimeout(autoStatusHandler, parseInt(TimeStatus[1])*_autoStatusTime); |
---|
| 197 | else |
---|
| 198 | _autoStatus = setTimeout(autoStatusHandler, parseInt(_autoStatusTime)); |
---|
[382] | 199 | } |
---|
| 200 | |
---|
[697] | 201 | function autoStatusHandler() |
---|
[382] | 202 | { |
---|
[697] | 203 | var _div_status = document.getElementById('status_Jabber_Expresso'); |
---|
| 204 | if ( _div_status ) |
---|
| 205 | { |
---|
| 206 | var _status = _div_status.style.backgroundImage; |
---|
| 207 | _status = _status.substr(_status.lastIndexOf('/') + 1); |
---|
| 208 | _status = _status.substr(0, _status.indexOf('.')); |
---|
| 209 | if ( _status == 'available' ) |
---|
| 210 | { |
---|
| 211 | _div_status.setAttribute('autoStatus','true'); |
---|
| 212 | changeStatusJava("5"); |
---|
| 213 | } |
---|
| 214 | } |
---|
[382] | 215 | } |
---|
| 216 | |
---|
[697] | 217 | function changeStatusJava() |
---|
| 218 | { |
---|
| 219 | if(arguments.length > 0 ) |
---|
| 220 | { |
---|
| 221 | try |
---|
| 222 | { |
---|
[751] | 223 | var status = arguments[0]; |
---|
| 224 | var msg = ( arguments[1] ) ? arguments[1] : ""; |
---|
| 225 | |
---|
[697] | 226 | // If Layer; |
---|
| 227 | if( elementIframe = document.getElementById('iframe_applet_jabberit') ) |
---|
| 228 | { |
---|
| 229 | if( !is_ie ) |
---|
[751] | 230 | elementIframe.contentDocument.applets[0].changeStatusfromExpresso(status, msg); |
---|
[697] | 231 | else |
---|
[751] | 232 | elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(status, msg); |
---|
[697] | 233 | } |
---|
| 234 | else // If Pop-Up |
---|
| 235 | { |
---|
[751] | 236 | myWindow.document.applets[0].changeStatusfromExpresso(status, msg); |
---|
[697] | 237 | } |
---|
[751] | 238 | |
---|
[697] | 239 | } |
---|
| 240 | catch(e) |
---|
| 241 | { |
---|
| 242 | if( confirm('Deseja conectar o IM ?') ) |
---|
[1530] | 243 | windowShow(); |
---|
[697] | 244 | } |
---|
| 245 | } |
---|
| 246 | } |
---|
| 247 | |
---|
[382] | 248 | function configEvents(pObj, pEvent, pHandler) |
---|
| 249 | { |
---|
| 250 | if ( typeof pObj == 'object' ) |
---|
| 251 | { |
---|
| 252 | if ( pEvent.substring(0, 2) == 'on' ) |
---|
| 253 | pEvent = pEvent.substring(2, pEvent.length); |
---|
| 254 | |
---|
| 255 | if ( pObj.addEventListener ) |
---|
| 256 | pObj.addEventListener(pEvent, pHandler, false); |
---|
| 257 | else if ( pObj.attachEvent ) |
---|
| 258 | pObj.attachEvent('on' + pEvent, pHandler); |
---|
| 259 | } |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | function closeWindow() |
---|
| 263 | { |
---|
| 264 | myWindow = ''; |
---|
| 265 | } |
---|
| 266 | |
---|
[622] | 267 | function getElementStatus() |
---|
[382] | 268 | { |
---|
[622] | 269 | return document.getElementById('status_Jabber_Expresso'); |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | function getPreferences() |
---|
| 273 | { |
---|
| 274 | if( flagOpenIM == '' ) |
---|
[382] | 275 | { |
---|
[1801] | 276 | _conn.go("$this.preferences.getPreferences", |
---|
[622] | 277 | function(data) |
---|
| 278 | { |
---|
| 279 | var autoConnect = ''; |
---|
| 280 | flagOpenIM = data; |
---|
[697] | 281 | |
---|
[622] | 282 | if( data.indexOf(';') != -1) |
---|
| 283 | { |
---|
| 284 | var temp = data.split(';'); |
---|
| 285 | autoConnect = flagOpenIM = temp[0]; |
---|
[697] | 286 | |
---|
| 287 | // Open as Pop-Up |
---|
[622] | 288 | flagOpenPopup = 'openWindowJabberitPopUp:false'; |
---|
| 289 | |
---|
| 290 | if( temp[1] ) |
---|
| 291 | { |
---|
| 292 | if( temp[1] == 'openWindowJabberitPopUp:true' || temp[1] == 'openWindowJabberitPopUp:false') |
---|
| 293 | flagOpenPopup = temp[1]; |
---|
| 294 | } |
---|
[697] | 295 | |
---|
| 296 | // Away |
---|
| 297 | flagAwayIM = 'flagAwayIM:5'; |
---|
| 298 | |
---|
| 299 | if( temp[2] ) |
---|
| 300 | { |
---|
| 301 | flagAwayIM = temp[2]; |
---|
| 302 | } |
---|
[622] | 303 | } |
---|
| 304 | else |
---|
| 305 | { |
---|
| 306 | autoConnect = flagOpenIM; |
---|
| 307 | } |
---|
[697] | 308 | |
---|
[622] | 309 | if( autoConnect == 'openWindowJabberit:true' ) |
---|
| 310 | { |
---|
[1530] | 311 | setTimeout('loadscript.windowHidden();', 2500); |
---|
[622] | 312 | } |
---|
| 313 | }); |
---|
[382] | 314 | } |
---|
[622] | 315 | |
---|
[382] | 316 | } |
---|
| 317 | |
---|
| 318 | function helpJabberit() |
---|
| 319 | { |
---|
| 320 | var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes'); |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | function keyPressSearch() |
---|
| 324 | { |
---|
| 325 | var ev = arguments[0]; |
---|
| 326 | var element = arguments[1]; |
---|
| 327 | |
---|
| 328 | if ( ev.keyCode == 13 ) |
---|
| 329 | if( element.value.length >= 4 ) |
---|
| 330 | _ldap.search( element.value ); |
---|
| 331 | else |
---|
| 332 | alert(jabberitGetLang('Your search argument must be longer than 4 characters.')); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | function openPopup() |
---|
| 336 | { |
---|
[622] | 337 | var widPopup = '220'; |
---|
| 338 | |
---|
| 339 | if( is_ie ) |
---|
| 340 | widPopup = '250'; |
---|
| 341 | |
---|
[417] | 342 | try{ |
---|
[624] | 343 | |
---|
[622] | 344 | if(!myWindow ) |
---|
[417] | 345 | { |
---|
[624] | 346 | myWindow = window.open('','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0'); |
---|
| 347 | myWindow.close(); |
---|
[622] | 348 | myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0'); |
---|
[417] | 349 | myWindow.blur(); |
---|
| 350 | configEvents(myWindow,'onbeforeunload', closeWindow ); |
---|
[622] | 351 | } |
---|
| 352 | else |
---|
| 353 | { |
---|
| 354 | for( var i = 15 ; i > 0 ; i-- ) |
---|
| 355 | { |
---|
| 356 | myWindow.moveBy(i,0); myWindow.moveBy(-i,0); |
---|
| 357 | } |
---|
[417] | 358 | myWindow.focus(); |
---|
[622] | 359 | } |
---|
[417] | 360 | } |
---|
| 361 | catch(e) |
---|
| 362 | { |
---|
| 363 | delete myWindow; |
---|
[622] | 364 | myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0'); |
---|
[417] | 365 | myWindow.blur(); |
---|
[1530] | 366 | configEvents( myWindow, 'onbeforeunload', closeWindow ); |
---|
[417] | 367 | } |
---|
[382] | 368 | } |
---|
| 369 | |
---|
| 370 | function openWindow() |
---|
| 371 | { |
---|
[1530] | 372 | if( document.getElementById(_win_contacts.id_window + "__content") == null ) |
---|
[417] | 373 | { |
---|
[2225] | 374 | |
---|
| 375 | var _params = { |
---|
| 376 | 'path' : path_jabberit, |
---|
| 377 | 'width' : ( is_ie ) ? '100%' : '220px' |
---|
| 378 | }; |
---|
| 379 | |
---|
| 380 | _win_contacts.content = Xtools.parse(Xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params ); |
---|
| 381 | |
---|
| 382 | winBuild( _win_contacts ); |
---|
| 383 | |
---|
| 384 | /*var contacts = function() |
---|
[622] | 385 | { |
---|
[1584] | 386 | var _width = '220px'; |
---|
| 387 | |
---|
| 388 | if( is_ie ) |
---|
| 389 | _width = '100%'; |
---|
| 390 | |
---|
[1530] | 391 | var _params = {'path' : path_jabberit}; |
---|
| 392 | var _content = document.getElementById(_win_contacts.id_window + "__content"); |
---|
[1584] | 393 | _content.innerHTML = Xtools.parse(Xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', {'path' : path_jabberit, 'width' : _width}); |
---|
[2225] | 394 | }*/ |
---|
[1530] | 395 | |
---|
[2225] | 396 | //winBuild( _win_contacts ); |
---|
[1763] | 397 | |
---|
[2225] | 398 | //setTimeout( contacts , 250); |
---|
[551] | 399 | } |
---|
[417] | 400 | } |
---|
| 401 | |
---|
| 402 | function preferences() |
---|
| 403 | { |
---|
[2225] | 404 | var _params = { |
---|
| 405 | 'path' : path_jabberit, |
---|
| 406 | 'lang1' : jabberitGetLang('Your Preferences'), |
---|
| 407 | 'lang2' : jabberitGetLang('Connection'), |
---|
| 408 | 'lang3' : jabberitGetLang('Enable Auto Login IM'), |
---|
| 409 | 'lang4' : jabberitGetLang('Users OffLine'), |
---|
| 410 | 'lang5' : jabberitGetLang('Show friends Offline'), |
---|
| 411 | 'lang6' : jabberitGetLang('Save'), |
---|
| 412 | 'lang7' : jabberitGetLang('Cancel'), |
---|
| 413 | 'lang8' : jabberitGetLang('Window'), |
---|
| 414 | 'lang9' : jabberitGetLang('Open as Pop-Up Window'), |
---|
| 415 | 'lang10' : jabberitGetLang('Away'), |
---|
| 416 | 'lang11' : jabberitGetLang('Set status to away after'), |
---|
| 417 | 'lang12' : jabberitGetLang('minutes'), |
---|
| 418 | 'langYes': jabberitGetLang('Yes'), |
---|
| 419 | 'langNo' : jabberitGetLang('No') |
---|
| 420 | }; |
---|
| 421 | |
---|
[1530] | 422 | var _win_preferences = { |
---|
| 423 | id_window : "jabberit_preferences", |
---|
| 424 | width : 430, |
---|
| 425 | height : 330, |
---|
| 426 | top : 150, |
---|
| 427 | left : 100, |
---|
| 428 | draggable : true, |
---|
| 429 | visible : "display", |
---|
| 430 | resizable : true, |
---|
| 431 | zindex : _ZINDEX++, |
---|
| 432 | title : 'Expresso Messenger - ' + jabberitGetLang('Preferences'), |
---|
[2225] | 433 | closeAction : "remove", |
---|
| 434 | content : Xtools.parse(Xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params) |
---|
| 435 | }; |
---|
[417] | 436 | |
---|
[2225] | 437 | winBuild(_win_preferences); |
---|
| 438 | |
---|
[1530] | 439 | var _preferences = function() |
---|
| 440 | { |
---|
| 441 | // Element openWindowJabberit |
---|
| 442 | var value1 = flagOpenIM.split(':'); |
---|
| 443 | var element1 = document.getElementById(value1[0]); |
---|
| 444 | var valueSelect1 = value1[1]; |
---|
[560] | 445 | |
---|
[1530] | 446 | for(var i = 0; i < element1.options.length; i++) |
---|
| 447 | if( element1.options[i].value == valueSelect1 ) |
---|
| 448 | element1.options[i].selected = true; |
---|
| 449 | |
---|
| 450 | |
---|
| 451 | // Element openWindowJabberitPopUp |
---|
| 452 | var value2 = flagOpenPopup.split(':'); |
---|
| 453 | var element2 = document.getElementById(value2[0]); |
---|
| 454 | var valueSelect2 = value2[1]; |
---|
[697] | 455 | |
---|
[1530] | 456 | for(var i = 0; i < element2.options.length; i++) |
---|
| 457 | if( element2.options[i].value == valueSelect2 ) |
---|
| 458 | element2.options[i].selected = true; |
---|
| 459 | |
---|
| 460 | // Element flagAwayIM |
---|
| 461 | var value3 = flagAwayIM.split(':'); |
---|
| 462 | var element3 = document.getElementById(value3[0]); |
---|
| 463 | element3.value = value3[1]; |
---|
[2225] | 464 | |
---|
| 465 | |
---|
| 466 | var _pButtons = { |
---|
| 467 | 'lang1' : jabberitGetLang('Save'), |
---|
| 468 | 'lang2' : jabberitGetLang('Close'), |
---|
| 469 | 'onclickClose' : 'winBuild("jabberit_preferences","remove");', |
---|
| 470 | 'onclickSubmit' : 'javascript:loadscript.setPrefe();' |
---|
| 471 | }; |
---|
| 472 | |
---|
| 473 | document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); |
---|
[1530] | 474 | } |
---|
| 475 | |
---|
[2225] | 476 | setTimeout(function(){ _preferences();}, 220); |
---|
[417] | 477 | } |
---|
| 478 | |
---|
[382] | 479 | function searchUser() |
---|
| 480 | { |
---|
| 481 | var element = arguments[0].previousSibling; |
---|
| 482 | |
---|
| 483 | if( element.value.length >= 4 ) |
---|
| 484 | _ldap.search( element.value ); |
---|
| 485 | else |
---|
| 486 | alert(jabberitGetLang('Your search argument must be longer than 4 characters.')); |
---|
| 487 | } |
---|
[751] | 488 | |
---|
| 489 | function setItensStatusMenu() |
---|
| 490 | { |
---|
[1435] | 491 | var applet = ""; |
---|
| 492 | |
---|
| 493 | try |
---|
[751] | 494 | { |
---|
[1435] | 495 | // Layer |
---|
| 496 | if( elementIframe = document.getElementById('iframe_applet_jabberit') ) |
---|
| 497 | { |
---|
| 498 | if( !is_ie ) |
---|
| 499 | applet = elementIframe.contentDocument.applets[0]; |
---|
| 500 | else |
---|
| 501 | applet = elementIframe.contentWindow.document.applets[0]; |
---|
| 502 | } |
---|
| 503 | else // Pop-up |
---|
| 504 | { |
---|
| 505 | applet = myWindow.document.applets[0]; |
---|
| 506 | } |
---|
[751] | 507 | |
---|
[1435] | 508 | for( i = 1; i < 6; i++ ) |
---|
| 509 | itensSubMenu[i] = applet.getStatusMessages(i); |
---|
| 510 | |
---|
| 511 | }catch(e){} |
---|
[751] | 512 | } |
---|
[417] | 513 | |
---|
| 514 | function setPreferences() |
---|
| 515 | { |
---|
[560] | 516 | // Element openWindowJabberit |
---|
| 517 | var elementOpenW = document.getElementById('openWindowJabberit'); |
---|
| 518 | var value = ''; |
---|
[622] | 519 | var flagReload = false; |
---|
[417] | 520 | |
---|
[560] | 521 | for(var i = 0 ; i < elementOpenW.options.length; i++) |
---|
| 522 | if( elementOpenW.options[i].selected == true) |
---|
| 523 | { |
---|
| 524 | value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value; |
---|
[622] | 525 | flagOpenIM = 'openWindowJabberit:' + elementOpenW.options[i].value; |
---|
[560] | 526 | } |
---|
| 527 | |
---|
[622] | 528 | // Element openWindowJabberitPopUp |
---|
| 529 | var elementOpenPop = document.getElementById('openWindowJabberitPopUp'); |
---|
| 530 | |
---|
| 531 | for(var i = 0; i < elementOpenPop.options.length; i++ ) |
---|
| 532 | if( elementOpenPop.options[i].selected == true ) |
---|
[560] | 533 | { |
---|
[622] | 534 | value += '&preferences2=openWindowJabberitPopUp:' + elementOpenPop.options[i].value; |
---|
| 535 | |
---|
| 536 | if( flagOpenPopup != 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value) |
---|
| 537 | flagReload = true; |
---|
| 538 | |
---|
| 539 | flagOpenPopup = 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value; |
---|
| 540 | } |
---|
[697] | 541 | |
---|
| 542 | // Element flagAwayIM |
---|
| 543 | var elementFlagIM = document.getElementById('flagAwayIM'); |
---|
| 544 | |
---|
| 545 | if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 ) |
---|
| 546 | { |
---|
| 547 | flagAwayIM = 'flagAwayIM:' + elementFlagIM.value; |
---|
| 548 | value += '&preferences3=flagAwayIM:' + elementFlagIM.value; |
---|
| 549 | } |
---|
| 550 | else |
---|
| 551 | { |
---|
| 552 | alert(jabberitGetLang('Enter a value greater than or equal to 1!')); |
---|
| 553 | return false; |
---|
| 554 | } |
---|
| 555 | |
---|
[1801] | 556 | _conn.go('$this.preferences.setPreferences', |
---|
[417] | 557 | function(data) |
---|
| 558 | { |
---|
| 559 | if(data == 'true') |
---|
| 560 | { |
---|
[622] | 561 | if( flagReload ) |
---|
| 562 | { |
---|
| 563 | window.location.reload(); |
---|
[624] | 564 | myWindow.close(); |
---|
[622] | 565 | } |
---|
[417] | 566 | } |
---|
[622] | 567 | else{ alert(jabberitGetLang('Error saving your preferences!')); } |
---|
[1530] | 568 | |
---|
| 569 | winBuild('jabberit_preferences', 'remove'); |
---|
[417] | 570 | }, |
---|
[622] | 571 | value); |
---|
[417] | 572 | } |
---|
| 573 | |
---|
[2225] | 574 | function windowConf(pLeft) |
---|
| 575 | { |
---|
| 576 | if( !is_ie ) |
---|
| 577 | var sizeW = { w : 234, h : 432 }; |
---|
| 578 | else |
---|
| 579 | var sizeW = { w : 264, h : 430 }; |
---|
| 580 | |
---|
| 581 | _win_contacts = { |
---|
| 582 | id_window : "jabberit_contacts", |
---|
| 583 | width : sizeW.w, |
---|
| 584 | height : sizeW.h, |
---|
| 585 | top : 60, |
---|
| 586 | left : pLeft, |
---|
| 587 | draggable : true, |
---|
| 588 | visible : "display", |
---|
| 589 | resizable : true, |
---|
| 590 | zindex : _ZINDEX++, |
---|
| 591 | title : "Expresso Messenger", |
---|
| 592 | closeAction : "hidden", |
---|
| 593 | content : "" |
---|
| 594 | }; |
---|
| 595 | } |
---|
| 596 | |
---|
[1530] | 597 | function windowHidden() |
---|
[382] | 598 | { |
---|
[1530] | 599 | if( _win_contacts == null ) |
---|
[382] | 600 | { |
---|
[2225] | 601 | windowConf(-1500); |
---|
[1530] | 602 | windowContacts(); |
---|
[622] | 603 | } |
---|
| 604 | else |
---|
[1530] | 605 | winBuild( _win_contacts.id_window , "display" ); |
---|
| 606 | } |
---|
[622] | 607 | |
---|
[1530] | 608 | function windowShow() |
---|
| 609 | { |
---|
| 610 | if( _win_contacts == null ) |
---|
| 611 | { |
---|
[2225] | 612 | windowConf(70); |
---|
[1530] | 613 | windowContacts(); |
---|
[382] | 614 | } |
---|
[1530] | 615 | else |
---|
| 616 | winBuild( _win_contacts.id_window , "display" ); |
---|
[382] | 617 | } |
---|
[1530] | 618 | |
---|
| 619 | function windowContacts() |
---|
| 620 | { |
---|
| 621 | if( flagOpenPopup === 'openWindowJabberitPopUp:true' ) |
---|
[2225] | 622 | { |
---|
| 623 | openPopup(); |
---|
| 624 | } |
---|
[1530] | 625 | else |
---|
[2225] | 626 | { |
---|
[1530] | 627 | openWindow(); |
---|
[2225] | 628 | } |
---|
[1530] | 629 | } |
---|
[382] | 630 | |
---|
[697] | 631 | function subMenuChangeStatus() |
---|
| 632 | { |
---|
| 633 | if(document.getElementById('subMenu_Change_Status_JabberIt') == null ) |
---|
| 634 | { |
---|
| 635 | var _itens = [ |
---|
[1530] | 636 | ['Online', 'loadscript.subMnChStIt("2",this);', 'available_jabberit.src','jabberit_group_close.src'], |
---|
| 637 | ['Free For Chat', 'loadscript.subMnChStIt("1",this);', 'chat_jabberit.src','jabberit_group_close.src'], |
---|
| 638 | ['Xa', 'loadscript.subMnChStIt("3",this);','xa_jabberit.src','jabberit_group_close.src'], |
---|
| 639 | ['Dnd', 'loadscript.subMnChStIt("4",this);','dnd_jabberit.src','jabberit_group_close.src'], |
---|
| 640 | ['Away', 'loadscript.subMnChStIt("5",this);','away_jabberit.src','jabberit_group_close.src'], |
---|
[751] | 641 | ['Invisible', 'loadscript.subMnChStIt("6",this);','invisible_jabberit.src'] |
---|
[697] | 642 | ]; |
---|
| 643 | |
---|
[1530] | 644 | var _itensMenu = "<dl style='margin:2px 2px !important; font-size:8pt !important;'>"; |
---|
[697] | 645 | |
---|
| 646 | for(var i in _itens) |
---|
| 647 | { |
---|
[1530] | 648 | _itensMenu += '<dt onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this, false);" style="cursor: pointer;">'; |
---|
[751] | 649 | _itensMenu += "<div "; |
---|
| 650 | if( _itens[i][3] ) |
---|
| 651 | _itensMenu += "style='background: url(" + eval(_itens[i][3]) + ") no-repeat center right'"; |
---|
| 652 | _itensMenu += "onclick="+_itens[i][1] +"><img src='" + eval(_itens[i][2]) + "' style='margin-right:3px;'/>" + jabberitGetLang(_itens[i][0]) + "</div></dt>"; |
---|
[697] | 653 | } |
---|
| 654 | |
---|
| 655 | _itensMenu += "</dl>"; |
---|
| 656 | |
---|
| 657 | var _subMenu_div = document.createElement("div"); |
---|
| 658 | _subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt'); |
---|
[1530] | 659 | _subMenu_div.className = 'x-subMenuChangeStatus'; |
---|
| 660 | _subMenu_div.style.left = '55px'; |
---|
| 661 | _subMenu_div.style.width = ( is_ie ) ? '160px': '140px';; |
---|
| 662 | _subMenu_div.style.zindex = '99999'; |
---|
| 663 | _subMenu_div.innerHTML = _itensMenu; |
---|
[697] | 664 | |
---|
| 665 | var elementParent = document.getElementById('fast_menu_jabberit'); |
---|
| 666 | elementParent.appendChild(_subMenu_div); |
---|
[1435] | 667 | |
---|
| 668 | setItensStatusMenu(); |
---|
[697] | 669 | } |
---|
| 670 | } |
---|
[751] | 671 | |
---|
| 672 | function subMenuChangeStatusItens() |
---|
| 673 | { |
---|
| 674 | if( arguments.length > 0 ) |
---|
| 675 | { |
---|
| 676 | var status = arguments[0]; |
---|
| 677 | var element = arguments[1]; |
---|
| 678 | var msg = ""; |
---|
[697] | 679 | |
---|
[751] | 680 | if( itensSubMenu.length > 0 ) |
---|
| 681 | { |
---|
| 682 | var string = ""; |
---|
| 683 | for( var i = 0; i < itensSubMenu.length ; i++ ) |
---|
| 684 | { |
---|
| 685 | if( itensSubMenu[i] != undefined ) |
---|
| 686 | { |
---|
| 687 | string = itensSubMenu[i].substring(1); |
---|
| 688 | string = string.substring(0, string.indexOf("]")).toString(); |
---|
| 689 | |
---|
| 690 | if( string != "" ) |
---|
| 691 | { |
---|
| 692 | if( status == i ) |
---|
| 693 | { |
---|
| 694 | if ( ! ( string.indexOf( ',' ) < 0 ) ) |
---|
| 695 | { |
---|
| 696 | var phases = string.split(','); |
---|
[1530] | 697 | var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;'>"; |
---|
[751] | 698 | for ( var m = 0; m < phases.length; m++ ) |
---|
| 699 | { |
---|
[1530] | 700 | _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>"; |
---|
[751] | 701 | _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+phases[m]+"\")'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + phases[m] + "</div></dt>"; |
---|
| 702 | } |
---|
| 703 | _itensMenu += "</dl>"; |
---|
| 704 | } |
---|
| 705 | else |
---|
| 706 | { |
---|
[1530] | 707 | var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;'>"; |
---|
[751] | 708 | _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>"; |
---|
| 709 | _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+string+"\");'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + string + "</div></dt>"; |
---|
| 710 | _itensMenu += "</dl>"; |
---|
| 711 | } |
---|
| 712 | } |
---|
| 713 | |
---|
| 714 | for( var j = 0 ; j < 6 ; j++ ) |
---|
| 715 | { |
---|
| 716 | if( document.getElementById('ItemSubMenuJabberd_' + j) != null ) |
---|
| 717 | { |
---|
| 718 | var ElementItem = document.getElementById('ItemSubMenuJabberd_' + j); |
---|
| 719 | ElementItem.parentNode.removeChild(ElementItem); |
---|
| 720 | } |
---|
| 721 | } |
---|
| 722 | } |
---|
| 723 | } |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | if( _itensMenu ) |
---|
| 727 | { |
---|
| 728 | var _subMenuItem_div = document.createElement("div"); |
---|
| 729 | _subMenuItem_div.setAttribute('id','ItemSubMenuJabberd_' + status); |
---|
[1530] | 730 | _subMenuItem_div.className = "x-subMenuChangeStatusItens"; |
---|
| 731 | _subMenuItem_div.style.margin = ( is_ie ) ? '-3px 5px 0px 0px' : '-20px 5px 0px 0px'; |
---|
| 732 | _subMenuItem_div.style.left = ( is_ie ) ? '157px' : '140px'; |
---|
| 733 | _subMenuItem_div.style.width = ( is_ie ) ? '180px': '160px'; |
---|
| 734 | _subMenuItem_div.style.zindex = '99999'; |
---|
| 735 | _subMenuItem_div.innerHTML = _itensMenu; |
---|
[751] | 736 | |
---|
| 737 | element.appendChild( _subMenuItem_div ); |
---|
[1530] | 738 | |
---|
[751] | 739 | }else |
---|
| 740 | changeStatusJava(status,""); |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | } |
---|
| 744 | |
---|
[382] | 745 | function Load() |
---|
| 746 | { |
---|
| 747 | addIcon(); |
---|
[417] | 748 | getPreferences(); |
---|
[697] | 749 | |
---|
| 750 | // AutoStatus Away |
---|
| 751 | autoStatus(); |
---|
| 752 | configEvents(document, 'onmousemove', autoStatus); |
---|
| 753 | configEvents(document, 'onkeypress', autoStatus); |
---|
[382] | 754 | } |
---|
| 755 | |
---|
[751] | 756 | Load.prototype.adIcon = addIcon; |
---|
[1530] | 757 | Load.prototype.addUser = addUser; |
---|
[751] | 758 | Load.prototype.autoStatusIM = autoStatus; |
---|
| 759 | Load.prototype.chgStatusJava = changeStatusJava; |
---|
| 760 | Load.prototype.closeW = closeWindow; |
---|
| 761 | Load.prototype.getElement = getElementStatus; |
---|
| 762 | Load.prototype.keyPress = keyPressSearch; |
---|
| 763 | Load.prototype.search = searchUser; |
---|
| 764 | Load.prototype.setPrefe = setPreferences; |
---|
| 765 | Load.prototype.subMnChStIt = subMenuChangeStatusItens; |
---|
[1530] | 766 | Load.prototype.windowHidden = windowHidden; |
---|
[697] | 767 | |
---|
[1530] | 768 | configEvents(window, 'onload', function(){ window.loadscript = new Load; }); |
---|
[382] | 769 | |
---|
[697] | 770 | })(); |
---|
| 771 | |
---|
| 772 | // Functions OnMouseOver e OnMouseOut |
---|
| 773 | |
---|
| 774 | function elementOnMouseOut() |
---|
| 775 | { |
---|
| 776 | if( arguments.length > 0 ) |
---|
| 777 | { |
---|
| 778 | var _element = arguments[0]; |
---|
| 779 | _element.style.backgroundColor = ''; |
---|
| 780 | _element.style.border = ''; |
---|
| 781 | if( !arguments[1] ) |
---|
[1530] | 782 | _element.className = ''; |
---|
[697] | 783 | } |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | function elementOnMouseOver() |
---|
| 787 | { |
---|
| 788 | if( arguments.length > 0 ) |
---|
| 789 | { |
---|
| 790 | var _element = arguments[0]; |
---|
[1530] | 791 | _element.className = 'x-menuOnMouseOver'; |
---|
[697] | 792 | } |
---|
[1530] | 793 | } |
---|