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