var $,build_links,exports,init_form,remove_filter;$=jQuery;exports=this;build_links=function(filters){var links,rows,tmpl;tmpl='<a href="/reports/filters/delete/{{index}}"><img src="{{media_url}}imgs/sm-del.png" alt="[x]" /></a>'+'&nbsp;{{filter_field}} {{filter_by}} {{filter_value}}&nbsp;';rows=[];$.each(filters,function(i,f){var html;f.index=i;f.media_url=exports.media_url;html=$.mustache(tmpl,f);return rows.push(html);});links=rows.join('');return links;};remove_filter=function(e,url){e.preventDefault();$('#filter_form_submit').attr({disabled:'disabled',value:gettext('Loading')});$('#spinner').show();$.ajax(url+'.json',{type:'GET',cache:false,dataType:'json',success:process_response,error:ajax_error_redirect});return 1;};init_form=function(){var bool_fields,bool_values,fltdby,fltdval,num_fields,num_values,select_option,select_text,text_fields,text_values,time_fields,time_values;bool_fields=["scaned","spam","highspam","saspam","rblspam","whitelisted","blacklisted","virusinfected","nameinfected","otherinfected","isquarantined"];num_fields=["size","sascore"];text_fields=["messageid","from_address","from_domain","to_address","to_domain","subject","clientip","spamreport","headers"];time_fields=["date","time"];num_values=[{'value':1,'opt':gettext('is equal to')},{'value':2,'opt':gettext('is not equal to')},{'value':3,'opt':gettext('is greater than')},{'value':4,'opt':gettext('is less than')}];text_values=[{'value':1,'opt':gettext('is equal to')},{'value':2,'opt':gettext('is not equal to')},{'value':9,'opt':gettext('is null')},{'value':10,'opt':gettext('is not null')},{'value':5,'opt':gettext('contains')},{'value':6,'opt':gettext('does not contain')},{'value':7,'opt':gettext('matches regex')},{'value':8,'opt':gettext('does not match regex')}];time_values=[{'value':1,'opt':gettext('is equal to')},{'value':2,'opt':gettext('is not equal to')},{'value':3,'opt':gettext('is greater than')},{'value':4,'opt':gettext('is less than')}];bool_values=[{'value':11,'opt':gettext('is true')},{'value':12,'opt':gettext('is false')}];select_text=gettext('Please select');select_option="<option value=\"0\" selected=\"0\">"+select_text+"</option>";$("#filtered_field").prepend(select_option);$("#filtered_value").attr({disabled:'disabled'});fltdval=$("#filtered_value");fltdby=$("#filtered_by");$("#filtered_field").bind('change',function(){var value_to_check;value_to_check=$(this).val();if($.inArray(value_to_check,bool_fields)!==-1){fltdby.empty();$.each(bool_values,function(i,n){return fltdby.append($('<option/>',{value:n.value,html:n.opt}));});fltdval.attr({disabled:'disabled',value:''});}if($.inArray(value_to_check,num_fields)!==-1){fltdby.empty();$.each(num_values,function(i,n){return fltdby.append($('<option/>',{value:n.value,html:n.opt}));});fltdval.removeAttr('disabled');fltdval.attr({value:''});}if($.inArray(value_to_check,text_fields)!==-1){fltdby.empty();$.each(text_values,function(i,n){return fltdby.append($('<option/>',{value:n.value,html:n.opt}));});fltdval.removeAttr('disabled');fltdval.attr({value:''});}if($.inArray(value_to_check,time_fields)!==-1){fltdby.empty();$.each(time_values,function(i,n){return fltdby.append($('<option/>',{value:n.value,html:n.opt}));});fltdval.removeAttr('disabled');if(value_to_check==='time')return fltdval.attr({value:'HH:MM'});else return fltdval.attr({value:'YYYY-MM-DD'});}});return 1;};