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