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 | ['Ajuda', 'alert("2")' ], |
---|
347 | ['Preferências', 'loadscript.preferences();'], |
---|
348 | ]; |
---|
349 | |
---|
350 | var _itens = ""; |
---|
351 | |
---|
352 | for( var i in _options ) |
---|
353 | { |
---|
354 | if( _options[i].constructor == Function ) |
---|
355 | continue; |
---|
356 | |
---|
357 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
358 | _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>'; |
---|
359 | _itens += _options[i][0] + '</span><br/>'; |
---|
360 | } |
---|
361 | |
---|
362 | var _optionsItens = document.createElement("div"); |
---|
363 | _optionsItens.id = "fastMenu_Jabber"; |
---|
364 | _optionsItens.style.marginTop = "19px"; |
---|
365 | _optionsItens.style.marginLeft = "-8px"; |
---|
366 | _optionsItens.className = "x-menu"; |
---|
367 | _optionsItens.style.zIndex = '999999'; |
---|
368 | _optionsItens.innerHTML = _itens; |
---|
369 | _optionsItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
370 | _optionsItens.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
371 | _optionsItens.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
372 | |
---|
373 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
374 | |
---|
375 | element.parentNode.appendChild( _optionsItens ); |
---|
376 | } |
---|
377 | } |
---|
378 | |
---|
379 | function getElement( elementId ) |
---|
380 | { |
---|
381 | return document.getElementById( elementId ); |
---|
382 | } |
---|
383 | |
---|
384 | function getIsIE() |
---|
385 | { |
---|
386 | return is_ie; |
---|
387 | } |
---|
388 | |
---|
389 | function getPhotoUser( jid ) |
---|
390 | { |
---|
391 | try |
---|
392 | { |
---|
393 | var _divPhoto = getElement( jid + '__photo' ); |
---|
394 | |
---|
395 | if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) |
---|
396 | { |
---|
397 | var _imgUser = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); |
---|
398 | _imgUser += '&photo_ldap=' + jid; |
---|
399 | |
---|
400 | _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; |
---|
401 | } |
---|
402 | } |
---|
403 | catch(e) |
---|
404 | {} |
---|
405 | } |
---|
406 | |
---|
407 | function getShowContactsOffline() |
---|
408 | { |
---|
409 | if( _preferencesIM[3] ) |
---|
410 | { |
---|
411 | var showOffline = _preferencesIM[3].split(":"); |
---|
412 | |
---|
413 | if( showOffline[1] === "true") |
---|
414 | return true; |
---|
415 | else |
---|
416 | return false; |
---|
417 | } |
---|
418 | |
---|
419 | return true; |
---|
420 | } |
---|
421 | |
---|
422 | function getSmiles( String ) |
---|
423 | { |
---|
424 | String = String.replace( /:\)|:-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/1.gif'/> "); |
---|
425 | String = String.replace( /:-D/g , " <img src='"+path_jabberit+"templates/default/images/smiles/2.gif'/> "); |
---|
426 | String = String.replace( /;-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/3.gif'/> "); |
---|
427 | String = String.replace( /=-O/g , " <img src='"+path_jabberit+"templates/default/images/smiles/4.gif'/> "); |
---|
428 | String = String.replace( /:P/g , " <img src='"+path_jabberit+"templates/default/images/smiles/5.gif'/> "); |
---|
429 | String = String.replace( /8-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/6.gif'/> "); |
---|
430 | String = String.replace( /\>:o/g , " <img src='"+path_jabberit+"templates/default/images/smiles/7.gif'/> "); |
---|
431 | String = String.replace( /:-\$/g , " <img src='"+path_jabberit+"templates/default/images/smiles/8.gif'/> "); |
---|
432 | String = String.replace( /:s|:-X/g , " <img src='"+path_jabberit+"templates/default/images/smiles/9.gif'/> "); |
---|
433 | String = String.replace( /:-\(/g , " <img src='"+path_jabberit+"templates/default/images/smiles/10.gif'/> "); |
---|
434 | String = String.replace( /:\'\(/g , " <img src='"+path_jabberit+"templates/default/images/smiles/11.gif'/> "); |
---|
435 | String = String.replace( /:\|/g , " <img src='"+path_jabberit+"templates/default/images/smiles/12.gif'/> "); |
---|
436 | String = String.replace( /O:-\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/13.gif'/> "); |
---|
437 | String = String.replace( /\*\*@#%/g , " <img src='"+path_jabberit+"templates/default/images/smiles/14.gif'/> "); |
---|
438 | String = String.replace( /\(I\)/g , " <img src='"+path_jabberit+"templates/default/images/smiles/15.gif'/> "); |
---|
439 | |
---|
440 | return String; |
---|
441 | } |
---|
442 | |
---|
443 | function getStatusMessage() |
---|
444 | { |
---|
445 | return _statusMessage; |
---|
446 | } |
---|
447 | |
---|
448 | function getUserCurrent() |
---|
449 | { |
---|
450 | return userCurrent; |
---|
451 | } |
---|
452 | |
---|
453 | function getZindex() |
---|
454 | { |
---|
455 | return zIndex++; |
---|
456 | } |
---|
457 | |
---|
458 | function groupsHidden() |
---|
459 | { |
---|
460 | if( arguments.length > 0 ) |
---|
461 | { |
---|
462 | var _element = arguments[0]; |
---|
463 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left"; |
---|
464 | _element.onclick = function(){ groupsVisible(_element);}; |
---|
465 | |
---|
466 | // Hidden all |
---|
467 | var _elementNext = _element.nextSibling; |
---|
468 | |
---|
469 | while( _elementNext ) |
---|
470 | { |
---|
471 | if( _elementNext.nodeType == 1 ) |
---|
472 | _elementNext.style.display = "none"; |
---|
473 | |
---|
474 | _elementNext = _elementNext.nextSibling; |
---|
475 | } |
---|
476 | } |
---|
477 | } |
---|
478 | |
---|
479 | function groupsVisible() |
---|
480 | { |
---|
481 | if( arguments.length > 0 ) |
---|
482 | { |
---|
483 | var _element = arguments[0]; |
---|
484 | _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left"; |
---|
485 | _element.onclick = function(){ groupsHidden(_element);}; |
---|
486 | |
---|
487 | // Display all |
---|
488 | var _elementNext = _element.nextSibling; |
---|
489 | |
---|
490 | while( _elementNext ) |
---|
491 | { |
---|
492 | if( _elementNext.nodeType == 1 && _elementNext.nodeName.toLowerCase() == "div" ) |
---|
493 | { |
---|
494 | var is_off = _elementNext.style.backgroundImage.indexOf("unavailable"); |
---|
495 | |
---|
496 | if( is_off > 0 && !getShowContactsOffline()) |
---|
497 | { |
---|
498 | _elementNext.style.display = "none"; |
---|
499 | getElement("span_show_" + _elementNext.id ).style.display = "none"; |
---|
500 | |
---|
501 | } |
---|
502 | else |
---|
503 | { |
---|
504 | _elementNext.style.display = "block"; |
---|
505 | getElement("span_show_" + _elementNext.id ).style.display = "block"; |
---|
506 | } |
---|
507 | } |
---|
508 | |
---|
509 | _elementNext = _elementNext.nextSibling; |
---|
510 | } |
---|
511 | } |
---|
512 | } |
---|
513 | |
---|
514 | function keyPressSearch() |
---|
515 | { |
---|
516 | if( arguments.length > 0 ) |
---|
517 | { |
---|
518 | var ev = arguments[0]; |
---|
519 | var element = arguments[1]; |
---|
520 | |
---|
521 | if ( ev.keyCode == 13 ) |
---|
522 | if( element.value.length >= 3 ) |
---|
523 | searchUser( element.value ); |
---|
524 | else |
---|
525 | alert('Your search argument must be longer than 3 characters.'); |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|
529 | |
---|
530 | function loginPage() |
---|
531 | { |
---|
532 | var paramsLoginPage = |
---|
533 | { |
---|
534 | 'username' : ((( Base64.decode(getUserCurrent().jid) )) ? Base64.decode(getUserCurrent().jid) : ""), |
---|
535 | 'password' : ((( Base64.decode(getUserCurrent().password) )) ? Base64.decode(getUserCurrent().password) : "") |
---|
536 | } |
---|
537 | |
---|
538 | var winLoginPage = |
---|
539 | { |
---|
540 | id_window : "window_login_page", |
---|
541 | width : 260, |
---|
542 | height : 120, |
---|
543 | top : 100, |
---|
544 | left : 400, |
---|
545 | draggable : true, |
---|
546 | visible : "display", |
---|
547 | resizable : true, |
---|
548 | zindex : zIndex++, |
---|
549 | title : "Expresso Messenger - Login", |
---|
550 | closeAction : "remove", |
---|
551 | content : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl", paramsLoginPage) |
---|
552 | }; |
---|
553 | |
---|
554 | _winBuild( winLoginPage ); |
---|
555 | } |
---|
556 | |
---|
557 | function loadScripts(pFiles) |
---|
558 | { |
---|
559 | // Load JavaScript |
---|
560 | var loadJavaScript = function(pJs) |
---|
561 | { |
---|
562 | var newScript = document.createElement("script"); |
---|
563 | newScript.setAttribute("type", "text/javascript"); |
---|
564 | newScript.setAttribute("src", pJs ); |
---|
565 | |
---|
566 | return newScript; |
---|
567 | }; |
---|
568 | |
---|
569 | // Load CSS |
---|
570 | var loadStyleSheet = function(pCss) |
---|
571 | { |
---|
572 | var newStyle = document.createElement("link"); |
---|
573 | newStyle.setAttribute("rel", "stylesheet"); |
---|
574 | newStyle.setAttribute("type", "text/css"); |
---|
575 | newStyle.setAttribute("href", pCss); |
---|
576 | |
---|
577 | return newStyle; |
---|
578 | }; |
---|
579 | |
---|
580 | for(var i = 0; i < pFiles.length; i++) |
---|
581 | { |
---|
582 | if( pFiles[i].indexOf(".js") > -1 ) |
---|
583 | document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i])); |
---|
584 | |
---|
585 | if( pFiles[i].indexOf(".css") > -1 ) |
---|
586 | document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i])); |
---|
587 | } |
---|
588 | } |
---|
589 | |
---|
590 | function notificationNewMessage() |
---|
591 | { |
---|
592 | var _doc = document; |
---|
593 | var _id = arguments[0]; |
---|
594 | var _win_name = _id.replace( /\W/g, '' ); |
---|
595 | |
---|
596 | if ( windowPOPUP( _id ) ) |
---|
597 | { |
---|
598 | _doc = windowPopUp[_win_name].document; |
---|
599 | } |
---|
600 | |
---|
601 | var oldTitle = _doc.title; |
---|
602 | var newTitle = "## NOVA MENSAGEM ##"; |
---|
603 | |
---|
604 | if( timeoutId == null ) |
---|
605 | { |
---|
606 | timeoutId = setInterval(function() |
---|
607 | { |
---|
608 | _doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle; |
---|
609 | }, 1000); |
---|
610 | |
---|
611 | configEvents( _doc, 'onclick', function() |
---|
612 | { |
---|
613 | clearInterval(timeoutId); |
---|
614 | _doc.title = oldTitle; |
---|
615 | timeoutId = null; |
---|
616 | }); |
---|
617 | |
---|
618 | configEvents( _doc, 'onkeypress', function() |
---|
619 | { |
---|
620 | clearInterval(timeoutId); |
---|
621 | _doc.title = oldTitle; |
---|
622 | timeoutId = null; |
---|
623 | }); |
---|
624 | } |
---|
625 | } |
---|
626 | |
---|
627 | function optionsItensContact() |
---|
628 | { |
---|
629 | if( arguments.length > 0 ) |
---|
630 | { |
---|
631 | var jid = arguments[0]; |
---|
632 | var coord = arguments[1]; |
---|
633 | var element = getElement('itenContact_' + jid ); |
---|
634 | var action = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar"; |
---|
635 | |
---|
636 | if( showhidden == null ) |
---|
637 | showhidden = new ShowHidden(300); |
---|
638 | |
---|
639 | var _options = [ |
---|
640 | [ action , 'loadscript.setAutorization(\''+jid+'\')'], |
---|
641 | ['Remover' , 'loadscript.removeContact(\''+jid+'\')'], |
---|
642 | ['Renomear' , 'loadscript.renameContact(\''+jid+'\')'], |
---|
643 | ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')'] |
---|
644 | ]; |
---|
645 | |
---|
646 | var _itens = ""; |
---|
647 | |
---|
648 | for( var i in _options ) |
---|
649 | { |
---|
650 | if( typeof(_options[i]) == "object") |
---|
651 | { |
---|
652 | _itens += '<img src="'+arrow_right.src+'"/>'; |
---|
653 | _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>'; |
---|
654 | _itens += _options[i][0] + '</span><br/>'; |
---|
655 | } |
---|
656 | } |
---|
657 | |
---|
658 | var _optionsItens = document.createElement("div"); |
---|
659 | _optionsItens.className = "x-menu"; |
---|
660 | _optionsItens.style.top = coord.Y; |
---|
661 | _optionsItens.style.left = ( coord.X - element.offsetLeft ); |
---|
662 | _optionsItens.style.zIndex = getZindex(); |
---|
663 | _optionsItens.innerHTML = _itens; |
---|
664 | _optionsItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
665 | _optionsItens.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
666 | _optionsItens.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
667 | |
---|
668 | showhidden.action('onmouseover', 'onmouseout', _optionsItens); |
---|
669 | |
---|
670 | window.document.body.appendChild(_optionsItens); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | function parse() |
---|
675 | { |
---|
676 | if( arguments.length == 2 ) |
---|
677 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] ); |
---|
678 | |
---|
679 | if( arguments.length === 3 ) |
---|
680 | return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); |
---|
681 | } |
---|
682 | |
---|
683 | function preferences() |
---|
684 | { |
---|
685 | var paramPreferences = |
---|
686 | { |
---|
687 | 'path' : path, |
---|
688 | 'lang1' : 'Suas Preferências', |
---|
689 | 'lang2' : 'Conexão', |
---|
690 | 'lang3' : 'Conectar Automaticamente o IM', |
---|
691 | 'lang4' : 'Usuários OffLine', |
---|
692 | 'lang5' : 'Exibir amigos Offline', |
---|
693 | 'lang6' : 'Salvar', |
---|
694 | 'lang7' : 'Cancelar', |
---|
695 | 'lang8' : 'Janela de Contatos', |
---|
696 | 'lang9' : 'Abrir janela como Pop-up', |
---|
697 | 'lang10' : 'Ausente', |
---|
698 | 'lang11' : 'Definir status de ausente depois de', |
---|
699 | 'lang12' : 'minutos', |
---|
700 | 'lang13' : 'Mostrar Contatos', |
---|
701 | 'lang14' : 'Mostrar contatos desconectados', |
---|
702 | 'langYes': 'Sim', |
---|
703 | 'langNo' : 'Não' |
---|
704 | }; |
---|
705 | |
---|
706 | |
---|
707 | var _win_preferences = |
---|
708 | { |
---|
709 | id_window : "jabberit_preferences", |
---|
710 | width : 430, |
---|
711 | height : 350, |
---|
712 | top : 150, |
---|
713 | left : 100, |
---|
714 | draggable : true, |
---|
715 | visible : "display", |
---|
716 | resizable : true, |
---|
717 | zindex : zIndex++, |
---|
718 | title : 'Expresso Messenger - Preferências', |
---|
719 | closeAction : "remove", |
---|
720 | content : Xtools.parse(Xtools.xml('preferences'), 'preferences.xsl', paramPreferences) |
---|
721 | }; |
---|
722 | |
---|
723 | _winBuild(_win_preferences); |
---|
724 | |
---|
725 | |
---|
726 | var _pButtons = { |
---|
727 | 'lang1' : 'Salvar', |
---|
728 | 'lang2' : 'Fechar', |
---|
729 | 'onclickClose' : '_winBuild("jabberit_preferences","remove");', |
---|
730 | 'onclickSubmit' : 'javascript:loadscript.setPreferences();' |
---|
731 | }; |
---|
732 | |
---|
733 | document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); |
---|
734 | |
---|
735 | // Element openWindowJabberit |
---|
736 | var value1 = _preferencesIM[0].split(':'); |
---|
737 | var element1 = document.getElementById(value1[0]); |
---|
738 | var valueSelect1 = value1[1]; |
---|
739 | |
---|
740 | for(var i = 0; i < element1.options.length; i++) |
---|
741 | if( element1.options[i].value == valueSelect1 ) |
---|
742 | element1.options[i].selected = true; |
---|
743 | |
---|
744 | // Element openWindowJabberitPopUp |
---|
745 | var value2 = _preferencesIM[1].split(':'); |
---|
746 | |
---|
747 | // Element flagAwayIM |
---|
748 | var value3 = _preferencesIM[2].split(':'); |
---|
749 | var element3 = document.getElementById(value3[0]); |
---|
750 | element3.value = value3[1]; |
---|
751 | |
---|
752 | // Element showContactsOfflineJabberit |
---|
753 | var value4 = _preferencesIM[3].split(':'); |
---|
754 | var element4 = document.getElementById(value4[0]); |
---|
755 | var valueSelect4 = value4[1]; |
---|
756 | for(var i = 0; i < element4.options.length; i++) |
---|
757 | if( element4.options[i].value == valueSelect4 ) |
---|
758 | element4.options[i].selected = true; |
---|
759 | } |
---|
760 | |
---|
761 | function removeContact( jid ) |
---|
762 | { |
---|
763 | TrophyIM.removeContact( jid ); |
---|
764 | } |
---|
765 | |
---|
766 | function removeElement( ) |
---|
767 | { |
---|
768 | if( arguments.length > 0 ) |
---|
769 | { |
---|
770 | var _element = arguments[0] |
---|
771 | var _parent = _element.parentNode; |
---|
772 | |
---|
773 | if( _element ) |
---|
774 | _parent.removeChild( _element ); |
---|
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 | 'zIndex_' : zIndex++ |
---|
818 | }; |
---|
819 | |
---|
820 | var winRosterDiv = |
---|
821 | { |
---|
822 | id_window : "window_Roster_im", |
---|
823 | width : 250, |
---|
824 | height : 410, |
---|
825 | top : 50, |
---|
826 | left : -1500, |
---|
827 | leftOld : 50, |
---|
828 | draggable : true, |
---|
829 | visible : "display", |
---|
830 | resizable : true, |
---|
831 | zindex : zIndex++, |
---|
832 | title : "Expresso Messenger - Contatos", |
---|
833 | closeAction : "hidden", |
---|
834 | content : Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact) |
---|
835 | }; |
---|
836 | |
---|
837 | if( _preferencesIM[0] == "openWindowJabberit:false" ) |
---|
838 | { |
---|
839 | winRosterDiv.left = 50; |
---|
840 | winRosterDiv.leftOld = -1500; |
---|
841 | } |
---|
842 | |
---|
843 | _winBuild( winRosterDiv ); |
---|
844 | |
---|
845 | // Photo User |
---|
846 | getPhotoUser(_idUser); |
---|
847 | } |
---|
848 | |
---|
849 | setTimeout( function(){ _rosterDiv(); }, 200 ); |
---|
850 | } |
---|
851 | |
---|
852 | function searchUser() |
---|
853 | { |
---|
854 | var _input = getElement('search_user_jabber'); |
---|
855 | |
---|
856 | if( _input.value.length >= 3 ) |
---|
857 | addUser.search(); |
---|
858 | else |
---|
859 | alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); |
---|
860 | } |
---|
861 | |
---|
862 | function setAutorization() |
---|
863 | { |
---|
864 | var divItenContact = null; |
---|
865 | |
---|
866 | if( arguments.length > 0 ) |
---|
867 | { |
---|
868 | var jidTo = arguments[0]; |
---|
869 | |
---|
870 | if( getElement('itenContact_' + jidTo) ) |
---|
871 | divItenContact = getElement('itenContact_' + jidTo ); |
---|
872 | } |
---|
873 | |
---|
874 | if( divItenContact ) |
---|
875 | { |
---|
876 | var subscription = divItenContact.getAttribute('subscription'); |
---|
877 | |
---|
878 | switch(subscription) |
---|
879 | { |
---|
880 | case 'from': |
---|
881 | |
---|
882 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
883 | break; |
---|
884 | |
---|
885 | case 'none' : |
---|
886 | |
---|
887 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
888 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
889 | |
---|
890 | break; |
---|
891 | |
---|
892 | case 'not-in-roster': |
---|
893 | |
---|
894 | setTimeout(function() |
---|
895 | { |
---|
896 | var _add = ""; |
---|
897 | |
---|
898 | if( ( _add = confirm("Deseja adicionar o usuario!")) ) |
---|
899 | { |
---|
900 | addUser.add( jidTo ); |
---|
901 | } |
---|
902 | |
---|
903 | },100); |
---|
904 | |
---|
905 | break; |
---|
906 | |
---|
907 | case 'to' : |
---|
908 | |
---|
909 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); |
---|
910 | |
---|
911 | removeElement( getElement('itenContactNotification_' + jidTo ) ); |
---|
912 | |
---|
913 | case 'subscribe' : |
---|
914 | |
---|
915 | TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribe'); |
---|
916 | |
---|
917 | break; |
---|
918 | |
---|
919 | default : |
---|
920 | alert( "SEM PARAMETRO DEFINIDO : " + subscription ); |
---|
921 | |
---|
922 | } |
---|
923 | } |
---|
924 | } |
---|
925 | |
---|
926 | function setMessageStatus() |
---|
927 | { |
---|
928 | if( arguments.length > 0 ) |
---|
929 | { |
---|
930 | var _element = arguments[0]; |
---|
931 | var _parent = _element.parentNode; |
---|
932 | |
---|
933 | if( _element.nodeName.toLowerCase() == "label") |
---|
934 | { |
---|
935 | var _input = document.createElement("input"); |
---|
936 | _input.size = "35"; |
---|
937 | _input.maxlength = "35"; |
---|
938 | _input.style.border = "0"; |
---|
939 | _input.value = _element.innerHTML; |
---|
940 | |
---|
941 | // OnkeyUp |
---|
942 | configEvents( _input, "onkeyup", function(e) |
---|
943 | { |
---|
944 | if( e.keyCode == 13 ) loadscript.setMessageStatus(_input, _element); |
---|
945 | } |
---|
946 | ); |
---|
947 | |
---|
948 | // Onblur |
---|
949 | configEvents(_input, "onblur", function(){ loadscript.setMessageStatus(_input, _element)}); |
---|
950 | |
---|
951 | |
---|
952 | if( _parent != null ) |
---|
953 | { |
---|
954 | // Remove label |
---|
955 | if( _element != null ) |
---|
956 | _parent.removeChild( _element ); |
---|
957 | |
---|
958 | // Add Input |
---|
959 | if( _input != null ) |
---|
960 | _parent.appendChild( _input ); |
---|
961 | } |
---|
962 | |
---|
963 | _input.focus(); |
---|
964 | _input.select(); |
---|
965 | } |
---|
966 | else |
---|
967 | { |
---|
968 | var _label = arguments[1]; |
---|
969 | _statusMessage = _element.value.replace(/^\(+|\)+$/g,""); |
---|
970 | |
---|
971 | if( ( _statusMessage = _statusMessage.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") |
---|
972 | _label.innerHTML = "( " + _statusMessage + " )"; |
---|
973 | else |
---|
974 | _label.innerHTML = "( " + i18n.TYPE_YOUR_MESSAGE_HERE_STATUS + " )"; |
---|
975 | |
---|
976 | if( _parent != null ) |
---|
977 | { |
---|
978 | // Remove Input |
---|
979 | if( _element != null ) |
---|
980 | _parent.removeChild( _element ); |
---|
981 | |
---|
982 | // Add Label |
---|
983 | if( _label != null ) |
---|
984 | _parent.appendChild( _label ); |
---|
985 | } |
---|
986 | |
---|
987 | // Send Status Message |
---|
988 | _statusMessage = ( ( _statusMessage != i18n.TYPE_YOUR_MESSAGE_HERE_STATUS ) ? _statusMessage : "" ); |
---|
989 | |
---|
990 | TrophyIM.setPresence("status", _statusMessage ); |
---|
991 | } |
---|
992 | } |
---|
993 | } |
---|
994 | |
---|
995 | function setPreferences() |
---|
996 | { |
---|
997 | // Element openWindowJabberit |
---|
998 | var elementOpenW = document.getElementById('openWindowJabberit'); |
---|
999 | var value = ''; |
---|
1000 | |
---|
1001 | for(var i = 0 ; i < elementOpenW.options.length; i++) |
---|
1002 | if( elementOpenW.options[i].selected == true) |
---|
1003 | { |
---|
1004 | value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value; |
---|
1005 | _preferencesIM[0] = 'openWindowJabberit:' + elementOpenW.options[i].value; |
---|
1006 | } |
---|
1007 | |
---|
1008 | // Element openWindowJabberitPopUp |
---|
1009 | value += '&preferences2=openWindowJabberitPopUp:false'; |
---|
1010 | _preferencesIM[1] = 'openWindowJabberitPopUp:false'; |
---|
1011 | |
---|
1012 | // Element flagAwayIM |
---|
1013 | var elementFlagIM = document.getElementById('flagAwayIM'); |
---|
1014 | |
---|
1015 | if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 ) |
---|
1016 | { |
---|
1017 | _preferencesIM[2] = 'flagAwayIM:' + elementFlagIM.value; |
---|
1018 | value += '&preferences3=flagAwayIM:' + elementFlagIM.value; |
---|
1019 | } |
---|
1020 | else |
---|
1021 | { |
---|
1022 | alert('Informe um valor igual ou maior que 1!'); |
---|
1023 | return false; |
---|
1024 | } |
---|
1025 | |
---|
1026 | // Element showContactsOfflineJabberit |
---|
1027 | var elementShowOffline = document.getElementById('showContactsOfflineJabberit'); |
---|
1028 | |
---|
1029 | for(var i = 0 ; i < elementShowOffline.options.length; i++) |
---|
1030 | if( elementShowOffline.options[i].selected == true) |
---|
1031 | { |
---|
1032 | _preferencesIM[3] = 'showContactsOfflineJabberit:' + elementShowOffline.options[i].value; |
---|
1033 | value += '&preferences4=showContactsOfflineJabberit:' + elementShowOffline.options[i].value; |
---|
1034 | } |
---|
1035 | |
---|
1036 | // Save Preferences |
---|
1037 | conn.go('p.pf.setPreferences', |
---|
1038 | function(data) |
---|
1039 | { |
---|
1040 | if( data == 'false' ) |
---|
1041 | { |
---|
1042 | alert('Erro salvando suas preferências!'); |
---|
1043 | } |
---|
1044 | |
---|
1045 | _winBuild('jabberit_preferences', 'remove'); |
---|
1046 | }, |
---|
1047 | value); |
---|
1048 | } |
---|
1049 | |
---|
1050 | function setPresence() |
---|
1051 | { |
---|
1052 | if( arguments.length > 0 ) |
---|
1053 | { |
---|
1054 | var element = arguments[0]; |
---|
1055 | |
---|
1056 | if( showhidden == null ) |
---|
1057 | showhidden = new ShowHidden(300); |
---|
1058 | |
---|
1059 | var _status = [ |
---|
1060 | ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'], |
---|
1061 | ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'], |
---|
1062 | ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'], |
---|
1063 | ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], |
---|
1064 | ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], |
---|
1065 | ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'], |
---|
1066 | ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'], |
---|
1067 | ]; |
---|
1068 | |
---|
1069 | var _itens = ""; |
---|
1070 | |
---|
1071 | for( var i in _status ) |
---|
1072 | { |
---|
1073 | if( typeof( _status[i]) == "object" ) |
---|
1074 | { |
---|
1075 | _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadscript.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">'; |
---|
1076 | _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>"; |
---|
1077 | } |
---|
1078 | } |
---|
1079 | |
---|
1080 | var _statusItens = document.createElement("div"); |
---|
1081 | _statusItens.style.marginTop = "65px"; |
---|
1082 | _statusItens.style.marginLeft = "67px"; |
---|
1083 | _statusItens.className = "x-menu"; |
---|
1084 | _statusItens.style.zIndex = '99999'; |
---|
1085 | _statusItens.innerHTML = _itens; |
---|
1086 | _statusItens.onclick = function(){ showhidden.hiddenObject(false); }; |
---|
1087 | |
---|
1088 | showhidden.action('onmouseover', 'onmouseout', _statusItens); |
---|
1089 | |
---|
1090 | element.parentNode.onmouseout = function(){ showhidden.hiddenObject(false); }; |
---|
1091 | element.parentNode.onmouseover = function(){ showhidden.hiddenObject(true); }; |
---|
1092 | element.parentNode.appendChild(_statusItens); |
---|
1093 | } |
---|
1094 | } |
---|
1095 | |
---|
1096 | function setSelectEditable(element) |
---|
1097 | { |
---|
1098 | if( getElement('selectBox0') == null ) |
---|
1099 | selectEditable.create(element); |
---|
1100 | } |
---|
1101 | |
---|
1102 | function setStatusJabber() |
---|
1103 | { |
---|
1104 | if( arguments.length > 0 ) |
---|
1105 | { |
---|
1106 | if( arguments[1] != 'status' ) |
---|
1107 | { |
---|
1108 | var _text = arguments[0]; |
---|
1109 | var _img = statusUserIM = arguments[1]; |
---|
1110 | |
---|
1111 | getElement('statusJabberText').innerHTML = _text; |
---|
1112 | getElement('statusJabberImg').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')"; |
---|
1113 | getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; |
---|
1114 | } |
---|
1115 | } |
---|
1116 | } |
---|
1117 | |
---|
1118 | function _setUserCurrent( _user ) |
---|
1119 | { |
---|
1120 | userCurrent = |
---|
1121 | { |
---|
1122 | 'jid' : _user.jid.substring(11, _user.jid.length), |
---|
1123 | 'password' : _user.password.substring(11, _user.password.length) |
---|
1124 | } |
---|
1125 | } |
---|
1126 | |
---|
1127 | function setUserCurrent() |
---|
1128 | { |
---|
1129 | if( getUserCurrent() == null ) |
---|
1130 | { |
---|
1131 | conn.go('p.ff.data_0', |
---|
1132 | function(_User) |
---|
1133 | { |
---|
1134 | conn.go('p.ff.data_1', |
---|
1135 | function(_pass) |
---|
1136 | { |
---|
1137 | _setUserCurrent( { jid : _User, password : _pass } ); |
---|
1138 | }); |
---|
1139 | }); |
---|
1140 | } |
---|
1141 | } |
---|
1142 | |
---|
1143 | var _stylesheets = [ ]; |
---|
1144 | var _links = document.getElementsByTagName( 'link' ); |
---|
1145 | |
---|
1146 | for ( var i = 0; i < _links.length; i++ ) |
---|
1147 | if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' ) |
---|
1148 | _stylesheets[ _stylesheets.length ] = _links.item( i ); |
---|
1149 | |
---|
1150 | function windowPOPUP() |
---|
1151 | { |
---|
1152 | var _id = arguments[0]; |
---|
1153 | var _win_name = _id.replace( /\W/g, '' ); |
---|
1154 | |
---|
1155 | if ( arguments.length == 1 ) |
---|
1156 | { |
---|
1157 | if ( windowPopUp[_win_name] ) |
---|
1158 | return true; |
---|
1159 | else |
---|
1160 | return false; |
---|
1161 | } |
---|
1162 | |
---|
1163 | if( arguments.length == 2 ) |
---|
1164 | { |
---|
1165 | if( !windowPopUp[_win_name] ) |
---|
1166 | { |
---|
1167 | 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'); |
---|
1168 | var tmp = windowPopUp[_win_name].document; |
---|
1169 | |
---|
1170 | tmp.write('<html><head>'); |
---|
1171 | tmp.write('</head><body>'); |
---|
1172 | tmp.write('</body></html>'); |
---|
1173 | tmp.close(); |
---|
1174 | |
---|
1175 | for ( var i = 0; i < _stylesheets.length; i++ ) |
---|
1176 | tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) ); |
---|
1177 | |
---|
1178 | var divPOP = getElement( _id + "__popUp" ); |
---|
1179 | divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat"; |
---|
1180 | divPOP.innerHTML = "PopIn"; |
---|
1181 | |
---|
1182 | function _close( ) |
---|
1183 | { |
---|
1184 | windowPopUp[_win_name].close(); |
---|
1185 | configEvents( divPOP ,'onclick', _close, true ); |
---|
1186 | } |
---|
1187 | |
---|
1188 | configEvents( divPOP ,'onclick', _close ); |
---|
1189 | |
---|
1190 | var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode ); |
---|
1191 | |
---|
1192 | _content.firstChild.scrollTop = _content.firstChild.scrollHeight; |
---|
1193 | |
---|
1194 | configEvents( windowPopUp[_win_name] ,'onbeforeunload', function() |
---|
1195 | { |
---|
1196 | delete windowPopUp[_win_name]; |
---|
1197 | divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat"; |
---|
1198 | divPOP.innerHTML = "PopUp"; |
---|
1199 | divPOP.onclick = function(){ loadscript.windowPOPUP( _id , true ); }; |
---|
1200 | _winBuild( 'window_chat_area_' + _id, "display" ).content( true ); |
---|
1201 | }); |
---|
1202 | |
---|
1203 | _winBuild( 'window_chat_area_' + _id, 'hidden' ); |
---|
1204 | } |
---|
1205 | } |
---|
1206 | } |
---|
1207 | |
---|
1208 | function windowNotificationNewUsers() |
---|
1209 | { |
---|
1210 | var _users = Xtools.xml('notification_new_users'); |
---|
1211 | |
---|
1212 | for( var user in TrophyIM.rosterObj.roster ) |
---|
1213 | { |
---|
1214 | if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) |
---|
1215 | continue; |
---|
1216 | |
---|
1217 | if( TrophyIM.rosterObj.roster[ user ].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) |
---|
1218 | { |
---|
1219 | var _subscription = TrophyIM.rosterObj.roster[user].contact.subscription; |
---|
1220 | |
---|
1221 | if ( _subscription == 'to' || _subscription == 'not-in-roster' ) |
---|
1222 | { |
---|
1223 | var _user = _users.createElement('user'); |
---|
1224 | var _jid = _users.createElement('jid'); |
---|
1225 | var _status = _users.createElement('status'); |
---|
1226 | _jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) ); |
---|
1227 | _status.appendChild( _users.createTextNode( _subscription ) ); |
---|
1228 | _user.appendChild( _jid ); |
---|
1229 | _user.appendChild( _status ); |
---|
1230 | _users.documentElement.appendChild( _user ); |
---|
1231 | } |
---|
1232 | } |
---|
1233 | } |
---|
1234 | |
---|
1235 | var paramsNotification = |
---|
1236 | { |
---|
1237 | 'lang_1' : "Notificação", |
---|
1238 | 'lang_2' : "O(s) usuário(s) abaixo pedem sua autorização.", |
---|
1239 | 'lang_3' : "Autorizar", |
---|
1240 | 'lang_4' : "Remover" |
---|
1241 | }; |
---|
1242 | |
---|
1243 | var winNotification = |
---|
1244 | { |
---|
1245 | id_window : "window_notification_new_users", |
---|
1246 | width : 400, |
---|
1247 | height : 300, |
---|
1248 | top : 100, |
---|
1249 | left : 400, |
---|
1250 | draggable : true, |
---|
1251 | visible : "display", |
---|
1252 | resizable : true, |
---|
1253 | zindex : zIndex++, |
---|
1254 | title : "Expresso Messenger - Notificação de Novos Usuários", |
---|
1255 | closeAction : "remove", |
---|
1256 | content : Xtools.parse( _users , "notificationNewUsers.xsl", paramsNotification ) |
---|
1257 | }; |
---|
1258 | |
---|
1259 | _winBuild( winNotification ); |
---|
1260 | } |
---|
1261 | |
---|
1262 | function loadIM() |
---|
1263 | { |
---|
1264 | if( arguments.length > 0 ) |
---|
1265 | { |
---|
1266 | var files = [ |
---|
1267 | path_jabberit + 'js/connector.js', |
---|
1268 | path_jabberit + 'js/xtools.js', |
---|
1269 | path_jabberit + 'js/lang/i18n_pt_Br.js', |
---|
1270 | path_jabberit + 'js/dragdrop.js', |
---|
1271 | path_jabberit + 'js/makeW.js', |
---|
1272 | path_jabberit + 'js/show_hidden.js', |
---|
1273 | path_jabberit + 'js/trophyim.js', |
---|
1274 | //path_jabberit + 'js/strophe.min.js', |
---|
1275 | path_jabberit + 'js/json2.js', |
---|
1276 | path_jabberit + 'js/AddUser.js', |
---|
1277 | path_jabberit + 'js/SelectEditable.js', |
---|
1278 | path_jabberit + 'templates/default/css/button.css', |
---|
1279 | path_jabberit + 'templates/default/css/common.css', |
---|
1280 | path_jabberit + 'templates/default/css/selectEditableStyle.css', |
---|
1281 | path_jabberit + 'templates/default/css/' + theme_jabberit |
---|
1282 | ]; |
---|
1283 | // FullName |
---|
1284 | fullName = arguments[0]; |
---|
1285 | |
---|
1286 | // Preferences |
---|
1287 | _preferencesIM = arguments[1].split(";"); |
---|
1288 | |
---|
1289 | if( !_preferencesIM[3] ) _preferencesIM[3] = "showContactsOfflineJabberit:true"; |
---|
1290 | |
---|
1291 | loadScripts(files); |
---|
1292 | |
---|
1293 | setTimeout(function() |
---|
1294 | { |
---|
1295 | // Object Xtools |
---|
1296 | if( Xtools == null ) |
---|
1297 | Xtools = new xtools(path_jabberit); |
---|
1298 | |
---|
1299 | // Object Conector |
---|
1300 | if( conn == null ) |
---|
1301 | conn = new AjaxConnector(path_jabberit); |
---|
1302 | |
---|
1303 | // Object Add User |
---|
1304 | if( addUser == null ) |
---|
1305 | addUser = new addUserIM(Xtools, conn); |
---|
1306 | |
---|
1307 | |
---|
1308 | // Object SelectEditable |
---|
1309 | if( selectEditable == null ) |
---|
1310 | selectEditable = new SelectEditable(); |
---|
1311 | |
---|
1312 | // Add Jabber in StatusBar; |
---|
1313 | addIcon(); |
---|
1314 | |
---|
1315 | // Auto Connect |
---|
1316 | setTimeout(function() |
---|
1317 | { |
---|
1318 | if( _preferencesIM[0] === 'openWindowJabberit:true' ) |
---|
1319 | { |
---|
1320 | TrophyIM.load(); |
---|
1321 | } |
---|
1322 | |
---|
1323 | },1500); |
---|
1324 | |
---|
1325 | // Auto Status |
---|
1326 | autoStatus(); |
---|
1327 | configEvents( document, 'onmousemove', autoStatus ); |
---|
1328 | configEvents( document, 'onkeypress', autoStatus ); |
---|
1329 | |
---|
1330 | }, 2000); |
---|
1331 | } |
---|
1332 | } |
---|
1333 | |
---|
1334 | loadIM.prototype.adIcon = addIcon; |
---|
1335 | loadIM.prototype.actionButton = actionButton; |
---|
1336 | loadIM.prototype.addContact = addContact; |
---|
1337 | loadIM.prototype.addNewUser = addNewUser; |
---|
1338 | loadIM.prototype.clrAllContacts = clrAllContacts; |
---|
1339 | loadIM.prototype.configEvents = configEvents; |
---|
1340 | loadIM.prototype.disabledNotificationNewUsers = disabledNotificationNewUsers; |
---|
1341 | loadIM.prototype.enabledNotificationNewUsers = enabledNotificationNewUsers; |
---|
1342 | loadIM.prototype.getIsIE = getIsIE; |
---|
1343 | loadIM.prototype.getPhotoUser = getPhotoUser; |
---|
1344 | loadIM.prototype.getSmiles = getSmiles; |
---|
1345 | loadIM.prototype.getStatusMessage = getStatusMessage; |
---|
1346 | loadIM.prototype.getShowContactsOffline = getShowContactsOffline; |
---|
1347 | loadIM.prototype.getUserCurrent = getUserCurrent; |
---|
1348 | loadIM.prototype.getZIndex = getZindex; |
---|
1349 | loadIM.prototype.groupsHidden = groupsHidden; |
---|
1350 | loadIM.prototype.groupsVisible = groupsVisible; |
---|
1351 | loadIM.prototype.keyPressSearch = keyPressSearch; |
---|
1352 | loadIM.prototype.loginPage = loginPage; |
---|
1353 | loadIM.prototype.notification = notificationNewMessage; |
---|
1354 | loadIM.prototype.parse = parse; |
---|
1355 | loadIM.prototype.preferences = preferences; |
---|
1356 | loadIM.prototype.searchUser = searchUser |
---|
1357 | loadIM.prototype.setAutorization = setAutorization; |
---|
1358 | loadIM.prototype.setMessageStatus = setMessageStatus; |
---|
1359 | loadIM.prototype.setPreferences = setPreferences; |
---|
1360 | loadIM.prototype.setPresence = setPresence; |
---|
1361 | loadIM.prototype.setStatusJabber = setStatusJabber; |
---|
1362 | loadIM.prototype.setSelectEditable = setSelectEditable; |
---|
1363 | loadIM.prototype.setUserCurrent = setUserCurrent; |
---|
1364 | loadIM.prototype.removeContact = removeContact; |
---|
1365 | loadIM.prototype.removeElement = removeElement; |
---|
1366 | loadIM.prototype.removeGroup = removeGroup; |
---|
1367 | loadIM.prototype.renameContact = renameContact; |
---|
1368 | loadIM.prototype.renameGroup = renameGroup; |
---|
1369 | loadIM.prototype.rosterDiv = rosterDiv; |
---|
1370 | loadIM.prototype.windowNotificationNewUsers = windowNotificationNewUsers; |
---|
1371 | loadIM.prototype.windowPOPUP = windowPOPUP; |
---|
1372 | |
---|
1373 | |
---|
1374 | window.LoadIM = loadIM; |
---|
1375 | |
---|
1376 | |
---|
1377 | // Necessário para não ocasionar problema no ExpressoMail |
---|
1378 | // quando os itens abaixo não são criados pelo próprio ExpressoMail |
---|
1379 | if( is_ie ) |
---|
1380 | { |
---|
1381 | configEvents( window, 'onload', function( ) |
---|
1382 | { |
---|
1383 | if ( ! document.getElementById( 'cc_msg_err_serialize_data_unknown' ) ) |
---|
1384 | { |
---|
1385 | var fix = document.createElement('input'); |
---|
1386 | fix.type = 'hidden'; |
---|
1387 | fix.id = 'cc_msg_err_serialize_data_unknown'; |
---|
1388 | |
---|
1389 | document.appendChild( fix ); |
---|
1390 | } |
---|
1391 | if ( ! window.showMessage ) |
---|
1392 | window.showMessage = function(){}; |
---|
1393 | }); |
---|
1394 | } |
---|
1395 | |
---|
1396 | })(); |
---|