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