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