1 // Factory function for sets of filters.
2 function filterSet(team) {
8 that.list = function() {
12 that.add = function(filter) {
16 that.visitTargets = function(callback) {
17 for (var i in m_list) {
18 var filter = m_list[i];
20 callback(filter.id, filter.name);
25 that.visitFields = function(callback) {
26 for (var i in m_list) {
27 var filter = m_list[i];
29 callback(filter.field, filter.value);
34 that.removeMatching = function(matchFn) {
36 for (var i in m_list) {
37 var filter = m_list[i];
38 if (matchFn(filter)) {
39 m_team.log("removeMatching() removing filter " + $.toJSON(filter));
41 m_team.log("removeMatching() keeping filter " + $.toJSON(filter));
48 that.targetFiltered = function(id) {
49 for (var i = 0; i < m_list.length; i++) {
50 if (m_list[i].id === id ||
51 m_list[i].id === 'pz:id=' + id) {
58 that.pp2filter = function() {
61 for (var i in m_list) {
62 var filter = m_list[i];
65 if (filter.id.match(/^[a-z:]+[=~]/)) {
66 m_team.log("filter '" + filter.id + "' already begins with SETTING OP");
68 filter.id = 'pz:id=' + filter.id;
77 that.pp2limit = function(initial) {
78 var res = initial || "";
80 for (var i in m_list) {
81 var filter = m_list[i];
84 res += filter.field + "=" + filter.value.replace(/[\\|,]/g, '\\$&');
96 // Factory function for filters. These can be of several types.
97 function filter(id, name, field, value) {
101 res = { id: id, name: name };
103 res = { field: field, value: value };