var lastPage = 1; var numPages = 5; var last_folder = 'INBOX'; function draw_quota(data){ build_quota(data); } function update_quota(folder_id){ cExecute ("expressoMail1_2.imap_functions.get_quota&folder_id="+folder_id,build_quota); } function draw_search(headers_msgs){ Element("border_id_0").innerHTML = "  " + get_lang('Search Result') + "  "; var tbody = Element('tbody_box'); for (var i=0; i<(headers_msgs.length); i++){ var tr = this.make_tr_message(headers_msgs[i], headers_msgs[i].msg_folder); if (tr) tbody.appendChild(tr); } } function draw_header_box(){ switch(sort_box_type){ case 'SORTFROM': type_name = get_lang("Who"); break; case 'SORTSUBJECT': type_name = get_lang("Subject"); break; case 'SORTARRIVAL': type_name = get_lang("Date"); break; case 'SORTSIZE': type_name = get_lang("Size"); break; default: type_name = get_lang("Date"); break; } document.getElementById("_msgheadSORTFROM_"+numBox).innerHTML = get_lang("Who"); document.getElementById("_msgheadSORTSUBJECT_"+numBox).innerHTML = get_lang("Subject"); document.getElementById("_msgheadSORTARRIVAL_"+numBox).innerHTML = get_lang("Date"); document.getElementById("_msgheadSORTSIZE_"+numBox).innerHTML = get_lang("Size"); var elHead = document.getElementById("_msghead"+(sort_box_type.lastIndexOf("SORT") != "-1" ? sort_box_type : "SORTARRIVAL")+"_"+numBox ); if(elHead != null) elHead.innerHTML = ""+type_name+''; } function draw_search_header_box(){ var _tbl_msghead_bx = Element("_tbl_msghead_bx"); _tbl_msghead_bx.parentNode.removeChild(_tbl_msghead_bx); var content_id_0 = Element("content_id_0"); var table_element = document.createElement("TABLE"); var tbody_element = document.createElement("TBODY"); table_element.setAttribute("id", "_tbl_msghead_bx"); table_element.className = "table_message_header_box"; tr_element = document.createElement("TR"); tr_element.className = "message_header"; td_element1 = document.createElement("TD"); td_element1.setAttribute("width", "1%"); chk_box_element = document.createElement("INPUT"); chk_box_element.id = "chkbox_sel_allmsg"; chk_box_element.setAttribute("type", "checkbox"); chk_box_element.className = "checkbox"; chk_box_element.onclick = function(){ select_all_messages(this.checked); }; chk_box_element.onmouseover = function () { this.title=get_lang('Select all messages.') }; chk_box_element.onkeydown = function (e){ if (is_ie) { if ((window.event.keyCode) == 46) { //delete_all_selected_msgs_imap(); proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } } else { if ((e.keyCode) == 46) { //delete_all_selected_msgs_imap(); proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } } }; td_element1.appendChild(chk_box_element); td_element2 = document.createElement("TD"); td_element2.setAttribute("width", "3%"); td_element3 = document.createElement("TD"); td_element3.setAttribute("width", "30%"); td_element3.id = "_msgheadSORTFROM"; td_element3.align = "left"; td_element3.innerHTML = get_lang("From"); td_element4 = document.createElement("TD"); td_element4.setAttribute("width", "49%"); td_element4.id = "_msgheadSORTSUBJECT"; td_element4.align = "left"; td_element4.innerHTML = get_lang("Subject"); td_element5 = document.createElement("TD"); td_element5.setAttribute("width", "10%"); td_element5.id = "_msgheadSORTARRIVAL"; td_element5.align = "center"; td_element5.innerHTML = ""+get_lang("Date")+""; td_element5.innerHTML += ''; td_element6 = document.createElement("TD"); td_element6.setAttribute("width", "10%"); td_element6.id = "_msgheadSORTSIZE"; td_element6.align = "right"; td_element6.innerHTML = get_lang("Size"); tr_element.appendChild(td_element1); tr_element.appendChild(td_element2); tr_element.appendChild(td_element3); tr_element.appendChild(td_element4); tr_element.appendChild(td_element5); tr_element.appendChild(td_element6); tbody_element.appendChild(tr_element); table_element.appendChild(tbody_element); content_id_0.appendChild(table_element); } function draw_search_division(msg){ var tbody = Element('tbody_box'); var tr = document.createElement("TR"); var td = document.createElement("TD"); td.colSpan = '7'; td.width = '100%'; var action_info_table = document.createElement("TABLE"); var action_info_tbody = document.createElement("TBODY"); action_info_table.className = "action_info_table"; action_info_table.width = "100%"; var action_info_tr = document.createElement("TR"); var action_info_th1 = document.createElement("TH"); action_info_th1.width = "40%"; action_info_th1.innerHTML = " "; var action_info_th2 = document.createElement("TH"); action_info_th2.innerHTML = msg; action_info_th2.className = "action_info_th"; action_info_th2.setAttribute("noWrap", "true"); var action_info_th3 = document.createElement("TH"); action_info_th3.width = "40%"; action_info_th3.innerHTML = " "; action_info_tr.appendChild(action_info_th1); action_info_tr.appendChild(action_info_th2); action_info_tr.appendChild(action_info_th3); action_info_tbody.appendChild(action_info_tr); action_info_table.appendChild(action_info_tbody); td.appendChild(action_info_table); tr.appendChild(td); tbody.appendChild(tr); } function draw_search_box(){ var content_id_0 = Element("content_id_0"); var table = document.createElement("TABLE"); table.id = "table_box"; table.width = 'auto'; var tbody = document.createElement("TBODY"); tbody.id = "tbody_box"; table.className = "table_box"; table.setAttribute("frame", "below"); table.setAttribute("rules", "none"); table.setAttribute("cellpadding", "0"); table.onkeydown = function (e){ if (is_ie) { if ((window.event.keyCode) == 46) { //delete_all_selected_msgs_imap(); proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } } else { if ((e.keyCode) == 46) { //delete_all_selected_msgs_imap(); proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } } }; if (is_ie) table.style.cursor = "hand"; table.appendChild(tbody); content_id_0.appendChild(table); } function build_quota(data){ id = "content_quota"; q_limit = data['quota_limit']*1024; var div = document.getElementById(id); if(!q_limit){ div.innerHTML = ''+get_lang("Without Quota")+''; } else{ if(div) { div.innerHTML = ''; value = data['quota_percent']; q_used = data['quota_used']*1024; table = document.getElementById("table_quota"); if(table) table.parentNode.removeChild(table); table = document.createElement("TABLE"); tbody = document.createElement("TBODY"); table.appendChild(tbody); table.id = "table_quota"; table.width="102"; table.border="0"; table.cellSpacing = 0; table.cellPadding = 0; //tr1 = document.createElement("TR"); td11 = document.createElement("TD"); td11.align="center"; td11.setAttribute("noWrap","true"); td11.innerHTML += ' ' + value+"% ("+borkb(q_used)+"/"+borkb(q_limit)+")"; //tr1.appendChild(td11); tr2 = document.createElement("TR"); td21 = document.createElement("TD"); td21.setAttribute("noWrap","true"); td21.height="15"; td22 = document.createElement("TD"); td21.setAttribute("background", URL_SERVER + 'phpgwapi/templates/' + template + '/images/dsunused.gif'); table221 = document.createElement("TABLE"); tbody221 = document.createElement("TBODY"); table221.appendChild(tbody221); table221.style.width=value+"%"; td21.width="102"; table221.border="0"; table221.cellSpacing = 0; table221.cellPadding = 0; tr221 = document.createElement("TR"); td221 = document.createElement("TD"); td221.height="15"; if(value > 90) { if(value >= 100) write_msg(get_lang("Your Mailbox is 100% full! You must free more space or will not receive messages.")); else write_msg(get_lang("Warning: Your Mailbox is almost full!")); td221.setAttribute("background","templates/"+template+"/images/dsalert.gif"); } else if(value > 80) td221.setAttribute("background", URL_SERVER + 'expressoMail1_2/templates/' + template + '/images/dswarn.gif'); else td221.className = 'dsused'; tr221.appendChild(td221); tbody221.appendChild(tr221); td21.appendChild(table221); tr2.appendChild(td21); tr2.appendChild(td11); //tr2.appendChild(td1); tbody.appendChild(tr2); //Desenho //tbody.appendChild(tr1); //Letras div.appendChild(table); } } } function draw_paging(num_msgs){ num_msgs = parseInt(num_msgs); total_pages = 1; if(last_folder != current_folder){ lastPage = 1; current_page = 1; last_folder = current_folder; } if(num_msgs > parseInt(preferences.max_email_per_page)) { total_pages = parseInt(num_msgs/preferences.max_email_per_page); if((num_msgs/preferences.max_email_per_page) > total_pages) total_pages++; } if(total_pages == 1) { if(span_paging = document.getElementById("span_paging")) { span_paging.parentNode.removeChild(span_paging); } return; } span_paging = document.getElementById("span_paging"); if(!span_paging){ span_paging = document.createElement("DIV"); span_paging.id = "span_paging"; span_paging.className = "boxHeaderText"; span_paging.align="right"; var div_menu_c3 = document.getElementById("div_menu_c3"); if ( div_menu_c3 ) div_menu_c3.appendChild(span_paging); } span_paging.style.width="100%"; span_paging.innerHTML=""; msg_range_begin = 1; msg_range_end = preferences.max_email_per_page; if(current_page != 1) { lnk_page = document.createElement("A"); lnk_page.setAttribute("href", "javascript:current_page=1;kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){draw_box.draw_newBox(data, get_current_folder());});"); } else { lnk_page = document.createElement("SPAN"); } span_paging.appendChild(lnk_page); lnk_page.innerHTML = "<<"; lnk_page.title = get_lang("First"); span_paging.innerHTML += " "; if(current_page == lastPage + numPages) lastPage = current_page - 1; else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages) lastPage = current_page - (numPages - 1); else if(current_page == 1) lastPage = 1; if(lastPage < 1) lastPage = 1; else if(lastPage > 1 && (lastPage > (total_pages -(numPages - 1)))) lastPage = total_pages -(numPages - 1); var hasMarked = false; for(i = lastPage; i <= total_pages; i++) { if(current_page == i || (i == total_pages && !hasMarked)) { lnk_page = document.createElement("SPAN"); span_paging.appendChild(lnk_page); lnk_page.innerHTML = " "+i+" "; hasMarked = true; continue; } else{ lnk_page = document.createElement("A"); span_paging.appendChild(lnk_page); msg_range_begin = ((i*preferences.max_email_per_page)-(preferences.max_email_per_page-1)); msg_range_end = (i*preferences.max_email_per_page); lnk_page.setAttribute("href", "javascript:current_page="+i+";kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){draw_box.draw_newBox(data, get_current_folder());});"); } lnk_page.innerHTML = " ... "; if(i == (lastPage + numPages)) break; else if(lastPage == 1 || i != lastPage) lnk_page.innerHTML = " "+i+" "; span_paging.innerHTML += " "; } if(current_page != total_pages) { lnk_page = document.createElement("A"); msg_range_begin = ((total_pages*preferences.max_email_per_page)-(preferences.max_email_per_page-1)); msg_range_end = (total_pages*preferences.max_email_per_page); lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";kill_current_box(); draw_paging("+num_msgs+"); proxy_mensagens.messages_list(get_current_folder(),"+msg_range_begin+","+msg_range_end+",'"+sort_box_type+"','"+search_box_type+"',"+sort_box_reverse+","+preferences.preview_msg_subject+","+preferences.preview_msg_tip+",function handler(data){draw_box.draw_newBox(data, get_current_folder());});"); } else { lnk_page = document.createElement("SPAN"); } span_paging.innerHTML += " "; span_paging.appendChild(lnk_page); lnk_page.title = get_lang("Last"); lnk_page.innerHTML = ">>"; } function draw_tree_local_folders() { /** * Pastas locais */ if(preferences.use_local_messages==1 || expresso_offline) { var local_folders = expresso_local_messages.list_local_folders(); var has_changes = false; for (var i in local_folders) { //Coloca as pastas locais. if(!isNaN(i)){ var new_caption = local_folders[i][0]; if(local_folders[i][0].indexOf("/")!="-1") { final_pos = local_folders[i][0].lastIndexOf("/"); new_caption = local_folders[i][0].substr(final_pos+1); } var folder_unseen = Element('dftree_local_'+local_folders[i][0]+'_unseen'); if ((folder_unseen) && (local_folders[i][1] > 0)) { folder_unseen.innerHTML = local_folders[i][1]; has_changes = true; } else if (local_folders[i][1] > 0) { tree_folders.getNodeById("local_"+local_folders[i][0]).alter({ caption:lang_folder(new_caption) + ' ('+local_folders[i][1]+')' }); tree_folders.getNodeById("local_"+local_folders[i][0])._refresh(); has_changes = true; } else if (local_folders[i][1] <= 0) { tree_folders.getNodeById("local_"+local_folders[i][0]).alter({ caption:lang_folder(new_caption) }); tree_folders.getNodeById("local_"+local_folders[i][0])._refresh(); has_changes = true; } if("local_"+local_folders[i][0] == get_current_folder()){ var old_new_m = isNaN(parseInt(Element('new_m').innerHTML)) ? parseInt(Element('new_m').firstChild.innerHTML) : parseInt(Element('new_m').innerHTML); if(!isNaN(old_new_m) && old_new_m < local_folders[i][1]){ Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + (parseInt(local_folders[i][1])-old_new_m); } Element('new_m').innerHTML = local_folders[i][1] ? ''+local_folders[i][1]+'' : 0; draw_paging(Element('tot_m').innerHTML); has_changes = true; } } } if(has_changes) tree_folders.getNodeById("local_root").open(); } } function draw_tree_folders( folders ) { // Check if the tree folders alredy exist. if ( ! Element( 'dftree_tree_folders' ) ) { translatedFolders = new Map( ); if ( ! expresso_offline ) { tree_folders = new dFTree( { "name" : 'tree_folders' } ); var n_root = new dNode( { "id" : 'root', "caption" : get_lang( "My Folders" ) } ); tree_folders.add( n_root, 'anything' ); //Places the root; second argument can be anything. var unseen_in_mailbox = 0; var unseen_in_shared_folders = 0; for ( var i = 0; i < folders.length; i++ ) { if ( folders[ i ].folder_unseen > 0 ) { unseen_in_mailbox = parseInt( unseen_in_mailbox + folders[ i ].folder_unseen ); if ( folders[i].folder_id.indexOf( 'INBOX' ) !== 0 ) unseen_in_shared_folders = parseInt( unseen_in_shared_folders + folders[ i ].folder_unseen ); var nn = new dNode( { "id" : folders[i].folder_id, "caption" : lang_folder( folders[ i ].folder_name ) + ' (' + folders[ i ].folder_unseen + ')', "onClick" : "change_folder('" + folders[ i ].folder_id+"','" + folders[ i ].folder_name + "')", "plusSign" : folders[ i ].folder_hasChildren } ); if ( folders[ i ].folder_name.toLowerCase( ) == 'inbox' ) Element( 'new_m' ).innerHTML = '' + folders[ i ].folder_unseen + ''; } else var nn = new dNode( { "id" : folders[ i ].folder_id, "caption" : lang_folder( folders[ i ].folder_name ), "onClick" : "change_folder('" + folders[ i ].folder_id + "','" + folders[ i ].folder_name + "')", "plusSign" : folders[ i ].folder_hasChildren }); if ( folders[ i ].folder_parent == '' ) folders[ i ].folder_parent = 'root'; else { if ( folders[ i ].folder_parent == 'user' && ( ! tree_folders.getNodeById( 'user' ) ) ) { tmpFolderId = folders[ i ].folder_id.split( cyrus_delimiter ).pop( ); if ( tmpFolderId != folders[ i ].folder_name ) translatedFolders.add( tmpFolderId, folders[ i ].folder_name ); var n_root_shared_folders = new dNode( { "id" : 'user', "caption" : get_lang( "Shared folders" ), "plusSign" : true } ); tree_folders.add( n_root_shared_folders, 'root' ); } } tree_folders.add( nn, folders[ i ].folder_parent ); } } /** * Pastas locais */ if (preferences.use_local_messages==1 || expresso_offline) { if (!window.google || !google.gears) { if (!expresso_local_messages.installGears()) preferences.use_local_messages=0; } else{ if (!window.google || !google.gears) { temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); if (temp) { location.href = "http://gears.google.com/?action=install&message="+ "Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href; } else { preferences.use_local_messages=0; } } else{ if (expresso_offline) tree_folders = new dFTree({ "name" : 'tree_folders' }); var root_local = new dNode({ "id" : "local_root", "caption" : get_lang('local folders') }); tree_folders.add(root_local, "root"); //coloca root local var local_folders = expresso_local_messages.list_local_folders(); for (var i in local_folders) { //Coloca as pastas locais. if(!isNaN(i)){ var node_root = "local_root"; var new_caption = local_folders[i][0]; if (local_folders[i][0].indexOf("/") != "-1") { final_pos = local_folders[i][0].lastIndexOf("/"); node_root = "local_" + local_folders[i][0].substr(0, final_pos); new_caption = local_folders[i][0].substr(final_pos + 1); } if (local_folders[i][1] > 0) var nodeLocal = new dNode({ "id": "local_" + local_folders[i][0], "caption": lang_folder(new_caption) + ' (' + local_folders[i][1] + ')', "onClick": "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')", "plusSign": local_folders[i][2] }); else var nodeLocal = new dNode({ "id": "local_" + local_folders[i][0], "caption": lang_folder(new_caption), "onClick": "change_folder('local_" + local_folders[i][0] + "','" + new_caption + "')", "plusSign": local_folders[i][2] }); tree_folders.add(nodeLocal, node_root); } } } } } tree_folders.draw( Element( 'content_folders' ) ); if ( ! expresso_offline ) { n_root.changeState( ); folder_select = ( current_folder ? current_folder : "INBOX" ); if ( typeof( tree_folders.getNodeById( folder_select ) ) != 'function' ) return false; tree_folders.getNodeById( folder_select )._select( ); } else { root_local.changeState( ); tree_folders.getNodeById( 'local_Inbox' )._select( ); } var trash_span = document.getElementById( 'lINBOX/' + trashfolder + 'tree_folders' ); var draft_span = document.getElementById( 'lINBOX/' + draftsfolder + 'tree_folders' ); var sent_span = document.getElementById( 'lINBOX/' + sentfolder + 'tree_folders' ); var spam_span = document.getElementById( 'lINBOX/' + spamfolder + 'tree_folders' ); var folder_img = URL_SERVER + "phpgwapi/templates/" +template + "/images/foldertree_"; if ( trash_span ) trash_span.style.backgroundImage = "url(" + folder_img + "trash.png)"; if ( draft_span ) draft_span.style.backgroundImage = "url(" + folder_img + "draft.png)"; if ( sent_span ) sent_span.style.backgroundImage = "url(" + folder_img + "sent.png)"; if ( spam_span ) spam_span.style.backgroundImage = "url(" + folder_img + "spam.png)"; draw_paging( Element( 'tot_m' ).innerHTML ); if ( document.getElementById( "nINBOX/" + trashfolder + "tree_folders" ) ) { var trash = document.createElement( "SPAN" ); trash.id = 'empty_trash'; trash.className = 'clean_folder'; trash.style.cursor = 'pointer'; trash.onclick = function( ) { empty_trash_imap( ); }; trash.innerHTML = "[" + get_lang( "Clean" ) + "]"; trash.title = get_lang( "Empty trash" ); trash.onmouseover = function( ) { trash.style.color = "red"; }; trash.onmouseout= function( ) { trash.style.color="#666666"; }; document.getElementById( "nINBOX/" + trashfolder + "tree_folders" ).appendChild( trash ); } if ( document.getElementById( "nINBOX/" + spamfolder + "tree_folders" ) ) { var spam = document.createElement( "SPAN" ); spam.id = 'empty_spam'; spam.className = 'clean_folder'; spam.style.cursor = 'pointer'; spam.style.padding = '0 0 0 6px'; spam.onclick = function( ) { empty_spam_imap( ); }; spam.innerHTML = "[" + get_lang( "Clean" ) + "]"; spam.title = get_lang( "Empty Spam Folder" ); spam.onmouseover = function( ) { spam.style.color = "red"; }; spam.onmouseout = function( ) { spam.style.color = "#666666"; }; document.getElementById( "nINBOX/" + spamfolder + "tree_folders" ).appendChild( spam ); } if ( ! expresso_offline ) var _disp_unseen_mb = tree_folders.getNodeById( 'root' ); else var _disp_unseen_mb = tree_folders.getNodeById( 'local_root' ); _disp_unseen_mb.alter( { "caption" : get_lang( "My Folders" ) } ); _disp_unseen_mb._refresh( ); var _dip_unseen_shardfolder = tree_folders.getNodeById( 'user' ); if ( _dip_unseen_shardfolder ) { if ( unseen_in_shared_folders ) _dip_unseen_shardfolder.alter( { "caption" : '[' + unseen_in_shared_folders + '] ' + get_lang( "Shared folders" ) } ); else _dip_unseen_shardfolder.alter( { "caption" : get_lang( "Shared folders" ) } ); _dip_unseen_shardfolder._refresh( ); } } if ( ! expresso_offline ) { var folder_create = ""; var nm1 = ""; if ( tree_folders._folderPr.length > 0 ) { var nm_folder = ""; for ( var i = 0; i < tree_folders._folderPr.length; i++ ) { nm_folder = tree_folders._folderPr[ i ].split( cyrus_delimiter ); if( nm_folder[ 0 ] == "INBOX" ) { if ( nm1 == "" ) { nm1 = nm_folder[ 1 ]; folder_create = "INBOX" + cyrus_delimiter + nm_folder[ 1 ] + ";"; } else { if ( nm1 != nm_folder[ 1 ] ) { folder_create += "INBOX" + cyrus_delimiter + nm_folder[ 1 ] + ";"; nm1 = nm_folder[ 1 ]; } } } } } if ( folder_create != "" ) { if ( confirm( get_lang( "There are folders with invalid format. Do you want to fix them?" ) ) ) { var handler_correct_folders = function( data ) { //Timeout to release HTTPRequest , loadScript and update tree folders. if ( data ) setTimeout( "expresso.connector.loadScript('jscode/TreeShow');ttreeBox.update_folder();", 500 ); }; cExecute( "expressoMail1_2.imap_functions.create_extra_mailbox", handler_correct_folders, "nw_folders=" + folder_create ); } } } Element( 'main_table' ).style.display = ''; draw_box.prepare_box( false ); resizeWindow( ); } function update_menu(data){ /* * @AUTHOR Rodrigo Souza dos Santos * @DATE 2008/09/15 * @BRIEF When occurs a error in imap server show the message that is in file "error.html". */ if ( data && data.imap_error ) { if(preferences.use_local_messages==1 && expresso_local_messages.is_offline_installed){ conf = confirm(get_lang("The expresso imap server is currently down, expresso noticed you have offline mail module installed, would you like to use it?")); if(conf) { window.onresize = function() { var target = document.getElementById('divAppbox'); target.style.height= document.body.clientHeight - 83; }; var target = document.getElementById('divAppbox'); document.getElementById("divAppboxHeader").innerHTML=""; target.style.height= document.body.clientHeight - 83; expresso_local_messages.set_as_logged(account_id,0,true); target.innerHTML = ""; return false; } } expresso.connector.newRequest('error.html', URL_SERVER + 'expressoMail1_2/templates/'+template+'/error.html', 'GET', function(data) { var target = document.getElementById('divAppbox'); if ( target ) target.innerHTML = data; } ); return false; } draw_tree_folders(data); if(data) { build_quota(data); var f_unseen = Element('dftree_'+current_folder+'_unseen'); if(f_unseen && f_unseen.innerHTML) Element('new_m').innerHTML = ''+f_unseen.innerHTML+''; else { if( parseInt(Element('new_m').innerHTML) == 0 ) Element('new_m').innerHTML = 0; } folders = data; } } var handler_draw_box = function(data){ draw_box.draw_newBox( expresso.connector.unserialize( data ), 'INBOX', true); //alternate_border(0); }; // Action on change folders. function change_folder(folder, folder_name){ alternate_border(numBox); if (openTab.imapBox[numBox] != folder) { current_folder = folder; draw_box.prepare_box(true); Element("border_id_0").innerHTML = " " + lang_folder(folder_name) + ' [0 / 0]'; var handler_draw_box = function(data) { draw_box.headers_msgs = data; draw_box.draw_box_messages(data, folder, true); draw_paging(data.num_msgs); Element("tot_m").innerHTML = data.num_msgs; Element("new_m").innerHTML = '' + data.num_unseen + ''; folder_unseen = Element('dftree_'+current_folder+'_unseen'); var num_unseen = data.num_unseen; if (folder_unseen) num_unseen -= folder_unseen.innerHTML; increment_folder_unseen(num_unseen); update_menu(); return true; }; proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort_box_type,search_box_type,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box); } } function open_folder(folder, folder_name){ if (current_folder!= folder) { current_folder = folder; var handler_draw_box = function(data){ numBox++; create_border(folder_name,numBox.toString()); draw_box.draw_newBox(data, current_folder); alternate_border(numBox); return true; }; cExecute ("expressoMail1_2.imap_functions.get_range_msgs2&folder="+current_folder+"&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type="+sort_box_type+ "&search_box_type="+ search_box_type +"&sort_box_reverse="+sort_box_reverse+"", handler_draw_box); } else alternate_border(numBox); return true; } function sort_box(search, sort){ var message_header = Element("message_header_"+search); var handler_draw_box = function(data){ draw_box.headers_msgs = data; draw_box.draw_box_messages(current_folder); draw_paging(Element('tot_m').innerHTML); //Mostrar as msgs nao lidas de acordo com o filtro de relevancia var msgs_unseen = 0; for(i in data){ if(data[i].Unseen == 'U') msgs_unseen++; } Element("new_m").innerHTML = '' + msgs_unseen + ''; }; if(sort_box_type == sort && search_box_type == search){ sort_box_reverse = sort_box_reverse ? 0 : 1; } else if(sort_box_type != sort){ if ( (sort == 'SORTFROM') || (sort == 'SORTSUBJECT') ) sort_box_reverse = 0; else sort_box_reverse = 1; } // Global variable. sort_box_type = sort; search_box_type = search; draw_box.prepare_box(true); proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort,search,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box); current_page = 1; //Comentado para nao sobrepor o numero de msgs nao lidas ao utilizar os filtros //update_menu(); } function make_tr_message(headers_msgs, msg_folder) { var tr_element = document.createElement('tr'); tr_element.style.height = preferences.line_height; tr_element.id = headers_msgs.msg_number; tr_element.msg_sample = ""; //if(headers_msgs.msg_sample && headers_msgs.msg_sample.preview_msg_subject != "") if(headers_msgs.msg_sample && preferences.preview_msg_subject == "1") { tr_element.msg_sample = headers_msgs.msg_sample.body.substr(0,120) + "..."; //trecho do body que sera exibido com o assunto; } tr_element.tip = ""; if(headers_msgs.msg_sample && preferences.preview_msg_tip == "1") { tr_element.tip = headers_msgs.msg_sample.body.substr(3,300) + "..."; //trecho do body que sera exibido no tool-tip; } if ((headers_msgs.Unseen == 'U') || (headers_msgs.Recent == 'N')){ if ((headers_msgs.Flagged == 'F') || (headers_msgs.Importance.toLowerCase().indexOf("high")!=-1 && parseInt(preferences.use_important_flag))) add_className(tr_element, 'flagged_msg'); add_className(tr_element, 'tr_msg_unread'); } else{ if ((headers_msgs.Flagged == 'F') || (headers_msgs.Importance.toLowerCase().indexOf("high")!=-1 && parseInt(preferences.use_important_flag))) add_className(tr_element,'flagged_msg'); } if ((headers_msgs.Unseen == 'U') || (headers_msgs.Recent == 'N')) add_className(tr_element, 'tr_msg_unread'); if (headers_msgs.Flagged == 'F') add_className(tr_element,'flagged_msg'); td_element1 = createAndSet("TD",['class','width'],['td_msg','1%']); _chkbox = createAndSet("INPUT", ['type','class','id'], ['checkbox','checkbox',"check_box_message_"+headers_msgs.msg_number]); _chkbox.onclick = function(e){ if (is_ie) changeBgColor(window.event,headers_msgs.msg_number); else changeBgColor(e,headers_msgs.msg_number); }; td_element1.appendChild(_chkbox); td_element2 = document.createElement("TD"); td_element2.className = "td_msg"; td_element2.setAttribute("width", "2%"); if (headers_msgs.attachment && headers_msgs.attachment.number_attachments > 0) td_element2.innerHTML = ''; td_element21 = document.createElement("TD"); td_element21.className = "td_msg"; td_element21.setAttribute("width", "1%"); td_element21.id = "td_message_answered_"+headers_msgs.msg_number; if (headers_msgs.attachment && headers_msgs.attachment.number_attachments > 0) { attach_name = headers_msgs.attachment.names.split(", "); for(var item=0; item < attach_name.length; item++) { if (url_decode(attach_name[item]) != 'smime.p7s' && url_decode(attach_name[item]) != 'smime.p7m'){ td_element21.innerHTML = ''; break; } } } if ((headers_msgs.Forwarded == 'F') || (headers_msgs.Draft == 'X' && headers_msgs.Answered == 'A')){ td_element21.innerHTML = ''; headers_msgs.Draft = ''; headers_msgs.Answered = ''; } else if (headers_msgs.Draft == 'X') td_element21.innerHTML = ''; else if (headers_msgs.Answered == 'A') td_element21.innerHTML = ''; else td_element21.innerHTML = "   "; td_element22 = document.createElement("TD"); td_element22.className = "td_msg"; td_element22.setAttribute("width", "1%"); td_element22.id = "td_message_signed_"+headers_msgs.msg_number; switch(headers_msgs.ContentType) { case "signature": { td_element22.innerHTML = ''; break; } case "cipher": { td_element22.innerHTML = ''; break; } default: { break; } }; td_element23 = document.createElement("TD"); td_element23.className = "td_msg"; td_element23.setAttribute("width", "1%"); td_element23.id = "td_message_important_"+headers_msgs.msg_number; if (headers_msgs.Flagged == 'F' || (parseInt(preferences.use_important_flag) && headers_msgs.Importance.toLowerCase().indexOf("high") != -1)) { td_element23.innerHTML = ''; } else td_element23.innerHTML = "   "; td_element24 = document.createElement("TD"); td_element24.className = "td_msg"; td_element24.setAttribute("width", "1%"); td_element24.id = "td_message_sent_"+headers_msgs.msg_number; td_element24.innerHTML = "   "; // preload images var _img_sent = new Image(); _img_sent.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/sent.gif'; var _img_unseen = new Image(); _img_unseen.src = URL_SERVER + 'expressoMail1_2/templates/'+template+'/images/unseen.gif'; var td_element25 = document.createElement("TD"); td_element25.className = "td_msg"; td_element25.setAttribute("width", "1%"); td_element25.id = "td_message_unseen_"+headers_msgs.msg_number; if ((headers_msgs.Unseen == 'U') || (headers_msgs.Recent == 'N')) td_element25.innerHTML = ""; else td_element25.innerHTML = ""; td_element3 = document.createElement("TD"); td_element3.className = "td_msg"; td_element3.id = "td_who_"+ headers_msgs.msg_number; td_element3.setAttribute("width", "20%"); var _onclick = function(){ try { InfoContact.hide(); }catch(e){ if(e.toString().match("InfoContact is null")){ return false; } }; proxy_mensagens.get_msg(headers_msgs, msg_folder,true, show_msg); }; td_element3.onclick = _onclick; td_element3.innerHTML = ' '; if (typeof(headers_msgs.from) == 'undefined') return false; if( headers_msgs.from.email && headers_msgs.from.email.toLowerCase() == Element("user_email").value ) { td_element3.onmouseover = function () { this.title=headers_msgs.to.email; }; if (headers_msgs.Draft == 'X') td_element3.innerHTML += "("+get_lang("Draft")+") "; else{ if(headers_msgs.to.email != null && headers_msgs.to.email.toLowerCase() != Element("user_email").value) td_element24.innerHTML = ''; if ((headers_msgs.to)&&(headers_msgs.to.name != null)) td_element3.innerHTML += headers_msgs.to.name; else if (headers_msgs.to){ td_element3.innerHTML += headers_msgs.to.email; } } } else{ if (headers_msgs.Draft == 'X'){ td_element3.innerHTML = "("+get_lang("Draft")+") "; } else{ var spanSender = document.createElement("SPAN"); spanSender.onmouseover = function (event) { this.style.textDecoration = "underline";try { InfoContact.begin(this,headers_msgs.from.email) } catch(e){}; }; spanSender.onmouseout = function (){ try { this.style.textDecoration = "none"; clearTimeout(InfoContact.timeout); } catch(e){} }; spanSender.innerHTML = headers_msgs.from.name != null ? headers_msgs.from.name : headers_msgs.from.email; if (spanSender.innerHTML.indexOf(" ") == '-1' && spanSender.innerHTML.length > 25){ spanSender.innerHTML = spanSender.innerHTML.substring(0,25) + "..."; } else if (spanSender.innerHTML.length > 40 ){ spanSender.innerHTML = spanSender.innerHTML.substring(0,40) + "..."; } td_element3.appendChild(spanSender); } } td_element4 = document.createElement("TD"); td_element4.className = "td_msg"; td_element4.setAttribute("width", "50%"); td_element4.onclick = _onclick; // td_element4.setAttribute("style","white-space:nowrap;"); td_element4.innerHTML = !is_ie ? " " : " "; if ((headers_msgs.subject)&&(headers_msgs.subject.length > 50)) { // if( (headers_msgs.subject.length+tr_element.msg_sample.length)> td_element4.innerHTML += headers_msgs.subject.substring(0,50) + "..." + " " + tr_element.msg_sample +"";//modificacao feita para exibir o trecho do body ao lado do assunto da mensagem; } else { td_element4.innerHTML += headers_msgs.subject + " " + tr_element.msg_sample + "";//modificacao feita para exibir o trecho do body ao lado do assunto da mensagem; } td_element4.title=tr_element.tip; if(!is_ie){ td_element4.innerHTML += ""; } td_element5 = document.createElement("TD"); td_element5.className = "td_msg"; td_element5.setAttribute("width", "14%"); td_element5.onclick = _onclick; td_element5.setAttribute("align", "center"); var date_msg = new Date(headers_msgs.udate*1000); td_element5.innerHTML = strDateShow(headers_msgs.udate); td_element5.title = norm(date_msg.getDate()) + '/' + norm(date_msg.getMonth()+1) + '/' +date_msg.getFullYear(); td_element5.alt = td_element5.title; td_element6 = document.createElement("TD"); td_element6.className = "td_msg"; td_element6.setAttribute("width", "14%"); td_element6.setAttribute("noWrap","true"); td_element6.setAttribute("align", "center"); td_element6.onclick = _onclick; td_element6.innerHTML = borkb(headers_msgs.Size); return appendChilds(tr_element,td_element1,td_element2,td_element21,td_element22,td_element23,td_element24,td_element25,td_element3,td_element4,td_element5,td_element6); } function draw_folder(){ } draw_folder.prototype.draw_newBox = function(headers_msgs,msg_folder,alternate){ this.headers_msgs = headers_msgs; this.prepare_box( alternate ); this.draw_box_messages(headers_msgs,msg_folder); }; draw_folder.prototype.prepare_box = function(alternate){ if (alternate) kill_current_box(); if(is_ie) document.getElementById("border_table").width = "99.5%"; openTab.content_id[numBox] = document.getElementById("content_id_"+numBox); openTab.type[numBox] = 0; _tbl_msghead_bx = Element("_tbl_msghead_bx_"+numBox); if (_tbl_msghead_bx == null){ var table_element = document.createElement("TABLE"); table_element.setAttribute("id", "_tbl_msghead_bx_"+numBox); table_element.setAttribute('class', "table_message_header_box"); var tbody_element = document.createElement("TBODY"); tr_element = createAndSet("TR",['class'],['message_header']); td_element1 = createAndSet("TD",['width'],['1%']); _chkbox_element = createAndSet("INPUT",['id','type','class'],["chkbox_sel_allmsg","checkbox","checkbox"]); _chkbox_element.onclick = function(){ select_all_messages(this.checked); }; _chkbox_element.onmouseover = function () { this.title=get_lang('Select all messages.'); }; _chkbox_element.onkeydown = function (e){ if (is_ie) { if ((window.event.keyCode) == 46) proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } else { if ((e.keyCode) == 46) proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } }; td_element1.appendChild(_chkbox_element); td_element2 = document.createElement("TD"); td_element2.setAttribute("width", "7%"); td_element3 = createAndSet("TD",['width','id','align'],['29%',"_msgheadSORTFROM_"+numBox,'left'],get_lang("Who")); td_element3.onclick = function () { sort_box(search_box_type,'SORTFROM'); }; td_element4 = createAndSet("TD",['width','id','align'],['38%',"_msgheadSORTSUBJECT_"+numBox,"left"],get_lang("Subject")); td_element4.onclick = function () { sort_box(search_box_type,'SORTSUBJECT'); }; td_element5 = createAndSet("TD",['width','id','align'],["14%","_msgheadSORTARRIVAL_"+numBox,"center"],get_lang("Date")); td_element5.onclick = function () { sort_box(search_box_type,'SORTARRIVAL'); }; td_element6 = createAndSet("TD",['width','id','align'],["14%","_msgheadSORTSIZE_"+numBox,"left"],get_lang("Size")); td_element6.onclick = function () { sort_box(search_box_type,'SORTSIZE'); }; appendChilds(tr_element,td_element1,td_element2); var td_element21 = document.createElement("TD"); td_element21.innerHTML = "   "; var td_element22 = document.createElement("TD"); td_element22.innerHTML = "   "; var td_element23 = document.createElement("TD"); td_element23.innerHTML = "  "; tbody_element.appendChild(appendChilds(tr_element,td_element21,td_element22,td_element23,td_element3,td_element4,td_element5,td_element6)); table_element.appendChild(tbody_element); openTab.content_id[numBox].appendChild(table_element); } draw_header_box(); var _divScroll = document.getElementById("divScrollMain_"+numBox); if(!_divScroll){ _divScroll = document.createElement("DIV"); _divScroll.id = "divScrollMain_"+numBox; } _divScroll.style.overflowY = "auto"; _divScroll.style.overflowX = "hidden"; _divScroll.style.width ="100%"; var _t_element = createAndSet("TABLE",['id','class','borderColorDark','frame','rules','cellPadding','cellSpacing'],["table_box","table_box","#bbbbbb","void","rows","0","0"]); _t_element.onkeydown = function (e){ if (is_ie) { if ((window.event.keyCode) == 46) { //delete_all_selected_msgs_imap(); proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } } else { if ((e.keyCode) == 46) { //delete_all_selected_msgs_imap(); proxy_mensagens.delete_msgs(get_current_folder(),'selected','null'); } } }; if (is_ie) _t_element.style.cursor = "hand"; var _tbody_element = document.createElement("TBODY"); _tbody_element.setAttribute("id", "tbody_box"); _t_element.appendChild(_tbody_element); _divScroll.appendChild(_t_element); openTab.content_id[numBox].appendChild(_divScroll); if (alternate) _divScroll.appendChild(loading_img); }; draw_folder.prototype.draw_box_messages = function(msg_folder){ openTab.content_id[numBox] = document.getElementById("content_id_"+numBox); var _divScroll = document.getElementById("divScrollMain_"+numBox); try{ loading_img = _divScroll.removeChild( loading_img ); } catch(e){ } var tbody_element = _divScroll.firstChild.firstChild; var f_unseen = 0; openTab.imapBox[numBox] = msg_folder; if (this.headers_msgs.num_msgs == 0){ var tr_info = document.createElement("TR"); var td_info = createAndSet("TD",['colspan','background','align','style'], ['10','#FFF','center','padding-top: 25px;font-weight:bold;font-size:11pt;'],get_lang("This mail box is empty")); tr_info.setAttribute("id", "msg_info"); tr_info.appendChild(td_info); tbody_element.appendChild(tr_info); } for (var i=0; i < this.headers_msgs.length; i++){ if ((this.headers_msgs[i].Unseen == 'U') || (this.headers_msgs[i].Recent == 'N')) f_unseen++; tr_element = make_tr_message(this.headers_msgs[i], msg_folder); if (tr_element){ tbody_element.appendChild(tr_element); add_className(tr_element, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read'); } if ( _dragArea == null ) _dragArea = new DragArea( ); _dragArea.makeDragged(tr_element, this.headers_msgs[i].msg_number, this.headers_msgs[i].subject, true); } if ((preferences.use_shortcuts == '1') && (this.headers_msgs[0])) select_msg(this.headers_msgs[0].msg_number, 'null', true); var tdFolders = Element("folderscol"); tdFolders.style.display = preferences.hide_folders == '1' ? "none" : ""; draw_footer_box(this.headers_msgs.num_msgs); Element('main_table').style.display = ''; resizeWindow(); if(debug) { var _eTime = new Date(); _eTime = _eTime.getTime(); alert("Carregou em "+(_eTime - _bTime)+" ms"); } var msg_folder = Element('msg_folder').value; var msg_number = Element('msg_number').value; if(!msg_folder && msg_number) { new_message('new','null'); } else if(msg_folder && msg_number){ proxy_mensagens.get_msg(this.headers_msgs, url_encode(msg_folder),true, show_msg); Element('msg_folder').value = ''; Element('msg_number').value = ''; } var scripts = new Array("jscode/messages_controller", "jscode/InfoContact", "jscode/local_messages", "jscode/draw_api_messages", "jscode/draw_messages"); expresso.connector.loadAllScripts(scripts); // Loading Quota View Folder Component (if exists...) if(Element("table_quota")) expresso.connector.loadScript("jscode/InfoQuota"); alternate_border(numBox); }; function draw_footer_box(num_msgs){ folder = get_current_folder(); var span_R = Element("table_message"); var span_options = Element("span_options"); if(!span_options) { span_options = document.createElement("TD"); span_options.style.fontSize = "12"; span_options.id = "span_options"; span_R.appendChild(span_options); } var change_font_color = 'onmouseover="var last_class = this.className;'+ 'if (this.className != \'message_options_over\')'+ 'this.className=\'message_options_active\'; '+ 'this.onmouseout=function(){this.className=last_class;}"'; span_options.innerHTML = ''+get_lang("Delete")+''+ ''+get_lang("Move")+''+ ((expresso_offline)?" ":''+get_lang("Print")+'')+ // ''+get_lang("Print")+''+ ((expresso_offline)?" ":''+get_lang("Export")+'') + ((expresso_offline)?" ":''+get_lang("Import")+''); if(preferences.use_local_messages==1 && !expresso_offline) if(proxy_mensagens.is_local_folder(current_folder)) span_options.innerHTML += '  '+get_lang("Unarchive")+''; else span_options.innerHTML += '  '+get_lang("Archive")+''; if (use_spam_filter) { if ( current_folder == 'INBOX'+cyrus_delimiter+'Spam' ) { span_options.innerHTML += ' | '+get_lang("Not Spam")+''; } else { span_options.innerHTML += ' | '+get_lang("Mark as Spam")+''; } } var span_D = Element("span_D"); if(!span_D){ span_D = document.createElement("TD"); span_D.align = "right"; span_D.style.fontSize = "12"; span_D.id = "span_D"; span_R.appendChild(span_D); } span_D.innerHTML = get_lang("List")+': '+ ''+get_lang("All")+', '+ ''+get_lang("l_unseen")+', '+ ''+get_lang("l_seen")+', '+ ''+get_lang("l_answered")+', '+ ''+get_lang("l_important")+'  '; draw_paging(num_msgs); Element("tot_m").innerHTML = num_msgs; }; // Objeto Map, talvez o ideal fosse adicionar este objeto à Api do egroupware, e carregá-lo // aqui no expressoMail. function Map() { this.keys = new Array(); this.values = new Array(); } Map.prototype.add = function(key, value) { this.keys.push(key); this.values.push(value); }; Map.prototype.get = function(key) { result = new Array(); for (i = 0; i < this.keys.length; i++) { if (this.keys[i] == key) { result.push(this.values[i]); } } if (result.length == 0) { return null; } return result; }; var translatedFolders = new Map(); draw_box = new draw_folder();