[2517] | 1 | // BEGIN: FUNCTION RESIZE WINDOW |
---|
| 2 | if (!expresso_offline) { |
---|
| 3 | var _showBar = showBar; |
---|
| 4 | var _hideBar = hideBar; |
---|
| 5 | } |
---|
| 6 | |
---|
| 7 | function __showBar(){ |
---|
| 8 | _showBar(); |
---|
| 9 | resizeWindow(); |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | function __hideBar(){ |
---|
| 13 | _hideBar(); |
---|
| 14 | resizeWindow(); |
---|
| 15 | } |
---|
| 16 | showBar = __showBar; |
---|
| 17 | hideBar = __hideBar; |
---|
| 18 | |
---|
[2642] | 19 | XEvents.add( window, 'onresize', resizeWindow ); |
---|
[2517] | 20 | |
---|
| 21 | function resizeWindow(){ |
---|
| 22 | |
---|
| 23 | var bar = Element("toolbar"); |
---|
| 24 | var offset = 0; |
---|
| 25 | if(bar.style.visibility != 'hidden') |
---|
| 26 | offset = (bar.offsetHeight ? bar.offsetHeight : bar.clientHeight); |
---|
| 27 | |
---|
| 28 | var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight; |
---|
| 29 | var defaultHeight = screenHeight - offset; |
---|
| 30 | |
---|
| 31 | if(typeof(BordersArray) != 'undefined') { |
---|
| 32 | for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) { |
---|
| 33 | var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence); |
---|
| 34 | var div = Element("content_id_"+BordersArray[i].sequence); |
---|
| 35 | |
---|
| 36 | if(div) |
---|
[2642] | 37 | div.style.height = ( defaultHeight - 90 ) + 'px'; |
---|
[2517] | 38 | if(div_scroll) |
---|
[2642] | 39 | div_scroll.style.height = ( defaultHeight - 130 ) + 'px'; |
---|
[2517] | 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | if(Element('content_folders')) |
---|
| 44 | Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150); |
---|
| 45 | if(Element("divScrollMain_"+numBox)) |
---|
| 46 | Element("divScrollMain_"+numBox).style.height = defaultHeight - (is_ie ? 111 : 110); |
---|
| 47 | } |
---|
| 48 | // END: FUNCTION RESIZE WINDOW |
---|
| 49 | |
---|
| 50 | var _beforeunload_ = window.onbeforeunload; |
---|
| 51 | |
---|
| 52 | window.onbeforeunload = function() |
---|
| 53 | { |
---|
| 54 | return unloadMess(); |
---|
[2555] | 55 | }; |
---|
[2517] | 56 | |
---|
| 57 | function unloadMess(){ |
---|
| 58 | if (typeof(expresso_mail_sync) != "undefined" && expresso_mail_sync.working) { |
---|
| 59 | var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?"); |
---|
| 60 | return mess; |
---|
| 61 | } |
---|
| 62 | else { |
---|
| 63 | var mess = get_lang("Your message has not been sent and will be discarted."); |
---|
| 64 | for (var i = 0; i < BordersArray.length; i++) { |
---|
| 65 | var body = Element('body_' + BordersArray[i].sequence); |
---|
| 66 | if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') { |
---|
| 67 | return mess; |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | // Change the class of message. |
---|
| 74 | // In refresh, the flags UnRead and UnSeen don't exist anymore. |
---|
| 75 | function set_msg_as_read(msg_number, selected){ |
---|
| 76 | tr_message = Element(msg_number); |
---|
| 77 | if (exist_className(tr_message, 'tr_msg_unread')) |
---|
| 78 | decrement_folder_unseen(); |
---|
| 79 | remove_className(tr_message, 'tr_msg_unread'); |
---|
| 80 | remove_className(tr_message, 'selected_msg'); |
---|
| 81 | expresso.connector.purgeCache(); |
---|
| 82 | return true; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | function msg_is_read(msg_number, selected){ |
---|
| 86 | tr_message = Element(msg_number); |
---|
[2555] | 87 | return !(tr_message && LTrim(tr_message.className).match('tr_msg_unread')); |
---|
[2517] | 88 | } |
---|
| 89 | |
---|
| 90 | function set_msg_as_unread(msg_number){ |
---|
| 91 | tr_message = Element(msg_number); |
---|
| 92 | if ((exist_className(tr_message, 'tr_msg_read') || exist_className(tr_message, 'tr_msg_read2')) && (!exist_className(tr_message, 'tr_msg_unread'))) |
---|
| 93 | increment_folder_unseen(); |
---|
| 94 | remove_className(tr_message, 'selected_msg'); |
---|
| 95 | add_className(tr_message, 'tr_msg_unread'); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | function set_msg_as_flagged(msg_number){ |
---|
| 99 | var msg = Element(msg_number); |
---|
| 100 | remove_className(msg, 'selected_msg'); |
---|
| 101 | add_className(msg, 'flagged_msg'); |
---|
| 102 | Element("td_message_important_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/important.gif' title='"+get_lang('Important')+"'>"; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | function set_msg_as_unflagged(msg_number){ |
---|
| 106 | var msg = Element(msg_number); |
---|
| 107 | remove_className(msg, 'selected_msg'); |
---|
| 108 | remove_className(msg, 'flagged_msg'); |
---|
| 109 | Element("td_message_important_"+msg_number).innerHTML = " "; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | function get_current_folder(){ |
---|
| 114 | return current_folder; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | // Kill current box (folder or page). |
---|
| 118 | function kill_current_box(){ |
---|
| 119 | var box = document.getElementById("table_box"); |
---|
| 120 | if (box != null) |
---|
| 121 | box.parentNode.removeChild(box); |
---|
| 122 | else |
---|
| 123 | return false; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | // Kill current paging. |
---|
| 127 | function kill_current_paging(){ |
---|
| 128 | var paging = Element("span_paging"); |
---|
| 129 | if (paging != null) |
---|
| 130 | paging.parentNode.removeChild(paging); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | function show_hide_span_paging(ID){ |
---|
| 134 | if ((ID != "0") && Element("span_paging")) |
---|
| 135 | Element("span_paging").style.display = 'none'; |
---|
| 136 | else |
---|
| 137 | if (Element("span_paging")) |
---|
| 138 | Element("span_paging").style.display = ''; |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | //Get the current number of messages in a page. |
---|
| 142 | function get_messages_number_in_page(){ |
---|
| 143 | //Get element tBody. |
---|
| 144 | main = document.getElementById("tbody_box"); |
---|
| 145 | |
---|
| 146 | // Get all TR (messages) in tBody. |
---|
| 147 | main_list = main.childNodes; |
---|
| 148 | |
---|
| 149 | return main_list.length; |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | function download_local_attachment(url) { |
---|
| 153 | if (div_attachment == null){ |
---|
| 154 | var div_attachment = document.createElement("DIV"); |
---|
| 155 | div_attachment.id="id_div_attachment"; |
---|
| 156 | document.body.appendChild(div_attachment); |
---|
| 157 | } |
---|
| 158 | div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='"+url+"'></iframe>"; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){ |
---|
| 162 | div_attachment = document.getElementById("id_div_attachment"); |
---|
| 163 | var params = ''; |
---|
| 164 | |
---|
| 165 | if (div_attachment == null){ |
---|
| 166 | var div_attachment = document.createElement("DIV"); |
---|
| 167 | div_attachment.id="id_div_attachment"; |
---|
| 168 | document.body.appendChild(div_attachment); |
---|
| 169 | } |
---|
| 170 | if(new_file_name) |
---|
| 171 | params = "&newfilename="+escape(new_file_name); |
---|
| 172 | if(encoding) |
---|
| 173 | params += "&encoding="+encoding; |
---|
| 174 | |
---|
| 175 | div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='inc/gotodownload.php?msg_folder="+msg_folder+"&msg_number="+msg_number+"&idx_file="+idx_file+"&msg_part="+msg_part+params+"'></iframe>"; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | function download_all_attachments(msg_folder, msg_number){ |
---|
| 179 | var handler_source = function(data){ |
---|
| 180 | download_attachments(null, null, data, null,null,'anexos.zip'); |
---|
[2555] | 181 | }; |
---|
[2519] | 182 | cExecute("expressoMail1_2.exporteml.download_all_attachments",handler_source,"folder="+msg_folder+"&num_msg="+msg_number); |
---|
[2517] | 183 | } |
---|
| 184 | //ADD forwarded files |
---|
| 185 | function addForwardedFile(id_border,file_name,link){ |
---|
| 186 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
| 187 | |
---|
| 188 | if (! divFiles) |
---|
| 189 | return false; |
---|
| 190 | |
---|
| 191 | if (divFiles.lastChild) |
---|
| 192 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 193 | |
---|
| 194 | if (! countDivFiles) |
---|
| 195 | var countDivFiles = 1; |
---|
| 196 | |
---|
| 197 | divFile = document.createElement('DIV'); |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | if (!expresso_offline) { |
---|
| 201 | if (!is_ie) { |
---|
| 202 | var inputFile = document.createElement("INPUT"); |
---|
| 203 | |
---|
| 204 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 205 | tmp_id_border.value = id_border; |
---|
| 206 | |
---|
| 207 | inputFile.setAttributeNode(tmp_id_border); |
---|
| 208 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
| 209 | inputFile.type = 'file'; |
---|
| 210 | inputFile.size = 50; |
---|
| 211 | inputFile.maxLength = 255; |
---|
| 212 | inputFile.name = 'file_' + countDivFiles; |
---|
| 213 | inputFile.style.display = "none"; |
---|
| 214 | } |
---|
| 215 | else { |
---|
| 216 | var inputFile = document.createElement("link"); |
---|
| 217 | |
---|
| 218 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 219 | tmp_id_border.value = id_border; |
---|
| 220 | |
---|
| 221 | inputFile.setAttributeNode(tmp_id_border); |
---|
| 222 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
| 223 | inputFile.name = 'file_' + countDivFiles; |
---|
| 224 | |
---|
| 225 | |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | } |
---|
| 229 | else { |
---|
| 230 | var inputFile = document.createElement("input"); |
---|
| 231 | inputFile.type = 'hidden'; |
---|
| 232 | inputFile.name = 'offline_forward_' + countDivFiles; |
---|
| 233 | } |
---|
| 234 | divFile.appendChild(inputFile); |
---|
| 235 | |
---|
| 236 | var a_tmp = new Array(); |
---|
| 237 | a_tmp[0] = "local_"; |
---|
| 238 | a_tmp[1] = 'file_' + countDivFiles; |
---|
| 239 | a_tmp[2] = file_name; |
---|
| 240 | s_tmp = escape(expresso.connector.serialize(a_tmp)); |
---|
| 241 | var checkbox = document.createElement("INPUT"); |
---|
| 242 | checkbox.type = "checkbox"; |
---|
| 243 | checkbox.id = "checkbox_"+id_border+"_"+countDivFiles; |
---|
| 244 | checkbox.name = "local_attachments[]"; |
---|
| 245 | |
---|
| 246 | checkbox.value = s_tmp; |
---|
| 247 | divFile.appendChild(checkbox); |
---|
| 248 | |
---|
| 249 | var link_attachment = document.createElement("A"); |
---|
| 250 | link_attachment.setAttribute("href", link); |
---|
| 251 | |
---|
| 252 | link_attachment.innerHTML = file_name; |
---|
| 253 | divFile.appendChild(link_attachment); |
---|
| 254 | |
---|
| 255 | countDivFiles++; |
---|
| 256 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
| 257 | divFiles.appendChild(divFile); |
---|
| 258 | |
---|
| 259 | checkbox.checked = true; //IncrÃvel, mas no Internet Explorer o checked só funciona efetivamente se o elemente já estiver renderizado... por isso só aqui eu seleciono ele... |
---|
| 260 | return inputFile; |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | // Add Input File Dynamically. |
---|
| 264 | function addFile(id_border){ |
---|
| 265 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
| 266 | if (! divFiles) |
---|
| 267 | return false; |
---|
| 268 | |
---|
| 269 | if (divFiles.lastChild) |
---|
| 270 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 271 | |
---|
| 272 | if (! countDivFiles) |
---|
| 273 | var countDivFiles = 1; |
---|
| 274 | |
---|
| 275 | divFile = document.createElement('DIV'); |
---|
| 276 | |
---|
| 277 | |
---|
| 278 | divFile.innerHTML = "<input type='file' id_border='"+id_border+"' size='50' maxLength='255' onchange=\"function () {validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border'));};\" id='"+"inputFile_"+id_border+"_"+countDivFiles+"' name='file_"+countDivFiles+"'>"; |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | var linkFile = document.createElement("A"); |
---|
| 282 | linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; |
---|
| 283 | linkFile.href='javascript:void(0)'; |
---|
| 284 | linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; |
---|
| 285 | linkFile.innerHTML=get_lang("Remove"); |
---|
| 286 | //divFile.innerHTML += " "; |
---|
| 287 | divFile.appendChild(linkFile); |
---|
| 288 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
| 289 | divFiles.appendChild(divFile); |
---|
| 290 | |
---|
| 291 | |
---|
| 292 | |
---|
| 293 | return document.getElementById("inputFile_"+id_border+"_"+countDivFiles); |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | var setTimeout_write_msg = 0; |
---|
| 297 | var old_msg = false; |
---|
| 298 | // Funcao usada para escrever mensagem |
---|
| 299 | // notimeout = True : mensagem nao apaga |
---|
| 300 | function write_msg(msg, notimeout){ |
---|
| 301 | |
---|
| 302 | if (setTimeout_write_msg) |
---|
| 303 | clearTimeout(setTimeout_write_msg); |
---|
| 304 | |
---|
| 305 | var msg_div = Element('em_div_write_msg'); |
---|
| 306 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 307 | |
---|
| 308 | if(!msg_div) { |
---|
| 309 | msg_div = document.createElement('DIV'); |
---|
| 310 | msg_div.id = 'em_div_write_msg'; |
---|
| 311 | msg_div.className = 'em_div_write_msg'; |
---|
| 312 | old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar); |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | if( document.getElementById('JabberMessenger')) |
---|
| 316 | loadscript.adIcon(); |
---|
| 317 | |
---|
| 318 | msg_div.innerHTML = '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tbody><tr><th width="40%"></th><th noWrap class="action_info_th">'+msg+'</th><th width="40%"></th></tr></tbody></table>'; |
---|
| 319 | |
---|
| 320 | old_divStatusBar.style.display = 'none'; |
---|
| 321 | msg_div.style.display = ''; |
---|
| 322 | // Nao ponha var na frente!! jakjr |
---|
| 323 | handle_write_msg = function(){ |
---|
| 324 | try{ |
---|
| 325 | if(!old_msg) |
---|
| 326 | clean_msg(); |
---|
| 327 | else |
---|
| 328 | write_msg(old_msg, true); |
---|
| 329 | } |
---|
| 330 | catch(e){} |
---|
[2555] | 331 | }; |
---|
[2517] | 332 | if(notimeout) |
---|
| 333 | old_msg = msg; |
---|
| 334 | else |
---|
| 335 | setTimeout_write_msg = setTimeout("handle_write_msg();", 5000); |
---|
| 336 | } |
---|
| 337 | // Funcao usada para apagar mensagem sem timeout |
---|
| 338 | function clean_msg(){ |
---|
| 339 | old_msg = false; |
---|
| 340 | var msg_div = Element('em_div_write_msg'); |
---|
| 341 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 342 | if(msg_div) |
---|
| 343 | msg_div.style.display = 'none'; |
---|
| 344 | old_divStatusBar.style.display = ''; |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | function make_body_reply(body, to, date_day, date_hour){ |
---|
| 348 | to = to.replace("<","<"); |
---|
| 349 | to = to.replace(">",">"); |
---|
| 350 | block_quoted_body ="<br><br>"; |
---|
| 351 | block_quoted_body += get_lang('At %1, %2 hours, %3 wrote:', date_day, date_hour, to); |
---|
| 352 | block_quoted_body += "<blockquote style=\"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;\">"; |
---|
| 353 | block_quoted_body += body; |
---|
| 354 | block_quoted_body += "</blockquote>"; |
---|
| 355 | return block_quoted_body; |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | function make_forward_body(body, from, date, subject, to, cc){ |
---|
| 359 | from = from.replace(/</g,"<"); |
---|
| 360 | from = from.replace(/>/g,">"); |
---|
| 361 | to = to.replace(/</g,"<"); |
---|
| 362 | to = to.replace(/>/g,">"); |
---|
| 363 | var forward_body = '<BR><BR>---------- ' + get_lang('Forwarded message') + ' ----------<BR>'; |
---|
| 364 | forward_body += get_lang('From') + ': ' + from + '<BR>'; |
---|
| 365 | forward_body += get_lang('Date') + ': ' + date + '<BR>'; |
---|
| 366 | forward_body += get_lang('Subject') + ': ' + subject + '<BR>'; |
---|
| 367 | forward_body += get_lang('To') + ': ' + to+ '<BR>'; |
---|
| 368 | if(cc != undefined){ |
---|
| 369 | cc = cc.replace(/</g,"<"); |
---|
| 370 | cc = cc.replace(/>/g,">"); |
---|
| 371 | forward_body += get_lang('CC') + ': ' + cc+ '<BR><BR>'; |
---|
| 372 | } |
---|
| 373 | forward_body += body; |
---|
| 374 | return forward_body; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | function emMessageSearch(e,value){ |
---|
| 378 | var e = is_ie ? window.event : e; |
---|
| 379 | if(e.keyCode == 13) { |
---|
| 380 | search_emails(value); |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | function emQuickSearch(emailList, field, ID){ |
---|
| 385 | var quickSearchKeyBegin; |
---|
| 386 | var quickSearchKeyEnd; |
---|
| 387 | if(expresso_offline) { |
---|
| 388 | alert(get_lang('Not allowed in offline mode')); |
---|
| 389 | return; |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | var handler_emQuickSearch = function(data) |
---|
| 393 | { |
---|
| 394 | window_DropDownContacts = Element('tipDiv'); |
---|
| 395 | if (window_DropDownContacts.style.visibility != 'hidden'){ |
---|
| 396 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | if ((!data.status) && (data.error == "many results")){ |
---|
| 400 | alert(get_lang('More than %1 results. Please, try to refine your search.',200)); |
---|
| 401 | return false; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | if (data.length > 0){ |
---|
| 405 | if ((field != 'null') && (ID != 'null')) |
---|
| 406 | { |
---|
| 407 | expresso.connector.loadScript("jscode/QuickCatalogSearch"); |
---|
| 408 | QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd); |
---|
| 409 | } |
---|
| 410 | else |
---|
| 411 | { |
---|
| 412 | expresso.connector.loadScript("jscode/QuickSearchUser"); |
---|
| 413 | QuickSearchUser.showList(data); |
---|
| 414 | } |
---|
| 415 | } |
---|
| 416 | else |
---|
| 417 | alert(get_lang('None result was found.')); |
---|
| 418 | return true; |
---|
[2555] | 419 | }; |
---|
[2517] | 420 | |
---|
| 421 | if ((field != 'null') && (ID != 'null')) |
---|
| 422 | { |
---|
| 423 | Element(field +'_'+ ID).focus(); //It requires for IE. |
---|
| 424 | var i = getPosition(Element(field +'_'+ ID)); //inputBox.selectionStart; |
---|
| 425 | var j = --i; |
---|
| 426 | |
---|
| 427 | // Acha o inicio |
---|
| 428 | while ((j >= 0) && (emailList.charAt(j) != ',')){j--}; |
---|
| 429 | quickSearchKeyBegin = ++j; |
---|
| 430 | |
---|
| 431 | // Acha o final |
---|
| 432 | while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++}; |
---|
| 433 | quickSearchKeyEnd = i; |
---|
| 434 | |
---|
| 435 | // A Chave da Pesquisa |
---|
| 436 | var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd)); |
---|
| 437 | } |
---|
| 438 | else |
---|
| 439 | var search_for = emailList; |
---|
| 440 | |
---|
| 441 | if (search_for.length < preferences.search_characters_number){ |
---|
| 442 | alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number)); |
---|
| 443 | return false; |
---|
| 444 | } |
---|
| 445 | |
---|
[2519] | 446 | cExecute ("expressoMail1_2.ldap_functions.quicksearch&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch); |
---|
[2517] | 447 | } |
---|
| 448 | |
---|
| 449 | function folderbox(){ |
---|
| 450 | expresso.connector.loadScript("jscode/TreeS"); |
---|
| 451 | ttree.make_Window(); |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | function filterbox(){ |
---|
| 455 | expresso.connector.loadScript("jscode/filter"); |
---|
| 456 | expresso.connector.loadScript("jscode/filters"); |
---|
| 457 | filters.Forms(); |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | function sharebox(){ |
---|
| 461 | var handler_imap_getacl = function(data) |
---|
| 462 | { |
---|
| 463 | var options = ''; |
---|
| 464 | for (var x in data) |
---|
| 465 | { |
---|
| 466 | options += "<option value='"+data[x].uid+"'>"+data[x].cn+"</option>"; |
---|
| 467 | } |
---|
| 468 | expresso.connector.loadScript("jscode/sharemailbox"); |
---|
| 469 | sharemailbox.makeWindow(options); |
---|
[2555] | 470 | }; |
---|
[2519] | 471 | cExecute ("expressoMail1_2.imap_functions.getacl", handler_imap_getacl); |
---|
[2517] | 472 | } |
---|
| 473 | |
---|
| 474 | function preferences_mail(){ |
---|
| 475 | location.href="../preferences/preferences.php?appname=expressoMail1_2"; |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | function search_emails(value){ |
---|
| 479 | expresso.connector.loadScript("jscode/search"); |
---|
| 480 | EsearchE.showForms(value); |
---|
| 481 | } |
---|
| 482 | |
---|
| 483 | function source_msg(id_msg,folder){ |
---|
| 484 | var num_msg = id_msg.substr(0,(id_msg.length - 2)); |
---|
| 485 | var handler_source = function(data){ |
---|
| 486 | download_attachments(null, null, data, null,null,'fonte_da_mensagem.eml'); |
---|
[2555] | 487 | }; |
---|
[2519] | 488 | cExecute("expressoMail1_2.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg); |
---|
[2517] | 489 | } |
---|
| 490 | |
---|
| 491 | function Element (el) { |
---|
| 492 | return document.getElementById(el); |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | function getPosition(obj) |
---|
| 496 | { |
---|
| 497 | if(typeof obj.selectionStart != "undefined") |
---|
| 498 | { |
---|
| 499 | return obj.selectionStart; |
---|
| 500 | } |
---|
| 501 | else if(document.selection && document.selection.createRange) |
---|
| 502 | { |
---|
| 503 | var M = document.selection.createRange(); |
---|
| 504 | try |
---|
| 505 | { |
---|
| 506 | var Lp = M.duplicate(); |
---|
| 507 | Lp.moveToElementText(obj); |
---|
| 508 | } |
---|
| 509 | catch(e) |
---|
| 510 | { |
---|
| 511 | var Lp=obj.createTextRange(); |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | Lp.setEndPoint("EndToStart",M); |
---|
| 515 | var rb=Lp.text.length; |
---|
| 516 | |
---|
| 517 | if(rb > obj.value.length) |
---|
| 518 | { |
---|
| 519 | return -1; |
---|
| 520 | } |
---|
| 521 | return rb; |
---|
| 522 | } |
---|
[2616] | 523 | }; |
---|
[2517] | 524 | |
---|
| 525 | function increment_folder_unseen(){ |
---|
| 526 | var folder_id = get_current_folder(); |
---|
| 527 | |
---|
| 528 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
| 529 | var abas_unseen = Element('new_m').innerHTML; |
---|
| 530 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 531 | |
---|
| 532 | if (folder_unseen) |
---|
| 533 | { |
---|
| 534 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + 1); |
---|
| 535 | } |
---|
| 536 | else |
---|
| 537 | { |
---|
| 538 | tree_folders.getNodeById(folder_id).alter({caption: tree_folders.getNodeById(current_folder).caption + '<font style=color:red> (</font><span id="dftree_'+current_folder+'_unseen" style=color:red>1</span><font style=color:red>)</font>'}); |
---|
| 539 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 540 | } |
---|
| 541 | if (abas_unseen) |
---|
| 542 | { |
---|
| 543 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
| 544 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 545 | } |
---|
| 546 | else{ |
---|
| 547 | abas_unseen = Element('new_m').innerHTML; |
---|
| 548 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 549 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
| 550 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 551 | } |
---|
| 552 | if ( current_folder.indexOf( 'INBOX' ) !== 0 && current_folder.indexOf( 'local_' ) !== 0 ) |
---|
| 553 | { |
---|
| 554 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
| 555 | if ( display_unseen_in_shared_folders ) |
---|
| 556 | tree_folders.getNodeById( 'user' ).alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">' + ( parseInt( display_unseen_in_shared_folders.innerHTML) + 1 ) + '</span><font style=color:red>]</font>' + get_lang("Shared folders")}); |
---|
| 557 | else |
---|
| 558 | tree_folders.getNodeById( 'user' ).alter({caption:'<font style=color:red>[</font><span id="dftree_user_unseen" style="color:red">1</span><font style=color:red>]</font>' + get_lang("Shared folders")}); |
---|
| 559 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
| 560 | } |
---|
| 561 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
| 562 | if(!expresso_offline) |
---|
| 563 | var node_to_refresh = 'root'; |
---|
| 564 | else |
---|
| 565 | var node_to_refresh = 'local_root'; |
---|
| 566 | tree_folders.getNodeById( node_to_refresh )._refresh(); |
---|
| 567 | } |
---|
| 568 | function decrement_folder_unseen(){ |
---|
| 569 | var folder_id = get_current_folder(); |
---|
| 570 | |
---|
| 571 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
| 572 | var abas_unseen = Element('new_m').innerHTML; |
---|
| 573 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 574 | |
---|
| 575 | if(!folder_unseen || !abas_unseen) |
---|
| 576 | return; |
---|
| 577 | |
---|
| 578 | if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > 1)) |
---|
| 579 | { |
---|
| 580 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - 1); |
---|
| 581 | } |
---|
| 582 | else if (parseInt(folder_unseen.innerHTML) <= 1) |
---|
| 583 | { |
---|
| 584 | var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<'); |
---|
| 585 | var folder_name = tmp_folder_name[0]; |
---|
| 586 | tree_folders.getNodeById(folder_id).alter({caption: folder_name}); |
---|
| 587 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 588 | } |
---|
| 589 | if ((abas_unseen) && (parseInt(abas_unseen) > 1)) |
---|
| 590 | { |
---|
| 591 | abas_unseen = (parseInt(abas_unseen) - 1); |
---|
| 592 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 593 | } |
---|
| 594 | else if (parseInt(abas_unseen) <= 1) |
---|
| 595 | { |
---|
| 596 | Element('new_m').innerHTML = '0'; |
---|
| 597 | } |
---|
| 598 | if ( current_folder.indexOf( 'INBOX' ) !== 0 ) |
---|
| 599 | { |
---|
| 600 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
| 601 | if ( display_unseen_in_shared_folders ) |
---|
| 602 | { |
---|
| 603 | var unseen_in_shared_folders = parseInt( display_unseen_in_shared_folders.innerHTML ); |
---|
| 604 | unseen_in_shared_folders--; |
---|
| 605 | if ( unseen_in_shared_folders > 0 ) |
---|
| 606 | tree_folders.getNodeById( 'user' ).alter({caption:'<font style=color:red>[</font><span id="dftree_root_unseen" style="color:red">' + unseen_in_shared_folders + '</span><font style=color:red>]</font>' + get_lang("My Folders")}); |
---|
| 607 | else |
---|
| 608 | tree_folders.getNodeById( 'user' ).alter({caption:get_lang("Shared folders")}); |
---|
| 609 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
| 610 | } |
---|
| 611 | } |
---|
| 612 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
| 613 | if ( display_unseen_in_mailbox ) |
---|
| 614 | { |
---|
| 615 | var unseen_in_mailbox = parseInt( display_unseen_in_mailbox.innerHTML ); |
---|
| 616 | unseen_in_mailbox--; |
---|
| 617 | //if ( unseen_in_mailbox > 0 ) |
---|
| 618 | // tree_folders.getNodeById( 'root' ).alter({caption:'<font style=color:red>[</font><span id="dftree_root_unseen" style="color:red">' + unseen_in_mailbox + '</span><font style=color:red>]</font>' + get_lang("My Folders")}); |
---|
| 619 | //else |
---|
| 620 | if(!expresso_offline) |
---|
| 621 | var node_to_refresh = 'root'; |
---|
| 622 | else |
---|
| 623 | var node_to_refresh = 'local_root'; |
---|
| 624 | tree_folders.getNodeById( node_to_refresh ).alter({caption:get_lang("My Folders")}); |
---|
| 625 | tree_folders.getNodeById( node_to_refresh )._refresh(); |
---|
| 626 | } |
---|
| 627 | } |
---|
| 628 | |
---|
| 629 | //changes MENU background color. |
---|
| 630 | function set_menu_bg(menu) |
---|
| 631 | { |
---|
| 632 | menu.style.backgroundColor = 'white'; |
---|
| 633 | menu.style.border = '1px solid black'; |
---|
| 634 | menu.style.padding = '0px 0px'; |
---|
| 635 | } |
---|
| 636 | //changes MENU background color. |
---|
| 637 | function unset_menu_bg(menu) |
---|
| 638 | { |
---|
| 639 | menu.style.backgroundColor = ''; |
---|
| 640 | menu.style.border = '0px'; |
---|
| 641 | menu.style.padding = '1px 0px'; |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | function array_search(needle, haystack) { |
---|
| 645 | var n = haystack.length; |
---|
| 646 | for (var i=0; i<n; i++) { |
---|
| 647 | if (haystack[i]==needle) { |
---|
| 648 | return true; |
---|
| 649 | } |
---|
| 650 | } |
---|
| 651 | return false; |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | function lang_folder(fn) { |
---|
| 655 | if (fn.toUpperCase() == "INBOX") return get_lang("Inbox"); |
---|
| 656 | if (special_folders[fn] && typeof(special_folders[fn]) == 'string') { |
---|
| 657 | return get_lang(special_folders[fn]); |
---|
| 658 | } |
---|
| 659 | return fn; |
---|
| 660 | } |
---|
| 661 | |
---|
| 662 | function select_all_messages(select) |
---|
| 663 | { |
---|
| 664 | var main = Element("tbody_box"); |
---|
| 665 | var main_list = main.childNodes; |
---|
| 666 | var len_main_list = main_list.length; |
---|
| 667 | |
---|
| 668 | if (select) |
---|
| 669 | { |
---|
| 670 | for (i=0; i<len_main_list; i++) |
---|
| 671 | { |
---|
| 672 | Element("check_box_message_"+main_list[i].id).checked = true; |
---|
| 673 | add_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 674 | } |
---|
| 675 | } |
---|
| 676 | else |
---|
| 677 | { |
---|
| 678 | for (i=0; i<len_main_list; i++) |
---|
| 679 | { |
---|
| 680 | Element("check_box_message_"+main_list[i].id).checked = false; |
---|
| 681 | remove_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 682 | } |
---|
| 683 | } |
---|
[2579] | 684 | }; |
---|