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