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