source: trunk/instant_messenger/js/im_templates.js @ 64

Revision 64, 12.2 KB checked in by niltonneto, 17 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1/**
2* @AUTHOR: Alexandre Correia / Rodrigo Souza
3* @DATE: 2006/10/24 17:03:00
4* @LAST CHANGE: Seg 11 Dez 2006 10:21:34 BRST::
5* Instant Messenger
6* im_templates.js
7**/
8
9        function Templates(){
10
11                this.element    = document.getElementById("im_expresso");
12                this.form               = "";
13                this.time_set   = "";
14                this.transfer   = 0;
15                this.arquivo    = "";
16        }
17
18   /*
19        * Conf forms
20        */
21
22        Templates.prototype.conf_form = function(pName,pWidth,pHeight,pHTML,pTitle)
23        {
24             var params = new Array();
25         params['body'] = pHTML;
26         params['height'] = pHeight;
27         params['id'] = pName;
28         params['maximize'] = false;
29         params['minimize'] = false;
30         params['title'] = pTitle;
31         params['width'] = pWidth;
32                 im_win.create_window(params);
33        }
34
35   /*
36        * Add Usuario
37        */
38
39        Templates.prototype.add_user = function()
40        {
41                var _this = this;
42                var _XmlAddUser = '<adduser>' +
43                                                        '<top lang1="'+IM.get_lang('Selecione uma Organização')+'" />' +
44                                                        '<bottom lang1="'+IM.get_lang('Jid Contact')+'" lang2="'+IM.get_lang('Nickname')+'" lang3="'+IM.get_lang('Group')+'" lang4="'+IM.get_lang('Add')+'"/>' +
45                                                  '</adduser>';
46               
47                _this.conf_form("divAddUser",525,295,parse_XmlXsl(_XmlAddUser,'add_user.xsl'),":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
48        }
49       
50        Templates.prototype.AcceptRequestUser = function()
51        {
52                var _this = this;
53                var _XmlupdUser = '<updUser>' +
54                                                        '<body lang1="'+IM.get_lang('Nickname')+'" lang2="'+IM.get_lang('Group')+'" lang3="'+IM.get_lang('Update')+'" />' +             
55                                                  '</updUser>';
56                                                 
57                _this.conf_form("divUpdateUser",300,110,parse_XmlXsl(_XmlupdUser,'upd_user.xsl'),":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
58        }
59
60   /*
61        * Del Usuario
62        */
63
64        Templates.prototype.remove_user = function()
65        {
66                var _this = this;
67                var _XmlDelUser = '<deluser>' +
68                                                        '<body lang1="'+IM.get_lang('Contact')+'" lang2="'+IM.get_lang('Remove')+'" />' +
69                                                  '</deluser>';
70
71                _this.conf_form("divDelUser",300,110,parse_XmlXsl(_XmlDelUser,'del_user.xsl'),":: " + IM.get_lang('Remove Contact') + " - Expresso ::");
72        }
73
74   /*
75        * Update Usuario
76        */
77
78        Templates.prototype.Users_Not_Auth = function (jids)
79        {
80                var _this = this;
81                var _XmlUserNAuth = '<jids>';   
82                for(var i in jids)
83                {               
84                        _XmlUserNAuth += '<item id="im_cell_'+jids[i]+'" jid="'+jids[i]+'" />';
85                }
86                _XmlUserNAuth += '</jids>';
87                if(document.getElementById('divFormAuthUser_im') == null){
88                        _this.conf_form("divFormAuthUser",360,250,parse_XmlXsl(_XmlUserNAuth,'user_not_auth.xsl'), ":: Contatos sem Cadastro - Expresso ::");
89                }else{
90                        document.getElementById('divFormAuthUser_im').innerHTML = '';
91                        document.getElementById('divFormAuthUser_im').innerHTML = parse_XmlXsl(_XmlUserNAuth,'user_not_auth.xsl');
92                }
93        }
94
95   /*
96        * Vcard Usuario
97        */
98
99        Templates.prototype.information_user = function(pVcardUser)
100        {
101                var _this = this;
102                var _XmlInfoUser = '<info_user>' +
103                                                                '<vcard>' +
104                                                                        pVcardUser +   
105                                                                '</vcard>' +
106                                                            '<getlang>' +
107                                                                        '<FN>' + IM.get_lang('Full Name') + '</FN>'+
108                                                                        '<NICKNAME>' + IM.get_lang('NickName') + '</NICKNAME>' +
109                                                                        '<ORGNAME>' + IM.get_lang('Orgname') + '</ORGNAME>' +
110                                                                        '<ORGUNIT>' + IM.get_lang('Orgunit') + '</ORGUNIT>' +
111                                                                        '<ROLE>' + IM.get_lang('Role') + '</ROLE>' +
112                                                                        '<BDAY>' + IM.get_lang('Birthday') + '</BDAY>' +
113                                                                        '<DESC>' + IM.get_lang('Status') + '</DESC>' +
114                                                                        '<SAVE>' +IM.get_lang('save') + '</SAVE>' +
115                                                                '</getlang>' +
116                                                   '</info_user>';     
117                _this.conf_form("divInfoUser",400,220,parse_XmlXsl(_XmlInfoUser,'information_user.xsl'), ":: " + IM.get_lang('Information User') + " - Expresso ::");
118        }
119
120        Templates.prototype.information_Contact = function(pVcardContact)
121        {
122                var _this = this;
123                var _XmlInfoContact = '<info_contact>' +
124                                                                 '<vcard> ' +
125                                                                        pVcardContact +
126                                                                 '</vcard> ' +         
127                                                                 '<getlang>'+
128                                                                        '<FN>' + IM.get_lang('Full Name') + '</FN>' +
129                                                                        '<NICKNAME>' + IM.get_lang('NickName') + '</NICKNAME>' +       
130                                                                        '<ORGUNIT>' + IM.get_lang('Orgunit') + '</ORGUNIT>' +   
131                                                                        '<ROLE>' + IM.get_lang('Role') + '</ROLE>' +   
132                                                                        '<BDAY>' + IM.get_lang('Birthday') + '</BDAY>' +       
133                                                             '</getlang>' +
134                                                          '</info_contact>';
135                _this.conf_form("divInfoContact",430,110,parse_XmlXsl(_XmlInfoContact,'info_contact.xsl'),":: Informações do Contato - Expresso ::");
136
137        }
138
139   Templates.prototype.emotions = function()
140   {
141          var smiles = new Array("\':)\'#smile_1.src","\':d\'#smile_2.src","\';)\'#smile_3.src","\':o\'#smile_4.src","\':p\'#smile_5.src","\'(h)\'#smile_6.src","\':@\'#smile_7.src","\':$\'#smile_8.src","\':s\'#smile_9.src","\':(\'#smile_10.src","\':\\\'\(\'#smile_11.src","\':|\'#smile_12.src");
142          var grid = '';
143              grid += '<table cellpadding="0" cellspacing="0" border="0">';
144              grid += '<tr>';
145                  for(var i = 0 ; i < 4; i++)   
146                      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
147                  grid += '</tr>';     
148              grid += '<tr>';
149                  for(var i = 4 ; i < 8; i++)   
150                      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
151                  grid += '</tr>';     
152              grid += '<tr>';
153                  for(var i = 8 ; i < 12; i++) 
154                      grid += '<td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion('+smiles[i].substr(0,smiles[i].indexOf('#'))+')" id="sendMessageMenuId"><img width="19" height="19" src="'+eval(smiles[i].substr(smiles[i].indexOf('#') + 1))+'" /></div></td>';
155                  grid += '</tr>';     
156              grid += '<tr>';
157              grid += '<td colspan="18"><hr style="background:#cccccc;margin:1px:size:1px;"/></td>';
158              grid += '</tr>';
159              grid += '<tr>';
160              grid += '<td colspan="18"><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideEmotionSelection()" id="closeEmotionSelectionDiv">Close This Menu</div></td>';
161              grid += '</tr>';
162              grid += '</table>';
163      return grid;
164   }
165
166   Templates.prototype.font_name = function()
167   {
168          var fonts_n = new Array("Arial:Arial","Courier:Courier","Times:Times New Roman");
169          var grid = '';
170
171          for(var i in fonts_n )
172          grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFont(\'' + fonts_n[i].substr(0,fonts_n[i].indexOf(':') + 1 )+'\')" id="fontStyle1" style="width:120px;font-family:'+fonts_n[i].substr(fonts_n[i].indexOf(':') + 1 )+'">' + fonts_n[i].substr(fonts_n[i].indexOf(':') + 1 ) + '</div>';       
173
174      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
175          grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontNameSelection()" id="fontStyle1" style="width:120px">Close This Menu</div>';
176
177      return grid;
178   }
179
180   Templates.prototype.font_size = function()
181   {
182      var fonts_s = new Array("9pt:9","10pt:10","11pt:11","12pt:12","14pt:14","16pt:16","18pt:18");
183      var grid = '';
184
185          for(var i in fonts_s)
186              grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'' + fonts_s[i].substr(0,fonts_s[i].indexOf(':')) + '\');" id="fontStyle1" style="width:100px">' + fonts_s[i].substr(fonts_s[i].indexOf(':') + 1 ) + '</div>';
187
188      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
189      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontSizeSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
190
191      return grid;
192   }
193
194   Templates.prototype.font_color = function()
195   {
196      var fonts_c = new Array("#000000:Black","#c0c0c0:Silver","#ffff00:Yellow","#ff0000:Red","#ff00ff:Pink","#00ff00:Green","#1111ff:Blue","#800080:Magenta");
197          var grid = '';                 
198         
199          for(var i in fonts_c)
200              grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'' + fonts_c[i].substr(0,fonts_c[i].indexOf(':')) + '\')" id="fontStyle1" style="width:100px">' + fonts_c[i].substr(fonts_c[i].indexOf(':') + 1 )  + '</div>';
201
202      grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
203      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontColorSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
204                     
205      return grid;
206   }
207
208   Templates.prototype.font_style = function()
209   {
210     var fonts = new Array("normal:Regular","italic:Italic","bold:Bold");
211     var grid = '';
212     
213     for(var i in fonts)
214        grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontStyle(\'' + fonts[i].substr(0,fonts.indexOf(':')) + '\')" id="fontStyle1" style="width:100px">' + fonts[i].substr( fonts[i].indexOf(':') + 1 ) + '</div>';
215     grid += '<hr style="background:#cccccc;margin:1px:size:1px;width:120px;"/>';
216     grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontStyleSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
217         
218     return grid;
219   }
220
221  /*
222   * Preferências do usuário
223   */
224   
225   Templates.prototype.yourPreferences = function()
226   {
227                var _this = this;
228                var _XmlPreferences = '<preferences />';
229                _this.conf_form("divYourPreferences",345,222,parse_XmlXsl(_XmlPreferences,'preferences.xsl'),":: Informações do Contato - Expresso ::");
230                IM_Preferences.LoadPreferences(null);
231   }
232
233   /*
234        * Send File
235        */
236
237   Templates.prototype.Send_file = function(pJid)
238   {
239                var _this = this;
240                var _XmlSendFile = '<send_file path="'+im_path+'" jid="'+pJid+'" lang1="'+IM.get_lang('Send File')+'" lang2="'+IM.get_lang('Send')+'" lang3="'+IM.get_lang('Status of the Transference')+'"/>';
241
242                _this.conf_form("divSendFile",360,110,parse_XmlXsl(_XmlSendFile,'send_file.xsl'),":: Envio de Arquivo - Expresso ::");
243   }
244
245   Templates.prototype.Wait_file = function(pJid)
246   {
247                if(document.getElementById("send_file_im").value != ""){
248                        document.getElementById("div_send_file_im").style.display = "none";
249                        document.getElementById("status_upload").style.display = "block";
250                        this.UpdateStatusSendFile(pJid);
251                }else{
252                        alert("É necessário informar um arquivo para envio!");
253                }
254        }
255
256        Templates.prototype.UpdateStatusSendFile = function(pJid)
257        {
258                var _this = this;
259                this.time_set = setTimeout("Templates.Wait_file('" + pJid + "')",80);
260                if(this.transfer == 100){
261                        clearTimeout(this.time_set);
262                        document.getElementById("div_send_file_im").style.display = "block";
263                        document.getElementById("status_upload").style.display = "none";
264                        document.getElementById("send_file_im").value = "";
265                        this.transfer = 0;
266                        this.time_set = "";
267
268                        var h_name_file = function(data){
269                                var pJID = pJid;
270                                var message_conf = '<iframe name="IM_down_file" style="display:none"></iframe>'+
271                                                                   '<b>VOCÊ ACABA DE RECEBER UM ARQUIVO !!!!&nbsp;</b>'+
272                                                                   '<a href="../instant_messenger/inc/class.download.inc.php?file=' + data + '" target="IM_down_file">Clique aqui</a>';
273                                var Conf_send_file = function(data){
274                                if(!data)
275                                alert(data);
276                         }
277                        cIM.cExecute("$this.Ujabber.SendMessage",Conf_send_file,"to="+pJID+"&body="+url_encode(encodeURI(message_conf)));
278                        }
279                        cIM.cExecute("$this.upload.name_file",h_name_file);
280                }else{
281                        var h_size_file = function(data){
282                                _this.transfer++;
283                                document.getElementById("progressbar_f").style.width = _this.transfer + "%";
284                                document.getElementById("porcent_im").innerHTML = _this.transfer + "%";
285                        }
286                        cIM.cExecute("$this.upload.size_file",h_size_file);
287                }
288        }
289
290        //Templates
291        var Templates = new Templates();
Note: See TracBrowser for help on using the repository browser.