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