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