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

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

Ticket #1059 - Corrigindo barra inferior que fica na posição errada

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 tbody_message_others_options = 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                tbody_message_others_options.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                tbody_message_others_options.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                tbody_message_others_options.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                tbody_message_others_options.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        tbody_message_others_options.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                tbody_message_others_options.appendChild(appendChilds(tr3,td3,cc,cc_values));
124        }
125
126        if (info_msg.bcc)
127        {
128                tbody_message_others_options.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        tbody_message_others_options.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        tbody_message_others_options.appendChild(appendChilds(tr5,td5,subject));
148        if (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.download_all_local_attachments('"+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                tbody_message_others_options.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(tbody_message_others_options);
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        }catch(e){};
279        content.appendChild(msg_number);
280        //////////////////////////////////////////////////////////////////////////////////////////////////////
281
282        //Exibe o cabecalho da mensagem totalmente aberto caso esteja setado nas preferencias do usuario
283        if (preferences.show_head_msg_full == 1)
284        {
285                option_hide_more.onclick();
286
287                if (Element('div_toaddress_'+this.id) != null)
288                {
289                        show_div_address_full(this.id,'to');
290                }       
291                if (Element('div_ccaddress_'+this.id) != null)
292                {
293                        show_div_address_full(this.id,'cc');
294                }
295        }
296
297};
298
299draw_message.prototype.make_options_message = function(info_msg, tbody_message){
300        var tr0 = document.createElement("TR");
301        tr0.className = "tr_message_header";
302        var td0 = document.createElement("TD");
303        var table_message_options = createAndSet("TABLE",['border','width','class'],["0","100%",'table_message']);
304        var tbody_message_options = document.createElement("TBODY");
305        var tr = document.createElement("TR");
306        var td = document.createElement("TD");
307        td.setAttribute("noWrap","true");
308        var _name = '';
309        var menuHidden = Element("folderscol").style.display == 'none' ? true : false;
310
311        var folder_id = info_msg.msg_number;
312        var folder = document.getElementById(folder_id);
313        if (!folder){
314                delete_border(this.id);
315                return false;
316        }
317
318        var next_previous_msg_td = this.createNxtPrevButtons(info_msg.msg_folder,folder_id);
319        if (typeof(next_previous_msg_td) == 'undefined')
320                return false;
321
322
323        var _maxChar = menuHidden ? 40 : 15;
324
325        if (info_msg.from.name)
326        {
327                var spanName = document.createElement("SPAN");
328                spanName.innerHTML = info_msg.from.name;
329                _name = spanName.innerHTML.length > _maxChar ? spanName.innerHTML.substring(0,_maxChar) + "..." : spanName.innerHTML;
330        }
331        else
332                _name = info_msg.from.email.length > _maxChar ? info_msg.from.email.substring(0,_maxChar) + "..." : info_msg.from.email;
333        var id = this.id;
334        td.innerHTML = _name.bold() + ', ' + info_msg.udate;
335        if (info_msg.attachment.names.length > 0)
336                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+"'>";
337
338        if(typeof(info_msg.signature) != 'undefined')
339            {
340                        if(info_msg.signature[0].indexOf('Message untouched') >= 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/signed_msg.gif' title='"+get_lang("Details")+"'>";
342                        else
343                            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")+"'>";
344            }
345           
346        if (info_msg.DispositionNotificationTo)
347        {
348                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">';
349        }
350
351        // NORMAL MSG
352        if(info_msg.Draft != 'X')
353        {
354                var options = createAndSet("TD",['noWrap','width','align'],['true','30%','right']);
355                var option_hide_more = createAndSet("SPAN",['class','value','id'],['message_options','more_options','option_hide_more_'+id],get_lang('show details'));
356                option_hide_more.onclick = function(){
357                        if (this.value != 'hide_options'){
358                                this.innerHTML = "<b><u>"+get_lang('hide details')+"</u></b>";
359                                this.value = 'hide_options';
360                                Element('table_msg_details_'+id).style.display = '';
361
362                        }
363                        else{
364                                this.innerHTML = get_lang('show details');
365                                this.value = 'more_options';
366                                Element('table_msg_details_'+id).style.display = 'none';
367                        }
368                        resizeWindow();
369                };
370                var option_mark = createAndSet("TD",['width','align'],['50%','left']);
371
372                var option_mark_as_unseen = '<span class="message_options" onclick="changeLinkState(this,\'seen\');set_messages_flag(\'unseen\','+
373                                                folder_id+');write_msg(\''+get_lang('Message marked as ')+get_lang("Unseen")+
374                                                '.\');">'+get_lang("Unseen")+'</span>, ';
375
376                if (info_msg.Flagged == "F")
377                        var option_mark_important = '<span class="message_options" onclick="changeLinkState(this,\'important\');set_messages_flag(\'unflagged\','+
378                                                        folder_id+');write_msg(\''+get_lang('Message marked as ')+get_lang("Normal")+
379                                                        '.\');">'+get_lang("Normal")+'</span>';
380                else
381                        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")+
382                                                                    '.\');">'+get_lang("Important")+'</span>';
383                option_mark.innerHTML = option_mark_as_unseen+option_mark_important;
384
385                var option_forward = createAndSet("SPAN",['id','class'],['msg_opt_forward_'+this.id, 'message_options'],get_lang('Forward'));
386                option_forward.onclick = function(){new_message('forward', this.id);};
387                appendChilds(options,option_hide_more,createAndSet('SPAN',false,false,'&nbsp;|&nbsp;'),option_forward);
388
389                var option_reply_options = createAndSet("IMG",['id', 'src', 'value'],['msg_opt_reply_options_'+id,URL_SERVER+'expressoMail1_2/templates/default/images/down.png','show']);
390                option_reply_options.onmouseover = function(){
391                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/over.png';
392                };
393                option_reply_options.onmouseout = function(){
394                        if (this.value == 'show')
395                        {
396                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/down.png';
397                        }
398                        else
399                        {
400                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/pressed.png';
401                        }
402                };
403                option_reply_options.onclick = function(){
404                        if (this.value != 'hide'){
405                                this.value = 'hide';
406                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/pressed.png';
407                                Element('tr_other_options_'+id).style.display = '';
408
409                        }
410                        else{
411                                this.value = 'show';
412                                option_reply_options.src= URL_SERVER+'expressoMail1_2/templates/default/images/down.png';
413                                Element('tr_other_options_'+id).style.display = 'none';
414                        }
415                };
416
417                var _option_reply = createAndSet("SPAN",['id','class'],['msg_opt_reply_'+id,'message_options'],get_lang('Reply'));
418                _option_reply.onclick = function(){new_message('reply_with_history', id);};
419
420                appendChilds(options,createAndSet('SPAN',false,false,'&nbsp;|&nbsp;'),option_reply_options,_option_reply);
421                appendChilds(tr,td,option_mark,options,next_previous_msg_td);
422                tbody_message_options.appendChild(tr);
423
424                ////////// OTHER OPTIONS ////////////////////
425                var _tr_other_options = createAndSet("TR",['id'],['tr_other_options_' + id]);
426                _tr_other_options.style.display = 'none';
427
428                var div_other_options = document.createElement("DIV");
429
430                var option_mark_as      = '<span>'+get_lang("Mark as")+'</span>: ';
431                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>, ';
432                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>, ';
433                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> | ';
434
435                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>';
436                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> | ';
437
438                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>';
439
440                div_other_options.innerHTML = option_reply_to_all + option_reply_to_all_without_history + option_reply_without_history;
441                if (use_spam_filter) {
442                        if(info_msg.msg_folder == 'INBOX'+cyrus_delimiter+'Spam')
443                                div_other_options.innerHTML += ' | <span class="reply_options" onclick="nospam('+info_msg.msg_number+',\'null\', \''+info_msg.msg_folder+'\')";>'+get_lang("Not Spam")+'</span>';
444                        else
445                                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>';
446                }
447
448                var td_other_options = createAndSet("TD",['colSpan','align','noWrap'],['3','right','true']);
449                td_other_options.appendChild(div_other_options);
450
451                _tr_other_options.appendChild(td_other_options);
452                tbody_message_options.appendChild(_tr_other_options);
453                ////////// END OTHER OPTIONS ////////////////
454                table_message_options.appendChild(tbody_message_options);
455                td0.appendChild(table_message_options);
456                tr0.appendChild(td0);
457                tbody_message.appendChild(tr0);
458                //if (info_msg.signature && info_msg.signature.length > 0)
459                //{
460                        //tbody_message.appendChild(draw_msg.putSignature(this.id,info_msg,td));
461                        //alert(info_msg.signature);
462                //}
463        }
464        else    // IF DRAFT
465        {
466                var options = createAndSet('TD',['width','noWrap','align'],['1%','true','right']);
467                var option_hide_more = createAndSet("SPAN",['class','value','id'],['message_options','more_options','option_hide_more_'+this.id],get_lang('Show details'));
468                option_hide_more.onclick = function(){
469                        var _height = Element("div_message_scroll_"+id).style.height;
470                        _height = parseInt(_height.replace("px",""));
471                        var _offset = 35;
472                        if (this.value != 'hide_options'){
473                                this.innerHTML = "<b><u>"+get_lang('Hide details')+"</u></b>";
474                                this.value = 'hide_options';
475                                Element("div_message_scroll_"+id).style.height = (_height - _offset)+"px";
476                                Element('table_msg_details_'+id).style.display = '';
477                        }
478                        else{
479                                this.innerHTML = get_lang('show details');
480                                this.value = 'more_options';
481                                Element("div_message_scroll_"+id).style.height = (_height + _offset)+"px";
482                                Element('table_msg_details_'+id).style.display = 'none';
483                        }
484                };
485                var option_edit = createAndSet('SPAN',['class'],['message_options'], get_lang('Edit'));
486                option_edit.onclick= function () { new_message('edit',this.id); };
487                appendChilds(options, option_hide_more, createAndSet('SPAN',false,false,"&nbsp;|&nbsp;"), option_edit);
488
489                tbody_message_options.appendChild(appendChilds(tr, td, options, next_previous_msg_td));
490                table_message_options.appendChild(tbody_message_options);
491                td0.appendChild(table_message_options);
492                tr0.appendChild(td0);
493                tbody_message.appendChild(tr0);
494        }
495        return true;
496};
497
498
499/* Class draw_message */
500function draw_message(){
501        this.id=0;
502}
503draw_message.prototype.createNxtPrevButtons = function(msg_folder,folder_id){
504        var next_previous_msg_td = createAndSet("TD",[ "noWrap", "align", "width" ], [ "true", "right", "40px"]);
505        var img_next_msg = createAndSet("IMG", [ 'id', 'src', 'title' ], [
506                        'msg_opt_next_' + this.id,
507                        URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/down.button.png',
508                        get_lang('Next') ]);
509        img_next_msg.style.cursor = 'pointer';
510
511        var folder = document.getElementById(folder_id);
512        if (folder){ // mensagem local criptografada nao tem ID da pasta local
513                if (folder.nextSibling){
514                        var nextMsgBox = folder.nextSibling.name?folder.nextSibling.name:msg_folder;
515
516                        if (nextMsgBox == "INBOX/decifradas")// teste para ver se a mensagem vem da pasta oculta decifradas
517                                nextMsgBox = get_current_folder();
518
519                        img_next_msg.onclick = function()
520                        {
521                                openTab.type[currentTab] = 2;
522                                if ( nextMsgBox == undefined )
523                                       nextMsgBox = current_folder;
524                                for (var i=0; i < draw_box.headers_msgs.length; i++)
525                                        if (draw_box.headers_msgs[i].msg_number == folder.nextSibling.id){
526                                                var nextHeader = draw_box.headers_msgs[i];
527                                                break;
528                                        }
529                                proxy_mensagens.get_msg(nextHeader,nextMsgBox,true,show_msg,currentTab);
530                        };
531                }
532                else
533                {
534                        img_next_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/down.gray.button.png';
535                        img_next_msg.style.cursor = 'default';
536                }
537        }
538        else
539        {
540                img_next_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/down.gray.button.png';
541                img_next_msg.style.cursor = 'default';
542                if (!proxy_mensagens.is_local_folder(get_current_folder()) && !(msg_folder == "INBOX/decifradas")) // testa se a mensagem e local
543                {
544                        img_next_msg.onclick = function()
545                        {
546                                delete_border(this.id);
547                        };
548                }
549        }
550        var img_space = document.createElement("SPAN");
551        img_space.innerHTML = "&nbsp;";
552        var img_previous_msg = createAndSet("IMG",['id','src','title'],['msg_opt_previous_' + this.id,
553                        URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/up.button.png',
554                        get_lang('Previous')]);
555        img_previous_msg.style.cursor = 'pointer';
556
557        if (!folder){
558                delete_border(this.id);
559                return;
560        }
561        if (folder){ // mensagem local criptografada nao tem this.id da pasta local
562                if (folder.previousSibling)
563                {
564                        var previousMsgBox = folder.previousSibling.name?folder.previousSibling.name:msg_folder;
565
566                        if (previousMsgBox == "INBOX/decifradas") // teste para ver se a mensagem vem da pasta oculta decifradas
567                                previousMsgBox = get_current_folder();
568
569                        img_previous_msg.onclick = function()
570                        {
571                                openTab.type[currentTab] = 2;
572                                if ( previousMsgBox == undefined )
573                                       previousMsgBox = current_folder;
574                                 for (var i=0; i < draw_box.headers_msgs.length; i++)
575                                        if (draw_box.headers_msgs[i].msg_number == folder.previousSibling.id){
576                                                var previousHeader = draw_box.headers_msgs[i];
577                                                break;
578                                        }
579                                proxy_mensagens.get_msg(previousHeader,previousMsgBox,true,show_msg,currentTab);
580                        };
581                }
582                else
583                {
584                        img_previous_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/up.gray.button.png';
585                        img_previous_msg.style.cursor = 'default';
586                }
587        }
588        else
589        {
590                img_previous_msg.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/up.gray.button.png';
591                img_previous_msg.style.cursor = 'default';
592                if (!proxy_mensagens.is_local_folder(get_current_folder()) && !(msg_folder == "INBOX/decifradas")) // testa se a mensagem e local
593                {
594                        img_previous_msg.onclick = function()
595                        {
596                                delete_border(this.id);
597                        };
598                }
599        }
600        next_previous_msg_td.appendChild(img_previous_msg);
601        next_previous_msg_td.appendChild(img_space);
602        next_previous_msg_td.appendChild(img_next_msg);
603        return next_previous_msg_td;
604
605};
606var idx_cc = 0;
607draw_message.prototype.draw_plugin_cc = function(addrs)
608{
609    expresso.connector.loadScript("jscode/ccQuickAdd");
610    var id=this.id;
611
612    var array_addrs = '';
613    var array_name      = '';
614    var cc_data = new Array();
615    if(typeof(addrs.name) != 'undefined') {
616        array_name      = LTrim(addrs.name).split(" ");
617        array_addrs = new Array(addrs.email);
618    }
619    else {
620        array_addrs = (typeof addrs == 'object' ? addrs.toString().split("\" ") : addrs.split("\" "));
621        array_name      = LTrim(array_addrs[0]).replace('"','').split(" ");
622    }
623
624    var _split = array_name[0].split('@');
625    cc_data[0] = _split[0];
626    cc_data[1] = _split[0];
627    cc_data[2] = '';
628
629    for (i=1; i < array_name.length; i++)
630        cc_data[2] += array_name[i] + " ";
631
632
633    if(array_addrs.length > 1)
634        cc_data[3] = array_addrs[1] ? array_addrs[1].replace("&lt;",'').replace("&gt;",'') : '';
635    else
636        cc_data[3] = array_addrs[0];
637
638    var sm_envelope_img1 = '<img style="cursor:'+ (is_ie ? 'hand' : 'pointer') +'" title="' + get_lang("Add Contact") +
639    '" onclick="ccQuickAddOne.showList(\''+cc_data+'\')" src="' + URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/user_card.png">';
640    var to_addybook_add = "<SPAN id='insert_plugin_"+idx_cc+"_"+id+"'>";
641    to_addybook_add += addrs;
642    to_addybook_add +=  sm_envelope_img1;
643    idx_cc++;
644    to_addybook_add += "</SPAN>";
645    return to_addybook_add;
646};
647
648draw_message.prototype.getThumbs = function(attachments, thumbs, msg_number, msg_folder){
649                var table_message_thumbs = document.createElement("TABLE");
650                table_message_thumbs.width = "80%";
651                table_message_thumbs.style.borderTop = "2px solid rgb(170, 170, 170)";
652                var tbody_message_thumbs = document.createElement("TBODY");
653                var tr = document.createElement("TR");
654                tr.className = "tr_message_body";
655                var td = document.createElement("TD");
656                td.setAttribute("colSpan","2");
657                td.id = "body_thumbs_"+msg_number;
658                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>";
659                var _link_attachments = '';
660                if(thumbs.length > 1){
661                        _link_attachments       = document.createElement("A");
662                        _link_attachments.className = "message_options";
663                        if(proxy_mensagens.is_local_folder(current_folder))
664                                _link_attachments.setAttribute("href", "javascript:expresso_local_messages.download_all_local_attachments('"+msg_folder+"','"+msg_number+"')");
665                        else
666                                _link_attachments.setAttribute("href", "javascript:download_all_attachments('"+msg_folder+"','"+msg_number+"')");
667                        _link_attachments.innerHTML = get_lang('Download all atachments');
668                }
669
670                if(_link_attachments){
671                        td.innerHTML += " :: ";
672                        td.appendChild(_link_attachments);
673                }
674
675                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>.");
676                td.innerHTML += "<BR>";
677
678                for (var i=0; i<thumbs.length; i++){
679                        if ((i % 4) == 0)
680                                td.innerHTML += "<BR>";
681                        td.innerHTML += thumbs[i];
682                        td.innerHTML += "&nbsp;&nbsp;";
683                }
684                tr.appendChild(td);
685                tbody_message_thumbs.appendChild(tr);
686                table_message_thumbs.appendChild(tbody_message_thumbs);
687                return table_message_thumbs;
688};
689
690draw_message.prototype.getBcc = function(bccField){
691        /*
692         * @AUTHOR Rodrigo Souza dos Santos
693         * @MODIFY-DATE 2008/09/11
694         * @BRIEF Adding routine to create bcc (blind carbon copy) field if there is one.
695         */
696        var tr3 = document.createElement("tr");
697        tr3.className = "tr_message_header";
698        var td3 = document.createElement("td");
699        td3.innerHTML = get_lang("BCC") + " : ";
700        var cco = document.createElement("td");
701        cco.id = "cco_"+this.id;
702
703        var cco_values = createAndSet("INPUT",['id', 'type', 'value'],["cco_values_"+this.id,"hidden",bccField]);
704        ccoaddress_array[this.id] = bccField.split(",");               
705        if (ccoaddress_array[this.id].length > 1){
706                var div_ccoaddress = document.createElement("SPAN");
707                div_ccoaddress.id = "div_ccoaddress_"+this.id;
708                var div_ccoaddress_full = createAndSet("SPAN",['id', 'style'],["div_ccoaddress_full_"+this.id, "display:inline"]);
709                /*
710                 * The function below is ugly, doesn't possible use this.
711                 * The problem is that the code's function was written
712                 * on a hardcode concept.
713                 */
714                //cco.innerHTML = this.draw_plugin_cc(ccoaddress_array[this.id][0]);
715                cco.innerHTML = ccoaddress_array[this.id][0];
716                div_ccoaddress.innerHTML += " (<a STYLE='color: RED;' onclick=javascript:show_div_address_full('"+this.id+"','cco');>"+get_lang('more')+"</a>)";
717                cco.appendChild(div_ccoaddress);
718        }
719        else{
720                /*
721                 * The function below is ugly, it is not possible to use this.
722                 * The problem is that the code's function was written
723                 * on a hardcode concept.
724                 */
725                //cco.innerHTML = this.draw_plugin_cc(info_msg.cco);
726                cco.innerHTML = bccField;
727        }
728        cco.className = "header_message_field";
729        return appendChilds(tr3,td3,cco,cco_values);
730};
731
732draw_message.prototype.blockImage = function(info_msg,ID,td){
733        var imgTag = info_msg.body.match(/(<img[^>]*src[^>=]*=['"]?[^'">]*["']?[^>]*>)|(<[^>]*(style[^=>]*=['"][^>]*background(-image)?:[^:;>]*url\()[^>]*>)/gi);
734
735        var newBody = info_msg.body;
736        if(!info_msg.showImg && imgTag)
737        {
738                var domains = '';
739                var blocked = false;
740                var forbidden = true;
741
742                if (preferences.notification_domains != null && typeof(preferences.notification_domains) != 'undefined')
743                {
744                        domains = preferences.notification_domains.split(',');
745                        for(var j = 0; j < imgTag.length; j++)
746                        {
747                                for (var i = 0; i < domains.length; i++)
748                                {
749                                        if (imgTag[j].match(/cid:([\w\d]){5,}/) || imgTag[j].match(/src=\"\.\/inc\/show_embedded_attach\.php/g))
750                                        {
751                                                forbidden = false;
752                                                continue;
753                                        }
754                                        imgSource = imgTag[j].match(/=['"](http:\/\/)+[^'"\/]*/);
755                                        if (imgSource && imgSource.toString().substr(5).match(domains[i]))
756                                                forbidden = false;
757                                }
758                                if (forbidden)
759                                {
760                                        newBody = newBody.replace(imgTag[j],"<img src='" + URL_SERVER + "expressoMail1_2/templates/"+template+"/images/forbidden.jpg'>");
761                                        blocked=true;
762                                }
763                        }
764                        if (blocked)
765                        {
766                                var showImgLink = document.createElement('DIV');
767                                showImgLink.id="show_img_link_"+ID;
768                                showImgLink.onclick = function(){show_msg_img(info_msg.msg_number,info_msg.msg_folder)};
769                                showImgLink.className="show_img_link";
770                                showImgLink.innerHTML = get_lang("Show images from")+": "+info_msg.from.email;
771                                td.appendChild(showImgLink);
772                        }
773                }
774        }
775        return newBody;
776
777};
778
779draw_msg = new draw_message();
780
Note: See TracBrowser for help on using the repository browser.