[2] | 1 | // BEGIN: FUNCTION RESIZE WINDOW |
---|
[1121] | 2 | if (!expresso_offline) { |
---|
| 3 | var _showBar = showBar; |
---|
| 4 | var _hideBar = hideBar; |
---|
| 5 | } |
---|
[2] | 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 | |
---|
| 19 | window.onresize = resizeWindow; |
---|
| 20 | |
---|
[320] | 21 | function config_events(pObj, pEvent, pHandler) |
---|
| 22 | { |
---|
| 23 | if( typeof pObj == 'object') |
---|
| 24 | { |
---|
| 25 | if( pEvent.substring(0, 2) == 'on') |
---|
| 26 | pEvent = pEvent.substring(2, pEvent.length); |
---|
| 27 | |
---|
| 28 | if ( pObj.addEventListener ) |
---|
| 29 | pObj.addEventListener(pEvent, pHandler, false); |
---|
| 30 | else if( pObj.attachEvent ) |
---|
| 31 | pObj.attachEvent('on' + pEvent, pHandler ); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
[2] | 35 | function resizeWindow(){ |
---|
| 36 | |
---|
| 37 | var bar = Element("toolbar"); |
---|
| 38 | var offset = 0; |
---|
[341] | 39 | if(bar.style.visibility != 'hidden') |
---|
| 40 | offset = (bar.offsetHeight ? bar.offsetHeight : bar.clientHeight); |
---|
[2] | 41 | |
---|
| 42 | var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight; |
---|
| 43 | var defaultHeight = screenHeight - offset; |
---|
[66] | 44 | |
---|
[813] | 45 | if(typeof(BordersArray) != 'undefined') { |
---|
[65] | 46 | for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) { |
---|
| 47 | var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence); |
---|
| 48 | var div = Element("content_id_"+BordersArray[i].sequence); |
---|
[813] | 49 | |
---|
[959] | 50 | // This comented code cause/avoid (!?) Firefox to stuck some request |
---|
[65] | 51 | if(div) |
---|
[813] | 52 | // div.setAttribute("style","height: "+parseInt(defaultHeight - 90)+"px;"); |
---|
| 53 | div.style.height = defaultHeight - 90; |
---|
| 54 | if(div_scroll) |
---|
[959] | 55 | // div_scroll.setAttribute("style","height: "+parseInt(defaultHeight - 130)+"px;"); |
---|
| 56 | div_scroll.style.height = defaultHeight - 130; |
---|
[65] | 57 | } |
---|
[2] | 58 | } |
---|
[812] | 59 | |
---|
[447] | 60 | if(Element('content_folders')) |
---|
| 61 | Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150); |
---|
[320] | 62 | if(Element("divScrollMain_"+numBox)) |
---|
[812] | 63 | Element("divScrollMain_"+numBox).style.height = defaultHeight - (is_ie ? 111 : 110); |
---|
[2] | 64 | } |
---|
| 65 | // END: FUNCTION RESIZE WINDOW |
---|
| 66 | |
---|
[320] | 67 | var _beforeunload_ = window.onbeforeunload; |
---|
| 68 | |
---|
| 69 | window.onbeforeunload = function() |
---|
[271] | 70 | { |
---|
[320] | 71 | return unloadMess(); |
---|
| 72 | } |
---|
[271] | 73 | |
---|
[2] | 74 | function unloadMess(){ |
---|
[1595] | 75 | if (expresso_mail_sync.working) { |
---|
[1518] | 76 | var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?"); |
---|
| 77 | return mess; |
---|
| 78 | } |
---|
| 79 | else { |
---|
| 80 | var mess = get_lang("Your message has not been sent and will be discarted."); |
---|
| 81 | for (var i = 0; i < BordersArray.length; i++) { |
---|
| 82 | var body = Element('body_' + BordersArray[i].sequence); |
---|
| 83 | if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') { |
---|
| 84 | return mess; |
---|
| 85 | } |
---|
[2] | 86 | } |
---|
| 87 | } |
---|
| 88 | } |
---|
[320] | 89 | |
---|
[2] | 90 | // Translate words and phrases using user language from eGroupware. |
---|
[812] | 91 | function get_lang(_key) { |
---|
[566] | 92 | var key = _key.toLowerCase(); |
---|
[812] | 93 | if(array_lang[key]) |
---|
| 94 | var _value = array_lang[key]; |
---|
| 95 | else |
---|
| 96 | var _value = _key+"*"; |
---|
[566] | 97 | |
---|
[812] | 98 | if(arguments.length > 1) |
---|
| 99 | for(j = 1; typeof(arguments[j]) != 'undefined'; j++) |
---|
| 100 | _value = _value.replace("%"+j,arguments[j]); |
---|
[2] | 101 | return _value; |
---|
[812] | 102 | } |
---|
| 103 | |
---|
[2] | 104 | // Make decimal round, using in size message |
---|
| 105 | function round(value, decimal){ |
---|
| 106 | var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal ); |
---|
| 107 | return( return_value ); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | // Change the class of message. |
---|
[341] | 111 | // In refresh, the flags UnRead and UnSeen don't exist anymore. |
---|
[163] | 112 | function set_msg_as_read(msg_number, selected){ |
---|
[2] | 113 | tr_message = Element(msg_number); |
---|
[163] | 114 | if (exist_className(tr_message, 'tr_msg_unread')) |
---|
| 115 | decrement_folder_unseen(); |
---|
| 116 | remove_className(tr_message, 'tr_msg_unread'); |
---|
| 117 | remove_className(tr_message, 'selected_msg'); |
---|
[1443] | 118 | connector.purgeCache(); |
---|
[163] | 119 | return true; |
---|
[2] | 120 | } |
---|
| 121 | |
---|
[605] | 122 | function msg_is_read(msg_number, selected){ |
---|
| 123 | tr_message = Element(msg_number); |
---|
[814] | 124 | return !(tr_message && LTrim(tr_message.className).match('tr_msg_unread')) |
---|
[605] | 125 | } |
---|
| 126 | |
---|
[163] | 127 | function set_msg_as_unread(msg_number){ |
---|
[2] | 128 | tr_message = Element(msg_number); |
---|
[1412] | 129 | if ((exist_className(tr_message, 'tr_msg_read') || exist_className(tr_message, 'tr_msg_read2')) && (!exist_className(tr_message, 'tr_msg_unread'))) |
---|
| 130 | increment_folder_unseen(); |
---|
[163] | 131 | remove_className(tr_message, 'selected_msg'); |
---|
| 132 | add_className(tr_message, 'tr_msg_unread'); |
---|
[2] | 133 | } |
---|
| 134 | |
---|
[163] | 135 | function set_msg_as_flagged(msg_number){ |
---|
| 136 | var msg = Element(msg_number); |
---|
| 137 | remove_className(msg, 'selected_msg'); |
---|
| 138 | add_className(msg, 'flagged_msg'); |
---|
[994] | 139 | Element("td_message_important_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/important.gif' title='"+get_lang('Important')+"'>"; |
---|
[2] | 140 | } |
---|
| 141 | |
---|
[163] | 142 | function set_msg_as_unflagged(msg_number){ |
---|
| 143 | var msg = Element(msg_number); |
---|
| 144 | remove_className(msg, 'selected_msg'); |
---|
| 145 | remove_className(msg, 'flagged_msg'); |
---|
[994] | 146 | Element("td_message_important_"+msg_number).innerHTML = " "; |
---|
[2] | 147 | } |
---|
| 148 | |
---|
[845] | 149 | function removeAll(id){ |
---|
| 150 | do |
---|
| 151 | { |
---|
| 152 | if (typeof(Element(id)) == 'undefined') |
---|
| 153 | break; |
---|
| 154 | Element(id).parentNode.removeChild(Element(id)); |
---|
| 155 | } |
---|
| 156 | while(Element(id)); |
---|
| 157 | } |
---|
| 158 | |
---|
[2] | 159 | function get_current_folder(){ |
---|
| 160 | return current_folder; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | // Kill current box (folder or page). |
---|
| 164 | function kill_current_box(){ |
---|
| 165 | var box = document.getElementById("table_box"); |
---|
| 166 | if (box != null) |
---|
| 167 | box.parentNode.removeChild(box); |
---|
[320] | 168 | else |
---|
| 169 | return false; |
---|
[2] | 170 | } |
---|
| 171 | |
---|
| 172 | // Kill current paging. |
---|
| 173 | function kill_current_paging(){ |
---|
| 174 | var paging = Element("span_paging"); |
---|
| 175 | if (paging != null) |
---|
| 176 | paging.parentNode.removeChild(paging); |
---|
| 177 | } |
---|
| 178 | |
---|
[412] | 179 | function show_hide_span_paging(ID){ |
---|
| 180 | if ((ID != "0") && Element("span_paging")) |
---|
| 181 | Element("span_paging").style.display = 'none'; |
---|
| 182 | else |
---|
| 183 | if (Element("span_paging")) |
---|
| 184 | Element("span_paging").style.display = ''; |
---|
| 185 | } |
---|
| 186 | |
---|
[2] | 187 | //Get the current number of messages in a page. |
---|
| 188 | function get_messages_number_in_page(){ |
---|
| 189 | //Get element tBody. |
---|
| 190 | main = document.getElementById("tbody_box"); |
---|
[341] | 191 | |
---|
[2] | 192 | // Get all TR (messages) in tBody. |
---|
| 193 | main_list = main.childNodes; |
---|
[341] | 194 | |
---|
[2] | 195 | return main_list.length; |
---|
| 196 | } |
---|
| 197 | |
---|
[689] | 198 | function download_local_attachment(url) { |
---|
| 199 | if (div_attachment == null){ |
---|
| 200 | var div_attachment = document.createElement("DIV"); |
---|
| 201 | div_attachment.id="id_div_attachment"; |
---|
| 202 | document.body.appendChild(div_attachment); |
---|
| 203 | } |
---|
| 204 | div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='"+url+"'></iframe>"; |
---|
| 205 | } |
---|
| 206 | |
---|
[271] | 207 | function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){ |
---|
[2] | 208 | div_attachment = document.getElementById("id_div_attachment"); |
---|
| 209 | var params = ''; |
---|
[341] | 210 | |
---|
[2] | 211 | if (div_attachment == null){ |
---|
| 212 | var div_attachment = document.createElement("DIV"); |
---|
| 213 | div_attachment.id="id_div_attachment"; |
---|
| 214 | document.body.appendChild(div_attachment); |
---|
| 215 | } |
---|
| 216 | if(new_file_name) |
---|
| 217 | params = "&newfilename="+new_file_name; |
---|
| 218 | if(encoding) |
---|
| 219 | params += "&encoding="+encoding; |
---|
[271] | 220 | |
---|
[5] | 221 | 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>"; |
---|
[2] | 222 | } |
---|
[271] | 223 | |
---|
[2] | 224 | function download_all_attachments(msg_folder, msg_number){ |
---|
[341] | 225 | var handler_source = function(data){ |
---|
[2] | 226 | download_attachments(null, null, data, null,null,'anexos.zip'); |
---|
| 227 | } |
---|
| 228 | cExecute("$this.exporteml.download_all_attachments",handler_source,"folder="+msg_folder+"&num_msg="+msg_number); |
---|
| 229 | } |
---|
[689] | 230 | //ADD forwarded files |
---|
| 231 | function addForwardedFile(id_border,file_name,link){ |
---|
| 232 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
| 233 | |
---|
| 234 | if (! divFiles) |
---|
| 235 | return false; |
---|
| 236 | |
---|
| 237 | if (divFiles.lastChild) |
---|
| 238 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 239 | |
---|
| 240 | if (! countDivFiles) |
---|
| 241 | var countDivFiles = 1; |
---|
| 242 | |
---|
| 243 | divFile = document.createElement('DIV'); |
---|
| 244 | |
---|
| 245 | |
---|
[1121] | 246 | if (!expresso_offline) { |
---|
| 247 | if (!is_ie) { |
---|
| 248 | var inputFile = document.createElement("INPUT"); |
---|
| 249 | |
---|
| 250 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 251 | tmp_id_border.value = id_border; |
---|
| 252 | |
---|
| 253 | inputFile.setAttributeNode(tmp_id_border); |
---|
| 254 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
| 255 | inputFile.type = 'file'; |
---|
| 256 | inputFile.size = 50; |
---|
| 257 | inputFile.maxLength = 255; |
---|
| 258 | inputFile.name = 'file_' + countDivFiles; |
---|
| 259 | inputFile.style.display = "none"; |
---|
| 260 | } |
---|
| 261 | else { |
---|
| 262 | var inputFile = document.createElement("link"); |
---|
| 263 | |
---|
| 264 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 265 | tmp_id_border.value = id_border; |
---|
| 266 | |
---|
| 267 | inputFile.setAttributeNode(tmp_id_border); |
---|
| 268 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
| 269 | inputFile.name = 'file_' + countDivFiles; |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | } |
---|
[689] | 273 | |
---|
| 274 | } |
---|
| 275 | else { |
---|
[1121] | 276 | var inputFile = document.createElement("input"); |
---|
| 277 | inputFile.type = 'hidden'; |
---|
| 278 | inputFile.name = 'offline_forward_' + countDivFiles; |
---|
| 279 | } |
---|
| 280 | divFile.appendChild(inputFile); |
---|
[689] | 281 | |
---|
| 282 | var a_tmp = new Array(); |
---|
| 283 | a_tmp[0] = "local_"; |
---|
| 284 | a_tmp[1] = 'file_' + countDivFiles; |
---|
| 285 | a_tmp[2] = file_name; |
---|
| 286 | s_tmp = escape(connector.serialize(a_tmp)); |
---|
| 287 | var checkbox = document.createElement("INPUT"); |
---|
| 288 | checkbox.type = "checkbox"; |
---|
| 289 | checkbox.id = "checkbox_"+id_border+"_"+countDivFiles; |
---|
| 290 | checkbox.name = "local_attachments[]"; |
---|
| 291 | |
---|
| 292 | checkbox.value = s_tmp; |
---|
| 293 | divFile.appendChild(checkbox); |
---|
| 294 | |
---|
| 295 | var link_attachment = document.createElement("A"); |
---|
| 296 | link_attachment.setAttribute("href", link); |
---|
| 297 | |
---|
| 298 | link_attachment.innerHTML = file_name; |
---|
| 299 | divFile.appendChild(link_attachment); |
---|
| 300 | |
---|
| 301 | countDivFiles++; |
---|
| 302 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
| 303 | divFiles.appendChild(divFile); |
---|
| 304 | |
---|
| 305 | 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... |
---|
| 306 | return inputFile; |
---|
| 307 | } |
---|
| 308 | |
---|
[2] | 309 | // Add Input File Dynamically. |
---|
| 310 | function addFile(id_border){ |
---|
| 311 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
[320] | 312 | if (! divFiles) |
---|
| 313 | return false; |
---|
[341] | 314 | |
---|
[271] | 315 | if (divFiles.lastChild) |
---|
| 316 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 317 | |
---|
| 318 | if (! countDivFiles) |
---|
| 319 | var countDivFiles = 1; |
---|
[341] | 320 | |
---|
[2] | 321 | divFile = document.createElement('DIV'); |
---|
[341] | 322 | |
---|
| 323 | |
---|
[1121] | 324 | 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+"'>"; |
---|
| 325 | |
---|
[341] | 326 | |
---|
[271] | 327 | var linkFile = document.createElement("A"); |
---|
| 328 | linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; |
---|
[2] | 329 | linkFile.href='javascript:void(0)'; |
---|
[320] | 330 | linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; |
---|
[341] | 331 | linkFile.innerHTML=get_lang("Remove"); |
---|
[2] | 332 | //divFile.innerHTML += " "; |
---|
| 333 | divFile.appendChild(linkFile); |
---|
[341] | 334 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
[2] | 335 | divFiles.appendChild(divFile); |
---|
[689] | 336 | |
---|
[1121] | 337 | |
---|
| 338 | |
---|
| 339 | return document.getElementById("inputFile_"+id_border+"_"+countDivFiles); |
---|
[2] | 340 | } |
---|
| 341 | // Remove Input File Dynamically. |
---|
| 342 | function removeFile(id){ |
---|
[271] | 343 | var border_id = id.substr(8,1); |
---|
[2] | 344 | var el = Element(id); |
---|
| 345 | el.parentNode.removeChild(el); |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | function validateFileExtension(fileName, id, id_border){ |
---|
[320] | 349 | |
---|
[271] | 350 | var error_flag = false; |
---|
[320] | 351 | |
---|
| 352 | if ( fileName.indexOf('/') != -1 ) |
---|
| 353 | { |
---|
| 354 | if (fileName[0] != '/'){ // file name is windows format? |
---|
| 355 | var file = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length); |
---|
| 356 | if ((fileName.indexOf(':\\') != 1) && (fileName.indexOf('\\\\') != 0)) // Is stored in partition or a network file? |
---|
| 357 | error_flag = true; |
---|
| 358 | } |
---|
| 359 | else // is Unix |
---|
| 360 | var file = fileName.substr(fileName.lastIndexOf('/') + 1, fileName.length); |
---|
[271] | 361 | } |
---|
[320] | 362 | else // is Firefox 3 |
---|
| 363 | var file = fileName; |
---|
[271] | 364 | |
---|
| 365 | var fileExtension = file.split("."); |
---|
[2] | 366 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 367 | for(var i=0; i<denyFileExtensions.length; i++) |
---|
| 368 | { |
---|
| 369 | if(denyFileExtensions[i] == fileExtension) |
---|
| 370 | { |
---|
[271] | 371 | error_flag = true; |
---|
| 372 | break; |
---|
[2] | 373 | } |
---|
[271] | 374 | |
---|
[2] | 375 | } |
---|
[271] | 376 | |
---|
[320] | 377 | if ( error_flag == true ) |
---|
| 378 | { |
---|
[271] | 379 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 380 | removeFile(id); |
---|
| 381 | addFile(id_border); |
---|
| 382 | return false; |
---|
| 383 | } |
---|
| 384 | return true; |
---|
[2] | 385 | } |
---|
| 386 | |
---|
| 387 | var setTimeout_write_msg = 0; |
---|
[197] | 388 | var old_msg = false; |
---|
| 389 | // Funcao usada para escrever mensagem |
---|
| 390 | // notimeout = True : mensagem nao apaga |
---|
[341] | 391 | function write_msg(msg, notimeout){ |
---|
| 392 | |
---|
[2] | 393 | if (setTimeout_write_msg) |
---|
| 394 | clearTimeout(setTimeout_write_msg); |
---|
[341] | 395 | |
---|
[80] | 396 | var msg_div = Element('em_div_write_msg'); |
---|
[2] | 397 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 398 | |
---|
[80] | 399 | if(!msg_div) { |
---|
| 400 | msg_div = document.createElement('DIV'); |
---|
| 401 | msg_div.id = 'em_div_write_msg'; |
---|
[831] | 402 | msg_div.className = 'em_div_write_msg'; |
---|
[80] | 403 | old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar); |
---|
[447] | 404 | } |
---|
| 405 | |
---|
| 406 | if( document.getElementById('JabberMessenger')) |
---|
[651] | 407 | loadscript.adIcon(); |
---|
[447] | 408 | |
---|
[831] | 409 | 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>'; |
---|
[651] | 410 | |
---|
[80] | 411 | old_divStatusBar.style.display = 'none'; |
---|
[341] | 412 | msg_div.style.display = ''; |
---|
[2] | 413 | // Nao ponha var na frente!! jakjr |
---|
| 414 | handle_write_msg = function(){ |
---|
| 415 | try{ |
---|
[197] | 416 | if(!old_msg) |
---|
| 417 | clean_msg(); |
---|
| 418 | else |
---|
[341] | 419 | write_msg(old_msg, true); |
---|
[2] | 420 | } |
---|
| 421 | catch(e){} |
---|
| 422 | } |
---|
[197] | 423 | if(notimeout) |
---|
| 424 | old_msg = msg; |
---|
| 425 | else |
---|
| 426 | setTimeout_write_msg = setTimeout("handle_write_msg();", 5000); |
---|
[2] | 427 | } |
---|
[197] | 428 | // Funcao usada para apagar mensagem sem timeout |
---|
| 429 | function clean_msg(){ |
---|
| 430 | old_msg = false; |
---|
| 431 | var msg_div = Element('em_div_write_msg'); |
---|
| 432 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 433 | if(msg_div) |
---|
| 434 | msg_div.style.display = 'none'; |
---|
[341] | 435 | old_divStatusBar.style.display = ''; |
---|
[197] | 436 | } |
---|
[2] | 437 | |
---|
| 438 | function make_body_reply(body, to, date_day, date_hour){ |
---|
| 439 | to = to.replace("<","<"); |
---|
| 440 | to = to.replace(">",">"); |
---|
| 441 | block_quoted_body ="<br><br>"; |
---|
[197] | 442 | block_quoted_body += get_lang('At %1, %2 hours, %3 wrote:', date_day, date_hour, to); |
---|
[2] | 443 | block_quoted_body += "<blockquote style=\"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;\">"; |
---|
| 444 | block_quoted_body += body; |
---|
| 445 | block_quoted_body += "</blockquote>"; |
---|
| 446 | return block_quoted_body; |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | function make_forward_body(body, from, date, subject, to, cc){ |
---|
| 450 | from = from.replace(/</g,"<"); |
---|
| 451 | from = from.replace(/>/g,">"); |
---|
| 452 | to = to.replace(/</g,"<"); |
---|
| 453 | to = to.replace(/>/g,">"); |
---|
| 454 | var forward_body = '<BR><BR>---------- ' + get_lang('Forwarded message') + ' ----------<BR>'; |
---|
| 455 | forward_body += get_lang('From') + ': ' + from + '<BR>'; |
---|
| 456 | forward_body += get_lang('Date') + ': ' + date + '<BR>'; |
---|
| 457 | forward_body += get_lang('Subject') + ': ' + subject + '<BR>'; |
---|
| 458 | forward_body += get_lang('To') + ': ' + to+ '<BR>'; |
---|
| 459 | if(cc != undefined){ |
---|
| 460 | cc = cc.replace(/</g,"<"); |
---|
| 461 | cc = cc.replace(/>/g,">"); |
---|
| 462 | forward_body += get_lang('CC') + ': ' + cc+ '<BR><BR>'; |
---|
| 463 | } |
---|
| 464 | forward_body += body; |
---|
| 465 | return forward_body; |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | function emMessageSearch(e,value){ |
---|
| 469 | var e = is_ie ? window.event : e; |
---|
| 470 | if(e.keyCode == 13) { |
---|
| 471 | search_emails(value); |
---|
| 472 | } |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | function emQuickSearch(emailList, field, ID){ |
---|
| 476 | var quickSearchKeyBegin; |
---|
| 477 | var quickSearchKeyEnd; |
---|
[1121] | 478 | if(expresso_offline) { |
---|
| 479 | alert(get_lang('Not allowed in offline mode')); |
---|
| 480 | return; |
---|
| 481 | } |
---|
| 482 | |
---|
[37] | 483 | var handler_emQuickSearch = function(data) |
---|
| 484 | { |
---|
[2] | 485 | window_DropDownContacts = Element('tipDiv'); |
---|
| 486 | if (window_DropDownContacts.style.visibility != 'hidden'){ |
---|
| 487 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 488 | } |
---|
[341] | 489 | |
---|
[2] | 490 | if ((!data.status) && (data.error == "many results")){ |
---|
| 491 | alert(get_lang('More than %1 results. Please, try to refine your search.',200)); |
---|
| 492 | return false; |
---|
| 493 | } |
---|
[341] | 494 | |
---|
[2] | 495 | if (data.length > 0){ |
---|
[37] | 496 | if ((field != 'null') && (ID != 'null')) |
---|
| 497 | { |
---|
| 498 | connector.loadScript("QuickCatalogSearch"); |
---|
| 499 | QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd); |
---|
| 500 | } |
---|
| 501 | else |
---|
| 502 | { |
---|
| 503 | connector.loadScript("QuickSearchUser"); |
---|
| 504 | QuickSearchUser.showList(data); |
---|
| 505 | } |
---|
[2] | 506 | } |
---|
| 507 | else |
---|
| 508 | alert(get_lang('None result was found.')); |
---|
| 509 | return true; |
---|
| 510 | } |
---|
[341] | 511 | |
---|
[37] | 512 | if ((field != 'null') && (ID != 'null')) |
---|
| 513 | { |
---|
[341] | 514 | Element(field +'_'+ ID).focus(); //It requires for IE. |
---|
[37] | 515 | var i = getPosition(Element(field +'_'+ ID)); //inputBox.selectionStart; |
---|
| 516 | var j = --i; |
---|
[2] | 517 | |
---|
[37] | 518 | // Acha o inicio |
---|
| 519 | while ((j >= 0) && (emailList.charAt(j) != ',')){j--}; |
---|
| 520 | quickSearchKeyBegin = ++j; |
---|
[2] | 521 | |
---|
[37] | 522 | // Acha o final |
---|
| 523 | while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++}; |
---|
| 524 | quickSearchKeyEnd = i; |
---|
[2] | 525 | |
---|
[37] | 526 | // A Chave da Pesquisa |
---|
| 527 | var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd)); |
---|
| 528 | } |
---|
| 529 | else |
---|
| 530 | var search_for = emailList; |
---|
[341] | 531 | |
---|
[2] | 532 | if (search_for.length < 4){ |
---|
| 533 | alert(get_lang('Your search argument must be longer than 4 characters.')); |
---|
| 534 | return false; |
---|
| 535 | } |
---|
[341] | 536 | |
---|
[2] | 537 | cExecute ("$this.ldap_functions.quicksearch&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch); |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | function folderbox(){ |
---|
| 541 | connector.loadScript("TreeS"); |
---|
| 542 | ttree.make_Window(); |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | function filterbox(){ |
---|
| 546 | connector.loadScript("filter"); |
---|
| 547 | connector.loadScript("filters"); |
---|
| 548 | filters.Forms(); |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | function sharebox(){ |
---|
| 552 | var handler_imap_getacl = function(data) |
---|
| 553 | { |
---|
| 554 | var options = ''; |
---|
| 555 | for (var x in data) |
---|
| 556 | { |
---|
| 557 | options += "<option value='"+data[x].uid+"'>"+data[x].cn+"</option>"; |
---|
| 558 | } |
---|
| 559 | connector.loadScript("sharemailbox"); |
---|
| 560 | sharemailbox.makeWindow(options); |
---|
| 561 | } |
---|
| 562 | cExecute ("$this.imap_functions.getacl", handler_imap_getacl); |
---|
| 563 | } |
---|
| 564 | |
---|
| 565 | function preferences_mail(){ |
---|
[1186] | 566 | location.href="../preferences/preferences.php?appname=expressoMail1_2"; |
---|
[2] | 567 | } |
---|
| 568 | |
---|
| 569 | function search_emails(value){ |
---|
| 570 | connector.loadScript("search"); |
---|
| 571 | EsearchE.showForms(value); |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | function source_msg(id_msg,folder){ |
---|
| 575 | var num_msg = id_msg.substr(0,(id_msg.length - 2)); |
---|
| 576 | var handler_source = function(data){ |
---|
| 577 | download_attachments(null, null, data, null,null,'fonte_da_mensagem.txt'); |
---|
| 578 | } |
---|
| 579 | cExecute("$this.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg); |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | function url_encode(str){ |
---|
[341] | 583 | var hex_chars = "0123456789ABCDEF"; |
---|
| 584 | var noEncode = /^([a-zA-Z0-9\_\-\.])$/; |
---|
| 585 | var n, strCode, hex1, hex2, strEncode = ""; |
---|
[2] | 586 | |
---|
[341] | 587 | for(n = 0; n < str.length; n++) { |
---|
| 588 | if (noEncode.test(str.charAt(n))) { |
---|
| 589 | strEncode += str.charAt(n); |
---|
| 590 | } else { |
---|
| 591 | strCode = str.charCodeAt(n); |
---|
| 592 | hex1 = hex_chars.charAt(Math.floor(strCode / 16)); |
---|
| 593 | hex2 = hex_chars.charAt(strCode % 16); |
---|
| 594 | strEncode += "%" + (hex1 + hex2); |
---|
| 595 | } |
---|
| 596 | } |
---|
| 597 | return strEncode; |
---|
| 598 | } |
---|
[2] | 599 | |
---|
[341] | 600 | function url_decode(str) { |
---|
[2] | 601 | |
---|
[341] | 602 | var n, strCode, strDecode = ""; |
---|
| 603 | for (n = 0; n < str.length; n++) { |
---|
| 604 | if (str.charAt(n) == "%") { |
---|
| 605 | strCode = str.charAt(n + 1) + str.charAt(n + 2); |
---|
| 606 | strDecode += String.fromCharCode(parseInt(strCode, 16)); |
---|
| 607 | n += 2; |
---|
| 608 | } else { |
---|
| 609 | strDecode += str.charAt(n); |
---|
| 610 | } |
---|
| 611 | } |
---|
| 612 | return strDecode; |
---|
| 613 | } |
---|
[2] | 614 | |
---|
[569] | 615 | function Element (el) { |
---|
| 616 | return document.getElementById(el); |
---|
[2] | 617 | } |
---|
| 618 | |
---|
| 619 | function getPosition(obj) |
---|
| 620 | { |
---|
| 621 | if(typeof obj.selectionStart != "undefined") |
---|
| 622 | { |
---|
| 623 | return obj.selectionStart; |
---|
| 624 | } |
---|
| 625 | else if(document.selection && document.selection.createRange) |
---|
| 626 | { |
---|
| 627 | var M = document.selection.createRange(); |
---|
| 628 | try |
---|
| 629 | { |
---|
| 630 | var Lp = M.duplicate(); |
---|
| 631 | Lp.moveToElementText(obj); |
---|
| 632 | } |
---|
| 633 | catch(e) |
---|
| 634 | { |
---|
| 635 | var Lp=obj.createTextRange(); |
---|
| 636 | } |
---|
[341] | 637 | |
---|
[2] | 638 | Lp.setEndPoint("EndToStart",M); |
---|
| 639 | var rb=Lp.text.length; |
---|
[341] | 640 | |
---|
[2] | 641 | if(rb > obj.value.length) |
---|
| 642 | { |
---|
| 643 | return -1; |
---|
| 644 | } |
---|
| 645 | return rb; |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | function trim(inputString) { |
---|
[341] | 650 | if (typeof inputString != "string") |
---|
[2] | 651 | return inputString; |
---|
[341] | 652 | |
---|
[2] | 653 | var retValue = inputString; |
---|
| 654 | var ch = retValue.substring(0, 1); |
---|
[341] | 655 | while (ch == " ") { |
---|
[2] | 656 | retValue = retValue.substring(1, retValue.length); |
---|
| 657 | ch = retValue.substring(0, 1); |
---|
| 658 | } |
---|
| 659 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
[341] | 660 | while (ch == " ") { |
---|
[2] | 661 | retValue = retValue.substring(0, retValue.length-1); |
---|
| 662 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 663 | } |
---|
[341] | 664 | while (retValue.indexOf(" ") != -1) { |
---|
| 665 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
[2] | 666 | } |
---|
[341] | 667 | return retValue; |
---|
[2] | 668 | } |
---|
| 669 | |
---|
| 670 | function increment_folder_unseen(){ |
---|
| 671 | var folder_id = get_current_folder(); |
---|
[812] | 672 | |
---|
[2] | 673 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
[406] | 674 | var abas_unseen = Element('new_m').innerHTML; |
---|
| 675 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 676 | |
---|
[2] | 677 | if (folder_unseen) |
---|
| 678 | { |
---|
| 679 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + 1); |
---|
| 680 | } |
---|
| 681 | else |
---|
| 682 | { |
---|
[823] | 683 | 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>'}); |
---|
[2] | 684 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 685 | } |
---|
[406] | 686 | if (abas_unseen) |
---|
[812] | 687 | { |
---|
| 688 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
| 689 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
[406] | 690 | } |
---|
[812] | 691 | else{ |
---|
| 692 | abas_unseen = Element('new_m').innerHTML; |
---|
| 693 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 694 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
| 695 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 696 | } |
---|
[1000] | 697 | if ( current_folder.indexOf( 'INBOX' ) !== 0 && current_folder.indexOf( 'local_' ) !== 0 ) |
---|
[823] | 698 | { |
---|
| 699 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
| 700 | if ( display_unseen_in_shared_folders ) |
---|
| 701 | 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")}); |
---|
| 702 | else |
---|
| 703 | 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")}); |
---|
| 704 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
| 705 | } |
---|
| 706 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
[1121] | 707 | if(!expresso_offline) |
---|
| 708 | var node_to_refresh = 'root'; |
---|
| 709 | else |
---|
| 710 | var node_to_refresh = 'local_root'; |
---|
| 711 | tree_folders.getNodeById( node_to_refresh )._refresh(); |
---|
[2] | 712 | } |
---|
| 713 | function decrement_folder_unseen(){ |
---|
| 714 | var folder_id = get_current_folder(); |
---|
[812] | 715 | |
---|
[2] | 716 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
[406] | 717 | var abas_unseen = Element('new_m').innerHTML; |
---|
| 718 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 719 | |
---|
| 720 | if(!folder_unseen || !abas_unseen) |
---|
[2] | 721 | return; |
---|
| 722 | |
---|
| 723 | if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > 1)) |
---|
| 724 | { |
---|
| 725 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - 1); |
---|
| 726 | } |
---|
| 727 | else if (parseInt(folder_unseen.innerHTML) <= 1) |
---|
| 728 | { |
---|
| 729 | var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<'); |
---|
| 730 | var folder_name = tmp_folder_name[0]; |
---|
| 731 | tree_folders.getNodeById(folder_id).alter({caption: folder_name}); |
---|
| 732 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 733 | } |
---|
[406] | 734 | if ((abas_unseen) && (parseInt(abas_unseen) > 1)) |
---|
| 735 | { |
---|
| 736 | abas_unseen = (parseInt(abas_unseen) - 1); |
---|
| 737 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
[812] | 738 | } |
---|
[406] | 739 | else if (parseInt(abas_unseen) <= 1) |
---|
| 740 | { |
---|
[470] | 741 | Element('new_m').innerHTML = '0'; |
---|
[406] | 742 | } |
---|
[823] | 743 | if ( current_folder.indexOf( 'INBOX' ) !== 0 ) |
---|
| 744 | { |
---|
| 745 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
| 746 | if ( display_unseen_in_shared_folders ) |
---|
| 747 | { |
---|
| 748 | var unseen_in_shared_folders = parseInt( display_unseen_in_shared_folders.innerHTML ); |
---|
| 749 | unseen_in_shared_folders--; |
---|
| 750 | if ( unseen_in_shared_folders > 0 ) |
---|
| 751 | 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")}); |
---|
| 752 | else |
---|
| 753 | tree_folders.getNodeById( 'user' ).alter({caption:get_lang("Shared folders")}); |
---|
| 754 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
| 755 | } |
---|
| 756 | } |
---|
| 757 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
| 758 | if ( display_unseen_in_mailbox ) |
---|
| 759 | { |
---|
| 760 | var unseen_in_mailbox = parseInt( display_unseen_in_mailbox.innerHTML ); |
---|
| 761 | unseen_in_mailbox--; |
---|
| 762 | //if ( unseen_in_mailbox > 0 ) |
---|
| 763 | // 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")}); |
---|
| 764 | //else |
---|
[1121] | 765 | if(!expresso_offline) |
---|
| 766 | var node_to_refresh = 'root'; |
---|
| 767 | else |
---|
| 768 | var node_to_refresh = 'local_root'; |
---|
| 769 | tree_folders.getNodeById( node_to_refresh ).alter({caption:get_lang("My Folders")}); |
---|
| 770 | tree_folders.getNodeById( node_to_refresh )._refresh(); |
---|
[823] | 771 | } |
---|
[2] | 772 | } |
---|
| 773 | |
---|
| 774 | function LTrim(value){ |
---|
| 775 | var w_space = String.fromCharCode(32); |
---|
| 776 | var strTemp = ""; |
---|
| 777 | var iTemp = 0; |
---|
[812] | 778 | |
---|
[814] | 779 | var v_length = value ? value.length : 0; |
---|
[2] | 780 | if(v_length < 1) |
---|
| 781 | return ""; |
---|
| 782 | |
---|
| 783 | while(iTemp < v_length){ |
---|
| 784 | if(value && value.charAt(iTemp) != w_space){ |
---|
| 785 | strTemp = value.substring(iTemp,v_length); |
---|
| 786 | break; |
---|
| 787 | } |
---|
| 788 | iTemp++; |
---|
[812] | 789 | } |
---|
[2] | 790 | return strTemp; |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | //changes MENU background color. |
---|
| 794 | function set_menu_bg(menu) |
---|
| 795 | { |
---|
| 796 | menu.style.backgroundColor = 'white'; |
---|
| 797 | menu.style.border = '1px solid black'; |
---|
[814] | 798 | menu.style.padding = '0px 0px'; |
---|
[2] | 799 | } |
---|
| 800 | //changes MENU background color. |
---|
| 801 | function unset_menu_bg(menu) |
---|
| 802 | { |
---|
| 803 | menu.style.backgroundColor = ''; |
---|
[814] | 804 | menu.style.border = '0px'; |
---|
| 805 | menu.style.padding = '1px 0px'; |
---|
[2] | 806 | } |
---|
| 807 | |
---|
[46] | 808 | function array_search(needle, haystack) { |
---|
| 809 | var n = haystack.length; |
---|
| 810 | for (var i=0; i<n; i++) { |
---|
| 811 | if (haystack[i]==needle) { |
---|
| 812 | return true; |
---|
| 813 | } |
---|
| 814 | } |
---|
| 815 | return false; |
---|
[96] | 816 | } |
---|
| 817 | |
---|
[812] | 818 | function lang_folder(fn) { |
---|
[689] | 819 | if (fn.toUpperCase() == "INBOX") return get_lang("Inbox"); |
---|
[365] | 820 | if (special_folders[fn] && typeof(special_folders[fn]) == 'string') { |
---|
[96] | 821 | return get_lang(special_folders[fn]); |
---|
[673] | 822 | } |
---|
[96] | 823 | return fn; |
---|
[812] | 824 | } |
---|
[163] | 825 | |
---|
| 826 | function add_className(obj, className){ |
---|
[651] | 827 | if (obj && !exist_className(obj, className)) |
---|
[163] | 828 | obj.className = obj.className + ' ' + className; |
---|
| 829 | } |
---|
| 830 | |
---|
| 831 | function remove_className(obj, className){ |
---|
| 832 | var re = new RegExp("\\s*"+className); |
---|
[320] | 833 | if (obj) |
---|
[976] | 834 | obj.className = obj.className.replace(re, ' '); |
---|
[163] | 835 | } |
---|
| 836 | |
---|
| 837 | function exist_className(obj, className){ |
---|
[651] | 838 | return ( obj && obj.className.indexOf(className) != -1 ) |
---|
[163] | 839 | } |
---|
| 840 | |
---|
| 841 | function select_all_messages(select) |
---|
| 842 | { |
---|
| 843 | var main = Element("tbody_box"); |
---|
| 844 | var main_list = main.childNodes; |
---|
| 845 | var len_main_list = main_list.length; |
---|
[341] | 846 | |
---|
[163] | 847 | if (select) |
---|
| 848 | { |
---|
| 849 | for (i=0; i<len_main_list; i++) |
---|
| 850 | { |
---|
| 851 | Element("check_box_message_"+main_list[i].id).checked = true; |
---|
| 852 | add_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 853 | } |
---|
| 854 | } |
---|
| 855 | else |
---|
| 856 | { |
---|
| 857 | for (i=0; i<len_main_list; i++) |
---|
| 858 | { |
---|
| 859 | Element("check_box_message_"+main_list[i].id).checked = false; |
---|
| 860 | remove_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 861 | } |
---|
| 862 | } |
---|
| 863 | } |
---|