[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 | |
---|
[5134] | 21 | var message = "Não Informado"; |
---|
| 22 | |
---|
[320] | 23 | function config_events(pObj, pEvent, pHandler) |
---|
| 24 | { |
---|
| 25 | if( typeof pObj == 'object') |
---|
| 26 | { |
---|
| 27 | if( pEvent.substring(0, 2) == 'on') |
---|
| 28 | pEvent = pEvent.substring(2, pEvent.length); |
---|
| 29 | |
---|
| 30 | if ( pObj.addEventListener ) |
---|
| 31 | pObj.addEventListener(pEvent, pHandler, false); |
---|
| 32 | else if( pObj.attachEvent ) |
---|
| 33 | pObj.attachEvent('on' + pEvent, pHandler ); |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | |
---|
[2] | 37 | function resizeWindow(){ |
---|
| 38 | |
---|
[3369] | 39 | var divScrollMain = Element("divScrollMain_"+numBox); |
---|
| 40 | var table_message = Element("table_message"); |
---|
| 41 | var content_folders = Element("content_folders"); |
---|
[5848] | 42 | |
---|
[5849] | 43 | var clientWidth = 0, clientHeight = 0; |
---|
| 44 | if( typeof( window.innerWidth ) == 'number' ) { |
---|
[5848] | 45 | //Non-IE |
---|
| 46 | clientWidth = window.innerWidth; |
---|
| 47 | clientHeight = window.innerHeight; |
---|
[5849] | 48 | } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { |
---|
[5848] | 49 | //IE 6+ in 'standards compliant mode' |
---|
| 50 | clientWidth = document.documentElement.clientWidth; |
---|
| 51 | clientHeight = document.documentElement.clientHeight; |
---|
[5849] | 52 | } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { |
---|
[5848] | 53 | //IE 4 compatible |
---|
| 54 | clientWidth = document.body.clientWidth; |
---|
| 55 | clientHeight = document.body.clientHeight; |
---|
[5849] | 56 | } |
---|
[5848] | 57 | clientHeight = clientHeight - 8; |
---|
[2] | 58 | |
---|
[3369] | 59 | if(divScrollMain){ |
---|
| 60 | divScrollMain.style.height = (clientHeight - (findPosY(divScrollMain) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight))) + "px"; |
---|
| 61 | } |
---|
[66] | 62 | |
---|
[813] | 63 | if(typeof(BordersArray) != 'undefined') { |
---|
[65] | 64 | for(var i = 1; BordersArray.length > 1 && i < BordersArray.length;i++) { |
---|
| 65 | var div_scroll = Element("div_message_scroll_"+BordersArray[i].sequence); |
---|
| 66 | var div = Element("content_id_"+BordersArray[i].sequence); |
---|
[813] | 67 | |
---|
[3369] | 68 | if(div){ |
---|
| 69 | div.style.height = (clientHeight - (findPosY(div) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+2)) + "px"; |
---|
| 70 | div.style.width = (clientWidth - (findPosX(div)+10)) + "px"; |
---|
| 71 | } |
---|
| 72 | if(div_scroll){ |
---|
| 73 | div_scroll.style.height = (clientHeight - (findPosY(div_scroll) + (table_message.clientHeight ? table_message.clientHeight : table_message.offsetHeight)+5)) + "px"; |
---|
| 74 | div_scroll.style.width = (clientWidth - (findPosX(div_scroll)+15)) + "px"; |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | } |
---|
[812] | 78 | |
---|
[3369] | 79 | if(content_folders){ |
---|
| 80 | var search_div = Element("search_div"); |
---|
| 81 | var contentFoldersY = findPosY(content_folders); |
---|
| 82 | content_folders.style.height = (clientHeight - (contentFoldersY + (contentFoldersY > findPosY(search_div) ? 0 : (search_div.clientHeight ? search_div.clientHeight : search_div.offsetHeight) + 5))) + "px"; |
---|
| 83 | } |
---|
[3336] | 84 | redim_borders(count_borders()); |
---|
[4062] | 85 | resizeMailList(); |
---|
[2] | 86 | } |
---|
| 87 | // END: FUNCTION RESIZE WINDOW |
---|
| 88 | |
---|
[320] | 89 | var _beforeunload_ = window.onbeforeunload; |
---|
| 90 | |
---|
[5785] | 91 | window.onbeforeunload = unloadMess; |
---|
[271] | 92 | |
---|
[2] | 93 | function unloadMess(){ |
---|
[3904] | 94 | if (typeof BordersArray == 'undefined') return; // We're not on expressoMail |
---|
[1657] | 95 | if (typeof(expresso_mail_sync) != "undefined" && expresso_mail_sync.working) { |
---|
[1518] | 96 | var mess = get_lang("You're about archiving your e-mails from server. Do you really want to stop this action?"); |
---|
| 97 | return mess; |
---|
| 98 | } |
---|
| 99 | else { |
---|
[5785] | 100 | for (var i = 0; i < BordersArray.length; i++) |
---|
| 101 | if(BordersArray[i].sequence > 0 && (!isNaN(BordersArray[i].sequence)&&parseInt(BordersArray[i].sequence) == BordersArray[i].sequence) ) |
---|
| 102 | return get_lang('There are still editing posts, really want to leave the page')+'?'; |
---|
[2] | 103 | } |
---|
| 104 | } |
---|
[320] | 105 | |
---|
[2] | 106 | // Translate words and phrases using user language from eGroupware. |
---|
[812] | 107 | function get_lang(_key) { |
---|
[3369] | 108 | if (typeof(_key) == 'undefined') |
---|
| 109 | return false; |
---|
[566] | 110 | var key = _key.toLowerCase(); |
---|
[812] | 111 | if(array_lang[key]) |
---|
| 112 | var _value = array_lang[key]; |
---|
| 113 | else |
---|
| 114 | var _value = _key+"*"; |
---|
[566] | 115 | |
---|
[812] | 116 | if(arguments.length > 1) |
---|
| 117 | for(j = 1; typeof(arguments[j]) != 'undefined'; j++) |
---|
| 118 | _value = _value.replace("%"+j,arguments[j]); |
---|
[2] | 119 | return _value; |
---|
[812] | 120 | } |
---|
| 121 | |
---|
[2] | 122 | // Make decimal round, using in size message |
---|
| 123 | function round(value, decimal){ |
---|
| 124 | var return_value = Math.round( value * Math.pow( 10 , decimal ) ) / Math.pow( 10 , decimal ); |
---|
| 125 | return( return_value ); |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | // Change the class of message. |
---|
[3369] | 129 | // In refresh, the flags UnRead and UnSeen don't exist anymore. |
---|
[163] | 130 | function set_msg_as_read(msg_number, selected){ |
---|
[2] | 131 | tr_message = Element(msg_number); |
---|
[163] | 132 | if (exist_className(tr_message, 'tr_msg_unread')) |
---|
| 133 | decrement_folder_unseen(); |
---|
| 134 | remove_className(tr_message, 'tr_msg_unread'); |
---|
| 135 | remove_className(tr_message, 'selected_msg'); |
---|
[3840] | 136 | |
---|
| 137 | if( document.getElementById("td_message_unseen_"+msg_number) != null ) |
---|
| 138 | Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/seen.gif' title='"+get_lang('Seen')+"'>"; |
---|
| 139 | |
---|
[1443] | 140 | connector.purgeCache(); |
---|
[163] | 141 | return true; |
---|
[2] | 142 | } |
---|
| 143 | |
---|
[605] | 144 | function msg_is_read(msg_number, selected){ |
---|
| 145 | tr_message = Element(msg_number); |
---|
[814] | 146 | return !(tr_message && LTrim(tr_message.className).match('tr_msg_unread')) |
---|
[605] | 147 | } |
---|
| 148 | |
---|
[5264] | 149 | function set_msg_as_unread(msg_number, isSearch){ |
---|
[2] | 150 | tr_message = Element(msg_number); |
---|
[1412] | 151 | if ((exist_className(tr_message, 'tr_msg_read') || exist_className(tr_message, 'tr_msg_read2')) && (!exist_className(tr_message, 'tr_msg_unread'))) |
---|
[3369] | 152 | increment_folder_unseen(); |
---|
[163] | 153 | remove_className(tr_message, 'selected_msg'); |
---|
| 154 | add_className(tr_message, 'tr_msg_unread'); |
---|
[5264] | 155 | if(!isSearch) |
---|
| 156 | Element("td_message_unseen_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/unseen.gif' title='"+get_lang('Unseen')+"'>"; |
---|
[2] | 157 | } |
---|
| 158 | |
---|
[5264] | 159 | function set_msg_as_flagged(msg_number, isSearch){ |
---|
[163] | 160 | var msg = Element(msg_number); |
---|
| 161 | remove_className(msg, 'selected_msg'); |
---|
| 162 | add_className(msg, 'flagged_msg'); |
---|
[5264] | 163 | if(isSearch) |
---|
[5582] | 164 | Element("td_message_important_"+msg_number.substr(0,msg_number.indexOf('_'))).innerHTML = "<img src ='templates/"+template+"/images/important.png' title='"+get_lang('Important')+"'>"; |
---|
[5264] | 165 | else |
---|
[5582] | 166 | Element("td_message_important_"+msg_number).innerHTML = "<img src ='templates/"+template+"/images/important.png' title='"+get_lang('Important')+"'>"; |
---|
[2] | 167 | } |
---|
| 168 | |
---|
[5264] | 169 | function set_msg_as_unflagged(msg_number, isSearch){ |
---|
[163] | 170 | var msg = Element(msg_number); |
---|
| 171 | remove_className(msg, 'selected_msg'); |
---|
| 172 | remove_className(msg, 'flagged_msg'); |
---|
[5264] | 173 | if(isSearch) |
---|
| 174 | Element("td_message_important_"+msg_number.substr(0,msg_number.indexOf('_'))).innerHTML = " "; |
---|
| 175 | else |
---|
| 176 | Element("td_message_important_"+msg_number).innerHTML = " "; |
---|
[2] | 177 | } |
---|
| 178 | |
---|
[845] | 179 | function removeAll(id){ |
---|
| 180 | do |
---|
| 181 | { |
---|
| 182 | if (typeof(Element(id)) == 'undefined') |
---|
| 183 | break; |
---|
| 184 | Element(id).parentNode.removeChild(Element(id)); |
---|
| 185 | } |
---|
| 186 | while(Element(id)); |
---|
| 187 | } |
---|
| 188 | |
---|
[2] | 189 | function get_current_folder(){ |
---|
| 190 | return current_folder; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | // Kill current box (folder or page). |
---|
| 194 | function kill_current_box(){ |
---|
| 195 | var box = document.getElementById("table_box"); |
---|
| 196 | if (box != null) |
---|
| 197 | box.parentNode.removeChild(box); |
---|
[320] | 198 | else |
---|
| 199 | return false; |
---|
[2] | 200 | } |
---|
| 201 | |
---|
[5134] | 202 | //Remove as linhas da tabela sem deletar o corrent_box |
---|
| 203 | function remove_rows(el){ |
---|
| 204 | while (el.rows.length > 0) { |
---|
| 205 | el.deleteRow(0); |
---|
| 206 | } |
---|
| 207 | Element("tot_m").innerHTML = 0 |
---|
| 208 | Element("new_m").innerHTML = 0 |
---|
| 209 | } |
---|
| 210 | |
---|
[2] | 211 | // Kill current paging. |
---|
| 212 | function kill_current_paging(){ |
---|
| 213 | var paging = Element("span_paging"); |
---|
| 214 | if (paging != null) |
---|
| 215 | paging.parentNode.removeChild(paging); |
---|
| 216 | } |
---|
| 217 | |
---|
[412] | 218 | function show_hide_span_paging(ID){ |
---|
[3380] | 219 | if ((ID != "0") && Element("span_paging")) |
---|
| 220 | Element("span_paging").style.display = 'none'; |
---|
| 221 | else |
---|
| 222 | if (Element("span_paging")) |
---|
| 223 | Element("span_paging").style.display = ''; |
---|
[412] | 224 | } |
---|
| 225 | |
---|
[2] | 226 | //Get the current number of messages in a page. |
---|
| 227 | function get_messages_number_in_page(){ |
---|
| 228 | //Get element tBody. |
---|
| 229 | main = document.getElementById("tbody_box"); |
---|
[3369] | 230 | |
---|
[2] | 231 | // Get all TR (messages) in tBody. |
---|
| 232 | main_list = main.childNodes; |
---|
[3369] | 233 | |
---|
[2] | 234 | return main_list.length; |
---|
| 235 | } |
---|
| 236 | |
---|
[689] | 237 | function download_local_attachment(url) { |
---|
[3270] | 238 | url=encodeURI(url); |
---|
| 239 | url=url.replace("%25","%"); |
---|
[689] | 240 | if (div_attachment == null){ |
---|
| 241 | var div_attachment = document.createElement("DIV"); |
---|
| 242 | div_attachment.id="id_div_attachment"; |
---|
| 243 | document.body.appendChild(div_attachment); |
---|
| 244 | } |
---|
| 245 | div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='"+url+"'></iframe>"; |
---|
| 246 | } |
---|
| 247 | |
---|
[271] | 248 | function download_attachments(msg_folder, msg_number, idx_file, msg_part, encoding, new_file_name, show_iframe){ |
---|
[2] | 249 | div_attachment = document.getElementById("id_div_attachment"); |
---|
| 250 | var params = ''; |
---|
[4820] | 251 | |
---|
[2] | 252 | if (div_attachment == null){ |
---|
| 253 | var div_attachment = document.createElement("DIV"); |
---|
| 254 | div_attachment.id="id_div_attachment"; |
---|
| 255 | document.body.appendChild(div_attachment); |
---|
| 256 | } |
---|
[4416] | 257 | if(new_file_name) { |
---|
[5134] | 258 | var extension = /\.[^.]*$/.exec(new_file_name); |
---|
| 259 | if (extension == ".eml") |
---|
[4416] | 260 | params = "&newFilename="+new_file_name; //name_of_message.eml |
---|
| 261 | else // when more than one message |
---|
| 262 | params = "&newFilename="+escape(new_file_name); //mensagens.zip |
---|
| 263 | } |
---|
[2] | 264 | if(encoding) |
---|
| 265 | params += "&encoding="+encoding; |
---|
[271] | 266 | |
---|
[4416] | 267 | div_attachment.innerHTML="<iframe style='display:none;width:0;height:0' name='attachment' src='inc/get_archive.php?msgFolder="+msg_folder+"&msgNumber="+msg_number+"&idx_file="+idx_file+"&indexPart="+msg_part+params+"'></iframe>"; |
---|
| 268 | |
---|
[2] | 269 | } |
---|
[271] | 270 | |
---|
[2] | 271 | function download_all_attachments(msg_folder, msg_number){ |
---|
[3369] | 272 | var handler_source = function(data){ |
---|
[2] | 273 | download_attachments(null, null, data, null,null,'anexos.zip'); |
---|
| 274 | } |
---|
| 275 | cExecute("$this.exporteml.download_all_attachments",handler_source,"folder="+msg_folder+"&num_msg="+msg_number); |
---|
| 276 | } |
---|
[689] | 277 | //ADD forwarded files |
---|
[3387] | 278 | function addForwardedFile(id_border,file_name,link,divFiles){ |
---|
| 279 | if(!divFiles) |
---|
[5134] | 280 | var divFiles = document.getElementById("divFiles_"+id_border); |
---|
[689] | 281 | |
---|
| 282 | if (! divFiles) |
---|
| 283 | return false; |
---|
[3369] | 284 | |
---|
[689] | 285 | if (divFiles.lastChild) |
---|
| 286 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 287 | |
---|
| 288 | if (! countDivFiles) |
---|
| 289 | var countDivFiles = 1; |
---|
[3369] | 290 | |
---|
[5134] | 291 | var divFile = document.createElement('DIV'); |
---|
[689] | 292 | |
---|
[5134] | 293 | var inputFile = document.createElement("INPUT"); |
---|
[1121] | 294 | if (!expresso_offline) { |
---|
| 295 | if (!is_ie) { |
---|
| 296 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 297 | tmp_id_border.value = id_border; |
---|
[3369] | 298 | |
---|
[1121] | 299 | inputFile.setAttributeNode(tmp_id_border); |
---|
| 300 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
| 301 | inputFile.type = 'file'; |
---|
| 302 | inputFile.size = 50; |
---|
| 303 | inputFile.maxLength = 255; |
---|
| 304 | inputFile.name = 'file_' + countDivFiles; |
---|
| 305 | inputFile.style.display = "none"; |
---|
| 306 | } |
---|
| 307 | else { |
---|
[5134] | 308 | inputFile = document.createElement("link"); |
---|
[3369] | 309 | |
---|
[1121] | 310 | var tmp_id_border = document.createAttribute('id_border'); |
---|
| 311 | tmp_id_border.value = id_border; |
---|
[3369] | 312 | |
---|
[1121] | 313 | inputFile.setAttributeNode(tmp_id_border); |
---|
| 314 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
| 315 | inputFile.name = 'file_' + countDivFiles; |
---|
[3369] | 316 | |
---|
| 317 | |
---|
[1121] | 318 | } |
---|
[3369] | 319 | |
---|
[689] | 320 | } |
---|
| 321 | else { |
---|
[1121] | 322 | inputFile.type = 'hidden'; |
---|
| 323 | inputFile.name = 'offline_forward_' + countDivFiles; |
---|
[3369] | 324 | } |
---|
[1121] | 325 | divFile.appendChild(inputFile); |
---|
[689] | 326 | |
---|
| 327 | var a_tmp = new Array(); |
---|
| 328 | a_tmp[0] = "local_"; |
---|
| 329 | a_tmp[1] = 'file_' + countDivFiles; |
---|
| 330 | a_tmp[2] = file_name; |
---|
| 331 | s_tmp = escape(connector.serialize(a_tmp)); |
---|
| 332 | var checkbox = document.createElement("INPUT"); |
---|
| 333 | checkbox.type = "checkbox"; |
---|
| 334 | checkbox.id = "checkbox_"+id_border+"_"+countDivFiles; |
---|
| 335 | checkbox.name = "local_attachments[]"; |
---|
[5134] | 336 | checkbox.setAttribute("checked", "checked"); |
---|
[3369] | 337 | |
---|
[689] | 338 | checkbox.value = s_tmp; |
---|
| 339 | divFile.appendChild(checkbox); |
---|
[3369] | 340 | |
---|
[689] | 341 | var link_attachment = document.createElement("A"); |
---|
| 342 | link_attachment.setAttribute("href", link); |
---|
[3369] | 343 | |
---|
[689] | 344 | link_attachment.innerHTML = file_name; |
---|
| 345 | divFile.appendChild(link_attachment); |
---|
[3369] | 346 | |
---|
[689] | 347 | countDivFiles++; |
---|
[3369] | 348 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
[689] | 349 | divFiles.appendChild(divFile); |
---|
| 350 | |
---|
| 351 | return inputFile; |
---|
| 352 | } |
---|
| 353 | |
---|
[2] | 354 | // Add Input File Dynamically. |
---|
| 355 | function addFile(id_border){ |
---|
| 356 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
[320] | 357 | if (! divFiles) |
---|
| 358 | return false; |
---|
[3369] | 359 | |
---|
[271] | 360 | if (divFiles.lastChild) |
---|
| 361 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
| 362 | |
---|
| 363 | if (! countDivFiles) |
---|
| 364 | var countDivFiles = 1; |
---|
[3369] | 365 | |
---|
[4457] | 366 | divFile = document.createElement('div'); |
---|
[689] | 367 | |
---|
[4820] | 368 | var inputFile = document.createElement("input"); |
---|
| 369 | inputFile.id = "inputFile_"+id_border+"_"+countDivFiles; |
---|
| 370 | inputFile.name = "file_"+countDivFiles; |
---|
| 371 | inputFile.type = "file"; |
---|
| 372 | inputFile.size = 50; |
---|
| 373 | inputFile.maxlength = 255; |
---|
| 374 | inputFile.onchange = function () { |
---|
| 375 | validateFileExtension(this.value, this.id.replace('input','div'), this.getAttribute('id_border')); |
---|
| 376 | }; |
---|
| 377 | |
---|
| 378 | divFile.appendChild(inputFile); |
---|
| 379 | |
---|
| 380 | var linkFile = document.createElement("a"); |
---|
| 381 | linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; |
---|
| 382 | linkFile.href = 'javascript:void(0)'; |
---|
| 383 | linkFile.onclick = function () {removeFile("divFile_"+id_border+"_"+countDivFiles); return false;}; |
---|
| 384 | linkFile.innerHTML = get_lang("Remove"); |
---|
| 385 | |
---|
| 386 | divFile.appendChild(linkFile); |
---|
| 387 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
| 388 | divFiles.appendChild(divFile); |
---|
| 389 | |
---|
[4413] | 390 | return inputFile; |
---|
[2] | 391 | } |
---|
| 392 | // Remove Input File Dynamically. |
---|
| 393 | function removeFile(id){ |
---|
| 394 | var el = Element(id); |
---|
| 395 | el.parentNode.removeChild(el); |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | function validateFileExtension(fileName, id, id_border){ |
---|
[3369] | 399 | |
---|
[271] | 400 | var error_flag = false; |
---|
[320] | 401 | |
---|
| 402 | if ( fileName.indexOf('/') != -1 ) |
---|
| 403 | { |
---|
| 404 | if (fileName[0] != '/'){ // file name is windows format? |
---|
| 405 | var file = fileName.substr(fileName.lastIndexOf('\\') + 1, fileName.length); |
---|
| 406 | if ((fileName.indexOf(':\\') != 1) && (fileName.indexOf('\\\\') != 0)) // Is stored in partition or a network file? |
---|
[3369] | 407 | error_flag = true; |
---|
[320] | 408 | } |
---|
| 409 | else // is Unix |
---|
[3369] | 410 | var file = fileName.substr(fileName.lastIndexOf('/') + 1, fileName.length); |
---|
[271] | 411 | } |
---|
[320] | 412 | else // is Firefox 3 |
---|
| 413 | var file = fileName; |
---|
[271] | 414 | |
---|
| 415 | var fileExtension = file.split("."); |
---|
[2] | 416 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 417 | for(var i=0; i<denyFileExtensions.length; i++) |
---|
| 418 | { |
---|
| 419 | if(denyFileExtensions[i] == fileExtension) |
---|
| 420 | { |
---|
[271] | 421 | error_flag = true; |
---|
| 422 | break; |
---|
[2] | 423 | } |
---|
[3369] | 424 | |
---|
[2] | 425 | } |
---|
[271] | 426 | |
---|
[320] | 427 | if ( error_flag == true ) |
---|
| 428 | { |
---|
[271] | 429 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 430 | removeFile(id); |
---|
| 431 | addFile(id_border); |
---|
| 432 | return false; |
---|
| 433 | } |
---|
| 434 | return true; |
---|
[2] | 435 | } |
---|
| 436 | |
---|
| 437 | var setTimeout_write_msg = 0; |
---|
[3742] | 438 | var old_msg = false; |
---|
[197] | 439 | // Funcao usada para escrever mensagem |
---|
| 440 | // notimeout = True : mensagem nao apaga |
---|
[3369] | 441 | function write_msg(msg, notimeout){ |
---|
| 442 | |
---|
[2] | 443 | if (setTimeout_write_msg) |
---|
| 444 | clearTimeout(setTimeout_write_msg); |
---|
[3369] | 445 | |
---|
[80] | 446 | var msg_div = Element('em_div_write_msg'); |
---|
[5436] | 447 | var old_divStatusBar = Element("divStatusBar"); |
---|
[2] | 448 | |
---|
[80] | 449 | if(!msg_div) { |
---|
| 450 | msg_div = document.createElement('DIV'); |
---|
| 451 | msg_div.id = 'em_div_write_msg'; |
---|
[831] | 452 | msg_div.className = 'em_div_write_msg'; |
---|
[5436] | 453 | old_divStatusBar.parentNode.insertBefore(msg_div,old_divStatusBar); |
---|
[447] | 454 | } |
---|
[3369] | 455 | |
---|
[447] | 456 | if( document.getElementById('JabberMessenger')) |
---|
[651] | 457 | loadscript.adIcon(); |
---|
[447] | 458 | |
---|
[831] | 459 | 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] | 460 | |
---|
[5436] | 461 | old_divStatusBar.style.display = 'none'; |
---|
| 462 | msg_div.style.display = ''; |
---|
[2] | 463 | // Nao ponha var na frente!! jakjr |
---|
| 464 | handle_write_msg = function(){ |
---|
| 465 | try{ |
---|
[197] | 466 | if(!old_msg) |
---|
[5436] | 467 | clean_msg(); |
---|
[197] | 468 | else |
---|
[3369] | 469 | write_msg(old_msg, true); |
---|
[2] | 470 | } |
---|
| 471 | catch(e){} |
---|
| 472 | } |
---|
[197] | 473 | if(notimeout) |
---|
| 474 | old_msg = msg; |
---|
| 475 | else |
---|
| 476 | setTimeout_write_msg = setTimeout("handle_write_msg();", 5000); |
---|
[2] | 477 | } |
---|
[197] | 478 | // Funcao usada para apagar mensagem sem timeout |
---|
| 479 | function clean_msg(){ |
---|
| 480 | old_msg = false; |
---|
| 481 | var msg_div = Element('em_div_write_msg'); |
---|
| 482 | var old_divStatusBar = Element("divStatusBar"); |
---|
| 483 | if(msg_div) |
---|
| 484 | msg_div.style.display = 'none'; |
---|
[3369] | 485 | old_divStatusBar.style.display = ''; |
---|
[197] | 486 | } |
---|
[2] | 487 | |
---|
| 488 | function make_body_reply(body, to, date_day, date_hour){ |
---|
| 489 | to = to.replace("<","<"); |
---|
| 490 | to = to.replace(">",">"); |
---|
[5134] | 491 | block_quoted_body ='<div>'; |
---|
| 492 | block_quoted_body += get_lang('At %1, %2 hours, %3 wrote:', date_day, date_hour, to) + '<br type="_moz"></div>'; |
---|
[2] | 493 | block_quoted_body += "<blockquote style=\"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;\">"; |
---|
| 494 | block_quoted_body += body; |
---|
| 495 | block_quoted_body += "</blockquote>"; |
---|
| 496 | return block_quoted_body; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | function make_forward_body(body, from, date, subject, to, cc){ |
---|
| 500 | from = from.replace(/</g,"<"); |
---|
| 501 | from = from.replace(/>/g,">"); |
---|
| 502 | to = to.replace(/</g,"<"); |
---|
| 503 | to = to.replace(/>/g,">"); |
---|
[5134] | 504 | var forward_body = '<div>---------- ' + get_lang('Forwarded message') + ' ----------<br type="_moz"></div><div>'; |
---|
| 505 | forward_body += get_lang('From') + ': ' + from + '<br type="_moz"></div><div>'; |
---|
| 506 | forward_body += get_lang('Date') + ': ' + date + '<br type="_moz"></div><div>'; |
---|
| 507 | forward_body += get_lang('Subject') + ': ' + subject + '<br type="_moz"></div><div>'; |
---|
| 508 | forward_body += get_lang('To') + ': ' + to+ '<br type="_moz"></div><div>'; |
---|
[2] | 509 | if(cc != undefined){ |
---|
| 510 | cc = cc.replace(/</g,"<"); |
---|
| 511 | cc = cc.replace(/>/g,">"); |
---|
[5464] | 512 | forward_body += get_lang('CC') + ': ' + cc+ '<div><br type="_moz"></div><div><br type="_moz"></div><div><br type="_moz"></div>'; |
---|
[2] | 513 | } |
---|
| 514 | forward_body += body; |
---|
| 515 | return forward_body; |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | function emMessageSearch(e,value){ |
---|
| 519 | var e = is_ie ? window.event : e; |
---|
| 520 | if(e.keyCode == 13) { |
---|
| 521 | search_emails(value); |
---|
| 522 | } |
---|
| 523 | } |
---|
| 524 | |
---|
[3227] | 525 | function validateEmail(email){ |
---|
| 526 | if (typeof(email) != 'string') |
---|
| 527 | return false; |
---|
[5695] | 528 | var validName = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/i; |
---|
| 529 | //emailParts = email.split('@'); |
---|
[5696] | 530 | return validName.test(email); |
---|
[3227] | 531 | } |
---|
| 532 | function validateDomain(domain){ |
---|
| 533 | 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; |
---|
| 534 | return (domainReg.test(domain)); |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | function validateUrl(url){ |
---|
| 538 | var urlReg = /([A-Za-z]{2,7}:\/\/)(.*)/i; |
---|
| 539 | urlParts = url.split(urlReg); |
---|
| 540 | return (urlParts[1].length > 4 && validateDomain(urlParts[2])); |
---|
| 541 | } |
---|
[3581] | 542 | |
---|
| 543 | function performQuickSearch(keyword){ |
---|
| 544 | if (preferences.quick_search_default=='1') |
---|
[5198] | 545 | emQuickSearch(keyword, 'null', 'null', 'expressoMail'); |
---|
[3581] | 546 | else |
---|
| 547 | search_emails(keyword); |
---|
| 548 | } |
---|
| 549 | |
---|
[5417] | 550 | function emQuickSearch(emailList, field, ID, Type, force){ |
---|
[2] | 551 | var quickSearchKeyBegin; |
---|
| 552 | var quickSearchKeyEnd; |
---|
[5941] | 553 | var content = $("#content_id_"+ID); |
---|
| 554 | |
---|
[1121] | 555 | if(expresso_offline) { |
---|
| 556 | alert(get_lang('Not allowed in offline mode')); |
---|
| 557 | return; |
---|
| 558 | } |
---|
[3871] | 559 | if ((field != 'null') && (ID != 'null')) |
---|
| 560 | { |
---|
| 561 | connector.loadScript("QuickCatalogSearch"); |
---|
| 562 | if (typeof(QuickCatalogSearch) == 'undefined'){ |
---|
[5456] | 563 | setTimeout('emQuickSearch("'+emailList+'", "'+field+'", "'+ID+'", "'+Type+'", "'+force+'")',500); |
---|
[3871] | 564 | return false; |
---|
| 565 | } |
---|
| 566 | } |
---|
| 567 | else |
---|
| 568 | { |
---|
| 569 | connector.loadScript("QuickSearchUser"); |
---|
| 570 | if (typeof(QuickSearchUser) == 'undefined'){ |
---|
[5456] | 571 | setTimeout('emQuickSearch("'+emailList+'", "'+field+'", "'+ID+'", "'+Type+'", "'+force+'")',500); |
---|
[3871] | 572 | return false; |
---|
| 573 | } |
---|
| 574 | } |
---|
[3369] | 575 | |
---|
[37] | 576 | var handler_emQuickSearch = function(data) |
---|
| 577 | { |
---|
[3369] | 578 | |
---|
[2] | 579 | if ((!data.status) && (data.error == "many results")){ |
---|
[4457] | 580 | alert(get_lang('More than %1 results. Please, try to refine your search.',data.maxResult)); |
---|
[2] | 581 | return false; |
---|
| 582 | } |
---|
[3369] | 583 | |
---|
[2] | 584 | if (data.length > 0){ |
---|
[37] | 585 | if ((field != 'null') && (ID != 'null')) |
---|
| 586 | { |
---|
[5075] | 587 | QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd, ID, field); |
---|
[37] | 588 | } |
---|
| 589 | else |
---|
| 590 | { |
---|
| 591 | QuickSearchUser.showList(data); |
---|
| 592 | } |
---|
[2] | 593 | } |
---|
| 594 | else |
---|
| 595 | alert(get_lang('None result was found.')); |
---|
| 596 | return true; |
---|
| 597 | } |
---|
[37] | 598 | if ((field != 'null') && (ID != 'null')) |
---|
| 599 | { |
---|
[5941] | 600 | content.find(field).focus(); |
---|
| 601 | var i = getPosition(content.find(field)[0]); //inputBox.selectionStart; |
---|
[37] | 602 | var j = --i; |
---|
[2] | 603 | |
---|
[37] | 604 | // Acha o inicio |
---|
| 605 | while ((j >= 0) && (emailList.charAt(j) != ',')){j--}; |
---|
| 606 | quickSearchKeyBegin = ++j; |
---|
[2] | 607 | |
---|
[37] | 608 | // Acha o final |
---|
| 609 | while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++}; |
---|
| 610 | quickSearchKeyEnd = i; |
---|
[2] | 611 | |
---|
[37] | 612 | // A Chave da Pesquisa |
---|
| 613 | var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd)); |
---|
| 614 | } |
---|
| 615 | else |
---|
| 616 | var search_for = emailList; |
---|
[6053] | 617 | if(preferences.search_characters_number == 'x') |
---|
| 618 | preferences.search_characters_number = 0; |
---|
| 619 | |
---|
[1610] | 620 | if (search_for.length < preferences.search_characters_number){ |
---|
[5852] | 621 | alert(get_lang('Your search argument must be longer than %1 characters.', preferences.search_characters_number)); |
---|
| 622 | return false; |
---|
[2] | 623 | } |
---|
[5209] | 624 | if(Type == undefined) |
---|
[5196] | 625 | cExecute ("$this.ldap_functions.quicksearchcontact&search_for="+search_for+"&field="+field+"&ID="+ID, handler_emQuickSearch); |
---|
| 626 | else |
---|
| 627 | cExecute ("$this.ldap_functions.quicksearchcontact&search_for="+search_for+"&field="+field+"&ID="+ID+"&Type="+Type, handler_emQuickSearch); |
---|
[2] | 628 | } |
---|
| 629 | |
---|
[5744] | 630 | function folderbox() |
---|
| 631 | { |
---|
[2] | 632 | connector.loadScript("TreeS"); |
---|
[5744] | 633 | |
---|
| 634 | if( typeof(window.ttree) == 'undefined') |
---|
| 635 | setTimeout(function(){ folderbox(); }, 200 ); |
---|
| 636 | else |
---|
| 637 | ttree.load(); |
---|
[2] | 638 | } |
---|
| 639 | |
---|
| 640 | function filterbox(){ |
---|
| 641 | connector.loadScript("filter"); |
---|
| 642 | connector.loadScript("filters"); |
---|
[3068] | 643 | if (typeof(filters) == 'undefined') |
---|
| 644 | { |
---|
| 645 | setTimeout('filterbox()',500); |
---|
| 646 | return false; |
---|
| 647 | } |
---|
[2] | 648 | filters.Forms(); |
---|
| 649 | } |
---|
| 650 | |
---|
[5539] | 651 | |
---|
| 652 | function filterbox2(){ |
---|
[5782] | 653 | init_filters(); |
---|
[5539] | 654 | jQuery('.expresso-window-container').dialog('open'); |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | |
---|
[2] | 658 | function sharebox(){ |
---|
| 659 | var handler_imap_getacl = function(data) |
---|
| 660 | { |
---|
[4476] | 661 | connector.loadScript("finder", "../services/"); |
---|
[2] | 662 | connector.loadScript("sharemailbox"); |
---|
[5458] | 663 | |
---|
[3068] | 664 | if (typeof(sharemailbox) == 'undefined') |
---|
| 665 | { |
---|
| 666 | setTimeout('sharebox()',500); |
---|
| 667 | return false; |
---|
| 668 | } |
---|
[5458] | 669 | |
---|
| 670 | sharemailbox.makeWindow(data); |
---|
[2] | 671 | } |
---|
| 672 | cExecute ("$this.imap_functions.getacl", handler_imap_getacl); |
---|
| 673 | } |
---|
| 674 | |
---|
[5533] | 675 | function configureLabels(data){ |
---|
| 676 | |
---|
| 677 | dialogElement = $('.label-configure-win').html(DataLayer.render("../prototype/modules/mail/templates/label_configure.ejs", {})) |
---|
| 678 | |
---|
| 679 | dialogElement.dialog({ |
---|
[5704] | 680 | width:815, |
---|
[5533] | 681 | height:410, |
---|
| 682 | title:' Configuração do Marcador', |
---|
| 683 | resizable:false, |
---|
| 684 | modal: true, |
---|
| 685 | closeOnEscape:true, |
---|
[5554] | 686 | close:function(event, ui) { |
---|
| 687 | select_all_search_messages(false, 'content_id_'+currentTab); |
---|
| 688 | event.stopPropagation(); |
---|
| 689 | }, |
---|
[5533] | 690 | autoOpen:false, |
---|
| 691 | dialogClass: 'dialog-configure-label' |
---|
| 692 | }); |
---|
[5640] | 693 | init_label({window:dialogElement, selectedItem:data.selectedItem, applyToSelectedMessages:data.applyToSelectedMessages}); |
---|
[5533] | 694 | dialogElement.dialog("open"); |
---|
| 695 | } |
---|
| 696 | |
---|
| 697 | function configureFollowupflag(){ |
---|
| 698 | |
---|
| 699 | var messages = new Array(); |
---|
| 700 | var selectedMessageIds = new Array(); |
---|
| 701 | var folder_name; |
---|
| 702 | if (currentTab == 0) { |
---|
| 703 | selectedMessageIds = get_selected_messages().split(","); |
---|
| 704 | } else { |
---|
| 705 | selectedMessageIds = get_selected_messages_search().split(","); |
---|
| 706 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 707 | } |
---|
| 708 | |
---|
[5588] | 709 | var roles = get_selected_messages_search_role().split(','); |
---|
[5533] | 710 | for (var i=0; i<selectedMessageIds.length; i++) { |
---|
| 711 | if (currentTab == 0) { |
---|
| 712 | folder_name = current_folder; |
---|
[5588] | 713 | var number = selectedMessageIds[i]; |
---|
[5533] | 714 | }else{ |
---|
[5588] | 715 | var tr = $('[role="'+roles[i]+'"]'); |
---|
| 716 | folder_name = $(tr).attr('name'); |
---|
| 717 | var id = $(tr).attr('id'); |
---|
| 718 | var number = id.replace(/_[a-zA-Z0-9]+/,""); |
---|
[5533] | 719 | } |
---|
[5588] | 720 | messages.push(onceOpenedHeadersMessages[folder_name][number]); |
---|
[5533] | 721 | } |
---|
| 722 | |
---|
| 723 | if(!User.followupflags) |
---|
[5640] | 724 | DataLayer.remove('followupflag', false); |
---|
[5571] | 725 | User.followupflags = DataLayer.get('followupflag', true); |
---|
[5533] | 726 | var data = { |
---|
| 727 | followupflags: User.followupflags, |
---|
| 728 | messages: messages |
---|
| 729 | }; |
---|
| 730 | dialogElement = $('.followupflag-configure-win').html(DataLayer.render("../prototype/modules/mail/templates/followupflag_configure.ejs", data)) |
---|
| 731 | |
---|
| 732 | dialogElement.dialog({ |
---|
[5713] | 733 | width:532, |
---|
[5533] | 734 | height:420, |
---|
[5571] | 735 | title:get_lang('Follow up'), |
---|
[5533] | 736 | resizable:false, |
---|
| 737 | modal: true, |
---|
| 738 | closeOnEscape:true, |
---|
| 739 | close:function(event, ui) { |
---|
[5554] | 740 | select_all_search_messages(false, 'content_id_'+currentTab); |
---|
[5533] | 741 | event.stopPropagation(); |
---|
| 742 | }, |
---|
| 743 | autoOpen:false |
---|
| 744 | }); |
---|
| 745 | init_followup({window:dialogElement, selectedMessages:selectedMessageIds}); |
---|
| 746 | dialogElement.dialog("open"); |
---|
| 747 | } |
---|
| 748 | |
---|
[3178] | 749 | function open_rss(param){ |
---|
| 750 | connector.loadScript("news_edit"); |
---|
| 751 | if (typeof(news_edit) == 'undefined') |
---|
| 752 | { |
---|
| 753 | setTimeout('open_rss(\''+param+'\')',500); |
---|
| 754 | return false; |
---|
| 755 | } |
---|
| 756 | news_edit.read_rss(param); |
---|
| 757 | return true; |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | function editrss(){ |
---|
| 761 | connector.loadScript("news_edit"); |
---|
| 762 | if (typeof(news_edit) == 'undefined') |
---|
| 763 | { |
---|
| 764 | setTimeout('editrss()',500); |
---|
| 765 | return false; |
---|
| 766 | } |
---|
| 767 | news_edit.makeWindow(); |
---|
| 768 | } |
---|
| 769 | |
---|
| 770 | |
---|
| 771 | |
---|
| 772 | |
---|
[2] | 773 | function preferences_mail(){ |
---|
[1186] | 774 | location.href="../preferences/preferences.php?appname=expressoMail1_2"; |
---|
[2] | 775 | } |
---|
| 776 | |
---|
| 777 | function search_emails(value){ |
---|
[5172] | 778 | var resize = false; |
---|
| 779 | resize = resize_borders(); |
---|
| 780 | if (!resize){ |
---|
| 781 | var str_continue = ''; |
---|
| 782 | var bolContinue = true; |
---|
| 783 | str_continue = '\n' + get_lang('You must manually close one of your tabs before opening a new one'); |
---|
| 784 | if (preferences.auto_close_first_tab == 1){ |
---|
| 785 | var children = Element('border_tr').childNodes; |
---|
| 786 | var bolDelete = true; |
---|
| 787 | for (var i=0; i<children.length; i++) { |
---|
| 788 | if ((children[i].nodeName === 'TD') && (children[i].id!=='border_id_0') && (children[i].id!=='border_blank')) |
---|
| 789 | { |
---|
| 790 | bolDelete = true; |
---|
| 791 | var num_child = children[i].id.toString().substr(10); |
---|
| 792 | alternate_border(num_child); |
---|
| 793 | if (editTest(num_child)){ |
---|
| 794 | bolDelete = false; |
---|
| 795 | } |
---|
| 796 | if (bolDelete || bolContinue){ |
---|
| 797 | str_fechar = '\n' + get_lang('Reached maximum tab limit. Want to close this tab'); |
---|
| 798 | var confirmacao = confirm(str_fechar); |
---|
| 799 | if(confirmacao){ |
---|
| 800 | bolContinue = false; |
---|
| 801 | delete_border(num_child, 'false'); |
---|
[6204] | 802 | break; |
---|
[5172] | 803 | }else{ |
---|
| 804 | return; |
---|
| 805 | } |
---|
| 806 | } |
---|
| 807 | } |
---|
| 808 | } |
---|
| 809 | }else{ |
---|
| 810 | alert(get_lang('Reached maximum tab limit') + str_continue ); |
---|
| 811 | return; |
---|
| 812 | } |
---|
| 813 | } |
---|
[3068] | 814 | connector.loadScript("TreeS"); |
---|
[2] | 815 | connector.loadScript("search"); |
---|
[3068] | 816 | if (typeof(EsearchE) == 'undefined' || typeof(ttree) == 'undefined'){ |
---|
[5540] | 817 | setTimeout("search_emails('"+value+"')",500); |
---|
[3068] | 818 | return false; |
---|
| 819 | } |
---|
[2] | 820 | EsearchE.showForms(value); |
---|
[5172] | 821 | } |
---|
[2] | 822 | |
---|
| 823 | function source_msg(id_msg,folder){ |
---|
| 824 | var num_msg = id_msg.substr(0,(id_msg.length - 2)); |
---|
| 825 | var handler_source = function(data){ |
---|
[1899] | 826 | download_attachments(null, null, data, null,null,'fonte_da_mensagem.eml'); |
---|
[2] | 827 | } |
---|
| 828 | cExecute("$this.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg); |
---|
| 829 | } |
---|
| 830 | |
---|
| 831 | function url_encode(str){ |
---|
[5134] | 832 | if(str === null) return false; |
---|
[3068] | 833 | var hex_chars = "0123456789ABCDEF"; |
---|
| 834 | var noEncode = /^([a-zA-Z0-9\_\-\.])$/; |
---|
| 835 | var n, strCode, hex1, hex2, strEncode = ""; |
---|
[2] | 836 | |
---|
[3068] | 837 | for(n = 0; n < str.length; n++) { |
---|
| 838 | if (noEncode.test(str.charAt(n))) { |
---|
| 839 | strEncode += str.charAt(n); |
---|
| 840 | } else { |
---|
| 841 | strCode = str.charCodeAt(n); |
---|
| 842 | hex1 = hex_chars.charAt(Math.floor(strCode / 16)); |
---|
| 843 | hex2 = hex_chars.charAt(strCode % 16); |
---|
| 844 | strEncode += "%" + (hex1 + hex2); |
---|
| 845 | } |
---|
| 846 | } |
---|
[4855] | 847 | |
---|
[3068] | 848 | return strEncode; |
---|
| 849 | } |
---|
[2] | 850 | |
---|
[3068] | 851 | function url_decode(str) { |
---|
| 852 | var n, strCode, strDecode = ""; |
---|
| 853 | for (n = 0; n < str.length; n++) { |
---|
[3369] | 854 | strDecode += str.charAt(n); |
---|
| 855 | //if (str.charAt(n) == "%") { |
---|
| 856 | // strCode = str.charAt(n + 1) + str.charAt(n + 2); |
---|
| 857 | // strDecode += String.fromCharCode(parseInt(strCode, 16)); |
---|
| 858 | // n += 2; |
---|
| 859 | //} else { |
---|
| 860 | // strDecode += str.charAt(n); |
---|
| 861 | //} |
---|
[3068] | 862 | } |
---|
| 863 | return strDecode; |
---|
| 864 | } |
---|
[5134] | 865 | //Método que remove os hexadecimais criados no enconde |
---|
| 866 | //e retorna string corretamente |
---|
| 867 | function url_decode_s(str) { |
---|
| 868 | var result = ""; |
---|
[2] | 869 | |
---|
[5134] | 870 | for (var i = 0; i < str.length; i++) { |
---|
| 871 | if (str.charAt(i) == "+") result += " "; |
---|
| 872 | else result += str.charAt(i); |
---|
[4855] | 873 | } |
---|
[5134] | 874 | return unescape(result); |
---|
| 875 | |
---|
[4855] | 876 | } |
---|
| 877 | |
---|
[569] | 878 | function Element (el) { |
---|
| 879 | return document.getElementById(el); |
---|
[2] | 880 | } |
---|
| 881 | |
---|
| 882 | function getPosition(obj) |
---|
| 883 | { |
---|
| 884 | if(typeof obj.selectionStart != "undefined") |
---|
| 885 | { |
---|
| 886 | return obj.selectionStart; |
---|
| 887 | } |
---|
| 888 | else if(document.selection && document.selection.createRange) |
---|
| 889 | { |
---|
| 890 | var M = document.selection.createRange(); |
---|
| 891 | try |
---|
| 892 | { |
---|
| 893 | var Lp = M.duplicate(); |
---|
| 894 | Lp.moveToElementText(obj); |
---|
| 895 | } |
---|
| 896 | catch(e) |
---|
| 897 | { |
---|
| 898 | var Lp=obj.createTextRange(); |
---|
| 899 | } |
---|
[3369] | 900 | |
---|
[2] | 901 | Lp.setEndPoint("EndToStart",M); |
---|
| 902 | var rb=Lp.text.length; |
---|
[3369] | 903 | |
---|
[2] | 904 | if(rb > obj.value.length) |
---|
| 905 | { |
---|
| 906 | return -1; |
---|
| 907 | } |
---|
| 908 | return rb; |
---|
| 909 | } |
---|
| 910 | } |
---|
| 911 | |
---|
| 912 | function trim(inputString) { |
---|
[3369] | 913 | if (typeof inputString != "string") |
---|
[2] | 914 | return inputString; |
---|
[3369] | 915 | |
---|
[2] | 916 | var retValue = inputString; |
---|
| 917 | var ch = retValue.substring(0, 1); |
---|
[3369] | 918 | while (ch == " ") { |
---|
[2] | 919 | retValue = retValue.substring(1, retValue.length); |
---|
| 920 | ch = retValue.substring(0, 1); |
---|
| 921 | } |
---|
| 922 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
[3369] | 923 | while (ch == " ") { |
---|
[2] | 924 | retValue = retValue.substring(0, retValue.length-1); |
---|
| 925 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
| 926 | } |
---|
[3369] | 927 | while (retValue.indexOf(" ") != -1) { |
---|
| 928 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
[2] | 929 | } |
---|
[3369] | 930 | return retValue; |
---|
[2] | 931 | } |
---|
| 932 | |
---|
| 933 | function increment_folder_unseen(){ |
---|
| 934 | var folder_id = get_current_folder(); |
---|
[812] | 935 | |
---|
[2] | 936 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
[406] | 937 | var abas_unseen = Element('new_m').innerHTML; |
---|
[3742] | 938 | abas_unseen = abas_unseen.match(/(<font.*?>){0,1} *([0-9]+) *(<\/font>){0,1}/)[2]; |
---|
[406] | 939 | |
---|
[2] | 940 | if (folder_unseen) |
---|
| 941 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + 1); |
---|
| 942 | else |
---|
| 943 | { |
---|
[823] | 944 | 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] | 945 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 946 | } |
---|
[3742] | 947 | |
---|
| 948 | if( abas_unseen == NaN || abas_unseen == undefined ) |
---|
| 949 | abas_unseen = 1; |
---|
| 950 | else |
---|
[812] | 951 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
[3742] | 952 | |
---|
| 953 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
| 954 | |
---|
[1000] | 955 | if ( current_folder.indexOf( 'INBOX' ) !== 0 && current_folder.indexOf( 'local_' ) !== 0 ) |
---|
[823] | 956 | { |
---|
| 957 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
| 958 | if ( display_unseen_in_shared_folders ) |
---|
| 959 | 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")}); |
---|
| 960 | else |
---|
| 961 | 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")}); |
---|
| 962 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
| 963 | } |
---|
| 964 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
[1121] | 965 | if(!expresso_offline) |
---|
| 966 | var node_to_refresh = 'root'; |
---|
| 967 | else |
---|
| 968 | var node_to_refresh = 'local_root'; |
---|
| 969 | tree_folders.getNodeById( node_to_refresh )._refresh(); |
---|
[2] | 970 | } |
---|
[3742] | 971 | |
---|
[2] | 972 | function decrement_folder_unseen(){ |
---|
| 973 | var folder_id = get_current_folder(); |
---|
[812] | 974 | |
---|
[2] | 975 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
[406] | 976 | var abas_unseen = Element('new_m').innerHTML; |
---|
[3742] | 977 | abas_unseen = abas_unseen.match( /(<font.*?>){0,1} *([0-9]+) *(<\/font>){0,1}/)[2]; |
---|
[406] | 978 | |
---|
| 979 | if(!folder_unseen || !abas_unseen) |
---|
[2] | 980 | return; |
---|
| 981 | |
---|
| 982 | if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > 1)) |
---|
| 983 | { |
---|
| 984 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - 1); |
---|
| 985 | } |
---|
| 986 | else if (parseInt(folder_unseen.innerHTML) <= 1) |
---|
| 987 | { |
---|
| 988 | var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<'); |
---|
| 989 | var folder_name = tmp_folder_name[0]; |
---|
| 990 | tree_folders.getNodeById(folder_id).alter({caption: folder_name}); |
---|
| 991 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
| 992 | } |
---|
[3742] | 993 | if (parseInt(abas_unseen) > 1) { |
---|
| 994 | Element('new_m').innerHTML = '<font style="color:red">' + (parseInt(abas_unseen) - 1) + '</font>'; |
---|
| 995 | } else { |
---|
[470] | 996 | Element('new_m').innerHTML = '0'; |
---|
[5495] | 997 | $(folder_unseen).parent().empty(); |
---|
[406] | 998 | } |
---|
[823] | 999 | if ( current_folder.indexOf( 'INBOX' ) !== 0 ) |
---|
| 1000 | { |
---|
| 1001 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
| 1002 | if ( display_unseen_in_shared_folders ) |
---|
| 1003 | { |
---|
| 1004 | var unseen_in_shared_folders = parseInt( display_unseen_in_shared_folders.innerHTML ); |
---|
| 1005 | unseen_in_shared_folders--; |
---|
| 1006 | if ( unseen_in_shared_folders > 0 ) |
---|
| 1007 | 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")}); |
---|
| 1008 | else |
---|
| 1009 | tree_folders.getNodeById( 'user' ).alter({caption:get_lang("Shared folders")}); |
---|
| 1010 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
| 1011 | } |
---|
| 1012 | } |
---|
| 1013 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
| 1014 | if ( display_unseen_in_mailbox ) |
---|
| 1015 | { |
---|
| 1016 | var unseen_in_mailbox = parseInt( display_unseen_in_mailbox.innerHTML ); |
---|
| 1017 | unseen_in_mailbox--; |
---|
| 1018 | //if ( unseen_in_mailbox > 0 ) |
---|
| 1019 | // 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")}); |
---|
| 1020 | //else |
---|
[1121] | 1021 | if(!expresso_offline) |
---|
| 1022 | var node_to_refresh = 'root'; |
---|
| 1023 | else |
---|
| 1024 | var node_to_refresh = 'local_root'; |
---|
| 1025 | tree_folders.getNodeById( node_to_refresh ).alter({caption:get_lang("My Folders")}); |
---|
| 1026 | tree_folders.getNodeById( node_to_refresh )._refresh(); |
---|
[823] | 1027 | } |
---|
[2] | 1028 | } |
---|
| 1029 | |
---|
| 1030 | function LTrim(value){ |
---|
| 1031 | var w_space = String.fromCharCode(32); |
---|
| 1032 | var strTemp = ""; |
---|
| 1033 | var iTemp = 0; |
---|
[812] | 1034 | |
---|
[814] | 1035 | var v_length = value ? value.length : 0; |
---|
[2] | 1036 | if(v_length < 1) |
---|
| 1037 | return ""; |
---|
| 1038 | |
---|
| 1039 | while(iTemp < v_length){ |
---|
| 1040 | if(value && value.charAt(iTemp) != w_space){ |
---|
| 1041 | strTemp = value.substring(iTemp,v_length); |
---|
| 1042 | break; |
---|
| 1043 | } |
---|
| 1044 | iTemp++; |
---|
[812] | 1045 | } |
---|
[2] | 1046 | return strTemp; |
---|
| 1047 | } |
---|
| 1048 | |
---|
| 1049 | //changes MENU background color. |
---|
| 1050 | function set_menu_bg(menu) |
---|
| 1051 | { |
---|
[5497] | 1052 | // TODO - remover esta função, por hora, apenas um retrun true para preservar menor impacto |
---|
| 1053 | return true; |
---|
[2] | 1054 | menu.style.backgroundColor = 'white'; |
---|
| 1055 | menu.style.border = '1px solid black'; |
---|
[814] | 1056 | menu.style.padding = '0px 0px'; |
---|
[2] | 1057 | } |
---|
| 1058 | //changes MENU background color. |
---|
| 1059 | function unset_menu_bg(menu) |
---|
| 1060 | { |
---|
[5497] | 1061 | // TODO - remover esta função, por hora, apenas um retrun true para preservar menor impacto |
---|
| 1062 | return true; |
---|
[2] | 1063 | menu.style.backgroundColor = ''; |
---|
[814] | 1064 | menu.style.border = '0px'; |
---|
| 1065 | menu.style.padding = '1px 0px'; |
---|
[2] | 1066 | } |
---|
| 1067 | |
---|
[46] | 1068 | function array_search(needle, haystack) { |
---|
| 1069 | var n = haystack.length; |
---|
| 1070 | for (var i=0; i<n; i++) { |
---|
| 1071 | if (haystack[i]==needle) { |
---|
| 1072 | return true; |
---|
| 1073 | } |
---|
| 1074 | } |
---|
| 1075 | return false; |
---|
[96] | 1076 | } |
---|
| 1077 | |
---|
[812] | 1078 | function lang_folder(fn) { |
---|
[689] | 1079 | if (fn.toUpperCase() == "INBOX") return get_lang("Inbox"); |
---|
[365] | 1080 | if (special_folders[fn] && typeof(special_folders[fn]) == 'string') { |
---|
[96] | 1081 | return get_lang(special_folders[fn]); |
---|
[673] | 1082 | } |
---|
[96] | 1083 | return fn; |
---|
[812] | 1084 | } |
---|
[163] | 1085 | |
---|
| 1086 | function add_className(obj, className){ |
---|
[651] | 1087 | if (obj && !exist_className(obj, className)) |
---|
[163] | 1088 | obj.className = obj.className + ' ' + className; |
---|
| 1089 | } |
---|
| 1090 | |
---|
| 1091 | function remove_className(obj, className){ |
---|
| 1092 | var re = new RegExp("\\s*"+className); |
---|
[320] | 1093 | if (obj) |
---|
[976] | 1094 | obj.className = obj.className.replace(re, ' '); |
---|
[163] | 1095 | } |
---|
| 1096 | |
---|
| 1097 | function exist_className(obj, className){ |
---|
[651] | 1098 | return ( obj && obj.className.indexOf(className) != -1 ) |
---|
[163] | 1099 | } |
---|
| 1100 | |
---|
[5134] | 1101 | //Verifica se ainda existem mensagens marcadas, se não desmarca |
---|
| 1102 | //o selecionar todas. |
---|
| 1103 | function remove_chk_box_select_all_messages(){ |
---|
| 1104 | var main = Element("tbody_box"); |
---|
| 1105 | var main_list = main.childNodes; |
---|
| 1106 | var len_main_list = main_list.length; |
---|
| 1107 | for (i=0; i<len_main_list; i++) |
---|
| 1108 | { |
---|
| 1109 | if (Element("check_box_message_"+main_list[i].id).checked){ |
---|
| 1110 | return; |
---|
| 1111 | } |
---|
| 1112 | } |
---|
| 1113 | document.getElementById("chk_box_select_all_messages").checked = false; |
---|
| 1114 | } |
---|
| 1115 | |
---|
[163] | 1116 | function select_all_messages(select) |
---|
| 1117 | { |
---|
| 1118 | var main = Element("tbody_box"); |
---|
| 1119 | var main_list = main.childNodes; |
---|
| 1120 | var len_main_list = main_list.length; |
---|
[3369] | 1121 | |
---|
[163] | 1122 | if (select) |
---|
| 1123 | { |
---|
| 1124 | for (i=0; i<len_main_list; i++) |
---|
| 1125 | { |
---|
| 1126 | Element("check_box_message_"+main_list[i].id).checked = true; |
---|
[5134] | 1127 | remove_className(Element(main_list[i].id), 'selected_msg'); |
---|
| 1128 | add_className(Element(main_list[i].id), 'selected_msg selected_shortcut_msg'); |
---|
[163] | 1129 | } |
---|
| 1130 | } |
---|
| 1131 | else |
---|
| 1132 | { |
---|
| 1133 | for (i=0; i<len_main_list; i++) |
---|
| 1134 | { |
---|
| 1135 | Element("check_box_message_"+main_list[i].id).checked = false; |
---|
[5134] | 1136 | remove_className(Element(main_list[i].id), 'selected_msg selected_shortcut_msg'); |
---|
[163] | 1137 | } |
---|
| 1138 | } |
---|
| 1139 | } |
---|
[1622] | 1140 | |
---|
[3064] | 1141 | function borkb(size){ |
---|
| 1142 | kbyte = 1024; |
---|
| 1143 | mbyte = kbyte*1024; |
---|
| 1144 | gbyte = mbyte*1024; |
---|
| 1145 | if (!size) |
---|
| 1146 | size = 0; |
---|
| 1147 | if (size < kbyte) |
---|
| 1148 | return size + ' B'; |
---|
| 1149 | else if (size < mbyte) |
---|
| 1150 | return parseInt(size/kbyte) + ' KB'; |
---|
| 1151 | else if (size < gbyte) |
---|
| 1152 | if (size/mbyte > 100) |
---|
| 1153 | return (size/mbyte).toFixed(0) + ' MB'; |
---|
| 1154 | else |
---|
| 1155 | return (size/mbyte).toFixed(1) + ' MB'; |
---|
| 1156 | else |
---|
| 1157 | return (size/gbyte).toFixed(1) + ' GB'; |
---|
| 1158 | } |
---|
[3018] | 1159 | |
---|
[5134] | 1160 | //valida se a primeira data é menor que a segunda data |
---|
| 1161 | function validate_date_order(dateStart, dateEnd){ |
---|
| 1162 | if ( parseInt( dateEnd.split( "/" )[2].toString() + dateEnd.split( "/" )[1].toString() + dateEnd.split( "/" )[0].toString() ) >= parseInt( dateStart.split( "/" )[2].toString() + dateStart.split( "/" )[1].toString() + dateStart.split( "/" )[0].toString() ) ){ |
---|
| 1163 | return true; |
---|
| 1164 | }else{ |
---|
| 1165 | return false; |
---|
| 1166 | } |
---|
| 1167 | } |
---|
| 1168 | |
---|
[1622] | 1169 | function validate_date(date){ |
---|
| 1170 | if (date.match(/^[0-3][0-9]\/[0-1][0-9]\/\d{4,4}$/)) |
---|
| 1171 | { |
---|
| 1172 | tmp = date.split('/'); |
---|
| 1173 | |
---|
| 1174 | day = new Number(tmp[0]); |
---|
| 1175 | month = new Number(tmp[1]); |
---|
| 1176 | year = new Number(tmp[2]); |
---|
| 1177 | if (month >= 1 && month <= 12 && day >= 1 && day <= 31) |
---|
| 1178 | { |
---|
| 1179 | if (month == 02 && day <= 29) |
---|
| 1180 | { |
---|
| 1181 | return true; |
---|
| 1182 | } |
---|
| 1183 | return true; |
---|
| 1184 | } |
---|
| 1185 | else |
---|
| 1186 | { |
---|
| 1187 | return false; |
---|
| 1188 | } |
---|
| 1189 | } |
---|
| 1190 | else |
---|
| 1191 | { |
---|
| 1192 | return false; |
---|
| 1193 | } |
---|
| 1194 | } |
---|
[3834] | 1195 | |
---|
| 1196 | function dateMask(inputData, e){ |
---|
| 1197 | if(document.all) // Internet Explorer |
---|
| 1198 | var tecla = event.keyCode; |
---|
| 1199 | else //Outros Browsers |
---|
| 1200 | var tecla = e.which; |
---|
| 1201 | |
---|
| 1202 | if(tecla >= 47 && tecla < 58){ // numeros de 0 a 9 e "/" |
---|
| 1203 | var data = inputData.value; |
---|
| 1204 | if (data.length == 2 || data.length == 5){ |
---|
| 1205 | data += '/'; |
---|
| 1206 | inputData.value = data; |
---|
| 1207 | } |
---|
| 1208 | } else { |
---|
| 1209 | if(tecla == 8 || tecla == 0) // Backspace, Delete e setas direcionais(para mover o cursor, apenas para FF) |
---|
| 1210 | return true; |
---|
| 1211 | else |
---|
| 1212 | return false; |
---|
| 1213 | } |
---|
[4749] | 1214 | } |
---|
| 1215 | |
---|
| 1216 | function translateFolder(folderName){ |
---|
| 1217 | |
---|
| 1218 | for (var i = 0; i < folders.length; i++) |
---|
| 1219 | { |
---|
| 1220 | if (folders[i].folder_parent == 'user' |
---|
| 1221 | && folderName == folders[i].folder_id.split(cyrus_delimiter).pop()) |
---|
| 1222 | { |
---|
| 1223 | if (folders[i].folder_id.split(cyrus_delimiter).pop() != folders[i].folder_name) |
---|
| 1224 | { |
---|
| 1225 | return folders[i].folder_name; |
---|
| 1226 | } |
---|
| 1227 | } |
---|
| 1228 | } |
---|
| 1229 | |
---|
| 1230 | return folderName; |
---|
[5695] | 1231 | } |
---|