From 459772a8ef79ac0adeaeba56577972e86074265e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 23 Dec 2014 01:26:03 +0100 Subject: [PATCH] web: squash bugs --- libmproxy/web/static/js/app.js | 28 +++++++++++--------------- web/src/js/components/flowtable.jsx.js | 7 ++++++- web/src/js/components/mainview.jsx.js | 19 +++++------------ web/src/js/store/view.js | 2 +- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/libmproxy/web/static/js/app.js b/libmproxy/web/static/js/app.js index 504743539..4347ada58 100644 --- a/libmproxy/web/static/js/app.js +++ b/libmproxy/web/static/js/app.js @@ -2293,7 +2293,7 @@ _.extend(StoreView.prototype, EventEmitter.prototype, { }, recalculate: function (filt, sortfun) { if (filt) { - this.filt = filt; + this.filt = filt.bind(this); } if (sortfun) { this.sortfun = sortfun.bind(this); @@ -3138,7 +3138,12 @@ var FlowTable = React.createClass({displayName: 'FlowTable', }, renderRow: function (flow) { var selected = (flow === this.props.selected); - var highlighted = (this.props.view._highlight && this.props.view._highlight[flow.id].length > 0); + var highlighted = + ( + this.props.view._highlight && + this.props.view._highlight[flow.id] + ); + return React.createElement(FlowRow, {key: flow.id, ref: flow.id, flow: flow, @@ -3538,27 +3543,18 @@ var MainView = React.createClass({displayName: 'MainView', try { var filt = Filt.parse(this.getQuery()[Query.FILTER] || ""); var highlightStr = this.getQuery()[Query.HIGHLIGHT]; - var highlight = highlightStr ? [Filt.parse(highlightStr)] : []; + var highlight = highlightStr ? Filt.parse(highlightStr) : false; } catch(e){ console.error("Error when processing filter: " + e); } - var FadedHighlightColors = ["hsla(57, 100%, 50%, 0.33)"]; - return function filter_and_highlight(flow) { - var view = this.state.view; - if(!view._highlight){ - view._highlight = {}; - } - view._highlight[flow.id] = []; - - for (var i = 0; i < highlight.length; i++) { - if (highlight[i] && highlight[i](flow)) { - view._highlight[flow.id].push(FadedHighlightColors[i]); - } + if(!this._highlight){ + this._highlight = {}; } + this._highlight[flow.id] = highlight && highlight(flow); return filt(flow); - }.bind(this); + }; }, getViewSort: function () { }, diff --git a/web/src/js/components/flowtable.jsx.js b/web/src/js/components/flowtable.jsx.js index 50caaab3f..efc975a6f 100644 --- a/web/src/js/components/flowtable.jsx.js +++ b/web/src/js/components/flowtable.jsx.js @@ -82,7 +82,12 @@ var FlowTable = React.createClass({ }, renderRow: function (flow) { var selected = (flow === this.props.selected); - var highlighted = (this.props.view._highlight && this.props.view._highlight[flow.id].length > 0); + var highlighted = + ( + this.props.view._highlight && + this.props.view._highlight[flow.id] + ); + return