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