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