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 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 | add_className(tr_message, 'tr_msg_read'); |
---|
111 | purgeCache(); |
---|
112 | return true; |
---|
113 | } |
---|
114 | |
---|
115 | function msg_is_read(msg_number, selected){ |
---|
116 | tr_message = Element(msg_number); |
---|
117 | return !(tr_message && LTrim(tr_message.className).match('tr_msg_unread')) |
---|
118 | } |
---|
119 | |
---|
120 | function set_msg_as_unread(msg_number){ |
---|
121 | tr_message = Element(msg_number); |
---|
122 | if (exist_className(tr_message, 'tr_msg_read')) |
---|
123 | increment_folder_unseen(); |
---|
124 | remove_className(tr_message, 'tr_msg_read'); |
---|
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 (!is_ie) { |
---|
241 | var inputFile = document.createElement("INPUT"); |
---|
242 | |
---|
243 | var tmp_id_border = document.createAttribute('id_border'); |
---|
244 | tmp_id_border.value = id_border; |
---|
245 | |
---|
246 | inputFile.setAttributeNode(tmp_id_border); |
---|
247 | inputFile.id = "inputFile_" + id_border + "_" + countDivFiles; |
---|
248 | inputFile.type = 'file'; |
---|
249 | inputFile.size = 50; |
---|
250 | inputFile.maxLength = 255; |
---|
251 | inputFile.name = 'file_' + countDivFiles; |
---|
252 | inputFile.style.display = "none"; |
---|
253 | divFile.appendChild(inputFile); |
---|
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 | divFile.appendChild(inputFile); |
---|
267 | } |
---|
268 | |
---|
269 | var a_tmp = new Array(); |
---|
270 | a_tmp[0] = "local_"; |
---|
271 | a_tmp[1] = 'file_' + countDivFiles; |
---|
272 | a_tmp[2] = file_name; |
---|
273 | s_tmp = escape(connector.serialize(a_tmp)); |
---|
274 | var checkbox = document.createElement("INPUT"); |
---|
275 | checkbox.type = "checkbox"; |
---|
276 | checkbox.id = "checkbox_"+id_border+"_"+countDivFiles; |
---|
277 | checkbox.name = "local_attachments[]"; |
---|
278 | |
---|
279 | checkbox.value = s_tmp; |
---|
280 | divFile.appendChild(checkbox); |
---|
281 | |
---|
282 | var link_attachment = document.createElement("A"); |
---|
283 | link_attachment.setAttribute("href", link); |
---|
284 | |
---|
285 | link_attachment.innerHTML = file_name; |
---|
286 | divFile.appendChild(link_attachment); |
---|
287 | |
---|
288 | countDivFiles++; |
---|
289 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
290 | divFiles.appendChild(divFile); |
---|
291 | |
---|
292 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
293 | divFiles.appendChild(divFile); |
---|
294 | 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... |
---|
295 | return inputFile; |
---|
296 | } |
---|
297 | |
---|
298 | // Add Input File Dynamically. |
---|
299 | function addFile(id_border){ |
---|
300 | divFiles = document.getElementById("divFiles_"+id_border); |
---|
301 | if (! divFiles) |
---|
302 | return false; |
---|
303 | |
---|
304 | if (divFiles.lastChild) |
---|
305 | var countDivFiles = parseInt(divFiles.lastChild.id.split('_')[2]) + 1; |
---|
306 | |
---|
307 | if (! countDivFiles) |
---|
308 | var countDivFiles = 1; |
---|
309 | |
---|
310 | divFile = document.createElement('DIV'); |
---|
311 | |
---|
312 | var inputFile = document.createElement("INPUT"); |
---|
313 | |
---|
314 | var tmp_id_border = document.createAttribute('id_border'); |
---|
315 | tmp_id_border.value = id_border; |
---|
316 | |
---|
317 | inputFile.setAttributeNode(tmp_id_border); |
---|
318 | inputFile.id = "inputFile_"+id_border+"_"+countDivFiles; |
---|
319 | inputFile.onchange = function () {validateFileExtension(this.value, this.id.replace("input","div"), this.getAttribute('id_border'));}; |
---|
320 | inputFile.type = 'file'; |
---|
321 | inputFile.size = 50; |
---|
322 | inputFile.maxLength = 255; |
---|
323 | inputFile.name='file_'+countDivFiles; |
---|
324 | |
---|
325 | divFile.appendChild(inputFile); |
---|
326 | |
---|
327 | var linkFile = document.createElement("A"); |
---|
328 | linkFile.id = "linkFile_"+id_border+"_"+countDivFiles; |
---|
329 | linkFile.href='javascript:void(0)'; |
---|
330 | linkFile.onclick=function () {removeFile(this.id.replace("link","div")); return false;}; |
---|
331 | linkFile.innerHTML=get_lang("Remove"); |
---|
332 | //divFile.innerHTML += " "; |
---|
333 | divFile.appendChild(linkFile); |
---|
334 | divFile.id = "divFile_"+id_border+"_"+countDivFiles; |
---|
335 | divFiles.appendChild(divFile); |
---|
336 | |
---|
337 | return inputFile; |
---|
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 | |
---|
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 | if(preferences.type_signature && preferences.type_signature == 'html') { |
---|
561 | location.href="../preferences/preferences.php?appname=expressoMail"; |
---|
562 | } |
---|
563 | else { |
---|
564 | connector.loadScript("preferences"); |
---|
565 | prefe.showList(); |
---|
566 | } |
---|
567 | } |
---|
568 | |
---|
569 | function search_emails(value){ |
---|
570 | connector.loadScript("search"); |
---|
571 | EsearchE.showForms(value); |
---|
572 | } |
---|
573 | |
---|
574 | function source_msg(id_msg,folder){ |
---|
575 | var num_msg = id_msg.substr(0,(id_msg.length - 2)); |
---|
576 | var handler_source = function(data){ |
---|
577 | download_attachments(null, null, data, null,null,'fonte_da_mensagem.txt'); |
---|
578 | } |
---|
579 | cExecute("$this.exporteml.export_msg",handler_source,"folder="+url_decode(folder)+"&msgs_to_export="+num_msg); |
---|
580 | } |
---|
581 | |
---|
582 | function url_encode(str){ |
---|
583 | var hex_chars = "0123456789ABCDEF"; |
---|
584 | var noEncode = /^([a-zA-Z0-9\_\-\.])$/; |
---|
585 | var n, strCode, hex1, hex2, strEncode = ""; |
---|
586 | |
---|
587 | for(n = 0; n < str.length; n++) { |
---|
588 | if (noEncode.test(str.charAt(n))) { |
---|
589 | strEncode += str.charAt(n); |
---|
590 | } else { |
---|
591 | strCode = str.charCodeAt(n); |
---|
592 | hex1 = hex_chars.charAt(Math.floor(strCode / 16)); |
---|
593 | hex2 = hex_chars.charAt(strCode % 16); |
---|
594 | strEncode += "%" + (hex1 + hex2); |
---|
595 | } |
---|
596 | } |
---|
597 | return strEncode; |
---|
598 | } |
---|
599 | |
---|
600 | function url_decode(str) { |
---|
601 | |
---|
602 | var n, strCode, strDecode = ""; |
---|
603 | for (n = 0; n < str.length; n++) { |
---|
604 | if (str.charAt(n) == "%") { |
---|
605 | strCode = str.charAt(n + 1) + str.charAt(n + 2); |
---|
606 | strDecode += String.fromCharCode(parseInt(strCode, 16)); |
---|
607 | n += 2; |
---|
608 | } else { |
---|
609 | strDecode += str.charAt(n); |
---|
610 | } |
---|
611 | } |
---|
612 | return strDecode; |
---|
613 | } |
---|
614 | |
---|
615 | function Element (el) { |
---|
616 | return document.getElementById(el); |
---|
617 | } |
---|
618 | |
---|
619 | function getPosition(obj) |
---|
620 | { |
---|
621 | if(typeof obj.selectionStart != "undefined") |
---|
622 | { |
---|
623 | return obj.selectionStart; |
---|
624 | } |
---|
625 | else if(document.selection && document.selection.createRange) |
---|
626 | { |
---|
627 | var M = document.selection.createRange(); |
---|
628 | try |
---|
629 | { |
---|
630 | var Lp = M.duplicate(); |
---|
631 | Lp.moveToElementText(obj); |
---|
632 | } |
---|
633 | catch(e) |
---|
634 | { |
---|
635 | var Lp=obj.createTextRange(); |
---|
636 | } |
---|
637 | |
---|
638 | Lp.setEndPoint("EndToStart",M); |
---|
639 | var rb=Lp.text.length; |
---|
640 | |
---|
641 | if(rb > obj.value.length) |
---|
642 | { |
---|
643 | return -1; |
---|
644 | } |
---|
645 | return rb; |
---|
646 | } |
---|
647 | } |
---|
648 | |
---|
649 | function trim(inputString) { |
---|
650 | if (typeof inputString != "string") |
---|
651 | return inputString; |
---|
652 | |
---|
653 | var retValue = inputString; |
---|
654 | var ch = retValue.substring(0, 1); |
---|
655 | while (ch == " ") { |
---|
656 | retValue = retValue.substring(1, retValue.length); |
---|
657 | ch = retValue.substring(0, 1); |
---|
658 | } |
---|
659 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
660 | while (ch == " ") { |
---|
661 | retValue = retValue.substring(0, retValue.length-1); |
---|
662 | ch = retValue.substring(retValue.length-1, retValue.length); |
---|
663 | } |
---|
664 | while (retValue.indexOf(" ") != -1) { |
---|
665 | retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); |
---|
666 | } |
---|
667 | return retValue; |
---|
668 | } |
---|
669 | |
---|
670 | function increment_folder_unseen(){ |
---|
671 | var folder_id = get_current_folder(); |
---|
672 | |
---|
673 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
674 | var abas_unseen = Element('new_m').innerHTML; |
---|
675 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
676 | |
---|
677 | if (folder_unseen) |
---|
678 | { |
---|
679 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) + 1); |
---|
680 | } |
---|
681 | else |
---|
682 | { |
---|
683 | 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>'}); |
---|
684 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
685 | } |
---|
686 | if (abas_unseen) |
---|
687 | { |
---|
688 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
689 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
690 | } |
---|
691 | else{ |
---|
692 | abas_unseen = Element('new_m').innerHTML; |
---|
693 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
694 | abas_unseen = parseInt(abas_unseen) + 1; |
---|
695 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
696 | } |
---|
697 | if ( current_folder.indexOf( 'INBOX' ) !== 0 ) |
---|
698 | { |
---|
699 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
700 | if ( display_unseen_in_shared_folders ) |
---|
701 | 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")}); |
---|
702 | else |
---|
703 | 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")}); |
---|
704 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
705 | } |
---|
706 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
707 | 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")}); |
---|
708 | tree_folders.getNodeById( 'root' )._refresh(); |
---|
709 | } |
---|
710 | function decrement_folder_unseen(){ |
---|
711 | var folder_id = get_current_folder(); |
---|
712 | |
---|
713 | var folder_unseen = Element('dftree_'+folder_id+'_unseen'); |
---|
714 | var abas_unseen = Element('new_m').innerHTML; |
---|
715 | abas_unseen = abas_unseen.match( /[0-9]+/); |
---|
716 | |
---|
717 | if(!folder_unseen || !abas_unseen) |
---|
718 | return; |
---|
719 | |
---|
720 | if ((folder_unseen) && (parseInt(folder_unseen.innerHTML) > 1)) |
---|
721 | { |
---|
722 | folder_unseen.innerHTML = (parseInt(folder_unseen.innerHTML) - 1); |
---|
723 | } |
---|
724 | else if (parseInt(folder_unseen.innerHTML) <= 1) |
---|
725 | { |
---|
726 | var tmp_folder_name = tree_folders.getNodeById(folder_id).caption.split('<'); |
---|
727 | var folder_name = tmp_folder_name[0]; |
---|
728 | tree_folders.getNodeById(folder_id).alter({caption: folder_name}); |
---|
729 | tree_folders.getNodeById(folder_id)._refresh(); |
---|
730 | } |
---|
731 | if ((abas_unseen) && (parseInt(abas_unseen) > 1)) |
---|
732 | { |
---|
733 | abas_unseen = (parseInt(abas_unseen) - 1); |
---|
734 | Element('new_m').innerHTML = '<font style="color:red">' + abas_unseen + '</font>'; |
---|
735 | } |
---|
736 | else if (parseInt(abas_unseen) <= 1) |
---|
737 | { |
---|
738 | Element('new_m').innerHTML = '0'; |
---|
739 | } |
---|
740 | if ( current_folder.indexOf( 'INBOX' ) !== 0 ) |
---|
741 | { |
---|
742 | var display_unseen_in_shared_folders = Element('dftree_user_unseen'); |
---|
743 | if ( display_unseen_in_shared_folders ) |
---|
744 | { |
---|
745 | var unseen_in_shared_folders = parseInt( display_unseen_in_shared_folders.innerHTML ); |
---|
746 | unseen_in_shared_folders--; |
---|
747 | if ( unseen_in_shared_folders > 0 ) |
---|
748 | 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")}); |
---|
749 | else |
---|
750 | tree_folders.getNodeById( 'user' ).alter({caption:get_lang("Shared folders")}); |
---|
751 | tree_folders.getNodeById( 'user' )._refresh(); |
---|
752 | } |
---|
753 | } |
---|
754 | var display_unseen_in_mailbox = Element('dftree_root_unseen'); |
---|
755 | if ( display_unseen_in_mailbox ) |
---|
756 | { |
---|
757 | var unseen_in_mailbox = parseInt( display_unseen_in_mailbox.innerHTML ); |
---|
758 | unseen_in_mailbox--; |
---|
759 | //if ( unseen_in_mailbox > 0 ) |
---|
760 | // 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")}); |
---|
761 | //else |
---|
762 | tree_folders.getNodeById( 'root' ).alter({caption:get_lang("My Folders")}); |
---|
763 | tree_folders.getNodeById( 'root' )._refresh(); |
---|
764 | } |
---|
765 | } |
---|
766 | |
---|
767 | function LTrim(value){ |
---|
768 | var w_space = String.fromCharCode(32); |
---|
769 | var strTemp = ""; |
---|
770 | var iTemp = 0; |
---|
771 | |
---|
772 | var v_length = value ? value.length : 0; |
---|
773 | if(v_length < 1) |
---|
774 | return ""; |
---|
775 | |
---|
776 | while(iTemp < v_length){ |
---|
777 | if(value && value.charAt(iTemp) != w_space){ |
---|
778 | strTemp = value.substring(iTemp,v_length); |
---|
779 | break; |
---|
780 | } |
---|
781 | iTemp++; |
---|
782 | } |
---|
783 | return strTemp; |
---|
784 | } |
---|
785 | |
---|
786 | //changes MENU background color. |
---|
787 | function set_menu_bg(menu) |
---|
788 | { |
---|
789 | menu.style.backgroundColor = 'white'; |
---|
790 | menu.style.border = '1px solid black'; |
---|
791 | menu.style.padding = '0px 0px'; |
---|
792 | } |
---|
793 | //changes MENU background color. |
---|
794 | function unset_menu_bg(menu) |
---|
795 | { |
---|
796 | menu.style.backgroundColor = ''; |
---|
797 | menu.style.border = '0px'; |
---|
798 | menu.style.padding = '1px 0px'; |
---|
799 | } |
---|
800 | |
---|
801 | function array_search(needle, haystack) { |
---|
802 | var n = haystack.length; |
---|
803 | for (var i=0; i<n; i++) { |
---|
804 | if (haystack[i]==needle) { |
---|
805 | return true; |
---|
806 | } |
---|
807 | } |
---|
808 | return false; |
---|
809 | } |
---|
810 | |
---|
811 | function lang_folder(fn) { |
---|
812 | if (fn.toUpperCase() == "INBOX") return get_lang("Inbox"); |
---|
813 | if (special_folders[fn] && typeof(special_folders[fn]) == 'string') { |
---|
814 | return get_lang(special_folders[fn]); |
---|
815 | } |
---|
816 | return fn; |
---|
817 | } |
---|
818 | |
---|
819 | function add_className(obj, className){ |
---|
820 | if (obj && !exist_className(obj, className)) |
---|
821 | obj.className = obj.className + ' ' + className; |
---|
822 | } |
---|
823 | |
---|
824 | function remove_className(obj, className){ |
---|
825 | var re = new RegExp("\\s*"+className); |
---|
826 | if (obj) |
---|
827 | obj.className = obj.className.replace(re, ''); |
---|
828 | } |
---|
829 | |
---|
830 | function exist_className(obj, className){ |
---|
831 | return ( obj && obj.className.indexOf(className) != -1 ) |
---|
832 | } |
---|
833 | |
---|
834 | function select_all_messages(select) |
---|
835 | { |
---|
836 | var main = Element("tbody_box"); |
---|
837 | var main_list = main.childNodes; |
---|
838 | var len_main_list = main_list.length; |
---|
839 | |
---|
840 | if (select) |
---|
841 | { |
---|
842 | for (i=0; i<len_main_list; i++) |
---|
843 | { |
---|
844 | Element("check_box_message_"+main_list[i].id).checked = true; |
---|
845 | add_className(Element(main_list[i].id), 'selected_msg'); |
---|
846 | } |
---|
847 | } |
---|
848 | else |
---|
849 | { |
---|
850 | for (i=0; i<len_main_list; i++) |
---|
851 | { |
---|
852 | Element("check_box_message_"+main_list[i].id).checked = false; |
---|
853 | remove_className(Element(main_list[i].id), 'selected_msg'); |
---|
854 | } |
---|
855 | } |
---|
856 | } |
---|