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