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

Revision 3077, 35.1 KB checked in by amuller, 14 years ago (diff)

Ticket #1145 - Arruma problema ao carregar script sob demanda

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