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