mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
web: add more keyboard shortcuts
This commit is contained in:
parent
fd911b75e6
commit
93d1d0416d
File diff suppressed because it is too large
Load Diff
@ -50,6 +50,7 @@ var FilterDocs = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var FilterInput = React.createClass({
|
var FilterInput = React.createClass({
|
||||||
|
mixins: [common.ChildFocus],
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
// Consider both focus and mouseover for showing/hiding the tooltip,
|
// Consider both focus and mouseover for showing/hiding the tooltip,
|
||||||
// because onBlur of the input is triggered before the click on the tooltip
|
// because onBlur of the input is triggered before the click on the tooltip
|
||||||
@ -114,11 +115,13 @@ var FilterInput = React.createClass({
|
|||||||
// If closed using ESC/ENTER, hide the tooltip.
|
// If closed using ESC/ENTER, hide the tooltip.
|
||||||
this.setState({mousefocus: false});
|
this.setState({mousefocus: false});
|
||||||
}
|
}
|
||||||
|
e.stopPropagation();
|
||||||
},
|
},
|
||||||
blur: function () {
|
blur: function () {
|
||||||
this.refs.input.getDOMNode().blur();
|
this.refs.input.getDOMNode().blur();
|
||||||
|
this.context.returnFocus && this.context.returnFocus();
|
||||||
},
|
},
|
||||||
focus: function () {
|
select: function () {
|
||||||
this.refs.input.getDOMNode().select();
|
this.refs.input.getDOMNode().select();
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
@ -184,18 +187,21 @@ var MainMenu = React.createClass({
|
|||||||
<div>
|
<div>
|
||||||
<div className="menu-row">
|
<div className="menu-row">
|
||||||
<FilterInput
|
<FilterInput
|
||||||
|
ref="filter"
|
||||||
placeholder="Filter"
|
placeholder="Filter"
|
||||||
type="filter"
|
type="filter"
|
||||||
color="black"
|
color="black"
|
||||||
value={filter}
|
value={filter}
|
||||||
onChange={this.onFilterChange} />
|
onChange={this.onFilterChange} />
|
||||||
<FilterInput
|
<FilterInput
|
||||||
|
ref="highlight"
|
||||||
placeholder="Highlight"
|
placeholder="Highlight"
|
||||||
type="tag"
|
type="tag"
|
||||||
color="hsl(48, 100%, 50%)"
|
color="hsl(48, 100%, 50%)"
|
||||||
value={highlight}
|
value={highlight}
|
||||||
onChange={this.onHighlightChange}/>
|
onChange={this.onHighlightChange}/>
|
||||||
<FilterInput
|
<FilterInput
|
||||||
|
ref="intercept"
|
||||||
placeholder="Intercept"
|
placeholder="Intercept"
|
||||||
type="pause"
|
type="pause"
|
||||||
color="hsl(208, 56%, 53%)"
|
color="hsl(208, 56%, 53%)"
|
||||||
@ -357,7 +363,7 @@ var Header = React.createClass({
|
|||||||
render: function () {
|
render: function () {
|
||||||
var header = header_entries.map(function (entry, i) {
|
var header = header_entries.map(function (entry, i) {
|
||||||
var className;
|
var className;
|
||||||
if(entry === this.state.active){
|
if (entry === this.state.active) {
|
||||||
className = "active";
|
className = "active";
|
||||||
} else {
|
} else {
|
||||||
className = "";
|
className = "";
|
||||||
@ -379,7 +385,7 @@ var Header = React.createClass({
|
|||||||
{header}
|
{header}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="menu">
|
<div className="menu">
|
||||||
<this.state.active/>
|
<this.state.active ref="active"/>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
@ -388,5 +394,6 @@ var Header = React.createClass({
|
|||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Header: Header
|
Header: Header,
|
||||||
|
MainMenu: MainMenu
|
||||||
};
|
};
|
@ -15,18 +15,13 @@ var MainView = React.createClass({
|
|||||||
flowStore: React.PropTypes.object.isRequired,
|
flowStore: React.PropTypes.object.isRequired,
|
||||||
},
|
},
|
||||||
childContextTypes: {
|
childContextTypes: {
|
||||||
returnFocus: React.PropTypes.func.isRequired,
|
|
||||||
view: React.PropTypes.object.isRequired,
|
view: React.PropTypes.object.isRequired,
|
||||||
},
|
},
|
||||||
getChildContext: function () {
|
getChildContext: function () {
|
||||||
return {
|
return {
|
||||||
returnFocus: this.returnFocus,
|
|
||||||
view: this.state.view
|
view: this.state.view
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
returnFocus: function () {
|
|
||||||
this.getDOMNode().focus();
|
|
||||||
},
|
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
var sortKeyFun = false;
|
var sortKeyFun = false;
|
||||||
var view = new views.StoreView(this.context.flowStore, this.getViewFilt(), sortKeyFun);
|
var view = new views.StoreView(this.context.flowStore, this.getViewFilt(), sortKeyFun);
|
||||||
|
@ -25,16 +25,18 @@ var ProxyAppMain = React.createClass({
|
|||||||
childContextTypes: {
|
childContextTypes: {
|
||||||
settingsStore: React.PropTypes.object.isRequired,
|
settingsStore: React.PropTypes.object.isRequired,
|
||||||
flowStore: React.PropTypes.object.isRequired,
|
flowStore: React.PropTypes.object.isRequired,
|
||||||
eventStore: React.PropTypes.object.isRequired
|
eventStore: React.PropTypes.object.isRequired,
|
||||||
|
returnFocus: React.PropTypes.func.isRequired,
|
||||||
},
|
},
|
||||||
componentDidMount: function () {
|
componentDidMount: function () {
|
||||||
React.findDOMNode(this).focus();
|
this.focus();
|
||||||
},
|
},
|
||||||
getChildContext: function () {
|
getChildContext: function () {
|
||||||
return {
|
return {
|
||||||
settingsStore: this.state.settingsStore,
|
settingsStore: this.state.settingsStore,
|
||||||
flowStore: this.state.flowStore,
|
flowStore: this.state.flowStore,
|
||||||
eventStore: this.state.eventStore
|
eventStore: this.state.eventStore,
|
||||||
|
returnFocus: this.focus,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
@ -50,21 +52,39 @@ var ProxyAppMain = React.createClass({
|
|||||||
eventStore: eventStore
|
eventStore: eventStore
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
focus: function () {
|
||||||
|
React.findDOMNode(this).focus();
|
||||||
|
},
|
||||||
getMainComponent: function () {
|
getMainComponent: function () {
|
||||||
return this.refs.view.refs.__routeHandler__;
|
return this.refs.view.refs.__routeHandler__;
|
||||||
},
|
},
|
||||||
onKeydown: function (e) {
|
onKeydown: function (e) {
|
||||||
switch(e.keyCode){
|
|
||||||
|
var selectFilterInput = function (name) {
|
||||||
|
var headerComponent = this.refs.header;
|
||||||
|
headerComponent.setState({active: header.MainMenu}, function () {
|
||||||
|
headerComponent.refs.active.refs[name].select();
|
||||||
|
});
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
switch (e.keyCode) {
|
||||||
case Key.I:
|
case Key.I:
|
||||||
console.error("unimplemented: intercept");
|
selectFilterInput("intercept");
|
||||||
|
break;
|
||||||
|
case Key.L:
|
||||||
|
selectFilterInput("filter");
|
||||||
|
break;
|
||||||
|
case Key.H:
|
||||||
|
selectFilterInput("highlight");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var main = this.getMainComponent();
|
var main = this.getMainComponent();
|
||||||
if(main && main.onMainKeyDown){
|
if (main.onMainKeyDown) {
|
||||||
main.onMainKeyDown(e);
|
main.onMainKeyDown(e);
|
||||||
}
|
}
|
||||||
|
return; // don't prevent default then
|
||||||
}
|
}
|
||||||
|
e.preventDefault();
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
var eventlog;
|
var eventlog;
|
||||||
@ -78,7 +98,7 @@ var ProxyAppMain = React.createClass({
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div id="container" tabIndex="0" onKeyDown={this.onKeydown}>
|
<div id="container" tabIndex="0" onKeyDown={this.onKeydown}>
|
||||||
<header.Header/>
|
<header.Header ref="header"/>
|
||||||
<RouteHandler ref="view" query={this.getQuery()}/>
|
<RouteHandler ref="view" query={this.getQuery()}/>
|
||||||
{eventlog}
|
{eventlog}
|
||||||
<Footer/>
|
<Footer/>
|
||||||
|
@ -2,10 +2,10 @@ var $ = require("jquery");
|
|||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
var actions = require("./actions.js");
|
var actions = require("./actions.js");
|
||||||
|
|
||||||
//debug
|
//Debug (don't expose by default, this increases compile time drastically)
|
||||||
window.$ = $;
|
//window.$ = $;
|
||||||
window._ = _;
|
//window._ = _;
|
||||||
window.React = require("React/addons");
|
//window.React = require("React");
|
||||||
|
|
||||||
var Key = {
|
var Key = {
|
||||||
UP: 38,
|
UP: 38,
|
||||||
|
Loading…
Reference in New Issue
Block a user