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