[2] | 1 | // BEGIN: FUNCTION RESIZE WINDOW |
---|
| 2 | var _showBar = showBar; |
---|
| 3 | var _hideBar = hideBar; |
---|
| 4 | |
---|
| 5 | function __showBar(){ |
---|
| 6 | _showBar(); |
---|
| 7 | resizeWindow(); |
---|
| 8 | } |
---|
| 9 | |
---|
| 10 | function __hideBar(){ |
---|
| 11 | _hideBar(); |
---|
| 12 | resizeWindow(); |
---|
| 13 | } |
---|
| 14 | showBar = __showBar; |
---|
| 15 | hideBar = __hideBar; |
---|
| 16 | |
---|
| 17 | window.onresize = resizeWindow; |
---|
| 18 | |
---|
[320] | 19 | function config_events(pObj, pEvent, pHandler) |
---|
| 20 | { |
---|
| 21 | if( typeof pObj == 'object') |
---|
| 22 | { |
---|
| 23 | if( pEvent.substring(0, 2) == 'on') |
---|
| 24 | pEvent = pEvent.substring(2, pEvent.length); |
---|
| 25 | |
---|
| 26 | if ( pObj.addEventListener ) |
---|
| 27 | pObj.addEventListener(pEvent, pHandler, false); |
---|
| 28 | else if( pObj.attachEvent ) |
---|
| 29 | pObj.attachEvent('on' + pEvent, pHandler ); |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
[2] | 33 | function resizeWindow(){ |
---|
| 34 | |
---|
| 35 | var bar = Element("toolbar"); |
---|
| 36 | var offset = 0; |
---|
[341] | 37 | if(bar.style.visibility != 'hidden') |
---|
| 38 | offset = (bar.offsetHeight ? bar.offsetHeight : bar.clientHeight); |
---|
[2] | 39 | |
---|
| 40 | var screenHeight = document.body.clientHeight ? document.body.clientHeight : document.body.offsetHeight; |
---|
| 41 | var defaultHeight = screenHeight - offset; |
---|
[66] | 42 | |
---|
[65] | 43 | if(BordersArray) { |
---|
| 44 | for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) { |
---|
| 45 | var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence); |
---|
| 46 | if(div_scroll) |
---|
| 47 | div_scroll.style.height = defaultHeight - 122; |
---|
| 48 | var div = Element("content_id_"+BordersArray[i].sequence); |
---|
| 49 | if(div) |
---|
| 50 | div.style.height = defaultHeight - 73; |
---|
| 51 | } |
---|
[2] | 52 | } |
---|
[51] | 53 | Element('content_folders').style.height = defaultHeight - (is_ie ? 165 : 150); |
---|
[320] | 54 | if(Element("divScrollMain_"+numBox)) |
---|
| 55 | Element("divScrollMain_"+numBox).style.height = defaultHeight - (is_ie ? 111 : 110); |
---|
[2] | 56 | } |
---|
| 57 | // END: FUNCTION RESIZE WINDOW |
---|
| 58 | |
---|
[320] | 59 | var _beforeunload_ = window.onbeforeunload; |
---|
| 60 | |
---|
| 61 | window.onbeforeunload = function() |
---|
[271] | 62 | { |
---|
[320] | 63 | return unloadMess(); |
---|
| 64 | } |
---|
[271] | 65 | |
---|
[2] | 66 | function unloadMess(){ |
---|
[53] | 67 | var mess = get_lang("Your message has not been sent and will be discarted."); |
---|
[2] | 68 | for(var i = 0; i < BordersArray.length;i++) { |
---|
| 69 | var body = Element('body_'+BordersArray[i].sequence); |
---|
| 70 | if (body && body.contentWindow && body.contentWindow.document.designMode.toLowerCase() == 'on') { |
---|
| 71 | return mess; |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
[320] | 75 | |
---|
[2] | 76 | // Translate words and phrases using user language from eGroupware. |
---|
| 77 | function get_lang(_key,_arg1,_arg2,_arg3,_arg4) { |
---|
| 78 | |
---|
[341] | 79 | if(!array_lang[0]){ |
---|
[2] | 80 | return _key+"*"; |
---|
| 81 | } |
---|
[341] | 82 | _value = ""; |
---|
[2] | 83 | for(i = 0; i < array_lang[0].length;i++){ |
---|
| 84 | if(array_lang[0][i] == _key.toLowerCase()) { |
---|
[341] | 85 | _value = array_lang[1][i]; |
---|
[2] | 86 | break; |
---|
| 87 | } |
---|
[341] | 88 | } |
---|
| 89 | |
---|
[2] | 90 | if(!_value) |
---|
| 91 | return _key+"*"; |
---|
[341] | 92 | |
---|
[2] | 93 | if(_arg1 || _arg2 ||_arg3 || _arg4) { |
---|
| 94 | for(j = 1; j <= 4; j++){ |
---|
| 95 | if(eval("_arg"+j)) { |
---|
[341] | 96 | var regExp = new RegExp("%"+j+""); |
---|
[2] | 97 | _value = _value.replace(regExp,eval("_arg"+j)); |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | } |
---|
[341] | 101 | |
---|
[2] | 102 | return _value; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | // Make decimal round, using in size message |
---|
| 106 | function round(value, decimal){ |
---|
| 107 | var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal ); |
---|
| 108 | return( return_value ); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | // Change the class of message. |
---|
[341] | 112 | // In refresh, the flags UnRead and UnSeen don't exist anymore. |
---|
[163] | 113 | function set_msg_as_read(msg_number, selected){ |
---|
[2] | 114 | tr_message = Element(msg_number); |
---|
[163] | 115 | if (exist_className(tr_message, 'tr_msg_unread')) |
---|
| 116 | decrement_folder_unseen(); |
---|
| 117 | remove_className(tr_message, 'tr_msg_unread'); |
---|
| 118 | remove_className(tr_message, 'selected_msg'); |
---|
| 119 | add_className(tr_message, 'tr_msg_read'); |
---|
| 120 | return true; |
---|
[2] | 121 | } |
---|
| 122 | |
---|
[163] | 123 | function set_msg_as_unread(msg_number){ |
---|
[2] | 124 | tr_message = Element(msg_number); |
---|
[163] | 125 | if (exist_className(tr_message, 'tr_msg_read')) |
---|
| 126 | increment_folder_unseen(); |
---|
| 127 | remove_className(tr_message, 'tr_msg_read'); |
---|
| 128 | remove_className(tr_message, 'selected_msg'); |
---|
| 129 | add_className(tr_message, 'tr_msg_unread'); |
---|
[2] | 130 | } |
---|
| 131 | |
---|
[163] | 132 | function set_msg_as_flagged(msg_number){ |
---|
| 133 | var msg = Element(msg_number); |
---|
| 134 | remove_className(msg, 'selected_msg'); |
---|
| 135 | add_className(msg, 'flagged_msg'); |
---|
| 136 | Element("td_message_important_"+msg_number).innerHTML = '<img src=templates/default/images/important.gif title=Importante!>'; |
---|
[2] | 137 | } |
---|
| 138 | |
---|
[163] | 139 | function set_msg_as_unflagged(msg_number){ |
---|
| 140 | var msg = Element(msg_number); |
---|
| 141 | remove_className(msg, 'selected_msg'); |
---|
| 142 | remove_className(msg, 'flagged_msg'); |
---|
| 143 | Element("td_message_important_"+msg_number).innerHTML = ''; |
---|
[2] | 144 | } |
---|
| 145 | |
---|
| 146 | function get_current_folder(){ |
---|
| 147 | return current_folder; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | // Kill current box (folder or page). |
---|
| 151 | function kill_current_box(){ |
---|
| 152 | var box = document.getElementById("table_box"); |
---|
| 153 | if (box != null) |
---|
| 154 | box.parentNode.removeChild(box); |
---|
[320] | 155 | else |
---|
| 156 | return false; |
---|
[2] | 157 | } |
---|
| 158 | |
---|
| 159 | // Kill current paging. |
---|
| 160 | function kill_current_paging(){ |
---|
| 161 | var paging = Element("span_paging"); |
---|
| 162 | if (paging != null) |
---|
| 163 | paging.parentNode.removeChild(paging); |
---|
| 164 | } |
---|
| 165 | |
---|
[412] | 166 | function show_hide_span_paging(ID){ |
---|
| 167 | if ((ID != "0") && Element("span_paging")) |
---|
| 168 | Element("span_paging").style.display = 'none'; |
---|
| 169 | else |
---|
| 170 | if (Element("span_paging")) |
---|
| 171 | Element("span_paging").style.display = ''; |
---|
| 172 | } |
---|
| 173 | |
---|
[2] | 174 | //Get the current number of messages in a page. |
---|
| 175 | function get_messages_number_in_page(){ |
---|
| 176 | //Get element tBody. |
---|
| 177 | main = document.getElementById("tbody_box"); |
---|
[341] | 178 | |
---|
[2] | 179 | // Get all TR (messages) in tBody. |
---|
| 180 | main_list = main.childNodes; |
---|
[341] | 181 | |
---|
[2] | 182 | return main_list.length; |
---|
| 183 | } |
---|
| 184 | |
---|
[271] | 185 | function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){ |
---|
[2] | 186 | div_attachment = document.getElementById("id_div_attachment"); |
---|
| 187 | var params = ''; |
---|
[341] | 188 | |
---|
[2] | 189 | if (div_attachment == null){ |
---|
| 190 | var div_attachment = document.createElement("DIV"); |
---|
| 191 | div_attachment.id="id_div_attachment"; |
---|
| 192 | document.body.appendChild(div_attachment); |
---|
| 193 | } |
---|
| 194 | if(new_file_name) |
---|
| 195 | params = "&newfilename="+new_file_name; |
---|
| 196 | if(encoding) |
---|
| 197 | params += "&encoding="+encoding; |
---|
[271] | 198 | |
---|
[5] | 199 | 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] | 200 | } |
---|
[271] | 201 | |
---|
[2] | 202 | function download_all_attachments(msg_folder, msg_number){ |
---|
[341] | 203 | var handler_source = function(data){ |
---|
[2] | 204 | download_attachments(null, null, data, null,null,'anexos.zip'); |
---|
| 205 | } |
---|
| 206 | cExecute("$this.exporteml.download_all_attachments",handler_source,"folder="+msg_folder+"&num_msg="+msg_number); |
---|
| 207 | } |
---|
| 208 | // Add Input File Dynamically. |
---|
| 209 | function addFile(id_border){ |
---|
| 210 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
[320] | 211 | if (! divFiles) |
---|
| 212 | return false; |
---|
[341] | 213 | |
---|
[271] | 214 | if (divFiles.lastChild) |
---|
| 215 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 216 | |
---|
| 217 | if (! countDivFiles) |
---|
| 218 | var countDivFiles = 1; |
---|
[341] | 219 | |
---|
[2] | 220 | divFile = document.createElement('DIV'); |
---|
[341] | 221 | |
---|
[271] | 222 | var inputFile = document.createElement("INPUT"); |
---|
[341] | 223 | |
---|
[2] | 224 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 225 | tmp_id_border.value = id_border; |
---|
[341] | 226 | |
---|
[2] | 227 | inputFile.setAttributeNode(tmp_id_border); |
---|
[271] | 228 | inputFile.id = "inputFile_"+id_border+"_"+countDivFiles; |
---|
[2] | 229 | inputFile.onchange = function () {validateFileExtension(this.value, this.id.replace("input","div"), this.getAttribute('id_border'));}; |
---|
| 230 | inputFile.type = 'file'; |
---|
| 231 | inputFile.size = 50; |
---|
| 232 | inputFile.maxLength = 255; |
---|
[271] | 233 | inputFile.name='file_'+countDivFiles; |
---|
[341] | 234 | |
---|
[2] | 235 | divFile.appendChild(inputFile); |
---|
[341] | 236 | |
---|
[271] | 237 | var linkFile = document.createElement("A"); |
---|
| 238 | linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; |
---|
[2] | 239 | linkFile.href='javascript:void(0)'; |
---|
[320] | 240 | linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; |
---|
[341] | 241 | linkFile.innerHTML=get_lang("Remove"); |
---|
[2] | 242 | //divFile.innerHTML += " "; |
---|
| 243 | divFile.appendChild(linkFile); |
---|
[341] | 244 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
[2] | 245 | divFiles.appendChild(divFile); |
---|
| 246 | } |
---|
| 247 | // Remove Input File Dynamically. |
---|
| 248 | function removeFile(id){ |
---|
[271] | 249 | var border_id = id.substr(8,1); |
---|
[2] | 250 | var el = Element(id); |
---|
| 251 | el.parentNode.removeChild(el); |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | function validateFileExtension(fileName, id, id_border){ |
---|
[320] | 255 | |
---|
[271] | 256 | var error_flag = false; |
---|
[320] | 257 | |
---|
| 258 | if ( fileName.indexOf('/') != -1 ) |
---|
| 259 | { |
---|
| 260 | if (fileName[0] != '/'){ // file name is windows format? |
---|
| 261 | var file = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length); |
---|
| 262 | if ((fileName.indexOf(':\\') != 1) && (fileName.indexOf('\\\\') != 0)) // Is stored in partition or a network file? |
---|
| 263 | error_flag = true; |
---|
| 264 | } |
---|
| 265 | else // is Unix |
---|
| 266 | var file = fileName.substr(fileName.lastIndexOf('/') + 1, fileName.length); |
---|
[271] | 267 | } |
---|
[320] | 268 | else // is Firefox 3 |
---|
| 269 | var file = fileName; |
---|
[271] | 270 | |
---|
| 271 | var fileExtension = file.split("."); |
---|
[2] | 272 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 273 | for(var i=0; i<denyFileExtensions.length; i++) |
---|
| 274 | { |
---|
| 275 | if(denyFileExtensions[i] == fileExtension) |
---|
| 276 | { |
---|
[271] | 277 | error_flag = true; |
---|
| 278 | break; |
---|
[2] | 279 | } |
---|
[271] | 280 | |
---|
[2] | 281 | } |
---|
[271] | 282 | |
---|
[320] | 283 | if ( error_flag == true ) |
---|
| 284 | { |
---|
[271] | 285 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 286 | removeFile(id); |
---|
| 287 | addFile(id_border); |
---|
| 288 | return false; |
---|
| 289 | } |
---|
| 290 | return true; |
---|
[2] | 291 | } |
---|
| 292 | |
---|
| 293 | var setTimeout_write_msg = 0; |
---|
[197] | 294 | var old_msg = false; |
---|
| 295 | // Funcao usada para escrever mensagem |
---|
| 296 | // notimeout = True : mensagem nao apaga |
---|
[341] | 297 | function write_msg(msg, notimeout){ |
---|
| 298 | |
---|
[2] | 299 | if (setTimeout_write_msg) |
---|
| 300 | clearTimeout(setTimeout_write_msg); |
---|
[341] | 301 | |
---|
[80] | 302 | var msg_div = Element('em_div_write_msg'); |
---|
[2] | 303 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 304 | |
---|
[80] | 305 | if(!msg_div) { |
---|
| 306 | msg_div = document.createElement('DIV'); |
---|
| 307 | msg_div.id = 'em_div_write_msg'; |
---|
| 308 | msg_div.style.height = is_ie ? '17px' : '15px'; |
---|
| 309 | msg_div.style.background = '#f7f8fa'; |
---|
| 310 | msg_div.style.display = 'none'; |
---|
| 311 | old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar); |
---|
[341] | 312 | } |
---|
[80] | 313 | msg_div.innerHTML = '<table bgcolor="#f7f8fa" 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>'; |
---|
| 314 | old_divStatusBar.style.display = 'none'; |
---|
[341] | 315 | msg_div.style.display = ''; |
---|
[2] | 316 | // Nao ponha var na frente!! jakjr |
---|
| 317 | handle_write_msg = function(){ |
---|
| 318 | try{ |
---|
[197] | 319 | if(!old_msg) |
---|
| 320 | clean_msg(); |
---|
| 321 | else |
---|
[341] | 322 | write_msg(old_msg, true); |
---|
[2] | 323 | } |
---|
| 324 | catch(e){} |
---|
| 325 | } |
---|
[197] | 326 | if(notimeout) |
---|
| 327 | old_msg = msg; |
---|
| 328 | else |
---|
| 329 | setTimeout_write_msg = setTimeout("handle_write_msg();", 5000); |
---|
[2] | 330 | } |
---|
[197] | 331 | // Funcao usada para apagar mensagem sem timeout |
---|
| 332 | function clean_msg(){ |
---|
| 333 | old_msg = false; |
---|
| 334 | var msg_div = Element('em_div_write_msg'); |
---|
| 335 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 336 | if(msg_div) |
---|
| 337 | msg_div.style.display = 'none'; |
---|
[341] | 338 | old_divStatusBar.style.display = ''; |
---|
[197] | 339 | } |
---|
[2] | 340 | |
---|
| 341 | function make_body_reply(body, to, date_day, date_hour){ |
---|
| 342 | to = to.replace("<","<"); |
---|
| 343 | to = to.replace(">",">"); |
---|
| 344 | block_quoted_body ="<br><br>"; |
---|
[197] | 345 | block_quoted_body += get_lang('At %1, %2 hours, %3 wrote:', date_day, date_hour, to); |
---|
[2] | 346 | block_quoted_body += "<blockquote style=\"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;\">"; |
---|
| 347 | block_quoted_body += body; |
---|
| 348 | block_quoted_body += "</blockquote>"; |
---|
| 349 | return block_quoted_body; |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | function make_forward_body(body, from, date, subject, to, cc){ |
---|
| 353 | from = from.replace(/</g,"<"); |
---|
| 354 | from = from.replace(/>/g,">"); |
---|
| 355 | to = to.replace(/</g,"<"); |
---|
| 356 | to = to.replace(/>/g,">"); |
---|
| 357 | var forward_body = '<BR><BR>---------- ' + get_lang('Forwarded message') + ' ----------<BR>'; |
---|
| 358 | forward_body += get_lang('From') + ': ' + from + '<BR>'; |
---|
| 359 | forward_body += get_lang('Date') + ': ' + date + '<BR>'; |
---|
| 360 | forward_body += get_lang('Subject') + ': ' + subject + '<BR>'; |
---|
| 361 | forward_body += get_lang('To') + ': ' + to+ '<BR>'; |
---|
| 362 | if(cc != undefined){ |
---|
| 363 | cc = cc.replace(/</g,"<"); |
---|
| 364 | cc = cc.replace(/>/g,">"); |
---|
| 365 | forward_body += get_lang('CC') + ': ' + cc+ '<BR><BR>'; |
---|
| 366 | } |
---|
| 367 | forward_body += body; |
---|
| 368 | return forward_body; |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | function emMessageSearch(e,value){ |
---|
| 372 | var e = is_ie ? window.event : e; |
---|
| 373 | if(e.keyCode == 13) { |
---|
| 374 | search_emails(value); |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | function emQuickSearch(emailList, field, ID){ |
---|
| 379 | var quickSearchKeyBegin; |
---|
| 380 | var quickSearchKeyEnd; |
---|
[341] | 381 | |
---|
[37] | 382 | var handler_emQuickSearch = function(data) |
---|
| 383 | { |
---|
[2] | 384 | window_DropDownContacts = Element('tipDiv'); |
---|
| 385 | if (window_DropDownContacts.style.visibility != 'hidden'){ |
---|
| 386 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 387 | } |
---|
[341] | 388 | |
---|
[2] | 389 | if ((!data.status) && (data.error == "many results")){ |
---|
| 390 | alert(get_lang('More than %1 results. Please, try to refine your search.',200)); |
---|
| 391 | return false; |
---|
| 392 | } |
---|
[341] | 393 | |
---|
[2] | 394 | if (data.length > 0){ |
---|
[37] | 395 | if ((field != 'null') && (ID != 'null')) |
---|
| 396 | { |
---|
| 397 | connector.loadScript("QuickCatalogSearch"); |
---|
| 398 | QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd); |
---|
| 399 | } |
---|
| 400 | else |
---|
| 401 | { |
---|
| 402 | connector.loadScript("QuickSearchUser"); |
---|
| 403 | QuickSearchUser.showList(data); |
---|
| 404 | } |
---|
[2] | 405 | } |
---|
| 406 | else |
---|
| 407 | alert(get_lang('None result was found.')); |
---|
| 408 | return true; |
---|
| 409 | } |
---|
[341] | 410 | |
---|
[37] | 411 | if ((field != 'null') && (ID != 'null')) |
---|
| 412 | { |
---|
[341] | 413 | Element(field +'_'+ ID).focus(); //It requires for IE. |
---|
[37] | 414 | var i = getPosition(Element(field +'_'+ ID)); //inputBox.selectionStart; |
---|
| 415 | var j = --i; |
---|
[2] | 416 | |
---|
[37] | 417 | // Acha o inicio |
---|
| 418 | while ((j >= 0) && (emailList.charAt(j) != ',')){j--}; |
---|
| 419 | quickSearchKeyBegin = ++j; |
---|
[2] | 420 | |
---|
[37] | 421 | // Acha o final |
---|
| 422 | while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++}; |
---|
| 423 | quickSearchKeyEnd = i; |
---|
[2] | 424 | |
---|
[37] | 425 | // A Chave da Pesquisa |
---|
| 426 | var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd)); |
---|
| 427 | } |
---|
| 428 | else |
---|
| 429 | var search_for = emailList; |
---|
[341] | 430 | |
---|
[2] | 431 | if (search_for.length < 4){ |
---|
| 432 | alert(get_lang('Your search argument must be longer than 4 characters.')); |
---|
| 433 | return false; |
---|
| 434 | } |
---|
[341] | 435 | |
---|
[2] | 436 | cExecute ("$this.ldap_functions.quicksearch&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | function folderbox(){ |
---|
| 440 | connector.loadScript("TreeS"); |
---|
| 441 | ttree.make_Window(); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | function filterbox(){ |
---|
| 445 | connector.loadScript("filter"); |
---|
| 446 | connector.loadScript("filters"); |
---|
| 447 | filters.Forms(); |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | function sharebox(){ |
---|
| 451 | var handler_imap_getacl = function(data) |
---|
| 452 | { |
---|
| 453 | var options = ''; |
---|
| 454 | for (var x in data) |
---|
| 455 | { |
---|
| 456 | options += "<option value='"+data[x].uid+"'>"+data[x].cn+"</option>"; |
---|
| 457 | } |
---|
| 458 | connector.loadScript("sharemailbox"); |
---|
| 459 | sharemailbox.makeWindow(options); |
---|
| 460 | } |
---|
| 461 | cExecute ("$this.imap_functions.getacl", handler_imap_getacl); |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | function preferences_mail(){ |
---|
[389] | 465 | if(preferences.type_signature && preferences.type_signature == 'html') { |
---|
| 466 | location.href="preferences.php"; |
---|
| 467 | } |
---|
| 468 | else { |
---|
| 469 | connector.loadScript("preferences"); |
---|
| 470 | prefe.showList(); |
---|
| 471 | } |
---|
[2] | 472 | } |
---|
| 473 | |
---|
| 474 | function search_emails(value){ |
---|
| 475 | connector.loadScript("search"); |
---|
| 476 | EsearchE.showForms(value); |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | function source_msg(id_msg,folder){ |
---|
| 480 | var num_msg = id_msg.substr(0,(id_msg.length - 2)); |
---|
| 481 | var handler_source = function(data){ |
---|
| 482 | download_attachments(null, null, data, null,null,'fonte_da_mensagem.txt'); |
---|
| 483 | } |
---|
| 484 | cExecute("$this.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg); |
---|
| 485 | } |
---|
| 486 | |
---|
| 487 | function url_encode(str){ |
---|
[341] | 488 | var hex_chars = "0123456789ABCDEF"; |
---|
| 489 | var noEncode = /^([a-zA-Z0-9\_\-\.])$/; |
---|
| 490 | var n, strCode, hex1, hex2, strEncode = ""; |
---|
[2] | 491 | |
---|
[341] | 492 | for(n = 0; n < str.length; n++) { |
---|
| 493 | if (noEncode.test(str.charAt(n))) { |
---|
| 494 | strEncode += str.charAt(n); |
---|
| 495 | } else { |
---|
| 496 | strCode = str.charCodeAt(n); |
---|
| 497 | hex1 = hex_chars.charAt(Math.floor(strCode / 16)); |
---|
| 498 | hex2 = hex_chars.charAt(strCode % 16); |
---|
| 499 | strEncode += "%" + (hex1 + hex2); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | return strEncode; |
---|
| 503 | } |
---|
[2] | 504 | |
---|
[341] | 505 | function url_decode(str) { |
---|
[2] | 506 | |
---|
[341] | 507 | var n, strCode, strDecode = ""; |
---|
| 508 | for (n = 0; n < str.length; n++) { |
---|
| 509 | if (str.charAt(n) == "%") { |
---|
| 510 | strCode = str.charAt(n + 1) + str.charAt(n + 2); |
---|
| 511 | strDecode += String.fromCharCode(parseInt(strCode, 16)); |
---|
| 512 | n += 2; |
---|
| 513 | } else { |
---|
| 514 | strDecode += str.charAt(n); |
---|
| 515 | } |
---|
| 516 | } |
---|
| 517 | return strDecode; |
---|
| 518 | } |
---|
[2] | 519 | |
---|
| 520 | |
---|
| 521 | function Element(element){ |
---|
| 522 | return document.getElementById(element); |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | function getPosition(obj) |
---|
| 526 | { |
---|
| 527 | if(typeof obj.selectionStart != "undefined") |
---|
| 528 | { |
---|
| 529 | return obj.selectionStart; |
---|
| 530 | } |
---|
| 531 | else if(document.selection && document.selection.createRange) |
---|
| 532 | { |
---|
| 533 | var M = document.selection.createRange(); |
---|
| 534 | try |
---|
| 535 | { |
---|
| 536 | var Lp = M.duplicate(); |
---|
| 537 | Lp.moveToElementText(obj); |
---|
| 538 | } |
---|
| 539 | catch(e) |
---|
| 540 | { |
---|
| 541 | var Lp=obj.createTextRange(); |
---|
| 542 | } |
---|
[341] | 543 | |
---|
[2] | 544 | Lp.setEndPoint("EndToStart",M); |
---|
| 545 | var rb=Lp.text.length; |
---|
[341] | 546 | |
---|
[2] | 547 | if(rb > obj.value.length) |
---|
| 548 | { |
---|
| 549 | return -1; |
---|
| 550 | } |
---|
| 551 | return rb; |
---|
| 552 | } |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | function trim(inputString) { |
---|
[341] | 556 | if (typeof inputString != "string") |
---|
[2] | 557 | return inputString; |
---|
[341] | 558 | |
---|
[2] | 559 | var retValue = inputString; |
---|
| 560 | var ch = retValue.substring(0, 1); |
---|
[341] | 561 | while (ch == " ") { |
---|
[2] | 562 | retValue = retValue.substring(1, retValue.length); |
---|
| 563 | ch = retValue.substring(0, 1); |
---|
| 564 | } |
---|
| 565 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
[341] | 566 | while (ch == " ") { |
---|
[2] | 567 | retValue = retValue.substring(0, retValue.length-1); |
---|
| 568 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 569 | } |
---|
[341] | 570 | while (retValue.indexOf(" ") != -1) { |
---|
| 571 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
[2] | 572 | } |
---|
[341] | 573 | return retValue; |
---|
[2] | 574 | } |
---|
| 575 | |
---|
| 576 | function increment_folder_unseen(){ |
---|
| 577 | var folder_id = get_current_folder(); |
---|
| 578 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
[406] | 579 | var abas_unseen = Element('new_m').innerHTML; |
---|
| 580 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 581 | |
---|
[2] | 582 | if (folder_unseen) |
---|
| 583 | { |
---|
| 584 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + 1); |
---|
| 585 | } |
---|
| 586 | else |
---|
| 587 | { |
---|
| 588 | tree_folders.getNodeById(folder_id).alter({caption: tree_folders.getNodeById(folder_id).caption + '<font style=color:red> (</font><span id="dftree_'+folder_id+'_unseen" style=color:red>1</span><font style=color:red>)</font>'}); |
---|
| 589 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 590 | } |
---|
[406] | 591 | if (abas_unseen) |
---|
| 592 | { |
---|
| 593 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
| 594 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 595 | } |
---|
| 596 | else{ |
---|
| 597 | abas_unseen = Element('new_m').innerHTML; |
---|
| 598 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 599 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
| 600 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 601 | } |
---|
[2] | 602 | } |
---|
| 603 | function decrement_folder_unseen(){ |
---|
| 604 | var folder_id = get_current_folder(); |
---|
| 605 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
[406] | 606 | var abas_unseen = Element('new_m').innerHTML; |
---|
| 607 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
| 608 | |
---|
| 609 | if(!folder_unseen || !abas_unseen) |
---|
[2] | 610 | return; |
---|
| 611 | |
---|
| 612 | if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > 1)) |
---|
| 613 | { |
---|
| 614 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - 1); |
---|
| 615 | } |
---|
| 616 | else if (parseInt(folder_unseen.innerHTML) <= 1) |
---|
| 617 | { |
---|
| 618 | var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<'); |
---|
| 619 | var folder_name = tmp_folder_name[0]; |
---|
| 620 | tree_folders.getNodeById(folder_id).alter({caption: folder_name}); |
---|
| 621 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 622 | } |
---|
[406] | 623 | if ((abas_unseen) && (parseInt(abas_unseen) > 1)) |
---|
| 624 | { |
---|
| 625 | abas_unseen = (parseInt(abas_unseen) - 1); |
---|
| 626 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 627 | } |
---|
| 628 | else if (parseInt(abas_unseen) <= 1) |
---|
| 629 | { |
---|
| 630 | Element('new_m').innerHTML = '<font style="color:red">0</font>'; |
---|
| 631 | } |
---|
[2] | 632 | } |
---|
| 633 | |
---|
| 634 | function LTrim(value){ |
---|
| 635 | var w_space = String.fromCharCode(32); |
---|
| 636 | var strTemp = ""; |
---|
| 637 | var iTemp = 0; |
---|
[341] | 638 | |
---|
[2] | 639 | if(v_length < 1) |
---|
| 640 | return ""; |
---|
| 641 | |
---|
| 642 | var v_length = value ? value.length : 0; |
---|
[341] | 643 | |
---|
[2] | 644 | while(iTemp < v_length){ |
---|
| 645 | if(value && value.charAt(iTemp) != w_space){ |
---|
| 646 | strTemp = value.substring(iTemp,v_length); |
---|
| 647 | break; |
---|
| 648 | } |
---|
| 649 | iTemp++; |
---|
[341] | 650 | } |
---|
[2] | 651 | return strTemp; |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | //changes MENU background color. |
---|
| 655 | function set_menu_bg(menu) |
---|
| 656 | { |
---|
| 657 | menu.style.backgroundColor = 'white'; |
---|
| 658 | menu.style.border = '1px solid black'; |
---|
| 659 | } |
---|
| 660 | //changes MENU background color. |
---|
| 661 | function unset_menu_bg(menu) |
---|
| 662 | { |
---|
| 663 | menu.style.backgroundColor = ''; |
---|
| 664 | menu.style.border = '1px solid #f7f7f7'; |
---|
| 665 | } |
---|
| 666 | |
---|
[46] | 667 | function array_search(needle, haystack) { |
---|
| 668 | var n = haystack.length; |
---|
| 669 | for (var i=0; i<n; i++) { |
---|
| 670 | if (haystack[i]==needle) { |
---|
| 671 | return true; |
---|
| 672 | } |
---|
| 673 | } |
---|
| 674 | return false; |
---|
[96] | 675 | } |
---|
| 676 | |
---|
| 677 | function lang_folder(fn) { |
---|
| 678 | if (fn == "Inbox") return get_lang("Inbox"); |
---|
[365] | 679 | if (special_folders[fn] && typeof(special_folders[fn]) == 'string') { |
---|
[96] | 680 | return get_lang(special_folders[fn]); |
---|
[365] | 681 | } |
---|
[96] | 682 | return fn; |
---|
| 683 | } |
---|
[163] | 684 | |
---|
| 685 | function add_className(obj, className){ |
---|
| 686 | if (!exist_className(obj, className)) |
---|
| 687 | obj.className = obj.className + ' ' + className; |
---|
| 688 | } |
---|
| 689 | |
---|
| 690 | function remove_className(obj, className){ |
---|
| 691 | var re = new RegExp("\\s*"+className); |
---|
[320] | 692 | if (obj) |
---|
| 693 | obj.className = obj.className.replace(re, ''); |
---|
[163] | 694 | } |
---|
| 695 | |
---|
| 696 | function exist_className(obj, className){ |
---|
[381] | 697 | if ( obj && obj.className.indexOf(className) != -1 ) |
---|
[163] | 698 | return true; |
---|
| 699 | return false; |
---|
| 700 | } |
---|
| 701 | |
---|
| 702 | function select_all_messages(select) |
---|
| 703 | { |
---|
| 704 | var main = Element("tbody_box"); |
---|
| 705 | var main_list = main.childNodes; |
---|
| 706 | var len_main_list = main_list.length; |
---|
[341] | 707 | |
---|
[163] | 708 | if (select) |
---|
| 709 | { |
---|
| 710 | for (i=0; i<len_main_list; i++) |
---|
| 711 | { |
---|
| 712 | Element("check_box_message_"+main_list[i].id).checked = true; |
---|
| 713 | add_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 714 | } |
---|
| 715 | } |
---|
| 716 | else |
---|
| 717 | { |
---|
| 718 | for (i=0; i<len_main_list; i++) |
---|
| 719 | { |
---|
| 720 | Element("check_box_message_"+main_list[i].id).checked = false; |
---|
| 721 | remove_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 722 | } |
---|
| 723 | } |
---|
| 724 | } |
---|