From dad66d20db2f682cc828b9cbf7e31c19df491733 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Wed, 23 Apr 2014 17:25:36 +0100 Subject: [PATCH] Rewrite Navi widget to use filters.visitTargets and visitFields. HTML generation is now separated from filter-list inspection. --- src/mkws-widgets.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js index 06047f1..cd9e45d 100644 --- a/src/mkws-widgets.js +++ b/src/mkws-widgets.js @@ -267,28 +267,21 @@ mkws.registerWidgetType('Navi', function() { var M = mkws.M; this.team.queue("navi").subscribe(function() { - // This is very low-level poking around inside the filter structure - var list = that.team.filters().list(); + var filters = that.team.filters(); var text = ""; - for (var i in list) { - var filter = list[i]; - if (filter.id) { - if (text) text += " | "; - text += M('source') + ': ' + filter.name + ''; - } - } - - for (var i in list) { - var filter = list[i]; - if (!filter.id) { - if (text) text += " | "; - text += M(filter.field) + ': ' + filter.value + ''; - } - } + filters.visitTargets(function(id, name) { + if (text) text += " | "; + text += M('source') + ': ' + name + ''; + }); + + filters.visitFields(function(field, value) { + if (text) text += " | "; + text += M(field) + ': ' + value + ''; + }); $(that.node).html(text); }); -- 1.7.10.4