1 | /**************************************************************************\ |
---|
2 | Início |
---|
3 | \**************************************************************************/ |
---|
4 | function searchE() |
---|
5 | { |
---|
6 | this.totalPages = 1; |
---|
7 | this.numPages = 5; |
---|
8 | this.lastPage = 0; |
---|
9 | this.searchW = []; |
---|
10 | this.condition = ""; |
---|
11 | this.sort_type = ""; |
---|
12 | //this.page = 0; |
---|
13 | this.name_box_search = ""; |
---|
14 | this.all_boxes = []; |
---|
15 | this.type = ""; |
---|
16 | this.txtfields = new Array("txt_ass","txt_de","txt_body","txt_para","txt_cc","txt_cco", "since_date", "before_date", "on_date"); |
---|
17 | this.selectFields = new Array("flagged", "seen", "answered", "recent"); |
---|
18 | } |
---|
19 | |
---|
20 | //Monta os forms dentro da janela; |
---|
21 | searchE.prototype.showForms = function(value) |
---|
22 | { |
---|
23 | // Principal |
---|
24 | if(!Element("window_search")) |
---|
25 | { |
---|
26 | var form_search = document.createElement("DIV"); |
---|
27 | form_search.style.visibility = 'hidden'; |
---|
28 | form_search.style.top = '0px'; |
---|
29 | form_search.style.left = '0px'; |
---|
30 | form_search.id = "window_search"; |
---|
31 | document.body.appendChild(form_search); |
---|
32 | } |
---|
33 | |
---|
34 | // Pesquisa |
---|
35 | if(!Element("div_form_search")) |
---|
36 | { |
---|
37 | var div_form_search = document.createElement("DIV"); |
---|
38 | div_form_search.id = "div_form_search"; |
---|
39 | div_form_search.style.position = "absolute"; |
---|
40 | div_form_search.style.left = "10px"; |
---|
41 | div_form_search.style.top = "10px"; |
---|
42 | div_form_search.style.borderStyle = "outset"; |
---|
43 | div_form_search.style.borderColor = "black"; |
---|
44 | div_form_search.style.borderWidth = "1px"; |
---|
45 | div_form_search.style.width = "784px"; |
---|
46 | div_form_search.style.height = "418px"; |
---|
47 | div_form_search.style.overflow = "hidden"; |
---|
48 | div_form_search.innerHTML = ""; |
---|
49 | var call_form_search = EsearchE.mount_form(); |
---|
50 | div_form_search.appendChild(call_form_search); |
---|
51 | form_search.appendChild(div_form_search); |
---|
52 | |
---|
53 | Calendar._TT['WEEKEND'] = '0,6'; // hack |
---|
54 | Calendar._TT['DAY_FIRST'] = 'Mostrar %s primeiro'; |
---|
55 | Calendar.setup({ |
---|
56 | inputField : 'since_date', |
---|
57 | button : 'since_date-trigger', |
---|
58 | ifFormat : '%d/%m/%Y', |
---|
59 | daFormat : '%d/%m/%Y' |
---|
60 | }); |
---|
61 | |
---|
62 | Calendar.setup({ |
---|
63 | inputField : 'before_date', |
---|
64 | button : 'before_date-trigger', |
---|
65 | ifFormat : '%d/%m/%Y', |
---|
66 | daFormat : '%d/%m/%Y' |
---|
67 | }); |
---|
68 | |
---|
69 | Calendar.setup({ |
---|
70 | inputField : 'on_date', |
---|
71 | button : 'on_date-trigger', |
---|
72 | ifFormat : '%d/%m/%Y', |
---|
73 | daFormat : '%d/%m/%Y' |
---|
74 | }); |
---|
75 | |
---|
76 | } |
---|
77 | |
---|
78 | if(!Element("div_button_search")){ |
---|
79 | var div_button_search = document.createElement("DIV"); |
---|
80 | div_button_search.id = "div_button_search"; |
---|
81 | div_button_search.style.position = "absolute"; |
---|
82 | div_button_search.style.marginLeft = "430px"; |
---|
83 | div_button_search.style.top = "223px"; |
---|
84 | div_button_search.style.width = "350px"; |
---|
85 | div_button_search.style.height = "25px"; |
---|
86 | div_button_search.innerHTML = "<table style='width: 100%;' border='0' cellpadding='0' cellspacing='0' align='center'>"+ |
---|
87 | "<tr>"+ |
---|
88 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Search') + " onclick='EsearchE.func_search()'></td>"+ |
---|
89 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Clean') + " onclick='EsearchE.func_clean()'></td>"+ |
---|
90 | "<td width='33%' align='center'><input type='button' value=" + get_lang('Close') + " onclick='EsearchE.func_close(\"hidden\")'></td>"+ |
---|
91 | "</tr>"+ |
---|
92 | "</table>"; |
---|
93 | form_search.appendChild(div_button_search); |
---|
94 | } |
---|
95 | |
---|
96 | if(!Element("table_layer")){ |
---|
97 | var table_layer = ""; |
---|
98 | } |
---|
99 | |
---|
100 | if(value == "") |
---|
101 | EsearchE.showWindow(Element("window_search")); |
---|
102 | |
---|
103 | // Cria as caixas postais; |
---|
104 | EsearchE.mount_folders(); |
---|
105 | |
---|
106 | if(value) |
---|
107 | { |
---|
108 | Element("check_all_msg").checked = true; |
---|
109 | EsearchE.all_mailboxes(); |
---|
110 | EsearchE.func_search(value, null, 'SORTDATE_REVERSE'); |
---|
111 | } |
---|
112 | |
---|
113 | } |
---|
114 | |
---|
115 | //Form |
---|
116 | searchE.prototype.mount_form = function(value) |
---|
117 | { |
---|
118 | var form_sch = document.createElement("FORM"); |
---|
119 | form_sch.id = "form_sch"; |
---|
120 | |
---|
121 | form_sch.innerHTML = '<fieldset style="width:400px; text-align:right; padding: 5px; position:absolute;">' |
---|
122 | + ' <legend>'+get_lang('Inform your search in the text fields')+'</legend>' |
---|
123 | + ' <label>'+get_lang("From")+':</label>' |
---|
124 | + ' <input style="margin-left: 6px;" type="text" id="txt_de" size="39">' |
---|
125 | + ' <br style="margin-bottom:15px"/>' |
---|
126 | + ' <label>'+get_lang('To')+':</label>' |
---|
127 | + ' <input style="margin-left: 6px;" type="text" id="txt_para" size="39">' |
---|
128 | + ' <br style="margin-bottom:15px"/>' |
---|
129 | + ' <label>'+get_lang('Cc')+':</label>' |
---|
130 | + ' <input style="margin-left: 6px;" type="text" id="txt_cc" size="39">' |
---|
131 | + ' <br style="margin-bottom:15px"/>' |
---|
132 | + ' <label>'+get_lang('Subject')+':</label>' |
---|
133 | + ' <input style="margin-left: 6px;" type="text" id="txt_ass" size="39">' |
---|
134 | + ' <br style="margin-bottom:15px"/>' |
---|
135 | + ' <label>'+get_lang('Message body')+':</label>' |
---|
136 | + ' <input style="margin-left: 6px;" type="text" id="txt_body" size="39">' |
---|
137 | |
---|
138 | + ' <br style="margin-bottom:30px"/>' |
---|
139 | + ' <label>'+get_lang("Since Date")+':</label>' |
---|
140 | + ' <input style="margin-left: 6px;" type="text" id="since_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
141 | + ' <img id="since_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
142 | + ' <label style="margin-left: 20px;">'+get_lang('Before Date')+':</label>' |
---|
143 | + ' <input style="margin-left: 6px;" type="text" id="before_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
144 | + ' <img id="before_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/>' |
---|
145 | + ' <br style="margin-bottom:15px"/>' |
---|
146 | |
---|
147 | + ' <label>'+get_lang('On Date')+':</label>' |
---|
148 | + ' <input style="margin-left: 6px;" type="text" id="on_date" size="8" maxlength="10" onkeypress="return dateMask(this, event);">' |
---|
149 | + ' <img style="margin-right: -8px" id="on_date-trigger" src="../phpgwapi/templates/default/images/datepopup.gif" title="'+get_lang("Select Date")+'" style="cursor:pointer; cursor:hand;"/><span> </span>' |
---|
150 | + ' <br style="margin-bottom:30px"/>' |
---|
151 | |
---|
152 | + ' <label>'+get_lang('Flags')+':</label>' |
---|
153 | + ' <select style="width:15em; margin-left: 6px" name="flagged" id="flagged">' |
---|
154 | + ' <option value=""/>' |
---|
155 | + ' <option value="FLAGGED">'+ get_lang("Flagged") +'</option>' |
---|
156 | + ' <option value="UNFLAGGED">'+ get_lang("Unflagged") +'</option>' |
---|
157 | + ' </select>' |
---|
158 | + ' <br style="margin-bottom:15px"/>' |
---|
159 | + ' <select style="width:15em;" name="seen" id="seen">' |
---|
160 | + ' <option value=""/>' |
---|
161 | + ' <option value="SEEN">'+ get_lang("Seen") +'</option>' |
---|
162 | + ' <option value="UNSEEN">'+ get_lang("Unseen") +'</option>' |
---|
163 | + ' </select>' |
---|
164 | + ' <br style="margin-bottom:15px"/>' |
---|
165 | + ' <select style="width:15em;" name="answered" id="answered">' |
---|
166 | + ' <option value=""/>' |
---|
167 | + ' <option value="ANSWERED">'+ get_lang('Answered/Forwarded') +'</option>' |
---|
168 | + ' <option value="UNANSWERED">'+ get_lang('Unanswered/Unforwarded') +'</option>' |
---|
169 | + ' </select>' |
---|
170 | + ' <br style="margin-bottom:15px"/>' |
---|
171 | + ' <select style="width:15em;visibility:hidden;" name="recent" id="recent">' |
---|
172 | + ' <option value=""/>' |
---|
173 | + ' <option value="RECENT">'+ get_lang('Recent') +'</option>' |
---|
174 | + ' <option value="OLD">'+ get_lang('Old') +'</option>' |
---|
175 | + ' </select>' |
---|
176 | |
---|
177 | + ' <br style="margin-bottom:60px"/>' |
---|
178 | + '</fieldset>' |
---|
179 | + '<fieldset style="width:350px; padding: 5px; position:absolute; margin-left: 414px">' |
---|
180 | + ' <legend>'+get_lang('Search the messages in these folders')+'</legend>' |
---|
181 | + ' <div id="folders" style="width:160px; height:150px;float:left;margin-bottom:10px;"></div>' |
---|
182 | + ' <div style="float:left;height:100px;padding-top:50px;margin: 0 3px;">' |
---|
183 | + ' <input type="button" id="incluir" name="incluir" value=">>" onclick="EsearchE.add_mailboxes()">' |
---|
184 | + ' <br style="margin-bottom:15px">' |
---|
185 | + ' <input type="button" id="excluir" name="excluir" value="<<" onclick="EsearchE.del_mailboxes()">' |
---|
186 | + ' </div>' |
---|
187 | + ' <div style="float:left;">' |
---|
188 | + ' <select multiple id="sel_search_nm_box1" name="sel_search_nm_box1" style="width:140px;height:150px;"></select>' |
---|
189 | + ' </div>' |
---|
190 | + ' <br clear="both">' |
---|
191 | + ' <input type="checkBox" id="check_all_msg" name="check_all_msg" onclick="EsearchE.all_mailboxes()">' |
---|
192 | + ' <b>'+get_lang('In all the folders')+'</b>' |
---|
193 | + '</fieldset>'; |
---|
194 | |
---|
195 | return form_sch; |
---|
196 | } |
---|
197 | |
---|
198 | // Pastas; |
---|
199 | searchE.prototype.mount_folders = function() |
---|
200 | { |
---|
201 | connector.loadScript("TreeS"); |
---|
202 | |
---|
203 | if( Element("div_folders_search") == null) |
---|
204 | { |
---|
205 | var div_folders = document.createElement("DIV"); |
---|
206 | div_folders.id = "div_folders_search"; |
---|
207 | div_folders.style.width = "155px"; |
---|
208 | div_folders.style.height = "152px"; |
---|
209 | div_folders.style.borderStyle = "outset"; |
---|
210 | div_folders.style.borderColor = "black"; |
---|
211 | div_folders.style.borderWidth = "1px"; |
---|
212 | div_folders.style.background = "#F7F7F7"; |
---|
213 | div_folders.style.overflow = "auto"; |
---|
214 | div_folders.innerHTML = ""; |
---|
215 | var dest_div = Element("folders"); |
---|
216 | dest_div.appendChild(div_folders); |
---|
217 | } |
---|
218 | ttree.make_tree(folders,"div_folders_search","_folders_tree_search","","","",""); |
---|
219 | } |
---|
220 | |
---|
221 | function openpage(data) |
---|
222 | { |
---|
223 | var _data = [3]; |
---|
224 | var _gears = []; |
---|
225 | var local_folders = []; |
---|
226 | |
---|
227 | // Gears - local |
---|
228 | if ( preferences.use_local_messages == 1 ) |
---|
229 | { |
---|
230 | temp = expresso_local_messages.list_local_folders(); |
---|
231 | for (var x in temp) |
---|
232 | { |
---|
233 | local_folders.push(temp[x][0]); |
---|
234 | } |
---|
235 | } |
---|
236 | |
---|
237 | if ( local_folders.length > 0 ) |
---|
238 | _gears = expresso_local_messages.search( local_folders, expresso_local_messages.getFilter() ); |
---|
239 | |
---|
240 | _data['data'] = data['data']; |
---|
241 | _data['num_msgs'] = data['num_msgs']; |
---|
242 | _data['gears_num_msgs'] = _gears.length; |
---|
243 | |
---|
244 | delete_border( data['currentTab'], false); |
---|
245 | |
---|
246 | EsearchE.mount_result(_data); |
---|
247 | } |
---|
248 | |
---|
249 | searchE.prototype.show_paging = function(size) |
---|
250 | { |
---|
251 | var span_pg = Element("span_paging"+currentTab); |
---|
252 | |
---|
253 | if( span_pg == null ) |
---|
254 | { |
---|
255 | span_pg = document.createElement('span'); |
---|
256 | span_pg.id = "span_paging"+currentTab; |
---|
257 | } |
---|
258 | else |
---|
259 | span_pg.innerHTML = ""; |
---|
260 | |
---|
261 | if(size > parseInt(preferences.max_email_per_page)) { |
---|
262 | this.totalPages = Math.ceil(size/preferences.max_email_per_page); |
---|
263 | if((size/preferences.max_email_per_page) > this.totalPages) |
---|
264 | this.totalPages++; |
---|
265 | } |
---|
266 | |
---|
267 | if(this.page != 0 && this.page != null) { |
---|
268 | _link = document.createElement("A"); |
---|
269 | if( this.value ) |
---|
270 | _link.href = 'javascript:EsearchE.quickSearchMail( false, '+0+', false, "'+currentTab+'" )'; |
---|
271 | else{ |
---|
272 | _link.href = 'javascript:EsearchE.page=0;'; |
---|
273 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page=0¤t_tab='+currentTab+'");'; |
---|
274 | } |
---|
275 | } |
---|
276 | else { |
---|
277 | _link = document.createElement("SPAN"); |
---|
278 | } |
---|
279 | span_pg.appendChild(_link); |
---|
280 | |
---|
281 | _link.innerHTML = "<<"; |
---|
282 | _link.title = get_lang("First"); |
---|
283 | span_pg.innerHTML += " "; |
---|
284 | |
---|
285 | if(this.page == this.lastPage + (this.numPages)) |
---|
286 | { |
---|
287 | this.lastPage = this.page - 1; |
---|
288 | } |
---|
289 | else if((this.lastPage != 0 && this.lastPage == this.page) || this.page == (this.totalPages-1)) |
---|
290 | { |
---|
291 | this.lastPage = this.page - (this.numPages - 1); |
---|
292 | } |
---|
293 | else if(this.page == 0) |
---|
294 | { |
---|
295 | this.lastPage = 0; |
---|
296 | } |
---|
297 | |
---|
298 | if(this.lastPage < 0) |
---|
299 | this.lastPage = 0; |
---|
300 | else if(this.lastPage > 0 && (this.lastPage > (this.totalPages -(this.numPages - 1)))) |
---|
301 | this.lastPage = this.totalPages -(this.numPages); |
---|
302 | |
---|
303 | var hasMarked = false; |
---|
304 | if(this.page == null){ |
---|
305 | this.page = 0; |
---|
306 | } |
---|
307 | for(i = this.lastPage; i <= this.totalPages; i++) |
---|
308 | { |
---|
309 | if( ( i * preferences.max_email_per_page ) > size) |
---|
310 | { |
---|
311 | break; |
---|
312 | } |
---|
313 | |
---|
314 | if( this.page == i || (i == this.totalPages && !hasMarked) ) |
---|
315 | { |
---|
316 | var _link = document.createElement('span'); |
---|
317 | _link.setAttribute("style", "font-weight:bold; color:red") |
---|
318 | _link.innerHTML = ( this.page + 1 ) + " "; |
---|
319 | } |
---|
320 | else |
---|
321 | { |
---|
322 | var _page = i; |
---|
323 | var _link = document.createElement('A'); |
---|
324 | _link.innerHTML = ( _page + 1 ) + " "; |
---|
325 | if( this.value ) |
---|
326 | _link.href = 'javascript: EsearchE.quickSearchMail( false, '+i+', false, "'+currentTab+'" )'; |
---|
327 | else{ |
---|
328 | _link.href = 'javascript:EsearchE.page='+i+';'; |
---|
329 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+_page+'¤t_tab='+currentTab+'");'; |
---|
330 | } |
---|
331 | } |
---|
332 | _link.innerHTML = " ... "; |
---|
333 | if(i == (this.lastPage + this.numPages)) |
---|
334 | { |
---|
335 | span_pg.appendChild( _link ); |
---|
336 | break; |
---|
337 | } |
---|
338 | else if(this.lastPage == 0 || i != this.lastPage) |
---|
339 | { |
---|
340 | _link.innerHTML = " "+( i + 1 )+" "; |
---|
341 | } |
---|
342 | //span_pg.innerHTML += " "; |
---|
343 | |
---|
344 | span_pg.appendChild( _link ); |
---|
345 | } |
---|
346 | |
---|
347 | if(this.page != (this.totalPages - 1)) { |
---|
348 | _link = document.createElement("A"); |
---|
349 | if( this.value ) |
---|
350 | _link.href = 'javascript: EsearchE.quickSearchMail( false, '+(this.totalPages-1)+', false, "'+currentTab+'" )'; |
---|
351 | else{ |
---|
352 | _link.href = 'javascript:EsearchE.page='+(this.totalPages-1)+';'; |
---|
353 | _link.href += 'cExecute("$this.imap_functions.search_msg",openpage,"condition='+this.condition+'&sort_type='+this.sort_type+'&page='+(this.totalPages-1)+'¤t_tab='+currentTab+'");'; |
---|
354 | } |
---|
355 | } |
---|
356 | else { |
---|
357 | _link = document.createElement("SPAN"); |
---|
358 | } |
---|
359 | |
---|
360 | span_pg.innerHTML += " "; |
---|
361 | span_pg.appendChild(_link); |
---|
362 | |
---|
363 | _link.title = get_lang("Last"); |
---|
364 | _link.innerHTML += ">>"; |
---|
365 | |
---|
366 | Element("div_menu_c3").appendChild(span_pg); |
---|
367 | } |
---|
368 | |
---|
369 | searchE.prototype.searchFor = function( borderID, sortType ) |
---|
370 | { |
---|
371 | var border_id = borderID; |
---|
372 | var sort_type = sortType; |
---|
373 | var is_local = border_id.match('.*_local_.*'); |
---|
374 | if(!is_local) |
---|
375 | if( this.value ) |
---|
376 | return this.quickSearchMail( document.getElementsByName(currentTab)[0].value, false, sortType, border_id ); |
---|
377 | |
---|
378 | var args = "$this.imap_functions.search_msg"; |
---|
379 | var params = "condition="+EsearchE.condition+"&page="+EsearchE.page+"&sort_type="+sort_type; |
---|
380 | |
---|
381 | var handler = function( data ) |
---|
382 | { |
---|
383 | var allMsg = [3]; |
---|
384 | var gears = []; |
---|
385 | var local_folders = []; |
---|
386 | |
---|
387 | if ( preferences.use_local_messages == 1 && is_local) |
---|
388 | { |
---|
389 | temp = expresso_local_messages.list_local_folders(); |
---|
390 | |
---|
391 | for (var x in temp) |
---|
392 | { |
---|
393 | local_folders.push( temp[x][0] ); |
---|
394 | } |
---|
395 | |
---|
396 | |
---|
397 | if ( local_folders.length > 0 ){ |
---|
398 | var currentSearch = document.getElementsByName(currentTab); |
---|
399 | expresso_local_messages.setSortType(sortType); |
---|
400 | gears = expresso_local_messages.search( local_folders, "##ALL <=>"+currentSearch[0].value +"##" ); |
---|
401 | } |
---|
402 | } |
---|
403 | if (!is_local) |
---|
404 | { |
---|
405 | if( data['num_msgs']) |
---|
406 | { |
---|
407 | allMsg['data'] = data['data']; |
---|
408 | allMsg['num_msgs'] = data['num_msgs']; |
---|
409 | |
---|
410 | } |
---|
411 | } |
---|
412 | |
---|
413 | if (gears.length > 0) |
---|
414 | { |
---|
415 | allMsg['data_gears'] = gears; |
---|
416 | } |
---|
417 | |
---|
418 | var currentSearch = document.getElementsByName(currentTab)[0].value; |
---|
419 | |
---|
420 | delete_border( border_id, false ); |
---|
421 | |
---|
422 | EsearchE.mount_result( allMsg , sort_type, null, null, null, currentSearch ); |
---|
423 | }; |
---|
424 | |
---|
425 | if (is_local) |
---|
426 | { |
---|
427 | eval("handler('none')"); |
---|
428 | } |
---|
429 | else |
---|
430 | { |
---|
431 | cExecute(args,handler,params); |
---|
432 | } |
---|
433 | } |
---|
434 | |
---|
435 | searchE.prototype.viewLocalMessage = function() |
---|
436 | { |
---|
437 | var data = [2]; |
---|
438 | var gears = []; |
---|
439 | var local_folders = []; |
---|
440 | |
---|
441 | // Gears - local |
---|
442 | if ( preferences.use_local_messages == 1 ) |
---|
443 | { |
---|
444 | temp = expresso_local_messages.list_local_folders(); |
---|
445 | |
---|
446 | for (var x in temp) |
---|
447 | { |
---|
448 | local_folders.push( temp[x][0] ); |
---|
449 | } |
---|
450 | |
---|
451 | if ( local_folders.length > 0 ){ |
---|
452 | var currentSearch = document.getElementsByName(currentTab); |
---|
453 | if(currentSearch[0].value != ''){ |
---|
454 | gears = expresso_local_messages.search( local_folders, "##ALL <=>"+currentSearch[0].value +"##"); |
---|
455 | }else{ |
---|
456 | if(openTab.condition[currentTab]){ |
---|
457 | var condit = openTab.condition[currentTab][0].split(','); |
---|
458 | var filter = condit[0].split('##'); |
---|
459 | gears = expresso_local_messages.search( local_folders, '##'+filter[1]+'##'); |
---|
460 | |
---|
461 | } |
---|
462 | |
---|
463 | } |
---|
464 | } |
---|
465 | |
---|
466 | data['data_gears'] = gears; |
---|
467 | data['num_msgs'] = gears.length; |
---|
468 | |
---|
469 | if(data['num_msgs'] != undefined) |
---|
470 | write_msg( data['num_msgs'] + " " + get_lang("results found") ); |
---|
471 | |
---|
472 | EsearchE.mount_result( data, 'SORTDATE' ); |
---|
473 | } |
---|
474 | } |
---|
475 | |
---|
476 | searchE.prototype.make_tr_message = function(aux,border_id,i) { |
---|
477 | var tr = document.createElement("TR"); |
---|
478 | if(typeof(preferences.line_height) != 'undefined') |
---|
479 | tr.style.height = preferences.line_height; |
---|
480 | |
---|
481 | var mailbox = aux.boxname; |
---|
482 | var uid_msg = aux.uid; |
---|
483 | var subject = aux.subject; |
---|
484 | |
---|
485 | tr.id = uid_msg+"_s"+numBox; |
---|
486 | |
---|
487 | // Keep the two lines together please |
---|
488 | tr.setAttribute('name',mailbox); |
---|
489 | tr.name = mailbox; |
---|
490 | |
---|
491 | if ( aux.flag.match("U") ) |
---|
492 | add_className(tr,'tr_msg_unread'); |
---|
493 | |
---|
494 | add_className(tr, i%2 != 0 ? 'tr_msg_read2' : 'tr_msg_read'); |
---|
495 | |
---|
496 | var _onclick = function() |
---|
497 | { |
---|
498 | proxy_mensagens.get_msg(this.parentNode.id,url_encode(this.parentNode.getAttribute('name')),false,show_msg); |
---|
499 | }; |
---|
500 | |
---|
501 | for(var j=0 ; j <= 10 ; j++) |
---|
502 | { |
---|
503 | var td = document.createElement("TD"); |
---|
504 | add_className(td, 'td_msg'); |
---|
505 | if (j == 0) |
---|
506 | { |
---|
507 | td.setAttribute("width", colSizes[1][0]); |
---|
508 | var chk_onclick; |
---|
509 | if (is_ie) |
---|
510 | chk_onclick = "changeBgColor(window.event,"+uid_msg+");"; |
---|
511 | else |
---|
512 | chk_onclick = "changeBgColor(event,"+uid_msg+");"; //'search_' + numBox |
---|
513 | var td1 = '<input type="checkbox" onclick="' + chk_onclick + '" id="' + border_id + '_check_box_message_'+uid_msg+'"></input>'; |
---|
514 | |
---|
515 | } |
---|
516 | if (j == 1) |
---|
517 | { |
---|
518 | td.setAttribute("width", colSizes[1][1]); |
---|
519 | if (aux.flag.match('T')) |
---|
520 | { |
---|
521 | attachNum = parseInt(aux.flag.substr(aux.flag.indexOf('T')+1)); |
---|
522 | td1 = "<img src='templates/"+template+"/images/clip.gif' title='"+attachNum +' '+ get_lang('attachment(s)')+"'>"; |
---|
523 | } |
---|
524 | else |
---|
525 | td1 = ''; |
---|
526 | } |
---|
527 | if (j == 2) |
---|
528 | { |
---|
529 | td.setAttribute("width", colSizes[1][2]); |
---|
530 | td.id = "td_message_answered_"+uid_msg; |
---|
531 | if (aux.flag.match('X')) |
---|
532 | td1 = '<img src=templates/'+template+'/images/forwarded.gif title="'+get_lang('Forwarded')+'">'; |
---|
533 | else |
---|
534 | if (aux.flag.match('A')) |
---|
535 | td1 = '<img src=templates/'+template+'/images/answered.gif title="'+get_lang('Answered')+'">'; |
---|
536 | else |
---|
537 | td1 = ''; |
---|
538 | } |
---|
539 | if (j == 3) |
---|
540 | { |
---|
541 | td.setAttribute("width", colSizes[1][3]); |
---|
542 | td.id = "td_message_important_"+uid_msg; |
---|
543 | if (aux.flag.match("F")) |
---|
544 | { |
---|
545 | add_className(tr, 'flagged_msg'); |
---|
546 | td1 = "<img src='templates/"+template+"/images/important.gif' title='"+get_lang('Flagged')+"'>"; |
---|
547 | } |
---|
548 | else |
---|
549 | td1 = ''; |
---|
550 | } |
---|
551 | if (j == 4) |
---|
552 | { |
---|
553 | td.setAttribute("width", colSizes[1][4]); |
---|
554 | td.id = "td_message_sent_"+uid_msg; |
---|
555 | td1 = ''; |
---|
556 | } |
---|
557 | |
---|
558 | if ( j == 5 ) |
---|
559 | { |
---|
560 | td.setAttribute("width", colSizes[1][5]); |
---|
561 | td.className = "td_resizable"; |
---|
562 | td.onclick = _onclick; |
---|
563 | var nm_box = aux.boxname.split(cyrus_delimiter); |
---|
564 | var td1 = nm_box.pop(); |
---|
565 | td.setAttribute("NoWrap","true"); |
---|
566 | td.style.overflow = "hidden"; |
---|
567 | td.style.color = "#42795b"; |
---|
568 | td.style.fontWeight = "bold"; |
---|
569 | |
---|
570 | var td1 = get_lang(td1).substr(get_lang(td1).length-1) == "*"?td1:get_lang(td1); |
---|
571 | |
---|
572 | td1 = translateFolder(td1); |
---|
573 | |
---|
574 | |
---|
575 | if( proxy_mensagens.is_local_folder(td1)) |
---|
576 | { |
---|
577 | var td1 = this.aux_local_folder_display(td1); |
---|
578 | } |
---|
579 | } |
---|
580 | |
---|
581 | if( j == 6 ) |
---|
582 | { |
---|
583 | if ( aux.from !== null && aux.from.length > 29) |
---|
584 | aux.from = aux.from.substr(0,29) + "..."; |
---|
585 | |
---|
586 | td.setAttribute("width", colSizes[1][6]); |
---|
587 | td.className = "td_resizable"; |
---|
588 | td.onclick = _onclick; |
---|
589 | td.setAttribute("NoWrap","true"); |
---|
590 | td.style.overflow = "hidden"; |
---|
591 | var td1 = '<div style="width:100%;overflow:hidden">'+aux.from+"</div>"; |
---|
592 | } |
---|
593 | |
---|
594 | if( j == 7 ) |
---|
595 | { |
---|
596 | var subject_encode = url_encode(subject); |
---|
597 | |
---|
598 | if (! subject_encode) |
---|
599 | aux.subject = get_lang("no subject") + "..."; |
---|
600 | if (aux.subject.length > 70) |
---|
601 | aux.subject = aux.subject.substr(0,70) + "..."; |
---|
602 | |
---|
603 | td.setAttribute("width", colSizes[1][7]); |
---|
604 | td.className = "td_resizable"; |
---|
605 | td.onclick = _onclick; |
---|
606 | td.setAttribute("NoWrap","true"); |
---|
607 | td.style.overflow = "hidden"; |
---|
608 | |
---|
609 | var td1 = aux.subject; |
---|
610 | } |
---|
611 | |
---|
612 | if( j == 8 ) |
---|
613 | { |
---|
614 | td.setAttribute("width", colSizes[1][8]); |
---|
615 | td.className = "td_resizable"; |
---|
616 | td.align = "center"; |
---|
617 | td.onclick = _onclick; |
---|
618 | |
---|
619 | if( validate_date( aux.udate ) ) |
---|
620 | { |
---|
621 | var td1 = aux.udate; |
---|
622 | } |
---|
623 | else |
---|
624 | { |
---|
625 | var dt = new Date( aux.udate * 1000 ); |
---|
626 | var td1 = dt.getDate() + "/"; |
---|
627 | |
---|
628 | if( !( dt.getMonth() + 1 ).toString().match(/\d{2}/) ) |
---|
629 | td1 += "0"+( dt.getMonth() + 1 ) + "/"; |
---|
630 | else |
---|
631 | td1 += ( dt.getMonth() + 1 ) + "/"; |
---|
632 | |
---|
633 | td1 += dt.getFullYear(); |
---|
634 | } |
---|
635 | } |
---|
636 | |
---|
637 | if( j == 9 ) |
---|
638 | { |
---|
639 | td.setAttribute("width", "9.4%");//alinhamento dos campos data e tamanho |
---|
640 | td.className = "td_resizable"; |
---|
641 | td.align = "center"; |
---|
642 | td.onclick = _onclick; |
---|
643 | var td1 = borkb(aux.size); |
---|
644 | } |
---|
645 | |
---|
646 | if( j == 10 ) |
---|
647 | { |
---|
648 | if (aux.flag.match("U")) |
---|
649 | add_className(tr, 'tr_msg_unread'); |
---|
650 | if (aux.flag.match("F")) |
---|
651 | add_className(tr, 'flagged_msg'); |
---|
652 | var td1 = ''; |
---|
653 | } |
---|
654 | if (j<10) { |
---|
655 | td.innerHTML = td1; |
---|
656 | tr.appendChild(td); |
---|
657 | } |
---|
658 | } |
---|
659 | |
---|
660 | _dragArea.makeDragged(tr, uid_msg, subject, true, mailbox); |
---|
661 | |
---|
662 | return tr; |
---|
663 | } |
---|
664 | |
---|
665 | // Form resultado |
---|
666 | searchE.prototype.mount_result = function( Data, sort_type, keep_border, keep_filled, division, actualSearch ) |
---|
667 | { |
---|
668 | var data = ( Data['data'] ) ? Data['data'] : Data['data_gears']; |
---|
669 | |
---|
670 | if ( data == undefined ) |
---|
671 | return; |
---|
672 | |
---|
673 | var cont = parseInt(0); |
---|
674 | |
---|
675 | if ( typeof(sort_type) != 'undefined') |
---|
676 | this.sort_type = sort_type; |
---|
677 | else |
---|
678 | sort_type = this.sort_type; |
---|
679 | |
---|
680 | if ( keep_border ) { |
---|
681 | var border_id = currentTab; |
---|
682 | } |
---|
683 | else { |
---|
684 | if(isNaN(numBox)){ |
---|
685 | var aux = numBox.split("_"); |
---|
686 | numBox = parseInt(aux[0]) + 1; |
---|
687 | }else{ |
---|
688 | inc_abas_search++; |
---|
689 | numBox = inc_abas_search; |
---|
690 | } |
---|
691 | if( Data['data'] ) |
---|
692 | if(!actualSearch) |
---|
693 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox); |
---|
694 | else |
---|
695 | var border_id = create_border(get_lang("Server Results"), "search_" + numBox, actualSearch); |
---|
696 | if( Data['data_gears']) |
---|
697 | if(!actualSearch) |
---|
698 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox); |
---|
699 | else |
---|
700 | var border_id = create_border(get_lang("Local Results"), "search_local_msg" + numBox, actualSearch); |
---|
701 | } |
---|
702 | |
---|
703 | if (!border_id) |
---|
704 | return; |
---|
705 | |
---|
706 | currentTab = border_id; |
---|
707 | openTab.content_id[currentTab] = Element('content_id_search_' + numBox); |
---|
708 | openTab.type[currentTab] = 1; |
---|
709 | openTab.condition[currentTab] = this.condition; |
---|
710 | |
---|
711 | if ( keep_border ) { |
---|
712 | var content_search = Element('content_id_' + border_id); |
---|
713 | var div_scroll_result = Element("divScrollMain_"+numBox); |
---|
714 | |
---|
715 | content_search.removeChild(div_scroll_result); |
---|
716 | |
---|
717 | if( !keep_filled ) |
---|
718 | div_scroll_result = false; |
---|
719 | } |
---|
720 | |
---|
721 | var table = document.createElement("TABLE"); |
---|
722 | table.id = "table_resultsearch_" + numBox; |
---|
723 | table.frame = "void"; |
---|
724 | table.rules = "rows"; |
---|
725 | table.cellPadding = "0"; |
---|
726 | table.cellSpacing = "0"; |
---|
727 | table.className = "table_box"; |
---|
728 | |
---|
729 | var tbody = document.createElement("TBODY"); |
---|
730 | tbody.id = "tbody_box_" + numBox; |
---|
731 | |
---|
732 | for( var i=0; i < data.length; i++) |
---|
733 | { |
---|
734 | if(data[i] !== null){ |
---|
735 | var tr = EsearchE.make_tr_message(data[i],border_id,i); |
---|
736 | tbody.appendChild(tr); |
---|
737 | } |
---|
738 | } |
---|
739 | |
---|
740 | //global_search++; //Tabs from search must not have the same id on its tr's // use numBox instead of this! |
---|
741 | |
---|
742 | table.appendChild(tbody); |
---|
743 | |
---|
744 | var colgr_element = buildColGroup(1); |
---|
745 | colgr_element.setAttribute("id","colgroup_main_"+numBox); |
---|
746 | table.appendChild(colgr_element); |
---|
747 | |
---|
748 | var content_search = Element('content_id_' + border_id); |
---|
749 | |
---|
750 | if( !div_scroll_result ) |
---|
751 | { |
---|
752 | var div_scroll_result = document.createElement("DIV"); |
---|
753 | div_scroll_result.id = "divScrollMain_"+numBox; |
---|
754 | div_scroll_result.style.overflowY = "scroll"; |
---|
755 | div_scroll_result.style.overflowX = "hidden"; |
---|
756 | div_scroll_result.style.width ="100%"; |
---|
757 | |
---|
758 | if (is_mozilla){ |
---|
759 | div_scroll_result.style.overflow = "-moz-scrollbars-vertical"; |
---|
760 | div_scroll_result.style.width ="100%"; |
---|
761 | } |
---|
762 | } |
---|
763 | if( division ) |
---|
764 | { |
---|
765 | var _div = document.createElement("div"); |
---|
766 | _div.className = 'local-messages-search-warning'; |
---|
767 | _div.innerHTML = division; |
---|
768 | div_scroll_result.appendChild(_div); |
---|
769 | } |
---|
770 | |
---|
771 | if(is_ie) |
---|
772 | Element("border_table").width = "99.5%"; |
---|
773 | |
---|
774 | // Put header |
---|
775 | var table_element = document.createElement("TABLE"); |
---|
776 | var tbody_element = document.createElement("TBODY"); |
---|
777 | if (is_ie) |
---|
778 | { |
---|
779 | table_element.attachEvent("onmousemove",changeCursorState); |
---|
780 | table_element.attachEvent("onmousedown",startColResize); |
---|
781 | } |
---|
782 | else { |
---|
783 | table_element.addEventListener("mousemove",changeCursorState,false); |
---|
784 | table_element.addEventListener("mousedown",startColResize,false); |
---|
785 | } |
---|
786 | table_element.setAttribute("id", "table_message_header_box_"+numBox); |
---|
787 | table_element.className = "table_message_header_box"; |
---|
788 | if (!is_ie) |
---|
789 | table_element.style.width = "98.8%"; |
---|
790 | table_element.emptyBody = false; |
---|
791 | |
---|
792 | tr_element = document.createElement("TR"); |
---|
793 | tr_element.className = "message_header"; |
---|
794 | td_element0 = createTDElement(1,0); |
---|
795 | chk_box_element = document.createElement("INPUT"); |
---|
796 | if(border_id.indexOf('local') > 0) |
---|
797 | chk_box_element.id = "chk_box_select_all_messages_search_local"; |
---|
798 | else |
---|
799 | chk_box_element.id = "chk_box_select_all_messages_search"; |
---|
800 | chk_box_element.setAttribute("type", "checkbox"); |
---|
801 | chk_box_element.className = "checkbox"; |
---|
802 | chk_box_element.onclick = function(){select_all_search_messages(this.checked,content_search.id);}; |
---|
803 | chk_box_element.onmouseover = function () {this.title=get_lang('Select all messages.')}; |
---|
804 | chk_box_element.onkeydown = function (e) |
---|
805 | { |
---|
806 | if (is_ie) |
---|
807 | { |
---|
808 | if ((window.event.keyCode) == 46) |
---|
809 | delete_msgs(current_folder,'selected','null'); |
---|
810 | } |
---|
811 | else |
---|
812 | { |
---|
813 | if ((e.keyCode) == 46) |
---|
814 | delete_msgs(current_folder,'selected','null'); |
---|
815 | } |
---|
816 | }; |
---|
817 | |
---|
818 | td_element0.appendChild(chk_box_element); |
---|
819 | td_element01 = createTDElement(1,1); |
---|
820 | td_element02 = createTDElement(1,2); |
---|
821 | td_element03 = createTDElement(1,3); |
---|
822 | td_element04 = createTDElement(1,4); |
---|
823 | td_element1 = createTDElement(1,5,"th_resizable","left"); |
---|
824 | |
---|
825 | var arrow_ascendant = function(Text) |
---|
826 | { |
---|
827 | return "<b>" + Text + "</b><img src='templates/"+template+"/images/arrow_ascendant.gif'>"; |
---|
828 | } |
---|
829 | |
---|
830 | // Ordernar Pasta |
---|
831 | if ( sort_type == 'SORTBOX' /*|| sort_type == 'SORTBOX_REVERSE'*/ ) |
---|
832 | { |
---|
833 | if( Data['data'] ) |
---|
834 | { |
---|
835 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); }; |
---|
836 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
837 | } |
---|
838 | else |
---|
839 | { |
---|
840 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX_REVERSE'); }; |
---|
841 | td_element1.innerHTML = "<b>"+get_lang("Folder")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
842 | } |
---|
843 | } |
---|
844 | else |
---|
845 | { |
---|
846 | if( Data['data'] ) |
---|
847 | { |
---|
848 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX'); }; |
---|
849 | } |
---|
850 | else |
---|
851 | { |
---|
852 | td_element1.onclick = function(){ EsearchE.searchFor(border_id, 'SORTBOX'); }; |
---|
853 | } |
---|
854 | td_element1.innerHTML = ( sort_type == 'SORTBOX_REVERSE' ) ? arrow_ascendant(get_lang("Folder")) : get_lang("Folder"); |
---|
855 | } |
---|
856 | |
---|
857 | // Ordernar Quem |
---|
858 | td_element2 = createTDElement(1,6,"th_resizable","left"); |
---|
859 | |
---|
860 | if (sort_type == 'SORTFROM' || sort_type == 'SORTWHO' /*|| sort_type == 'SORTWHO_REVERSE' || sort_type == 'SORTFROM_REVERSE'*/ ) |
---|
861 | { |
---|
862 | if(Data['data']) |
---|
863 | { |
---|
864 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTFROM_REVERSE'); }; |
---|
865 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
866 | } |
---|
867 | else |
---|
868 | { |
---|
869 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO_REVERSE'); }; |
---|
870 | td_element2.innerHTML = "<b>"+get_lang("From")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
871 | } |
---|
872 | } |
---|
873 | else |
---|
874 | { |
---|
875 | if( Data['data'] ) |
---|
876 | { |
---|
877 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO'); }; |
---|
878 | } |
---|
879 | else |
---|
880 | { |
---|
881 | td_element2.onclick = function(){ EsearchE.searchFor(border_id, 'SORTWHO'); }; |
---|
882 | } |
---|
883 | td_element2.innerHTML = ( sort_type == 'SORTWHO_REVERSE' ) ? arrow_ascendant(get_lang("From")) : get_lang("From"); |
---|
884 | } |
---|
885 | |
---|
886 | // Ordernar Subject |
---|
887 | td_element3 = createTDElement(1,7,"th_resizable","left"); |
---|
888 | |
---|
889 | if (sort_type == 'SORTSUBJECT' /*|| sort_type == 'SORTSUBJECT_REVERSE'*/) |
---|
890 | { |
---|
891 | if( Data['data']) |
---|
892 | { |
---|
893 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); }; |
---|
894 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
895 | } |
---|
896 | else |
---|
897 | { |
---|
898 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT_REVERSE'); }; |
---|
899 | td_element3.innerHTML = "<b>"+get_lang("subject")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
900 | } |
---|
901 | } |
---|
902 | else |
---|
903 | { |
---|
904 | if( Data['data'] ) |
---|
905 | { |
---|
906 | td_element3.onclick = function(){ EsearchE.searchFor( border_id, 'SORTSUBJECT'); }; |
---|
907 | } |
---|
908 | else |
---|
909 | { |
---|
910 | td_element3.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSUBJECT'); }; |
---|
911 | } |
---|
912 | td_element3.innerHTML = ( sort_type == 'SORTSUBJECT_REVERSE' ) ? arrow_ascendant(get_lang("subject")) : get_lang("subject"); |
---|
913 | } |
---|
914 | |
---|
915 | // Ordernar Data |
---|
916 | td_element4 = createTDElement(1,8,"th_resizable","center"); |
---|
917 | |
---|
918 | if ( sort_type == 'SORTDATE' /*|| sort_type == 'SORTDATE_REVERSE'*/ ) |
---|
919 | { |
---|
920 | if( Data['data'] ) |
---|
921 | { |
---|
922 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); }; |
---|
923 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
924 | } |
---|
925 | else |
---|
926 | { |
---|
927 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE_REVERSE'); }; |
---|
928 | td_element4.innerHTML = "<b>"+get_lang("Date")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
929 | } |
---|
930 | } |
---|
931 | else |
---|
932 | { |
---|
933 | if( Data['data'] ) |
---|
934 | { |
---|
935 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE'); }; |
---|
936 | } |
---|
937 | else |
---|
938 | { |
---|
939 | td_element4.onclick = function(){ EsearchE.searchFor(border_id, 'SORTDATE'); }; |
---|
940 | } |
---|
941 | td_element4.innerHTML = ( sort_type == 'SORTDATE_REVERSE' ) ? arrow_ascendant(get_lang("Date")) : get_lang("Date"); |
---|
942 | } |
---|
943 | |
---|
944 | // Ordernar Tamanho |
---|
945 | td_element5 = createTDElement(1,9,"th_resizable","center"); |
---|
946 | |
---|
947 | if ( sort_type == 'SORTSIZE' /*|| sort_type == 'SORTSIZE_REVERSE'*/ ) |
---|
948 | { |
---|
949 | if( Data['data'] ) |
---|
950 | { |
---|
951 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); }; |
---|
952 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
953 | } |
---|
954 | else |
---|
955 | { |
---|
956 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE_REVERSE'); }; |
---|
957 | td_element5.innerHTML = "<b>"+get_lang("size")+"</b><img src='templates/"+template+"/images/arrow_descendant.gif'>"; |
---|
958 | } |
---|
959 | } |
---|
960 | else |
---|
961 | { |
---|
962 | if( Data['data'] ) |
---|
963 | { |
---|
964 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE'); }; |
---|
965 | } |
---|
966 | else |
---|
967 | { |
---|
968 | td_element5.onclick = function(){ EsearchE.searchFor(border_id, 'SORTSIZE'); }; |
---|
969 | } |
---|
970 | td_element5.innerHTML = ( sort_type == 'SORTSIZE_REVERSE' ) ? arrow_ascendant(get_lang("size")) : get_lang("size"); |
---|
971 | } |
---|
972 | |
---|
973 | tr_element.appendChild(td_element0); |
---|
974 | tr_element.appendChild(td_element01); |
---|
975 | tr_element.appendChild(td_element02); |
---|
976 | tr_element.appendChild(td_element03); |
---|
977 | tr_element.appendChild(td_element04); |
---|
978 | tr_element.appendChild(td_element1); |
---|
979 | tr_element.appendChild(td_element2); |
---|
980 | tr_element.appendChild(td_element3); |
---|
981 | tr_element.appendChild(td_element4); |
---|
982 | tr_element.appendChild(td_element5); |
---|
983 | tbody_element.appendChild(tr_element); |
---|
984 | table_element.appendChild(tbody_element); |
---|
985 | |
---|
986 | var colgr_element = buildColGroup(1); |
---|
987 | colgr_element.setAttribute("id","colgroup_head_"+numBox); |
---|
988 | table_element.appendChild(colgr_element); |
---|
989 | |
---|
990 | if( parseInt( Data['gears_num_msgs'] ) > 0 && !keep_filled) |
---|
991 | { |
---|
992 | var messagesWarning = document.getElementById("local-messages-search-warning_"+border_id); |
---|
993 | if(!messagesWarning){ |
---|
994 | var _div_gears = document.createElement("div"); |
---|
995 | _div_gears.id = "local-messages-search-warning_"+border_id; |
---|
996 | _div_gears.onclick = function(){ EsearchE.viewLocalMessage(); }; |
---|
997 | _div_gears.className = 'local-messages-search-warning'; |
---|
998 | _div_gears.innerHTML = get_lang("The search has% 1 messages stored locally. Want to see them ? Click here.", Data['gears_num_msgs']); |
---|
999 | content_search.appendChild(_div_gears); |
---|
1000 | } |
---|
1001 | } |
---|
1002 | |
---|
1003 | var _divScroll = document.getElementById("divScrollHead_"+numBox); |
---|
1004 | |
---|
1005 | if( _divScroll ){ |
---|
1006 | content_search.removeChild(_divScroll); |
---|
1007 | _divScroll = false; |
---|
1008 | } |
---|
1009 | |
---|
1010 | _divScroll = document.createElement("DIV"); |
---|
1011 | _divScroll.id = "divScrollHead_"+numBox; |
---|
1012 | _divScroll.style.overflowY = "hidden"; |
---|
1013 | _divScroll.style.overflowX = "hidden"; |
---|
1014 | _divScroll.style.width ="100%"; |
---|
1015 | |
---|
1016 | if (is_mozilla){ |
---|
1017 | _divScroll.style.width ="99.3%"; |
---|
1018 | } |
---|
1019 | _divScroll.appendChild(table_element); |
---|
1020 | content_search.appendChild(_divScroll); |
---|
1021 | |
---|
1022 | /*end of "put header"*/ |
---|
1023 | if ( !expresso_offline ) |
---|
1024 | { |
---|
1025 | div_scroll_result.appendChild(table); |
---|
1026 | content_search.appendChild(div_scroll_result); |
---|
1027 | } |
---|
1028 | else |
---|
1029 | { |
---|
1030 | div_scroll_result.appendChild(table); |
---|
1031 | content_search.appendChild(div_scroll_result); |
---|
1032 | } |
---|
1033 | |
---|
1034 | resizeWindow(); |
---|
1035 | if(typeof(Data.data_gears)=="undefined") |
---|
1036 | EsearchE.show_paging( Data['num_msgs'] ); |
---|
1037 | } |
---|
1038 | |
---|
1039 | searchE.prototype.open_msg = function(mailbox, uid_msg, subject) |
---|
1040 | { |
---|
1041 | var handler_get_msg = function(data) |
---|
1042 | { |
---|
1043 | if( Element("border_id_" + uid_msg + "_r") ) |
---|
1044 | alert(get_lang("This message is already opened!")); |
---|
1045 | else |
---|
1046 | draw_message( data, create_border(url_decode(subject), uid_msg + "_r") ); |
---|
1047 | } |
---|
1048 | |
---|
1049 | proxy_mensagens.get_msg(uid_msg,mailbox,false,handler_get_msg); |
---|
1050 | } |
---|
1051 | |
---|
1052 | // Adiciona caixas postais na busca; |
---|
1053 | searchE.prototype.add_mailboxes = function() |
---|
1054 | { |
---|
1055 | var sel = Element("sel_search_nm_box1"); |
---|
1056 | if (!proxy_mensagens.is_local_folder(this.name_box_search)) { |
---|
1057 | var name_box = this.name_box_search.split(cyrus_delimiter); |
---|
1058 | if(this.name_box_search == "") |
---|
1059 | return false; |
---|
1060 | var name_box_def = ""; |
---|
1061 | if(name_box.length != 1){ |
---|
1062 | name_box_def = name_box[(name_box.length-1)]; |
---|
1063 | }else{ |
---|
1064 | name_box_def = get_lang("Inbox"); |
---|
1065 | } |
---|
1066 | } |
---|
1067 | else { |
---|
1068 | if(this.name_box_search=='local_root') |
---|
1069 | return; |
---|
1070 | if(this.name_box_search=='local_Inbox') |
---|
1071 | name_box_def = get_lang("Inbox"); |
---|
1072 | else if(this.name_box_search.indexOf("/")!="-1") { |
---|
1073 | final_pos = this.name_box_search.lastIndexOf("/"); |
---|
1074 | name_box_def = this.name_box_search.substr(final_pos+1); |
---|
1075 | } |
---|
1076 | else |
---|
1077 | name_box_def = this.name_box_search.substr(6);//Retira o 'local_' |
---|
1078 | } |
---|
1079 | if( sel.length > 0){ |
---|
1080 | for(var i=0; i < sel.options.length; i++){ |
---|
1081 | if(sel.options[i].value == this.name_box_search){ |
---|
1082 | alert(get_lang('This message is already selected!')); |
---|
1083 | return false; |
---|
1084 | } |
---|
1085 | } |
---|
1086 | } |
---|
1087 | name_box_def = translateFolder(name_box_def); |
---|
1088 | var opt = new Option(lang_folder(name_box_def),this.name_box_search,false,true); |
---|
1089 | sel[sel.length] = opt; |
---|
1090 | } |
---|
1091 | |
---|
1092 | // Remove as caixas postais na busca; |
---|
1093 | searchE.prototype.del_mailboxes = function() |
---|
1094 | { |
---|
1095 | var sel = Element("sel_search_nm_box1"); |
---|
1096 | if(sel.length > 0) |
---|
1097 | { |
---|
1098 | for(var i=0; i < sel.options.length; i++) |
---|
1099 | { |
---|
1100 | if(sel.options[i].selected == true) |
---|
1101 | { |
---|
1102 | sel.options[i] = null; |
---|
1103 | i--; |
---|
1104 | } |
---|
1105 | } |
---|
1106 | } |
---|
1107 | |
---|
1108 | } |
---|
1109 | |
---|
1110 | // todas as caixas |
---|
1111 | searchE.prototype.all_mailboxes = function() |
---|
1112 | { |
---|
1113 | var value = Element("check_all_msg").checked; |
---|
1114 | var cont = parseInt(0); |
---|
1115 | if(value) |
---|
1116 | { |
---|
1117 | if(EsearchE.all_boxes.length > 0) |
---|
1118 | { |
---|
1119 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1120 | } |
---|
1121 | for(var i=0; i < folders.length; i++) |
---|
1122 | { |
---|
1123 | EsearchE.all_boxes[cont++] = folders[i].folder_id; |
---|
1124 | } |
---|
1125 | } |
---|
1126 | else |
---|
1127 | { |
---|
1128 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1129 | } |
---|
1130 | } |
---|
1131 | |
---|
1132 | // Search; |
---|
1133 | searchE.prototype.func_search_complex = function() |
---|
1134 | { |
---|
1135 | var fields = "##"; |
---|
1136 | // Verifica se os campos estão preenchidos; |
---|
1137 | if(trim(Element("txt_ass").value) != ""){ |
---|
1138 | fields += "SUBJECT " + "<=>" +url_encode(Element("txt_ass").value) + "##"; |
---|
1139 | } |
---|
1140 | if(trim(Element("txt_body").value) != ""){ |
---|
1141 | fields += "BODY " + "<=>" + url_encode(Element("txt_body").value) + "##"; |
---|
1142 | } |
---|
1143 | if(trim(Element("txt_de").value) != ""){ |
---|
1144 | fields += "FROM " + "<=>" + url_encode(Element("txt_de").value) + "##"; |
---|
1145 | } |
---|
1146 | if(trim(Element("txt_para").value) != ""){ |
---|
1147 | fields += "TO " + "<=>" + url_encode(Element("txt_para").value) + "##"; |
---|
1148 | } |
---|
1149 | if(trim(Element("txt_cc").value) != ""){ |
---|
1150 | fields += "CC " + "<=>" + url_encode(Element("txt_cc").value) + "##"; |
---|
1151 | } |
---|
1152 | if (trim(Element("since_date").value) != "") |
---|
1153 | { |
---|
1154 | if (validate_date(Element("since_date").value)) |
---|
1155 | { |
---|
1156 | fields += "SINCE " + "<=>" + url_encode(Element("since_date").value) + "##"; |
---|
1157 | } |
---|
1158 | else |
---|
1159 | { |
---|
1160 | alert(get_lang('Invalid date on field %1', get_lang('Since Date'))); |
---|
1161 | return false; |
---|
1162 | } |
---|
1163 | } |
---|
1164 | |
---|
1165 | if (trim(Element("before_date").value) != "") |
---|
1166 | { |
---|
1167 | if (validate_date(Element("before_date").value)) |
---|
1168 | { |
---|
1169 | fields += "BEFORE " + "<=>" + url_encode(Element("before_date").value) + "##"; |
---|
1170 | } |
---|
1171 | else |
---|
1172 | { |
---|
1173 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
1174 | return false; |
---|
1175 | } |
---|
1176 | } |
---|
1177 | if ((trim(Element("since_date").value) != "") && (trim(Element("before_date").value) != "")){ |
---|
1178 | if(!(validate_date_order(trim(Element("since_date").value), trim(Element("before_date").value)))){ |
---|
1179 | alert(get_lang('Invalid date on field %1', get_lang('Before Date'))); |
---|
1180 | return false; |
---|
1181 | } |
---|
1182 | } |
---|
1183 | if(trim(Element("on_date").value) != "") |
---|
1184 | { |
---|
1185 | if (validate_date(Element("on_date").value)) |
---|
1186 | { |
---|
1187 | fields += "ON " + "<=>" + url_encode(Element("on_date").value) + "##"; |
---|
1188 | } |
---|
1189 | else |
---|
1190 | { |
---|
1191 | alert(get_lang('Invalid date on field %1', get_lang('On Date'))); |
---|
1192 | return false; |
---|
1193 | } |
---|
1194 | |
---|
1195 | } |
---|
1196 | |
---|
1197 | if(trim(Element("flagged").options[Element("flagged").selectedIndex].value) != "") |
---|
1198 | { |
---|
1199 | if (Element("flagged").options[Element("flagged").selectedIndex].value == "FLAGGED") |
---|
1200 | { |
---|
1201 | fields += "FLAGGED##"; |
---|
1202 | } |
---|
1203 | else |
---|
1204 | { |
---|
1205 | fields += "UNFLAGGED##"; |
---|
1206 | } |
---|
1207 | } |
---|
1208 | |
---|
1209 | if(trim(Element("seen").options[Element("seen").selectedIndex].value) != "") |
---|
1210 | { |
---|
1211 | if (Element("seen").options[Element("seen").selectedIndex].value == "SEEN") |
---|
1212 | { |
---|
1213 | fields += "SEEN##"; |
---|
1214 | } |
---|
1215 | else |
---|
1216 | { |
---|
1217 | fields += "UNSEEN##"; |
---|
1218 | } |
---|
1219 | } |
---|
1220 | |
---|
1221 | if(trim(Element("answered").options[Element("answered").selectedIndex].value) != "") |
---|
1222 | { |
---|
1223 | if (Element("answered").options[Element("answered").selectedIndex].value == "ANSWERED"){ |
---|
1224 | fields += "ANSWERED##"; |
---|
1225 | } |
---|
1226 | else { |
---|
1227 | fields += "UNANSWERED##"; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | |
---|
1231 | if(trim(Element("recent").options[Element("recent").selectedIndex].value) != "") |
---|
1232 | { |
---|
1233 | if (Element("answered").options[Element("answered").selectedIndex].value == "RECENT") |
---|
1234 | { |
---|
1235 | fields += "RECENT##"; |
---|
1236 | } |
---|
1237 | else |
---|
1238 | { |
---|
1239 | fields += "OLD##"; |
---|
1240 | } |
---|
1241 | } |
---|
1242 | |
---|
1243 | if(fields == "##") |
---|
1244 | { |
---|
1245 | alert(get_lang("Define some search parameters!")); |
---|
1246 | return false; |
---|
1247 | } |
---|
1248 | |
---|
1249 | var local_folders = new Array(); |
---|
1250 | var temp; |
---|
1251 | |
---|
1252 | if( Element("check_all_msg").checked ) |
---|
1253 | { |
---|
1254 | this.all_mailboxes(); |
---|
1255 | var nm_box = new Array; |
---|
1256 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
1257 | { |
---|
1258 | nm_box[i] = EsearchE.all_boxes[i] + fields; |
---|
1259 | } |
---|
1260 | if (preferences.use_local_messages == 1) |
---|
1261 | { |
---|
1262 | temp = expresso_local_messages.list_local_folders(); |
---|
1263 | for (var x in temp) |
---|
1264 | { |
---|
1265 | local_folders.push(temp[x][0]); |
---|
1266 | } |
---|
1267 | } |
---|
1268 | } |
---|
1269 | else |
---|
1270 | { |
---|
1271 | var nm_box = new Array; |
---|
1272 | var sel_combo = Element("sel_search_nm_box1"); |
---|
1273 | |
---|
1274 | if( sel_combo.options.length <= 0) |
---|
1275 | { |
---|
1276 | alert(get_lang("Define the boxes to search!")); |
---|
1277 | return false; |
---|
1278 | } |
---|
1279 | |
---|
1280 | for(var i=0; i < sel_combo.options.length; i++) |
---|
1281 | { |
---|
1282 | sel_combo.options[i].selected = true; |
---|
1283 | } |
---|
1284 | |
---|
1285 | for(var i=0; i < sel_combo.options.length; i++) |
---|
1286 | { |
---|
1287 | if( sel_combo.options[i].selected == true ) |
---|
1288 | { |
---|
1289 | if(!proxy_mensagens.is_local_folder(sel_combo.options[i].value)) |
---|
1290 | nm_box[nm_box.length] = sel_combo.options[i].value + fields; |
---|
1291 | else |
---|
1292 | local_folders.push(sel_combo.options[i].value.substr(6)); |
---|
1293 | } |
---|
1294 | } |
---|
1295 | } |
---|
1296 | |
---|
1297 | var handler = function( data ) |
---|
1298 | { |
---|
1299 | var allMsg = [3]; |
---|
1300 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
1301 | var tmp = []; |
---|
1302 | |
---|
1303 | // Gears - local |
---|
1304 | if ( local_folders.length > 0 ){ |
---|
1305 | expresso_local_messages.setSortType('SORTDATE'); |
---|
1306 | tmp = expresso_local_messages.search( local_folders, fields ); |
---|
1307 | } |
---|
1308 | |
---|
1309 | if( data['num_msgs'] ) |
---|
1310 | { |
---|
1311 | allMsg['data'] = data['data']; |
---|
1312 | allMsg['num_msgs'] = data['num_msgs']; |
---|
1313 | } |
---|
1314 | |
---|
1315 | if( tmp.length > 0 ) |
---|
1316 | { |
---|
1317 | allMsg['gears_num_msgs'] = tmp.length ; |
---|
1318 | } |
---|
1319 | |
---|
1320 | if( ( data['num_msgs'] ) == 0 ) |
---|
1321 | { |
---|
1322 | alert( get_lang("None result was found.") ); |
---|
1323 | } |
---|
1324 | else |
---|
1325 | { |
---|
1326 | if( (tmp.length > 0) && (!data['num_msgs']) ) |
---|
1327 | { |
---|
1328 | EsearchE.viewLocalMessage(); |
---|
1329 | } |
---|
1330 | else |
---|
1331 | { |
---|
1332 | if(count > 0) |
---|
1333 | EsearchE.func_clean(); |
---|
1334 | write_msg( count + " " + get_lang("results found") ); |
---|
1335 | EsearchE.mount_result( allMsg, 'SORTDATE' ); |
---|
1336 | } |
---|
1337 | } |
---|
1338 | } |
---|
1339 | |
---|
1340 | this.condition = nm_box; |
---|
1341 | this.page = 0; |
---|
1342 | var args = "$this.imap_functions.search_msg"; |
---|
1343 | var params = "condition=" + nm_box+ "&page=0"+ "&sort_type=SORTDATE"; |
---|
1344 | |
---|
1345 | if( expresso_offline ) |
---|
1346 | handler('none'); |
---|
1347 | else |
---|
1348 | cExecute( args, handler, params); |
---|
1349 | } |
---|
1350 | |
---|
1351 | searchE.prototype.func_search = function(value, page, sort, border_id) |
---|
1352 | { |
---|
1353 | if( !value ) |
---|
1354 | this.func_search_complex(); |
---|
1355 | else |
---|
1356 | this.quickSearchMail( value, page, sort, border_id ); |
---|
1357 | } |
---|
1358 | |
---|
1359 | searchE.prototype.quickSearchMail = function(value, page, sort, border_id) |
---|
1360 | { |
---|
1361 | var local_folders = new Array(); |
---|
1362 | var temp; |
---|
1363 | var not_found_corrent_folder = true; |
---|
1364 | |
---|
1365 | // if( Element("check_all_msg").checked ) |
---|
1366 | // { |
---|
1367 | this.all_mailboxes(); |
---|
1368 | var nm_box = new Array; |
---|
1369 | for(var i=0; i < EsearchE.all_boxes.length; i++) |
---|
1370 | { |
---|
1371 | nm_box[i] = EsearchE.all_boxes[i]/* + fields*/; |
---|
1372 | } |
---|
1373 | if (preferences.use_local_messages == 1) |
---|
1374 | { |
---|
1375 | temp = expresso_local_messages.list_local_folders(); |
---|
1376 | for (var x in temp) |
---|
1377 | { |
---|
1378 | local_folders.push(temp[x][0]); |
---|
1379 | } |
---|
1380 | } |
---|
1381 | this.sort = sort || this.sort || "SORTDATE"; |
---|
1382 | this.page = isNaN(page) ? ( value ? 0 : this.page ) : page; |
---|
1383 | this.value = value || this.value || false; |
---|
1384 | |
---|
1385 | if( !this.value ) |
---|
1386 | return alert( "Busca sem caracteres." ); |
---|
1387 | |
---|
1388 | var args = "$this.imap_functions.quickSearchMail"; |
---|
1389 | var params = { page: this.page, sort: this.sort, search: this.value }; |
---|
1390 | |
---|
1391 | var selection1 = [], selection2 = []; |
---|
1392 | |
---|
1393 | for( var i = 0; i < nm_box.length; i++ ) |
---|
1394 | if( nm_box[i] === current_folder ) |
---|
1395 | continue; |
---|
1396 | else if( /^user/.test(nm_box[i]) ) |
---|
1397 | selection2[selection2.length] = nm_box[i]; |
---|
1398 | else |
---|
1399 | selection1[selection1.length] = nm_box[i]; |
---|
1400 | |
---|
1401 | if( expresso_offline ) |
---|
1402 | handler('none'); |
---|
1403 | else |
---|
1404 | { |
---|
1405 | var url = [], labels = []; |
---|
1406 | |
---|
1407 | params['folder'] = current_folder; |
---|
1408 | url[0] = args + "&" + $.param( params ); |
---|
1409 | labels[0] = "mensagem na sua pasta atual"; |
---|
1410 | |
---|
1411 | if(selection1.length) |
---|
1412 | { |
---|
1413 | params['folder'] = selection1; |
---|
1414 | url[1] = args + "&" + $.param( params ); |
---|
1415 | labels[1] = "mensagens nas suas outras pastas"; |
---|
1416 | } |
---|
1417 | if(selection2.length) |
---|
1418 | { |
---|
1419 | params['folder'] = selection2; |
---|
1420 | url[2] = args + "&" + $.param( params ); |
---|
1421 | labels[2] = "mensagens nas suas pastas compartilhadas"; |
---|
1422 | } |
---|
1423 | var link = ' <a href="#" onclick="connector.cancelRequest(); clean_msg(); return false;">cancelar<a/>'; |
---|
1424 | |
---|
1425 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
1426 | |
---|
1427 | var keepFilled = false; |
---|
1428 | |
---|
1429 | var handler = function( data ) |
---|
1430 | { |
---|
1431 | data = $.parseJSON( Base64.decode(data) ); |
---|
1432 | |
---|
1433 | var allMsg = { |
---|
1434 | num_msgs: ( data['num_msgs'] || 0 ), |
---|
1435 | data: ( data['data'] || data['msgs'] || data ) |
---|
1436 | }; |
---|
1437 | |
---|
1438 | // Gears - local |
---|
1439 | if ( local_folders.length > 0 ){ |
---|
1440 | expresso_local_messages.setSortType('SORTDATE'); |
---|
1441 | var tmp = expresso_local_messages.search( local_folders, "##ALL <=>" + url_encode(value) + "##" ); |
---|
1442 | |
---|
1443 | if( tmp.length > 0 ) |
---|
1444 | if( !allMsg['num_msgs'] ){ |
---|
1445 | clean_msg(); |
---|
1446 | not_found_corrent_folder = false; |
---|
1447 | if(tmp.length) |
---|
1448 | allMsg['gears_num_msgs'] = tmp.length; |
---|
1449 | }else |
---|
1450 | allMsg['gears_num_msgs'] = tmp.length; |
---|
1451 | } |
---|
1452 | |
---|
1453 | if( !allMsg['num_msgs'] && !url.length && not_found_corrent_folder){ |
---|
1454 | clean_msg(); |
---|
1455 | //alert( get_lang("None result was found.") ); |
---|
1456 | return EsearchE.viewLocalMessage(); |
---|
1457 | } |
---|
1458 | |
---|
1459 | if( allMsg['num_msgs'] ) |
---|
1460 | EsearchE.total = allMsg['num_msgs'] = Math.max( (EsearchE.total || 0), allMsg['num_msgs'] ); |
---|
1461 | |
---|
1462 | EsearchE.mount_result( allMsg, EsearchE.sort, ( keepFilled || border_id === currentTab ), keepFilled, "Foram encontradas " + data['msgs'].length + " "+labels.shift()+"." ); |
---|
1463 | |
---|
1464 | keepFilled = true; |
---|
1465 | |
---|
1466 | write_msg( "pesquisando " + labels[0] + link, true ); |
---|
1467 | |
---|
1468 | if( url.length ) |
---|
1469 | cExecute( url.shift(), handler ); |
---|
1470 | else |
---|
1471 | clean_msg(); |
---|
1472 | } |
---|
1473 | |
---|
1474 | cExecute( url.shift(), handler ); |
---|
1475 | } |
---|
1476 | } |
---|
1477 | |
---|
1478 | // clean; |
---|
1479 | searchE.prototype.func_clean = function() |
---|
1480 | { |
---|
1481 | // Limpa os campos; |
---|
1482 | for( var i=0; i < this.txtfields.length; i++ ) |
---|
1483 | { |
---|
1484 | if( Element(this.txtfields[i]) != null ) |
---|
1485 | Element(this.txtfields[i]).value = ""; |
---|
1486 | } |
---|
1487 | |
---|
1488 | for(i = 0; i < this.selectFields.length; i++) |
---|
1489 | { |
---|
1490 | if (Element(this.selectFields[i])) |
---|
1491 | Element(this.selectFields[i]).selectedIndex = 0; |
---|
1492 | } |
---|
1493 | |
---|
1494 | if( Element("check_all_msg") != null ) |
---|
1495 | Element("check_all_msg").checked = false; |
---|
1496 | |
---|
1497 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1498 | EsearchE.del_mailboxes(); |
---|
1499 | } |
---|
1500 | |
---|
1501 | // close |
---|
1502 | searchE.prototype.func_close = function(type) |
---|
1503 | { |
---|
1504 | var _this = this; |
---|
1505 | _this.name_box_search = ""; |
---|
1506 | EsearchE.all_boxes.splice(0,(EsearchE.all_boxes.length)); |
---|
1507 | _this.type = type; |
---|
1508 | _this.searchW['window_search'].close(); |
---|
1509 | } |
---|
1510 | // Monta a janela em tela; |
---|
1511 | searchE.prototype.showWindow = function(div) |
---|
1512 | { |
---|
1513 | if(!this.searchW[div.id]) |
---|
1514 | { |
---|
1515 | div.style.width = "804px"; |
---|
1516 | div.style.height = "440px"; |
---|
1517 | div.style.visibility = "hidden"; |
---|
1518 | div.style.position = "absolute"; |
---|
1519 | div.style.zIndex = "10"; |
---|
1520 | var title = ":: "+ get_lang("Search")+" ::"; |
---|
1521 | var wHeight = div.offsetHeight + "px"; |
---|
1522 | var wWidth = div.offsetWidth + "px"; |
---|
1523 | |
---|
1524 | win = new dJSWin({ |
---|
1525 | id: 'ccList'+div.id, |
---|
1526 | content_id: div.id, |
---|
1527 | width: wWidth, |
---|
1528 | height: wHeight, |
---|
1529 | title_color: '#3978d6', |
---|
1530 | bg_color: '#eee', |
---|
1531 | title: title, |
---|
1532 | title_text_color: 'white', |
---|
1533 | button_y_img: '../phpgwapi/images/win_min.gif', |
---|
1534 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
1535 | border: true}); |
---|
1536 | this.searchW[div.id] = win; |
---|
1537 | win.draw(); |
---|
1538 | } |
---|
1539 | else |
---|
1540 | { |
---|
1541 | var _this = this; |
---|
1542 | win = this.searchW[div.id]; |
---|
1543 | if((_this.type == "close" && win.state == 0) || win.state == 2){EsearchE.func_clean();} |
---|
1544 | win.draw(); |
---|
1545 | } |
---|
1546 | win.open(); |
---|
1547 | } |
---|
1548 | |
---|
1549 | searchE.prototype.aux_local_folder_display = function(folder) |
---|
1550 | { |
---|
1551 | if(!expresso_offline) |
---|
1552 | return "(Local) " + lang_folder(folder.substr(6)); |
---|
1553 | else |
---|
1554 | return lang_folder(folder.substr(6)); |
---|
1555 | } |
---|
1556 | |
---|
1557 | searchE.prototype.refresh = function(alert_new_msg){ |
---|
1558 | var handler_refresh = function(data){ |
---|
1559 | var allMsg = [3]; |
---|
1560 | var count = ( data['num_msgs'] ) ? data['num_msgs'] : "0"; |
---|
1561 | |
---|
1562 | if( data['num_msgs'] ) |
---|
1563 | { |
---|
1564 | allMsg['data'] = data['data']; |
---|
1565 | allMsg['num_msgs'] = data['num_msgs']; |
---|
1566 | } |
---|
1567 | |
---|
1568 | if( ( data['num_msgs'] ) == 0 ) |
---|
1569 | { |
---|
1570 | alert( get_lang("None result was found.") ); |
---|
1571 | } |
---|
1572 | else |
---|
1573 | { |
---|
1574 | if( data['num_msgs'] ) |
---|
1575 | { |
---|
1576 | write_msg( count + " " + get_lang("results found") ); |
---|
1577 | EsearchE.mount_result( allMsg, 'SORTDATE', true ); |
---|
1578 | } |
---|
1579 | } |
---|
1580 | } |
---|
1581 | |
---|
1582 | this.condition = openTab.condition[currentTab]; |
---|
1583 | |
---|
1584 | var sort_type = (this.sort_type ? this.sort_type : 'SORTDATE'); |
---|
1585 | |
---|
1586 | if( expresso_offline ) |
---|
1587 | handler('none'); |
---|
1588 | else |
---|
1589 | cExecute( "$this.imap_functions.search_msg", handler_refresh, "condition="+openTab.condition[currentTab]+"&page="+EsearchE.page+"&sort_type="+sort_type); |
---|
1590 | } |
---|
1591 | |
---|
1592 | |
---|
1593 | // Cria o objeto |
---|
1594 | var EsearchE; |
---|
1595 | EsearchE = new searchE(); |
---|