diff --git a/CHANGELOG b/CHANGELOG index 4c7b58f..cef0d6b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +1 July: anyproxy 3.6.0: + + * add a filter on web ui + +1 July: anyproxy 3.5.2: + + * optimize the row height on web ui + 18 June: anyproxy 3.5.1: * print a hint when using SNI features in node <0.12 diff --git a/package.json b/package.json index 3df7701..e68f635 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "3.5.2", + "version": "3.6.0", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { diff --git a/web/build/index.js b/web/build/index.js index c95a4be..11dd760 100644 --- a/web/build/index.js +++ b/web/build/index.js @@ -101,6 +101,12 @@ var eventCenter = new EventManager(); list : recordSet }); }); + + eventCenter.addListener("filterUpdated",function(newKeyword){ + Panel.setState({ + filter: newKeyword + }); + }); })(); @@ -138,4 +144,27 @@ var eventCenter = new EventManager(); ifPause = false; } }); + + function switchFilterWidget(ifToShow){ + if(ifToShow){ + $(".J_filterSection").show(); + $("#J_filterKeyword").focus(); + }else{ + $(".J_filterSection").hide(); + $("#J_filterKeyword").val(""); + } + } + + $(".J_toggleFilterBtn").on("click",function(){ + switchFilterWidget( $(".J_filterSection").css("display") == "none" ); + }); + + $(".J_filterCloseBtn").on("click",function(){ + switchFilterWidget(false); + }); + + + $("#J_filterKeyword").on("change keyup",function(){ + eventCenter.dispatchEvent("filterUpdated",this.value); + }); })(); \ No newline at end of file diff --git a/web/build/recordPanel.js b/web/build/recordPanel.js index 59cb492..b9ae6b0 100644 --- a/web/build/recordPanel.js +++ b/web/build/recordPanel.js @@ -4,14 +4,34 @@ function init(React){ var RecordPanel = React.createClass({displayName: "RecordPanel", getInitialState : function(){ return { - list : [] + list : [], + filter: "" }; }, render : function(){ - var rowCollection = []; + var rowCollection = [], + filterStr = this.state.filter, + filter = filterStr; + + //regexp + if(filterStr[0]=="/" && filterStr[filterStr.length-1]=="/"){ + try{ + filter = new RegExp(filterStr.substr(1,filterStr.length-2)); + }catch(e){} + } + for(var i = this.state.list.length-1 ; i >=0 ; i--){ var item = this.state.list[i]; if(item){ + if(filter && item){ + try{ + if(typeof filter == "object" && !filter.test(item.url)){ + continue; + }else if(typeof filter == "string" && item.url.indexOf(filter) < 0){ + continue; + } + }catch(e){} + } if(item._justUpdated){ item._justUpdated = false; diff --git a/web/css/page.css b/web/css/page.css index 4758bc4..7e30da7 100644 --- a/web/css/page.css +++ b/web/css/page.css @@ -285,4 +285,31 @@ body, html { opacity:0.5; cursor: col-resize; z-index:999 +} + +.filterSection{ + background: #FFF; + padding: 15px 10px; + position: absolute; + left: 0; + top: 0; + border: 1px solid #333; + border-radius: 3px; +} + +.filterSection .filterIcon{ + font-size: 16px; +} + +.filterSection form{ + display: inline-block; + margin-right: 5px; +} + +.filterSection input{ + width: 250px; +} + +.filterSection i{ + cursor: pointer; } \ No newline at end of file diff --git a/web/index.html b/web/index.html index ac08f6d..cc621b3 100644 --- a/web/index.html +++ b/web/index.html @@ -14,21 +14,31 @@
- Stop - Resume - Clear(Ctrl+X) - | - Download rootCA.crt - QRCode of rootCA.crt + Stop + Resume + Filter + Clear(Ctrl+X) | - Anyproxy(Github) + Download rootCA.crt + QRCode of rootCA.crt + + | + Github
- {{rule}} + Rule : {{rule}}
+ + +
diff --git a/web/page.js b/web/page.js index 8f295cb..ae0d176 100644 --- a/web/page.js +++ b/web/page.js @@ -147,6 +147,12 @@ list : recordSet }); }); + + eventCenter.addListener("filterUpdated",function(newKeyword){ + Panel.setState({ + filter: newKeyword + }); + }); })(); @@ -184,6 +190,29 @@ ifPause = false; } }); + + function switchFilterWidget(ifToShow){ + if(ifToShow){ + $(".J_filterSection").show(); + $("#J_filterKeyword").focus(); + }else{ + $(".J_filterSection").hide(); + $("#J_filterKeyword").val(""); + } + } + + $(".J_toggleFilterBtn").on("click",function(){ + switchFilterWidget( $(".J_filterSection").css("display") == "none" ); + }); + + $(".J_filterCloseBtn").on("click",function(){ + switchFilterWidget(false); + }); + + + $("#J_filterKeyword").on("change keyup",function(){ + eventCenter.dispatchEvent("filterUpdated",this.value); + }); })(); /***/ }, @@ -395,14 +424,34 @@ var RecordPanel = React.createClass({displayName: "RecordPanel", getInitialState : function(){ return { - list : [] + list : [], + filter: "" }; }, render : function(){ - var rowCollection = []; + var rowCollection = [], + filterStr = this.state.filter, + filter = filterStr; + + //regexp + if(filterStr[0]=="/" && filterStr[filterStr.length-1]=="/"){ + try{ + filter = new RegExp(filterStr.substr(1,filterStr.length-2)); + }catch(e){} + } + for(var i = this.state.list.length-1 ; i >=0 ; i--){ var item = this.state.list[i]; if(item){ + if(filter && item){ + try{ + if(typeof filter == "object" && !filter.test(item.url)){ + continue; + }else if(typeof filter == "string" && item.url.indexOf(filter) < 0){ + continue; + } + }catch(e){} + } if(item._justUpdated){ item._justUpdated = false; diff --git a/web/src/index.js b/web/src/index.js index 465ccc2..11c5340 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -101,6 +101,12 @@ var eventCenter = new EventManager(); list : recordSet }); }); + + eventCenter.addListener("filterUpdated",function(newKeyword){ + Panel.setState({ + filter: newKeyword + }); + }); })(); @@ -138,4 +144,27 @@ var eventCenter = new EventManager(); ifPause = false; } }); + + function switchFilterWidget(ifToShow){ + if(ifToShow){ + $(".J_filterSection").show(); + $("#J_filterKeyword").focus(); + }else{ + $(".J_filterSection").hide(); + $("#J_filterKeyword").val(""); + } + } + + $(".J_toggleFilterBtn").on("click",function(){ + switchFilterWidget( $(".J_filterSection").css("display") == "none" ); + }); + + $(".J_filterCloseBtn").on("click",function(){ + switchFilterWidget(false); + }); + + + $("#J_filterKeyword").on("change keyup",function(){ + eventCenter.dispatchEvent("filterUpdated",this.value); + }); })(); \ No newline at end of file diff --git a/web/src/recordPanel.js b/web/src/recordPanel.js index 7ce041d..5eb4367 100644 --- a/web/src/recordPanel.js +++ b/web/src/recordPanel.js @@ -4,14 +4,34 @@ function init(React){ var RecordPanel = React.createClass({ getInitialState : function(){ return { - list : [] + list : [], + filter: "" }; }, render : function(){ - var rowCollection = []; + var rowCollection = [], + filterStr = this.state.filter, + filter = filterStr; + + //regexp + if(filterStr[0]=="/" && filterStr[filterStr.length-1]=="/"){ + try{ + filter = new RegExp(filterStr.substr(1,filterStr.length-2)); + }catch(e){} + } + for(var i = this.state.list.length-1 ; i >=0 ; i--){ var item = this.state.list[i]; if(item){ + if(filter && item){ + try{ + if(typeof filter == "object" && !filter.test(item.url)){ + continue; + }else if(typeof filter == "string" && item.url.indexOf(filter) < 0){ + continue; + } + }catch(e){} + } if(item._justUpdated){ item._justUpdated = false;