source: trunk/expressoMail1_2/js/jscode/draw_messages.js @ 2930

Revision 2930, 33.9 KB checked in by amuller, 14 years ago (diff)

Ticket #1059 - Diminui o tamanho do nome de variáveis com mais de 25 caracteres

Line 
1draw_message.prototype.draw_message_header = function(header,border_id){
2        this.id = border_id;
3
4        var table_message = createAndSet("TABLE",['id','border','width'],['table_message_'+border_id,"0","100%"]);
5        table_message.id = 'table_message_'+border_id;
6        var tbody_message = document.createElement("TBODY");
7        if (!this.make_options_message(header,tbody_message))
8                return;
9
10        table_message.appendChild(tbody_message);
11        var content = document.getElementById('content_id_' + border_id);
12        content.style.height = (window.innerHeight ? window.innerHeight : document.body.offsetHeight) - 180;
13        content.appendChild(table_message);
14        loading_img = content.appendChild(loading_img);
15};
16
17
18draw_message.prototype.draw_message_body = function (info_msg){
19        var table_message = Element('table_message_'+this.id);
20        var tbody_message = table_message.childNodes[0];
21
22        var _bodymsg_otheropt = document.createElement("TBODY");
23        var tr1 = document.createElement("TR");
24        tr1.className = "tr_message_header";
25        var td1 = createAndSet('TD',['width'],['7%'],get_lang("From: "));
26        td1.appendChild(deny_email(info_msg.from.email));
27        var id=this.id;
28
29        if (info_msg.sender){
30                var tr111 = document.createElement("TR");
31                tr111.className = "tr_message_header";
32                var td111 = createAndSet('TD',['noWrap'],['true'],get_lang("Sent by")+": ");
33                td111.appendChild(deny_email(info_msg.sender.email));
34                var sender = document.createElement("TD");
35                sender.className = "header_message_field";
36                sender.id = "sender_"+id;
37                sender.innerHTML += this.draw_plugin_cc(info_msg.sender.full);
38                var sender_values = createAndSet("INPUT",['id','type','value'],["sender_values_"+id,"HIDDEN",info_msg.sender.full]);
39
40                _bodymsg_otheropt.appendChild(appendChilds(tr111, td111, sender, sender_values));
41        }
42       
43        var from = createAndSet('TD',['id','class'],["from_"+this.id,"header_message_field"],info_msg.from.full);
44
45        if (info_msg.Draft != "X"){
46                from.innerHTML += this.draw_plugin_cc(info_msg.from);
47                _bodymsg_otheropt.appendChild(tr1);
48        }
49        var from_values = createAndSet('INPUT',['id','type','value'],["from_values_"+id,"HIDDEN",info_msg.from.full]);
50        var local_message = createAndSet("INPUT",['id','name','type','value'],["is_local_"+this.id,"is_local","HIDDEN",(info_msg.local_message)?"1":"0"]);
51        appendChilds(tr1,td1,from,from_values,local_message);
52
53        if(typeof(info_msg.signature) != 'undefined'){
54            if(info_msg.signature.length > 0){
55                var aux_signature = '';
56                for (i=0; i < info_msg.signature.length; i++)
57                   aux_signature += '<span>'+info_msg.signature[i]+'</span> <br /> ';
58                var tr7 = document.createElement("TR");
59                tr7.className = "tr_message_header";
60                var td7 = document.createElement("TD");
61                td7.innerHTML = 'Assinatura<br/>Digital:';
62                td7.vAlign = 'top';
63                var _certs = createAndSet('TD',['id', 'class'],["certs_"+this.id, "header_message_field"],aux_signature);
64                _bodymsg_otheropt.appendChild(appendChilds(tr7,td7,_certs));
65            }
66        }
67       
68        if (info_msg.reply_to){
69                var tr11 = document.createElement("TR");
70                tr11.className = "tr_message_header";
71                var _td11 = createAndSet('TD',['noWrap'],['true'],get_lang("Reply to")+": ");
72                var _reply_to = createAndSet('TD',['id', 'class'],["reply_to_"+id, "header_message_field"],this.draw_plugin_cc(info_msg.reply_to));
73                var _reply_to_values = createAndSet('INPUT',['id', 'type', 'value'],["reply_to_values_"+id,"HIDDEN",info_msg.reply_to]);
74                _bodymsg_otheropt.appendChild(appendChilds(tr11,_td11,_reply_to,_reply_to_values));
75        }
76        //////////////////////////////////////////////////////////////////////////////////////////////////////
77        var tr2 = document.createElement("TR");
78        tr2.className = "tr_message_header";
79        var td2 = document.createElement("TD");
80        td2.innerHTML = get_lang("To: ");
81        var to = document.createElement("TD");
82        to.id = "to_"+id;
83
84        var _to_values = createAndSet('INPUT',['id', 'type', 'value'],["to_values_"+id, "HIDDEN", info_msg.toaddress2]);
85        // Salva a pasta da mensagem
86        var _input_cfolder = createAndSet('INPUT',['id', 'name', 'type', 'value'],["input_folder_"+id, "input_folder", "hidden", info_msg.msg_folder]);
87        td2.appendChild(_input_cfolder);
88
89        toaddress_array[id] = info_msg.toaddress2.split(",");
90        if (toaddress_array[id].length > 1){
91                to.innerHTML += this.draw_plugin_cc(toaddress_array[id][0]);
92                var _div_toaddrs = createAndSet('SPAN',['id','style'],["div_toaddress_"+id,'display: inline']," (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+id+"','to');>"+get_lang('more')+"</a>)");
93                to.appendChild(_div_toaddrs);
94        }
95        else {
96                toAdd = toaddress_array[id].toString().replace("<","&lt;");
97                toAdd = toAdd.replace(">","&gt;");
98                to.innerHTML += this.draw_plugin_cc(toAdd);
99        }
100        to.className = "header_message_field";
101        _bodymsg_otheropt.appendChild(appendChilds(tr2,td2,to,_to_values));
102
103        if (info_msg.cc){
104                var tr3 = document.createElement("TR");
105                tr3.className = "tr_message_header";
106                var td3 = document.createElement("TD");
107                td3.innerHTML = "CC: ";
108                var cc = createAndSet("TD",['id', 'class'],["cc_"+this.id,"header_message_field"]);
109
110                var cc_values = createAndSet("INPUT",['id', 'type', 'value'],["cc_values_"+this.id, "HIDDEN", info_msg.cc]);
111                ccaddress_array[this.id] = info_msg.cc.split(",");             
112                if (ccaddress_array[this.id].length > 1){
113                        var div_ccaddress = document.createElement("SPAN");
114                        div_ccaddress.id = "div_ccaddress_"+this.id;
115                        var div_ccaddress_full = createAndSet("SPAN",['id', 'style'],["div_ccaddress_full_"+this.id, "display: inline"]);
116                        cc.innerHTML = this.draw_plugin_cc(ccaddress_array[this.id][0]);
117                        div_ccaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+this.id+"','cc');>"+get_lang('more')+"</a>)";
118                        cc.appendChild(div_ccaddress);
119                }
120                else{
121                        cc.innerHTML = this.draw_plugin_cc(info_msg.cc);
122                }
123                _bodymsg_otheropt.appendChild(appendChilds(tr3,td3,cc,cc_values));
124        }
125
126        if (info_msg.bcc)
127        {
128                _bodymsg_otheropt.appendChild(this.getBcc(info_msg.bcc));
129        }
130
131        var tr4 = document.createElement("TR");
132        tr4.className = "tr_message_header";
133        var td4 = document.createElement("TD");
134        td4.innerHTML = get_lang("Date: ");
135        var msgFull = info_msg.fulldate.split(' ');
136
137        var date = createAndSet('TD',['id','class'],["date_"+id,"header_message_field"],info_msg.fulldate);
138        var date_day = createAndSet('INPUT',['id', 'type', 'value'],["date_day_"+id, "HIDDEN", msgFull[0]]);
139        var date_hour = createAndSet('INPUT',['id', 'type', 'value'],["date_hour_"+id, "HIDDEN", msgFull[1]]);
140        _bodymsg_otheropt.appendChild(appendChilds(tr4,td4,date,date_day,date_hour));
141
142        var tr5 = document.createElement("TR");
143        tr5.className = "tr_message_header";
144        var td5 = document.createElement("TD");
145        td5.innerHTML = get_lang("Subject");
146        var subject = createAndSet('TD',['id', 'class'],["subject_"+this.id, "header_message_field"],info_msg.subject);
147        _bodymsg_otheropt.appendChild(appendChilds(tr5,td5,subject));
148        if ( info_msg.attachments  && info_msg.attachments.length > 0){
149                var tr6 = document.createElement("TR");
150                tr6.className = "tr_message_header";
151                var td6 = document.createElement("TD");
152                td6.innerHTML = get_lang("Attachments: ");
153
154                var attachments = document.createElement("TD");
155                attachments.align='left';
156                td6.vAlign = "top";
157
158                var zipped_attachments = '';
159                if(info_msg.attachments.length >= 1) {
160                        var zipped_attachments  = createAndSet("TABLE",['style','cellPadding','cellSpacing'],['margin-bottom: 4px','0','0']);
161                        var td = document.createElement("TD");
162                        if(info_msg.attachments.length > 1) {
163                                var link_attachment     = document.createElement("A");
164                                if(proxy_mensagens.is_local_folder(current_folder))
165                                        link_attachment.setAttribute("href", "javascript:expresso_local_messages._downalllocalatt('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
166                                else
167                                        link_attachment.setAttribute("href", "javascript:download_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
168                                link_attachment.innerHTML = " "+info_msg.attachments.length+' '+get_lang('files')+' :: '+get_lang('Download all atachments');
169                                link_attachment.innerHTML += '<BR>';
170                                td.appendChild(link_attachment);
171                        }
172                        var tr = document.createElement("TR");
173                        if(parseInt(preferences.remove_attachments_function))
174                        {
175                                var del_attachments = document.createElement("A");
176                                del_attachments.setAttribute("href", "javascript:remove_all_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"')");
177                                del_attachments.innerHTML = get_lang('remove all attachments');
178                                del_attachments.appendChild(document.createElement('BR'));
179                                td.appendChild(del_attachments);
180                                tr.appendChild(td);
181                        }
182                        tr.appendChild(td);
183                        zipped_attachments.appendChild(tr);
184                        attachments.appendChild(zipped_attachments);
185                }
186
187                attachments.id = "attachments_" + this.id;
188                for (var i=0; i<info_msg.attachments.length; i++){
189                        var link_attachment = document.createElement("A");
190                        link_attachment.setAttribute("href", proxy_mensagens.link_anexo(info_msg,i));
191                        //link_attachment.setAttribute("href", "javascript:download_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"',"+i+",'"+info_msg.attachments[i].pid+"','"+info_msg.attachments[i].encoding+"')");
192                        link_attachment.innerHTML = url_decode(info_msg.attachments[i].name);
193                        link_attachment.innerHTML += "&nbsp;"+borkb(info_msg.attachments[i].fsize);
194
195                        if((url_decode(info_msg.attachments[i].name).indexOf(".ics")!=-1) || (url_decode(info_msg.attachments[i].name).indexOf(".vcard")!=-1)){
196                                //Link para importar calendário
197                                var link_import_attachment = createAndSet("IMG",['src','onclick','title','align','style'],["templates/"+template+"/images/new.png","javascript:import_calendar('"+info_msg.msg_folder+"&msg_number="+info_msg.msg_number+"&msg_part="+info_msg.attachments[i].pid+"&idx_file="+i+"&encoding="+info_msg.attachments[i].encoding+"');",get_lang("Import to calendar"),"top","cursor: pointer"]);
198                                var space = document.createElement("span");
199                                space.innerHTML = "&nbsp;";
200                                appendChilds(attachments,link_attachment,space,link_import_attachment);
201                        }
202                        else {
203                                link_attachment.innerHTML += '<BR>';
204                                attachments.appendChild(link_attachment);
205                        }
206                }
207                tr6.appendChild(td6);
208                tr6.appendChild(attachments);
209                _bodymsg_otheropt.appendChild(tr6);
210        }
211
212        var div = document.createElement("DIV");
213        div.id = "div_message_scroll_"+this.id;
214        div.style.background = 'WHITE';
215        div.style.overflow = "auto";
216        div.style.width = "100%";
217
218        var table_msg_details = createAndSet("TABLE",['id','width','class'],['table_msg_details_' + this.id, '100%','table_message']);
219        table_msg_details.style.display = 'none';
220        table_msg_details.appendChild(_bodymsg_otheropt);
221        div.appendChild(table_msg_details);
222
223        var tr = document.createElement("TR");
224        var td = document.createElement("TD");
225        td.colSpan = '2';
226
227        var newBody = this.blockImage(info_msg,this.id,td);
228
229        td.appendChild(div);
230        tr.appendChild(td);
231        tbody_message.appendChild(tr);
232
233        ////////////////////////////////////////////////////////////////////////////////////////////////////// 
234        //Make the body message.
235        ///////////////////////////////////////////////////////////////////////////////////////////////////////
236        var tr = document.createElement("TR");
237        tr.className = "tr_message_body";
238        var td = document.createElement("TD");
239        //td.setAttribute("colSpan","2");
240        newBody = newBody.replace("<body","<span");
241        newBody = newBody.replace("<BODY","<span");
242        div.innerHTML+= "<span id='body_"+this.id+"' style='font-size:16px;'>"+newBody+"</span><br><br>";
243        function mailto( link )
244        {
245                var mail = link.href.substr( 7 );
246                link.onclick = function( )
247                {
248                        new_message_to( mail );
249                        return false;
250                };
251        }
252        var links = div.getElementsByTagName( 'a' );
253        for ( var i = 0; i < links.length; i++ ){
254                try{
255                        if ( links.item( i ).href.indexOf( 'mailto:' ) === 0 ){                         
256                                mailto( links.item( i ) );
257                        }
258                        else{
259                                if ( links.item( i ).href.indexOf( 'javascript:' ) !== 0 )
260                                        links.item( i ).setAttribute( 'target', '_blank' );
261                        }
262                }catch(e){
263                }
264        }
265
266        if ((info_msg.thumbs)&&(info_msg.thumbs.length > 0)){
267                ////////////////////////////////////////////////////////////////////////////////////////////////////// 
268                //Make the thumbs of the message.
269                //////////////////////////////////////////////////////////////////////////////////////////////////////
270                div.appendChild(this.getThumbs(info_msg.attachments, info_msg.thumbs, info_msg.msg_number, info_msg.msg_folder));
271        }
272
273
274        var msg_number = createAndSet("INPUT",['id','type','value'],["msg_number_" + this.id, "hidden", info_msg.msg_number]);
275        var content = document.getElementById('content_id_' + this.id);
276        try{
277                loading_img = content.removeChild( loading_img );
278        }
279        catch(e){
280                delete_border(this.id);
281                setTimeout('expresso.connector.cacheNextRequest();'+
282                        'cExecute("expressoMail1_2.imap_functions.get_info_msg&msg_number='+ info_msg.msg_number + '&msg_folder=" + current_folder, show_msg)',200);
283        };
284        content.appendChild(msg_number);
285        //////////////////////////////////////////////////////////////////////////////////////////////////////
286
287        //Exibe o cabecalho da mensagem totalmente aberto caso esteja setado nas preferencias do usuario
288        if (preferences.show_head_msg_full == 1)
289        {
290                option_hide_more.onclick();
291
292                if (Element('div_toaddress_'+this.id) != null)
293                {
294                        show_div_address_full(this.id,'to');
295                }       
296                if (Element('div_ccaddress_'+this.id) != null)
297                {
298                        show_div_address_full(this.id,'cc');
299                }
300        }
301
302};
303
304draw_message.prototype.make_options_message = function(info_msg, tbody_message){
305        var tr0 = document.createElement("TR");
306        tr0.className = "tr_message_header";
307        var td0 = document.createElement("TD");
308        var table_message_options = createAndSet("TABLE",['border','width','class'],["0","100%",'table_message']);
309        var tbody_message_options = document.createElement("TBODY");
310        var tr = document.createElement("TR");
311        var td = document.createElement("TD");
312        td.setAttribute("noWrap","true");
313        var _name = '';
314        var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
315
316        var folder_id = info_msg.msg_number;
317        var folder = document.getElementById(folder_id);
318        if (!folder){
319                delete_border(this.id);
320                return false;
321        }
322
323        var next_previous_msg_td = this.createNxtPrevButtons(info_msg.msg_folder,folder_id);
324        if (typeof(next_previous_msg_td) == 'undefined')
325                return false;
326
327
328        var _maxChar = menuHidden ? 40 : 15;
329
330        if (info_msg.from.name)
331        {
332                var spanName = document.createElement("SPAN");
333                spanName.innerHTML = info_msg.from.name;
334                _name = spanName.innerHTML.length > _maxChar ? spanName.innerHTML.substring(0,_maxChar) + "..." : spanName.innerHTML;
335        }
336        else
337                _name = info_msg.from.email.length > _maxChar ? info_msg.from.email.substring(0,_maxChar) + "..." : info_msg.from.email;
338        var id = this.id;
339        td.innerHTML = _name.bold() + ', ' + info_msg.udate;
340        if (info_msg.attachment.names.length > 0)
341                td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+id+"\").onclick()' src ='" + URL_SERVER + "expressoMail1_2/templates/"+template+"/images/clip.gif' title='"+info_msg.attachment.names+"'>";
342
343        if(typeof(info_msg.signature) != 'undefined')
344            {
345                        if(info_msg.signature[0].indexOf('Message untouched') >= 0)
346                            td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+id+"\").onclick()' src ='" + URL_SERVER + "expressoMail1_2/templates/"+template+"/images/signed_msg.gif' title='"+get_lang("Details")+"'>";
347                        else
348                            td.innerHTML += "&nbsp<img style='cursor:pointer' onclick='javascript:Element(\"option_hide_more_"+id+"\").onclick()' src ='" + URL_SERVER + "expressoMail1_2/templates/"+template+"/images/invalid.gif' title='"+get_lang("Details")+"'>";
349            }
350           
351        if (info_msg.DispositionNotificationTo)
352        {
353                td.innerHTML += '&nbsp;<img style="cursor:pointer" alt="'+ get_lang('Message with read notification') + '" title="'+ get_lang('Message with read notification') + '" src="' + URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/notification.gif">';
354        }
355
356        // NORMAL MSG
357        if(info_msg.Draft != 'X')
358        {
359                var options = createAndSet("TD",['noWrap','width','align'],['true','30%','right']);
360                var option_hide_more = createAndSet("SPAN",['class','value','id'],['message_options','more_options','option_hide_more_'+id],get_lang('show details'));
361                option_hide_more.onclick = function(){
362                        if (this.value != 'hide_options'){
363                                this.innerHTML = "<b><u>"+get_lang('hide details')+"</u></b>";
364                                this.value = 'hide_options';
365                                Element('table_msg_details_'+id).style.display = '';
366
367                        }
368                        else{
369                                this.innerHTML = get_lang('show details');
370                                this.value = 'more_options';
371                                Element('table_msg_details_'+id).style.display = 'none';
372                        }
373                        resizeWindow();
374                };
375                var option_mark = createAndSet("TD",['width','align'],['50%','left']);
376                var option_mark_as      = '<span>'+get_lang("Mark as")+'</span>: ';
377                var option_mark_as_unseen = '<span class="message_options" onclick="changeLinkState(this,\'seen\');set_messages_flag(\'unseen\','+
378                                                folder_id+');write_msg(\''+get_lang('Message marked as ')+get_lang("Unseen")+
379                                                '.\');">'+get_lang("Unseen")+'</span>, ';
380
381                if (info_msg.Flagged == "F")
382                        var _optmarkimportant = '<span class="message_options" onclick="changeLinkState(this,\'important\');set_messages_flag(\'unflagged\','+
383                                                        folder_id+');write_msg(\''+get_lang('Message marked as ')+get_lang("Normal")+
384                                                        '.\');">'+get_lang("Normal")+'</span>';
385                else
386                        var _optmarkimportant = '<span class="message_options" onclick="changeLinkState(this,\'normal\');set_messages_flag(\'flagged\','+folder_id+');write_msg(\''+get_lang('Message marked as ')+get_lang("Important")+
387                                                                    '.\');">'+get_lang("Important")+'</span>';
388                option_mark.innerHTML = option_mark_as+option_mark_as_unseen+_optmarkimportant;
389
390                var option_forward = createAndSet("SPAN",['id','class'],['msg_opt_forward_'+this.id, 'message_options'],get_lang('Forward'));
391                option_forward.onclick = function(){new_message('forward', this.id);};
392                appendChilds(options,option_hide_more,createAndSet('SPAN',false,false,'&nbsp;|&nbsp;'),option_forward);
393
394                var option_reply_options = createAndSet("IMG",['id', 'src', 'value'],['msg_opt_reply_options_'+id,URL_SERVER+'expressoMail1_2/templates/default/images/down.png','show']);
395                option_reply_options.onmouseover = function(){
396                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/over.png';
397                };
398                option_reply_options.onmouseout = function(){
399                        if (this.value == 'show')
400                        {
401                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/down.png';
402                        }
403                        else
404                        {
405                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/pressed.png';
406                        }
407                };
408                option_reply_options.onclick = function(){
409                        if (this.value != 'hide'){
410                                this.value = 'hide';
411                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/pressed.png';
412                                Element('tr_other_options_'+id).style.display = '';
413
414                        }
415                        else{
416                                this.value = 'show';
417                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/down.png';
418                                Element('tr_other_options_'+id).style.display = 'none';
419                        }
420                };
421
422                var _option_reply = createAndSet("SPAN",['id','class'],['msg_opt_reply_'+id,'message_options'],get_lang('Reply'));
423                _option_reply.onclick = function(){new_message('reply_with_history', id);};
424
425                appendChilds(options,createAndSet('SPAN',false,false,'&nbsp;|&nbsp;'),option_reply_options,_option_reply);
426                appendChilds(tr,td,option_mark,options,next_previous_msg_td);
427                tbody_message_options.appendChild(tr);
428
429                ////////// OTHER OPTIONS ////////////////////
430                var _tr_other_options = createAndSet("TR",['id'],['tr_other_options_' + id]);
431                _tr_other_options.style.display = 'none';
432
433                var div_other_options = document.createElement("DIV");
434
435                var option_mark_as_unseen       = '<span class="message_options" onclick="proxy_mensagens.proxy_set_messages_flag(\'unseen\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Unseen")+'.\');">'+get_lang("Unseen")+'</span>, ';
436                var _optmarkimportant                   = '<span class="message_options" onclick="proxy_mensagens.proxy_set_messages_flag(\'flagged\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Important")+'.\');">'+get_lang("Important")+'</span>, ';
437                var option_mark_as_normal                               = '<span class="message_options" onclick="proxy_mensagens.proxy_set_messages_flag(\'unflagged\','+info_msg.msg_number+');write_msg(\''+get_lang('Message marked as ')+get_lang("Normal")+'.\');">'+get_lang("Normal")+'</span> | ';
438
439                var _opt_rplywithout_hist               = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_without_history","'+id+'");>'+get_lang("Reply without history")+'</span>';
440                var option_reply_to_all                                 = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_to_all_with_history","'+id+'");>'+get_lang("Reply to all")+'</span> | ';
441
442                var _optreply_allwhithout_hist  = '<span onmouseover="this.className=\'reply_options_active\'" onmouseout="this.className=\'reply_options\'" class="reply_options" onclick=new_message("reply_to_all_without_history","'+id+'");>'+get_lang("Reply to all without history")+'</span> | </div>';
443
444                div_other_options.innerHTML = option_reply_to_all + _optreply_allwhithout_hist + _opt_rplywithout_hist;
445                if (use_spam_filter) {
446                        if(info_msg.msg_folder == 'INBOX'+cyrus_delimiter+'Spam')
447                                div_other_options.innerHTML += ' | <span class="reply_options" onclick="nospam('+info_msg.msg_number+',\'null\', \''+info_msg.msg_folder+'\')";>'+get_lang("Not Spam")+'</span>';
448                        else
449                                div_other_options.innerHTML += ' | <span class="reply_options" onclick="spam(\''+info_msg.msg_folder+'\', '+info_msg.msg_number+',\'null\')";>'+get_lang("Mark as Spam")+'</span>';
450                }
451
452                var td_other_options = createAndSet("TD",['colSpan','align','noWrap'],['3','right','true']);
453                td_other_options.appendChild(div_other_options);
454
455                _tr_other_options.appendChild(td_other_options);
456                tbody_message_options.appendChild(_tr_other_options);
457                ////////// END OTHER OPTIONS ////////////////
458                table_message_options.appendChild(tbody_message_options);
459                td0.appendChild(table_message_options);
460                tr0.appendChild(td0);
461                tbody_message.appendChild(tr0);
462                //if (info_msg.signature && info_msg.signature.length > 0)
463                //{
464                        //tbody_message.appendChild(draw_msg.putSignature(this.id,info_msg,td));
465                        //alert(info_msg.signature);
466                //}
467        }
468        else    // IF DRAFT
469        {
470                var options = createAndSet('TD',['width','noWrap','align'],['1%','true','right']);
471                var option_hide_more = createAndSet("SPAN",['class','value','id'],['message_options','more_options','option_hide_more_'+this.id],get_lang('Show details'));
472                option_hide_more.onclick = function(){
473                        var _height = Element("div_message_scroll_"+id).style.height;
474                        _height = parseInt(_height.replace("px",""));
475                        var _offset = 35;
476                        if (this.value != 'hide_options'){
477                                this.innerHTML = "<b><u>"+get_lang('Hide details')+"</u></b>";
478                                this.value = 'hide_options';
479                                Element("div_message_scroll_"+id).style.height = (_height - _offset)+"px";
480                                Element('table_msg_details_'+id).style.display = '';
481                        }
482                        else{
483                                this.innerHTML = get_lang('show details');
484                                this.value = 'more_options';
485                                Element("div_message_scroll_"+id).style.height = (_height + _offset)+"px";
486                                Element('table_msg_details_'+id).style.display = 'none';
487                        }
488                };
489                var option_edit = createAndSet('SPAN',['class'],['message_options'], get_lang('Edit'));
490                option_edit.onclick= function () { new_message('edit',this.id); };
491                appendChilds(options, option_hide_more, createAndSet('SPAN',false,false,"&nbsp;|&nbsp;"), option_edit);
492
493                tbody_message_options.appendChild(appendChilds(tr, td, options, next_previous_msg_td));
494                table_message_options.appendChild(tbody_message_options);
495                td0.appendChild(table_message_options);
496                tr0.appendChild(td0);
497                tbody_message.appendChild(tr0);
498        }
499        return true;
500};
501
502
503/* Class draw_message */
504function draw_message(){
505        this.id=0;
506}
507draw_message.prototype.createNxtPrevButtons = function(msg_folder,folder_id){
508        var next_previous_msg_td = createAndSet("TD",[ "noWrap", "align", "width" ], [ "true", "right", "40px"]);
509        var img_next_msg = createAndSet("IMG", [ 'id', 'src', 'title' ], [
510                        'msg_opt_next_' + this.id,
511                        URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/down.button.png',
512                        get_lang('Next') ]);
513        img_next_msg.style.cursor = 'pointer';
514
515        var folder = document.getElementById(folder_id);
516        if (folder){ // mensagem local criptografada nao tem ID da pasta local
517                if (folder.nextSibling){
518                        var nextMsgBox = folder.nextSibling.name?folder.nextSibling.name:msg_folder;
519
520                        if (nextMsgBox == "INBOX/decifradas")// teste para ver se a mensagem vem da pasta oculta decifradas
521                                nextMsgBox = get_current_folder();
522
523                        img_next_msg.onclick = function()
524                        {
525                                openTab.type[currentTab] = 2;
526                                if ( nextMsgBox == undefined )
527                                       nextMsgBox = current_folder;
528                                for (var i=0; i < draw_box.headers_msgs.length; i++)
529                                        if (draw_box.headers_msgs[i].msg_number == folder.nextSibling.id){
530                                                var nextHeader = draw_box.headers_msgs[i];
531                                                break;
532                                        }
533                                proxy_mensagens.get_msg(nextHeader,nextMsgBox,true,show_msg,currentTab);
534                        };
535                }
536                else
537                {
538                        img_next_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/down.gray.button.png';
539                        img_next_msg.style.cursor = 'default';
540                }
541        }
542        else
543        {
544                img_next_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/down.gray.button.png';
545                img_next_msg.style.cursor = 'default';
546                if (!proxy_mensagens.is_local_folder(get_current_folder()) && !(msg_folder == "INBOX/decifradas")) // testa se a mensagem e local
547                {
548                        img_next_msg.onclick = function()
549                        {
550                                delete_border(this.id);
551                        };
552                }
553        }
554        var img_space = document.createElement("SPAN");
555        img_space.innerHTML = "&nbsp;";
556        var img_previous_msg = createAndSet("IMG",['id','src','title'],['msg_opt_previous_' + this.id,
557                        URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/up.button.png',
558                        get_lang('Previous')]);
559        img_previous_msg.style.cursor = 'pointer';
560
561        if (!folder){
562                delete_border(this.id);
563                return;
564        }
565        if (folder){ // mensagem local criptografada nao tem this.id da pasta local
566                if (folder.previousSibling)
567                {
568                        var previousMsgBox = folder.previousSibling.name?folder.previousSibling.name:msg_folder;
569
570                        if (previousMsgBox == "INBOX/decifradas") // teste para ver se a mensagem vem da pasta oculta decifradas
571                                previousMsgBox = get_current_folder();
572
573                        img_previous_msg.onclick = function()
574                        {
575                                openTab.type[currentTab] = 2;
576                                if ( previousMsgBox == undefined )
577                                       previousMsgBox = current_folder;
578                                 for (var i=0; i < draw_box.headers_msgs.length; i++)
579                                        if (draw_box.headers_msgs[i].msg_number == folder.previousSibling.id){
580                                                var previousHeader = draw_box.headers_msgs[i];
581                                                break;
582                                        }
583                                proxy_mensagens.get_msg(previousHeader,previousMsgBox,true,show_msg,currentTab);
584                        };
585                }
586                else
587                {
588                        img_previous_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/up.gray.button.png';
589                        img_previous_msg.style.cursor = 'default';
590                }
591        }
592        else
593        {
594                img_previous_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/up.gray.button.png';
595                img_previous_msg.style.cursor = 'default';
596                if (!proxy_mensagens.is_local_folder(get_current_folder()) && !(msg_folder == "INBOX/decifradas")) // testa se a mensagem e local
597                {
598                        img_previous_msg.onclick = function()
599                        {
600                                delete_border(this.id);
601                        };
602                }
603        }
604        next_previous_msg_td.appendChild(img_previous_msg);
605        next_previous_msg_td.appendChild(img_space);
606        next_previous_msg_td.appendChild(img_next_msg);
607        return next_previous_msg_td;
608
609};
610var idx_cc = 0;
611draw_message.prototype.draw_plugin_cc = function(addrs)
612{
613    expresso.connector.loadScript("jscode/ccQuickAdd");
614    var id=this.id;
615
616    var array_addrs = '';
617    var array_name      = '';
618    var cc_data = new Array();
619    if(typeof(addrs.name) != 'undefined') {
620        array_name      = LTrim(addrs.name).split(" ");
621        array_addrs = new Array(addrs.email);
622    }
623    else {
624        array_addrs = (typeof addrs == 'object' ? addrs.toString().split("\" ") : addrs.split("\" "));
625        array_name      = LTrim(array_addrs[0]).replace('"','').split(" ");
626    }
627
628    var _split = array_name[0].split('@');
629    cc_data[0] = _split[0];
630    cc_data[1] = _split[0];
631    cc_data[2] = '';
632
633    for (i=1; i < array_name.length; i++)
634        cc_data[2] += array_name[i] + " ";
635
636
637    if(array_addrs.length > 1)
638        cc_data[3] = array_addrs[1] ? array_addrs[1].replace("&lt;",'').replace("&gt;",'') : '';
639    else
640        cc_data[3] = array_addrs[0];
641
642    var sm_envelope_img1 = '<img style="cursor:'+ (is_ie ? 'hand' : 'pointer') +'" title="' + get_lang("Add Contact") +
643    '" onclick="ccQuickAddOne.showList(\''+cc_data+'\')" src="' + URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/user_card.png">';
644    var to_addybook_add = "<SPAN id='insert_plugin_"+idx_cc+"_"+id+"'>";
645    to_addybook_add += addrs;
646    to_addybook_add +=  sm_envelope_img1;
647    idx_cc++;
648    to_addybook_add += "</SPAN>";
649    return to_addybook_add;
650};
651
652draw_message.prototype.getThumbs = function(attachments, thumbs, msg_number, msg_folder){
653                var table_message_thumbs = document.createElement("TABLE");
654                table_message_thumbs.width = "80%";
655                table_message_thumbs.style.borderTop = "2px solid rgb(170, 170, 170)";
656                var tbody_message_thumbs = document.createElement("TBODY");
657                var tr = document.createElement("TR");
658                tr.className = "tr_message_body";
659                var td = document.createElement("TD");
660                td.setAttribute("colSpan","2");
661                td.id = "body_thumbs_"+msg_number;
662                td.innerHTML += "&nbsp;<font color='DARKBLUE' size='2'><b>"+attachments.length+" "+get_lang("attachment")+(attachments.length > 1 ? "s" : "")+" "+get_lang("in this message")+"</font></b>";
663                var _link_attachments = '';
664                if(thumbs.length > 1){
665                        _link_attachments       = document.createElement("A");
666                        _link_attachments.className = "message_options";
667                        if(proxy_mensagens.is_local_folder(current_folder))
668                                _link_attachments.setAttribute("href", "javascript:expresso_local_messages._downalllocalatt('"+msg_folder+"','"+msg_number+"')");
669                        else
670                                _link_attachments.setAttribute("href", "javascript:download_all_attachments('"+msg_folder+"','"+msg_number+"')");
671                        _link_attachments.innerHTML = get_lang('Download all atachments');
672                }
673
674                if(_link_attachments){
675                        td.innerHTML += " :: ";
676                        td.appendChild(_link_attachments);
677                }
678
679                td.innerHTML += "<BR><img src='" + URL_SERVER + "expressoMail1_2/templates/"+template+"/images/menu/ktip.png'>"+get_lang("<b>Tip:</b> For faster save, click over the image with <u>right button</u>.");
680                td.innerHTML += "<BR>";
681
682                for (var i=0; i<thumbs.length; i++){
683                        if ((i % 4) == 0)
684                                td.innerHTML += "<BR>";
685                        td.innerHTML += thumbs[i];
686                        td.innerHTML += "&nbsp;&nbsp;";
687                }
688                tr.appendChild(td);
689                tbody_message_thumbs.appendChild(tr);
690                table_message_thumbs.appendChild(tbody_message_thumbs);
691                return table_message_thumbs;
692};
693
694draw_message.prototype.getBcc = function(bccField){
695        /*
696         * @AUTHOR Rodrigo Souza dos Santos
697         * @MODIFY-DATE 2008/09/11
698         * @BRIEF Adding routine to create bcc (blind carbon copy) field if there is one.
699         */
700        var tr3 = document.createElement("tr");
701        tr3.className = "tr_message_header";
702        var td3 = document.createElement("td");
703        td3.innerHTML = get_lang("BCC") + " : ";
704        var cco = document.createElement("td");
705        cco.id = "cco_"+this.id;
706
707        var cco_values = createAndSet("INPUT",['id', 'type', 'value'],["cco_values_"+this.id,"hidden",bccField]);
708        ccoaddress_array[this.id] = bccField.split(",");               
709        if (ccoaddress_array[this.id].length > 1){
710                var div_ccoaddress = document.createElement("SPAN");
711                div_ccoaddress.id = "div_ccoaddress_"+this.id;
712                var div_ccoaddress_full = createAndSet("SPAN",['id', 'style'],["div_ccoaddress_full_"+this.id, "display:inline"]);
713                /*
714                 * The function below is ugly, doesn't possible use this.
715                 * The problem is that the code's function was written
716                 * on a hardcode concept.
717                 */
718                //cco.innerHTML = this.draw_plugin_cc(ccoaddress_array[this.id][0]);
719                cco.innerHTML = ccoaddress_array[this.id][0];
720                div_ccoaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+this.id+"','cco');>"+get_lang('more')+"</a>)";
721                cco.appendChild(div_ccoaddress);
722        }
723        else{
724                /*
725                 * The function below is ugly, it is not possible to use this.
726                 * The problem is that the code's function was written
727                 * on a hardcode concept.
728                 */
729                //cco.innerHTML = this.draw_plugin_cc(info_msg.cco);
730                cco.innerHTML = bccField;
731        }
732        cco.className = "header_message_field";
733        return appendChilds(tr3,td3,cco,cco_values);
734};
735
736draw_message.prototype.blockImage = function(info_msg,ID,td){
737        var imgTag = info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi);
738
739        var newBody = info_msg.body;
740        if(!info_msg.showImg && imgTag)
741        {
742                var domains = '';
743                var blocked = false;
744                var forbidden = true;
745
746                if (preferences.notification_domains != null && typeof(preferences.notification_domains) != 'undefined')
747                {
748                        domains = preferences.notification_domains.split(',');
749                        for(var j = 0; j < imgTag.length; j++)
750                        {
751                                for (var i = 0; i < domains.length; i++)
752                                {
753                                        if (imgTag[j].match(/cid:([\w\d]){5,}/) || imgTag[j].match(/src=\"\.\/inc\/show_embedded_attach\.php/g))
754                                        {
755                                                forbidden = false;
756                                                continue;
757                                        }
758                                        imgSource = imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);
759                                        if (imgSource && imgSource.toString().substr(5).match(domains[i]))
760                                                forbidden = false;
761                                }
762                                if (forbidden)
763                                {
764                                        newBody = newBody.replace(imgTag[j],"<img src='" + URL_SERVER + "expressoMail1_2/templates/"+template+"/images/forbidden.jpg'>");
765                                        blocked=true;
766                                }
767                        }
768                        if (blocked)
769                        {
770                                var showImgLink = document.createElement('DIV');
771                                showImgLink.id="show_img_link_"+ID;
772                                showImgLink.onclick = function(){show_msg_img(info_msg.msg_number,info_msg.msg_folder)};
773                                showImgLink.className="show_img_link";
774                                showImgLink.innerHTML = get_lang("Show images from")+": "+info_msg.from.email;
775                                td.appendChild(showImgLink);
776                        }
777                }
778        }
779        return newBody;
780
781};
782
783draw_msg = new draw_message();
784
Note: See TracBrowser for help on using the repository browser.