- if (id) {
- res = { id: id, name: name };
- } else {
- res = { field: field, value: value };
+ var that = {};
+
+ that.toJSON = function() {
+ return mkws.$.toJSON(m_list);
+ };
+
+ that.add = function(filter) {
+ m_list.push(filter);
+ };
+
+ that.visitTargets = function(callback) {
+ for (var i in m_list) {
+ var filter = m_list[i];
+ if (filter.type === 'target') {
+ callback(filter.id, filter.name);
+ }
+ }
+ };
+
+ that.visitFields = function(callback) {
+ for (var i in m_list) {
+ var filter = m_list[i];
+ if (filter.type === 'field') {
+ callback(filter.field, filter.value);
+ }
+ }
+ };
+
+ that.visitCategories = function(callback) {
+ for (var i in m_list) {
+ var filter = m_list[i];
+ if (filter.type === 'category') {
+ callback(filter.id);
+ }