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

Revision 2853, 33.8 KB checked in by rafaelraymundo, 14 years ago (diff)

Ticket #1061 - Corrigidos para exibir dados do certificado qdo. msg assinada

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