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