mitmproxy/libmproxy/web/static/js/app.js

3979 lines
120 KiB
JavaScript
Raw Normal View History

2014-09-17 13:22:42 +00:00
// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html (also contains inverse example)
var AutoScrollMixin = {
componentWillUpdate: function () {
var node = this.getDOMNode();
2014-12-12 18:43:55 +00:00
this._shouldScrollBottom = (
2014-12-13 00:56:04 +00:00
node.scrollTop !== 0 &&
2014-12-12 18:43:55 +00:00
node.scrollTop + node.clientHeight === node.scrollHeight
);
2014-09-17 13:22:42 +00:00
},
componentDidUpdate: function () {
if (this._shouldScrollBottom) {
var node = this.getDOMNode();
node.scrollTop = node.scrollHeight;
}
},
};
2014-12-10 01:48:04 +00:00
2014-09-18 19:13:50 +00:00
var StickyHeadMixin = {
2014-09-18 23:35:36 +00:00
adjustHead: function () {
2014-09-18 19:13:50 +00:00
// Abusing CSS transforms to set the element
// referenced as head into some kind of position:sticky.
var head = this.refs.head.getDOMNode();
2014-09-18 23:35:36 +00:00
head.style.transform = "translate(0," + this.getDOMNode().scrollTop + "px)";
2014-09-18 19:13:50 +00:00
}
};
2014-12-10 01:48:04 +00:00
2014-12-12 18:19:00 +00:00
var Navigation = _.extend({}, ReactRouter.Navigation, {
2014-12-13 00:56:04 +00:00
setQuery: function (dict) {
2014-12-12 18:19:00 +00:00
var q = this.context.getCurrentQuery();
2014-12-13 00:56:04 +00:00
for(var i in dict){
if(dict.hasOwnProperty(i)){
q[i] = dict[i] || undefined; //falsey values shall be removed.
}
}
q._ = "_"; // workaround for https://github.com/rackt/react-router/pull/599
2014-12-12 18:19:00 +00:00
this.replaceWith(this.context.getCurrentPath(), this.context.getCurrentParams(), q);
},
replaceWith: function(routeNameOrPath, params, query) {
if(routeNameOrPath === undefined){
routeNameOrPath = this.context.getCurrentPath();
}
if(params === undefined){
params = this.context.getCurrentParams();
}
if(query === undefined){
query = this.context.getCurrentQuery();
}
2014-12-12 18:33:06 +00:00
ReactRouter.Navigation.replaceWith.call(this, routeNameOrPath, params, query);
2014-12-12 18:19:00 +00:00
}
});
2014-12-13 00:56:04 +00:00
_.extend(Navigation.contextTypes, ReactRouter.State.contextTypes);
2014-12-12 18:19:00 +00:00
var State = _.extend({}, ReactRouter.State, {
getInitialState: function () {
this._query = this.context.getCurrentQuery();
this._queryWatches = [];
return null;
},
onQueryChange: function (key, callback) {
this._queryWatches.push({
key: key,
callback: callback
});
},
componentWillReceiveProps: function (nextProps, nextState) {
var q = this.context.getCurrentQuery();
for (var i = 0; i < this._queryWatches.length; i++) {
var watch = this._queryWatches[i];
if (this._query[watch.key] !== q[watch.key]) {
watch.callback(this._query[watch.key], q[watch.key], watch.key);
}
}
this._query = q;
}
});
var Key = {
UP: 38,
DOWN: 40,
2014-09-18 19:13:50 +00:00
PAGE_UP: 33,
PAGE_DOWN: 34,
2014-12-13 00:56:04 +00:00
HOME: 36,
END: 35,
LEFT: 37,
RIGHT: 39,
ENTER: 13,
2014-09-19 15:56:54 +00:00
ESC: 27,
TAB: 9,
SPACE: 32,
2014-12-13 00:56:04 +00:00
BACKSPACE: 8,
2014-09-18 19:13:50 +00:00
};
2014-12-23 19:33:42 +00:00
// Add A-Z
for(var i=65; i <= 90; i++){
Key[String.fromCharCode(i)] = i;
}
2014-09-18 23:35:36 +00:00
2014-12-10 01:48:04 +00:00
2014-09-19 15:56:54 +00:00
var formatSize = function (bytes) {
var size = bytes;
2014-09-18 23:35:36 +00:00
var prefix = ["B", "KB", "MB", "GB", "TB"];
2014-11-27 00:40:26 +00:00
var i = 0;
while (Math.abs(size) >= 1024 && i < prefix.length - 1) {
2014-09-21 23:44:46 +00:00
i++;
2014-09-18 23:35:36 +00:00
size = size / 1024;
}
2014-09-21 23:44:46 +00:00
return (Math.floor(size * 100) / 100.0).toFixed(2) + prefix[i];
2014-09-19 15:56:54 +00:00
};
2014-12-10 01:48:04 +00:00
2014-09-19 15:56:54 +00:00
var formatTimeDelta = function (milliseconds) {
var time = milliseconds;
2014-09-21 21:43:27 +00:00
var prefix = ["ms", "s", "min", "h"];
2014-09-19 15:56:54 +00:00
var div = [1000, 60, 60];
2014-09-21 23:44:46 +00:00
var i = 0;
while (Math.abs(time) >= div[i] && i < div.length) {
time = time / div[i];
i++;
2014-09-19 15:56:54 +00:00
}
2014-09-21 23:44:46 +00:00
return Math.round(time) + prefix[i];
2014-09-18 23:35:36 +00:00
};
2014-11-29 02:25:07 +00:00
2014-12-10 01:48:04 +00:00
2014-11-29 02:25:07 +00:00
var formatTimeStamp = function (seconds) {
var ts = (new Date(seconds * 1000)).toISOString();
return ts.replace("T", " ").replace("Z", "");
};
2014-12-10 01:48:04 +00:00
function EventEmitter() {
this.listeners = {};
}
EventEmitter.prototype.emit = function (event) {
if (!(event in this.listeners)) {
return;
}
var args = Array.prototype.slice.call(arguments, 1);
this.listeners[event].forEach(function (listener) {
listener.apply(this, args);
}.bind(this));
};
EventEmitter.prototype.addListener = function (events, f) {
events.split(" ").forEach(function (event) {
this.listeners[event] = this.listeners[event] || [];
this.listeners[event].push(f);
}.bind(this));
};
EventEmitter.prototype.removeListener = function (events, f) {
if (!(events in this.listeners)) {
return false;
}
events.split(" ").forEach(function (event) {
var index = this.listeners[event].indexOf(f);
if (index >= 0) {
this.listeners[event].splice(index, 1);
}
}.bind(this));
};
2014-09-15 16:08:26 +00:00
const PayloadSources = {
2014-09-17 13:22:42 +00:00
VIEW: "view",
SERVER: "server"
2014-09-15 16:08:26 +00:00
};
2014-09-14 00:44:13 +00:00
2014-09-17 00:13:37 +00:00
function Dispatcher() {
2014-09-16 09:06:30 +00:00
this.callbacks = [];
}
2014-09-17 00:13:37 +00:00
Dispatcher.prototype.register = function (callback) {
2014-09-16 09:06:30 +00:00
this.callbacks.push(callback);
};
2014-09-17 00:13:37 +00:00
Dispatcher.prototype.unregister = function (callback) {
var index = this.callbacks.indexOf(callback);
2014-09-16 09:06:30 +00:00
if (index >= 0) {
this.callbacks.splice(index, 1);
2014-09-14 00:44:13 +00:00
}
2014-09-16 09:06:30 +00:00
};
2014-09-17 00:13:37 +00:00
Dispatcher.prototype.dispatch = function (payload) {
2014-09-16 09:06:30 +00:00
console.debug("dispatch", payload);
2014-11-27 00:40:26 +00:00
for (var i = 0; i < this.callbacks.length; i++) {
2014-09-21 23:44:46 +00:00
this.callbacks[i](payload);
}
2014-09-16 09:06:30 +00:00
};
2014-09-14 00:44:13 +00:00
2014-09-15 16:08:26 +00:00
AppDispatcher = new Dispatcher();
2014-09-17 00:13:37 +00:00
AppDispatcher.dispatchViewAction = function (action) {
2014-09-17 13:22:42 +00:00
action.source = PayloadSources.VIEW;
2014-09-15 22:56:43 +00:00
this.dispatch(action);
2014-09-15 16:08:26 +00:00
};
2014-09-17 00:13:37 +00:00
AppDispatcher.dispatchServerAction = function (action) {
2014-09-17 13:22:42 +00:00
action.source = PayloadSources.SERVER;
2014-09-15 22:56:43 +00:00
this.dispatch(action);
2014-09-15 22:05:06 +00:00
};
2014-09-15 16:08:26 +00:00
var ActionTypes = {
2014-12-09 17:55:16 +00:00
// Connection
CONNECTION_OPEN: "connection_open",
CONNECTION_CLOSE: "connection_close",
CONNECTION_ERROR: "connection_error",
2014-12-09 17:18:14 +00:00
2014-12-10 16:44:45 +00:00
// Stores
SETTINGS_STORE: "settings",
EVENT_STORE: "events",
FLOW_STORE: "flows",
};
var StoreCmds = {
ADD: "add",
UPDATE: "update",
REMOVE: "remove",
RESET: "reset"
2014-12-09 17:18:14 +00:00
};
var ConnectionActions = {
open: function () {
AppDispatcher.dispatchViewAction({
2014-12-09 17:55:16 +00:00
type: ActionTypes.CONNECTION_OPEN
2014-12-09 17:18:14 +00:00
});
},
close: function () {
AppDispatcher.dispatchViewAction({
2014-12-09 17:55:16 +00:00
type: ActionTypes.CONNECTION_CLOSE
2014-12-09 17:18:14 +00:00
});
},
error: function () {
AppDispatcher.dispatchViewAction({
2014-12-09 17:55:16 +00:00
type: ActionTypes.CONNECTION_ERROR
2014-12-09 17:18:14 +00:00
});
}
2014-09-15 16:08:26 +00:00
};
2014-09-14 00:44:13 +00:00
2014-09-15 16:08:26 +00:00
var SettingsActions = {
2014-09-17 00:13:37 +00:00
update: function (settings) {
2014-12-23 19:33:42 +00:00
jQuery.ajax({
type: "PUT",
url: "/settings",
data: settings
});
2014-09-15 22:56:43 +00:00
2014-12-10 16:44:45 +00:00
//Facebook Flux: We do an optimistic update on the client already.
2014-09-15 22:56:43 +00:00
AppDispatcher.dispatchViewAction({
type: ActionTypes.SETTINGS_STORE,
cmd: StoreCmds.UPDATE,
data: settings
2014-09-15 22:56:43 +00:00
});
}
2014-09-15 16:08:26 +00:00
};
2014-09-14 00:44:13 +00:00
2014-12-09 17:18:14 +00:00
var EventLogActions_event_id = 0;
2014-09-17 15:30:19 +00:00
var EventLogActions = {
2014-11-27 00:40:26 +00:00
add_event: function (message) {
2014-09-17 15:30:19 +00:00
AppDispatcher.dispatchViewAction({
type: ActionTypes.EVENT_STORE,
cmd: StoreCmds.ADD,
2014-09-17 15:30:19 +00:00
data: {
message: message,
2014-09-22 01:06:19 +00:00
level: "web",
2014-12-09 17:18:14 +00:00
id: "viewAction-" + EventLogActions_event_id++
2014-09-17 15:30:19 +00:00
}
});
}
};
2014-12-12 18:19:00 +00:00
Query = {
2014-12-13 00:56:04 +00:00
FILTER: "f",
HIGHLIGHT: "h"
2014-12-12 18:19:00 +00:00
};
Filt = (function() {
/*
* Generated by PEG.js 0.8.0.
*
* http://pegjs.majda.cz/
*/
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function SyntaxError(message, expected, found, offset, line, column) {
this.message = message;
this.expected = expected;
this.found = found;
this.offset = offset;
this.line = line;
this.column = column;
this.name = "SyntaxError";
}
peg$subclass(SyntaxError, Error);
function parse(input) {
var options = arguments.length > 1 ? arguments[1] : {},
peg$FAILED = {},
peg$startRuleFunctions = { start: peg$parsestart },
peg$startRuleFunction = peg$parsestart,
peg$c0 = { type: "other", description: "filter expression" },
peg$c1 = peg$FAILED,
peg$c2 = function(orExpr) { return orExpr; },
2014-12-12 18:33:06 +00:00
peg$c3 = [],
peg$c4 = function() {return trueFilter; },
peg$c5 = { type: "other", description: "whitespace" },
peg$c6 = /^[ \t\n\r]/,
peg$c7 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
peg$c8 = { type: "other", description: "control character" },
peg$c9 = /^[|&!()~"]/,
peg$c10 = { type: "class", value: "[|&!()~\"]", description: "[|&!()~\"]" },
peg$c11 = { type: "other", description: "optional whitespace" },
peg$c12 = "|",
peg$c13 = { type: "literal", value: "|", description: "\"|\"" },
peg$c14 = function(first, second) { return or(first, second); },
peg$c15 = "&",
peg$c16 = { type: "literal", value: "&", description: "\"&\"" },
peg$c17 = function(first, second) { return and(first, second); },
peg$c18 = "!",
peg$c19 = { type: "literal", value: "!", description: "\"!\"" },
peg$c20 = function(expr) { return not(expr); },
peg$c21 = "(",
peg$c22 = { type: "literal", value: "(", description: "\"(\"" },
peg$c23 = ")",
peg$c24 = { type: "literal", value: ")", description: "\")\"" },
2014-12-13 00:56:04 +00:00
peg$c25 = function(expr) { return binding(expr); },
2014-12-12 18:33:06 +00:00
peg$c26 = "~a",
peg$c27 = { type: "literal", value: "~a", description: "\"~a\"" },
peg$c28 = function() { return assetFilter; },
peg$c29 = "~e",
peg$c30 = { type: "literal", value: "~e", description: "\"~e\"" },
peg$c31 = function() { return errorFilter; },
peg$c32 = "~q",
peg$c33 = { type: "literal", value: "~q", description: "\"~q\"" },
peg$c34 = function() { return noResponseFilter; },
peg$c35 = "~s",
peg$c36 = { type: "literal", value: "~s", description: "\"~s\"" },
peg$c37 = function() { return responseFilter; },
peg$c38 = "true",
peg$c39 = { type: "literal", value: "true", description: "\"true\"" },
peg$c40 = function() { return trueFilter; },
peg$c41 = "false",
peg$c42 = { type: "literal", value: "false", description: "\"false\"" },
peg$c43 = function() { return falseFilter; },
peg$c44 = "~c",
peg$c45 = { type: "literal", value: "~c", description: "\"~c\"" },
peg$c46 = function(s) { return responseCode(s); },
peg$c47 = "~d",
peg$c48 = { type: "literal", value: "~d", description: "\"~d\"" },
peg$c49 = function(s) { return domain(s); },
peg$c50 = "~h",
peg$c51 = { type: "literal", value: "~h", description: "\"~h\"" },
peg$c52 = function(s) { return header(s); },
peg$c53 = "~hq",
peg$c54 = { type: "literal", value: "~hq", description: "\"~hq\"" },
peg$c55 = function(s) { return requestHeader(s); },
peg$c56 = "~hs",
peg$c57 = { type: "literal", value: "~hs", description: "\"~hs\"" },
peg$c58 = function(s) { return responseHeader(s); },
peg$c59 = "~m",
peg$c60 = { type: "literal", value: "~m", description: "\"~m\"" },
peg$c61 = function(s) { return method(s); },
peg$c62 = "~t",
peg$c63 = { type: "literal", value: "~t", description: "\"~t\"" },
peg$c64 = function(s) { return contentType(s); },
peg$c65 = "~tq",
peg$c66 = { type: "literal", value: "~tq", description: "\"~tq\"" },
peg$c67 = function(s) { return requestContentType(s); },
peg$c68 = "~ts",
peg$c69 = { type: "literal", value: "~ts", description: "\"~ts\"" },
peg$c70 = function(s) { return responseContentType(s); },
peg$c71 = "~u",
peg$c72 = { type: "literal", value: "~u", description: "\"~u\"" },
peg$c73 = function(s) { return url(s); },
2014-12-13 00:56:04 +00:00
peg$c74 = { type: "other", description: "integer" },
peg$c75 = null,
peg$c76 = /^['"]/,
peg$c77 = { type: "class", value: "['\"]", description: "['\"]" },
peg$c78 = /^[0-9]/,
peg$c79 = { type: "class", value: "[0-9]", description: "[0-9]" },
peg$c80 = function(digits) { return parseInt(digits.join(""), 10); },
peg$c81 = { type: "other", description: "string" },
peg$c82 = "\"",
peg$c83 = { type: "literal", value: "\"", description: "\"\\\"\"" },
peg$c84 = function(chars) { return chars.join(""); },
peg$c85 = "'",
peg$c86 = { type: "literal", value: "'", description: "\"'\"" },
peg$c87 = void 0,
peg$c88 = /^["\\]/,
peg$c89 = { type: "class", value: "[\"\\\\]", description: "[\"\\\\]" },
peg$c90 = { type: "any", description: "any character" },
peg$c91 = function(char) { return char; },
peg$c92 = "\\",
peg$c93 = { type: "literal", value: "\\", description: "\"\\\\\"" },
peg$c94 = /^['\\]/,
peg$c95 = { type: "class", value: "['\\\\]", description: "['\\\\]" },
peg$c96 = /^['"\\]/,
peg$c97 = { type: "class", value: "['\"\\\\]", description: "['\"\\\\]" },
peg$c98 = "n",
peg$c99 = { type: "literal", value: "n", description: "\"n\"" },
peg$c100 = function() { return "\n"; },
peg$c101 = "r",
peg$c102 = { type: "literal", value: "r", description: "\"r\"" },
peg$c103 = function() { return "\r"; },
peg$c104 = "t",
peg$c105 = { type: "literal", value: "t", description: "\"t\"" },
peg$c106 = function() { return "\t"; },
2014-12-12 18:19:00 +00:00
peg$currPos = 0,
peg$reportedPos = 0,
peg$cachedPos = 0,
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$reportedPos, peg$currPos);
}
function offset() {
return peg$reportedPos;
}
function line() {
return peg$computePosDetails(peg$reportedPos).line;
}
function column() {
return peg$computePosDetails(peg$reportedPos).column;
}
function expected(description) {
throw peg$buildException(
null,
[{ type: "other", description: description }],
peg$reportedPos
);
}
function error(message) {
throw peg$buildException(message, null, peg$reportedPos);
}
function peg$computePosDetails(pos) {
function advance(details, startPos, endPos) {
var p, ch;
for (p = startPos; p < endPos; p++) {
ch = input.charAt(p);
if (ch === "\n") {
if (!details.seenCR) { details.line++; }
details.column = 1;
details.seenCR = false;
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
details.line++;
details.column = 1;
details.seenCR = true;
} else {
details.column++;
details.seenCR = false;
}
}
}
if (peg$cachedPos !== pos) {
if (peg$cachedPos > pos) {
peg$cachedPos = 0;
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
}
advance(peg$cachedPosDetails, peg$cachedPos, pos);
peg$cachedPos = pos;
}
return peg$cachedPosDetails;
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildException(message, expected, pos) {
function cleanupExpected(expected) {
var i = 1;
expected.sort(function(a, b) {
if (a.description < b.description) {
return -1;
} else if (a.description > b.description) {
return 1;
} else {
return 0;
}
});
while (i < expected.length) {
if (expected[i - 1] === expected[i]) {
expected.splice(i, 1);
} else {
i++;
}
}
}
function buildMessage(expected, found) {
function stringEscape(s) {
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\x08/g, '\\b')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\f/g, '\\f')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
}
var expectedDescs = new Array(expected.length),
expectedDesc, foundDesc, i;
for (i = 0; i < expected.length; i++) {
expectedDescs[i] = expected[i].description;
}
expectedDesc = (expected.length > 1
? expectedDescs.slice(0, -1).join(", ")
+ " or "
+ expectedDescs[expected.length - 1]
: expectedDescs[0]);
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
return "Expected " + expectedDesc + " but " + foundDesc + " found.";
}
var posDetails = peg$computePosDetails(pos),
found = pos < input.length ? input.charAt(pos) : null;
if (expected !== null) {
cleanupExpected(expected);
}
return new SyntaxError(
message !== null ? message : buildMessage(expected, found),
expected,
found,
pos,
posDetails.line,
posDetails.column
);
}
function peg$parsestart() {
var s0, s1, s2, s3;
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parse__();
if (s1 !== peg$FAILED) {
s2 = peg$parseOrExpr();
if (s2 !== peg$FAILED) {
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c2(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
2014-12-12 18:33:06 +00:00
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = [];
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c4();
}
s0 = s1;
}
2014-12-12 18:19:00 +00:00
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c0); }
}
return s0;
}
function peg$parsews() {
var s0, s1;
peg$silentFails++;
2014-12-12 18:33:06 +00:00
if (peg$c6.test(input.charAt(peg$currPos))) {
2014-12-12 18:19:00 +00:00
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c7); }
2014-12-12 18:19:00 +00:00
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c5); }
2014-12-12 18:19:00 +00:00
}
return s0;
}
function peg$parsecc() {
var s0, s1;
peg$silentFails++;
2014-12-12 18:33:06 +00:00
if (peg$c9.test(input.charAt(peg$currPos))) {
2014-12-12 18:19:00 +00:00
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c10); }
2014-12-12 18:19:00 +00:00
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c8); }
2014-12-12 18:19:00 +00:00
}
return s0;
}
function peg$parse__() {
var s0, s1;
peg$silentFails++;
s0 = [];
s1 = peg$parsews();
while (s1 !== peg$FAILED) {
s0.push(s1);
s1 = peg$parsews();
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c11); }
2014-12-12 18:19:00 +00:00
}
return s0;
}
function peg$parseOrExpr() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseAndExpr();
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 124) {
2014-12-12 18:33:06 +00:00
s3 = peg$c12;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s3 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c13); }
2014-12-12 18:19:00 +00:00
}
if (s3 !== peg$FAILED) {
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
s5 = peg$parseOrExpr();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c14(s1, s5);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$parseAndExpr();
}
return s0;
}
function peg$parseAndExpr() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseNotExpr();
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 38) {
2014-12-12 18:33:06 +00:00
s3 = peg$c15;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s3 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c16); }
2014-12-12 18:19:00 +00:00
}
if (s3 !== peg$FAILED) {
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
s5 = peg$parseAndExpr();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c17(s1, s5);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseNotExpr();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseAndExpr();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c17(s1, s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$parseNotExpr();
}
}
return s0;
}
function peg$parseNotExpr() {
var s0, s1, s2, s3;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 33) {
2014-12-12 18:33:06 +00:00
s1 = peg$c18;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c19); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseNotExpr();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c20(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$parseBindingExpr();
}
return s0;
}
function peg$parseBindingExpr() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
2014-12-12 18:33:06 +00:00
s1 = peg$c21;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c22); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseOrExpr();
if (s3 !== peg$FAILED) {
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
2014-12-12 18:33:06 +00:00
s5 = peg$c23;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s5 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c24); }
2014-12-12 18:19:00 +00:00
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c25(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$parseExpr();
}
return s0;
}
function peg$parseExpr() {
var s0;
s0 = peg$parseNullaryExpr();
if (s0 === peg$FAILED) {
s0 = peg$parseUnaryExpr();
}
return s0;
}
function peg$parseNullaryExpr() {
var s0, s1;
s0 = peg$parseBooleanLiteral();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c26) {
s1 = peg$c26;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c27); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c28();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c29) {
s1 = peg$c29;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c30); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c31();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c32) {
s1 = peg$c32;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c33); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c34();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c35) {
s1 = peg$c35;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c36); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c37();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
}
}
}
}
return s0;
}
function peg$parseBooleanLiteral() {
var s0, s1;
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 4) === peg$c38) {
s1 = peg$c38;
2014-12-12 18:19:00 +00:00
peg$currPos += 4;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c39); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c40();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 5) === peg$c41) {
s1 = peg$c41;
2014-12-12 18:19:00 +00:00
peg$currPos += 5;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c42); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c43();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
}
return s0;
}
function peg$parseUnaryExpr() {
var s0, s1, s2, s3;
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c44) {
s1 = peg$c44;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c45); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
2014-12-13 00:56:04 +00:00
s3 = peg$parseIntegerLiteral();
2014-12-12 18:19:00 +00:00
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c46(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c47) {
s1 = peg$c47;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c48); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c49(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c50) {
s1 = peg$c50;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c51); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c52(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 3) === peg$c53) {
s1 = peg$c53;
2014-12-12 18:19:00 +00:00
peg$currPos += 3;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c54); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c55(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 3) === peg$c56) {
s1 = peg$c56;
2014-12-12 18:19:00 +00:00
peg$currPos += 3;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c57); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c58(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c59) {
s1 = peg$c59;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c60); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c61(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c62) {
s1 = peg$c62;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c63); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c64(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 3) === peg$c65) {
s1 = peg$c65;
2014-12-12 18:19:00 +00:00
peg$currPos += 3;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c66); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c67(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 3) === peg$c68) {
s1 = peg$c68;
2014-12-12 18:19:00 +00:00
peg$currPos += 3;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c69); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c70(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
2014-12-12 18:33:06 +00:00
if (input.substr(peg$currPos, 2) === peg$c71) {
s1 = peg$c71;
2014-12-12 18:19:00 +00:00
peg$currPos += 2;
} else {
s1 = peg$FAILED;
2014-12-12 18:33:06 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c72); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsews();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsews();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseStringLiteral();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c73(s3);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseStringLiteral();
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-12 18:33:06 +00:00
s1 = peg$c73(s1);
2014-12-12 18:19:00 +00:00
}
s0 = s1;
}
}
}
}
}
}
}
}
}
}
return s0;
}
2014-12-13 00:56:04 +00:00
function peg$parseIntegerLiteral() {
var s0, s1, s2, s3;
peg$silentFails++;
s0 = peg$currPos;
if (peg$c76.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c77); }
}
if (s1 === peg$FAILED) {
s1 = peg$c75;
}
if (s1 !== peg$FAILED) {
s2 = [];
if (peg$c78.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c79); }
}
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c78.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c79); }
}
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
if (peg$c76.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c77); }
}
if (s3 === peg$FAILED) {
s3 = peg$c75;
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c80(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}
return s0;
}
2014-12-12 18:19:00 +00:00
function peg$parseStringLiteral() {
var s0, s1, s2, s3;
peg$silentFails++;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 34) {
2014-12-13 00:56:04 +00:00
s1 = peg$c82;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c83); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseDoubleStringChar();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseDoubleStringChar();
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 34) {
2014-12-13 00:56:04 +00:00
s3 = peg$c82;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s3 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c83); }
2014-12-12 18:19:00 +00:00
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c84(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 39) {
2014-12-13 00:56:04 +00:00
s1 = peg$c85;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c86); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseSingleStringChar();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseSingleStringChar();
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 39) {
2014-12-13 00:56:04 +00:00
s3 = peg$c85;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s3 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c86); }
2014-12-12 18:19:00 +00:00
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c84(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parsecc();
peg$silentFails--;
if (s2 === peg$FAILED) {
2014-12-13 00:56:04 +00:00
s1 = peg$c87;
2014-12-12 18:19:00 +00:00
} else {
peg$currPos = s1;
s1 = peg$c1;
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseUnquotedStringChar();
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseUnquotedStringChar();
}
} else {
s2 = peg$c1;
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c84(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c81); }
2014-12-12 18:19:00 +00:00
}
return s0;
}
function peg$parseDoubleStringChar() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
2014-12-13 00:56:04 +00:00
if (peg$c88.test(input.charAt(peg$currPos))) {
2014-12-12 18:19:00 +00:00
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c89); }
2014-12-12 18:19:00 +00:00
}
peg$silentFails--;
if (s2 === peg$FAILED) {
2014-12-13 00:56:04 +00:00
s1 = peg$c87;
2014-12-12 18:19:00 +00:00
} else {
peg$currPos = s1;
s1 = peg$c1;
}
if (s1 !== peg$FAILED) {
if (input.length > peg$currPos) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c90); }
2014-12-12 18:19:00 +00:00
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c91(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 92) {
2014-12-13 00:56:04 +00:00
s1 = peg$c92;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c93); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = peg$parseEscapeSequence();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c91(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
}
return s0;
}
function peg$parseSingleStringChar() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
2014-12-13 00:56:04 +00:00
if (peg$c94.test(input.charAt(peg$currPos))) {
2014-12-12 18:19:00 +00:00
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c95); }
2014-12-12 18:19:00 +00:00
}
peg$silentFails--;
if (s2 === peg$FAILED) {
2014-12-13 00:56:04 +00:00
s1 = peg$c87;
2014-12-12 18:19:00 +00:00
} else {
peg$currPos = s1;
s1 = peg$c1;
}
if (s1 !== peg$FAILED) {
if (input.length > peg$currPos) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c90); }
2014-12-12 18:19:00 +00:00
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c91(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 92) {
2014-12-13 00:56:04 +00:00
s1 = peg$c92;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c93); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
s2 = peg$parseEscapeSequence();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c91(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
}
return s0;
}
function peg$parseUnquotedStringChar() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parsews();
peg$silentFails--;
if (s2 === peg$FAILED) {
2014-12-13 00:56:04 +00:00
s1 = peg$c87;
2014-12-12 18:19:00 +00:00
} else {
peg$currPos = s1;
s1 = peg$c1;
}
if (s1 !== peg$FAILED) {
if (input.length > peg$currPos) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c90); }
2014-12-12 18:19:00 +00:00
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c91(s2);
2014-12-12 18:19:00 +00:00
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c1;
}
} else {
peg$currPos = s0;
s0 = peg$c1;
}
return s0;
}
function peg$parseEscapeSequence() {
var s0, s1;
2014-12-13 00:56:04 +00:00
if (peg$c96.test(input.charAt(peg$currPos))) {
2014-12-12 18:19:00 +00:00
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c97); }
2014-12-12 18:19:00 +00:00
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 110) {
2014-12-13 00:56:04 +00:00
s1 = peg$c98;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c99); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c100();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 114) {
2014-12-13 00:56:04 +00:00
s1 = peg$c101;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c102); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c103();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 116) {
2014-12-13 00:56:04 +00:00
s1 = peg$c104;
2014-12-12 18:19:00 +00:00
peg$currPos++;
} else {
s1 = peg$FAILED;
2014-12-13 00:56:04 +00:00
if (peg$silentFails === 0) { peg$fail(peg$c105); }
2014-12-12 18:19:00 +00:00
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
2014-12-13 00:56:04 +00:00
s1 = peg$c106();
2014-12-12 18:19:00 +00:00
}
s0 = s1;
}
}
}
return s0;
}
function or(first, second) {
// Add explicit function names to ease debugging.
2014-12-13 00:56:04 +00:00
function orFilter() {
return first.apply(this, arguments) || second.apply(this, arguments);
}
orFilter.desc = first.desc + " or " + second.desc;
return orFilter;
2014-12-12 18:19:00 +00:00
}
function and(first, second) {
2014-12-13 00:56:04 +00:00
function andFilter() {
2014-12-12 18:19:00 +00:00
return first.apply(this, arguments) && second.apply(this, arguments);
}
2014-12-13 00:56:04 +00:00
andFilter.desc = first.desc + " and " + second.desc;
return andFilter;
2014-12-12 18:19:00 +00:00
}
function not(expr) {
2014-12-13 00:56:04 +00:00
function notFilter() {
2014-12-12 18:19:00 +00:00
return !expr.apply(this, arguments);
2014-12-13 00:56:04 +00:00
}
notFilter.desc = "not " + expr.desc;
return notFilter;
2014-12-12 18:19:00 +00:00
}
function binding(expr) {
2014-12-13 00:56:04 +00:00
function bindingFilter() {
2014-12-12 18:19:00 +00:00
return expr.apply(this, arguments);
2014-12-13 00:56:04 +00:00
}
bindingFilter.desc = "(" + expr.desc + ")";
return bindingFilter;
2014-12-12 18:19:00 +00:00
}
function trueFilter(flow) {
return true;
}
2014-12-13 00:56:04 +00:00
trueFilter.desc = "true";
2014-12-12 18:19:00 +00:00
function falseFilter(flow) {
return false;
}
2014-12-13 00:56:04 +00:00
falseFilter.desc = "false";
2014-12-12 18:19:00 +00:00
var ASSET_TYPES = [
new RegExp("text/javascript"),
new RegExp("application/x-javascript"),
new RegExp("application/javascript"),
new RegExp("text/css"),
new RegExp("image/.*"),
new RegExp("application/x-shockwave-flash")
];
function assetFilter(flow) {
if (flow.response) {
var ct = ResponseUtils.getContentType(flow.response);
var i = ASSET_TYPES.length;
while (i--) {
if (ASSET_TYPES[i].test(ct)) {
return true;
}
}
}
return false;
}
2014-12-13 00:56:04 +00:00
assetFilter.desc = "is asset";
2014-12-12 18:19:00 +00:00
function responseCode(code){
2014-12-13 00:56:04 +00:00
function responseCodeFilter(flow){
2014-12-12 18:19:00 +00:00
return flow.response && flow.response.code === code;
2014-12-13 00:56:04 +00:00
}
responseCodeFilter.desc = "resp. code is " + code;
return responseCodeFilter;
2014-12-12 18:19:00 +00:00
}
function domain(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function domainFilter(flow){
2014-12-12 18:19:00 +00:00
return flow.request && regex.test(flow.request.host);
2014-12-13 00:56:04 +00:00
}
domainFilter.desc = "domain matches " + regex;
return domainFilter;
2014-12-12 18:19:00 +00:00
}
function errorFilter(flow){
return !!flow.error;
}
2014-12-13 00:56:04 +00:00
errorFilter.desc = "has error";
2014-12-12 18:19:00 +00:00
function header(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function headerFilter(flow){
2014-12-12 18:19:00 +00:00
return (
(flow.request && RequestUtils.match_header(flow.request, regex))
||
(flow.response && ResponseUtils.match_header(flow.response, regex))
);
2014-12-13 00:56:04 +00:00
}
headerFilter.desc = "header matches " + regex;
return headerFilter;
2014-12-12 18:19:00 +00:00
}
function requestHeader(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function requestHeaderFilter(flow){
2014-12-12 18:19:00 +00:00
return (flow.request && RequestUtils.match_header(flow.request, regex));
}
2014-12-13 00:56:04 +00:00
requestHeaderFilter.desc = "req. header matches " + regex;
return requestHeaderFilter;
2014-12-12 18:19:00 +00:00
}
function responseHeader(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function responseHeaderFilter(flow){
2014-12-12 18:19:00 +00:00
return (flow.response && ResponseUtils.match_header(flow.response, regex));
}
2014-12-13 00:56:04 +00:00
responseHeaderFilter.desc = "resp. header matches " + regex;
return responseHeaderFilter;
2014-12-12 18:19:00 +00:00
}
function method(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function methodFilter(flow){
2014-12-12 18:19:00 +00:00
return flow.request && regex.test(flow.request.method);
2014-12-13 00:56:04 +00:00
}
methodFilter.desc = "method matches " + regex;
return methodFilter;
2014-12-12 18:19:00 +00:00
}
function noResponseFilter(flow){
return flow.request && !flow.response;
}
2014-12-13 00:56:04 +00:00
noResponseFilter.desc = "has no response";
2014-12-12 18:19:00 +00:00
function responseFilter(flow){
return !!flow.response;
}
2014-12-13 00:56:04 +00:00
responseFilter.desc = "has response";
2014-12-12 18:19:00 +00:00
function contentType(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function contentTypeFilter(flow){
2014-12-12 18:19:00 +00:00
return (
(flow.request && regex.test(RequestUtils.getContentType(flow.request)))
||
(flow.response && regex.test(ResponseUtils.getContentType(flow.response)))
);
2014-12-13 00:56:04 +00:00
}
contentTypeFilter.desc = "content type matches " + regex;
return contentTypeFilter;
2014-12-12 18:19:00 +00:00
}
function requestContentType(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function requestContentTypeFilter(flow){
2014-12-12 18:19:00 +00:00
return flow.request && regex.test(RequestUtils.getContentType(flow.request));
2014-12-13 00:56:04 +00:00
}
requestContentTypeFilter.desc = "req. content type matches " + regex;
return requestContentTypeFilter;
2014-12-12 18:19:00 +00:00
}
function responseContentType(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function responseContentTypeFilter(flow){
2014-12-12 18:19:00 +00:00
return flow.response && regex.test(ResponseUtils.getContentType(flow.response));
2014-12-13 00:56:04 +00:00
}
responseContentTypeFilter.desc = "resp. content type matches " + regex;
return responseContentTypeFilter;
2014-12-12 18:19:00 +00:00
}
function url(regex){
regex = new RegExp(regex, "i");
2014-12-13 00:56:04 +00:00
function urlFilter(flow){
2014-12-12 18:19:00 +00:00
return flow.request && regex.test(RequestUtils.pretty_url(flow.request));
}
2014-12-13 00:56:04 +00:00
urlFilter.desc = "url matches " + regex;
return urlFilter;
2014-12-12 18:19:00 +00:00
}
peg$result = peg$startRuleFunction();
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
return peg$result;
} else {
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
peg$fail({ type: "end", description: "end of input" });
}
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
}
}
return {
SyntaxError: SyntaxError,
parse: parse
};
})();
2014-09-18 23:35:36 +00:00
var _MessageUtils = {
getContentType: function (message) {
2014-09-18 23:57:50 +00:00
return this.get_first_header(message, /^Content-Type$/i);
2014-09-18 23:35:36 +00:00
},
get_first_header: function (message, regex) {
//FIXME: Cache Invalidation.
if (!message._headerLookups)
Object.defineProperty(message, "_headerLookups", {
value: {},
configurable: false,
enumerable: false,
writable: false
});
if (!(regex in message._headerLookups)) {
var header;
for (var i = 0; i < message.headers.length; i++) {
if (!!message.headers[i][0].match(regex)) {
header = message.headers[i];
break;
}
}
message._headerLookups[regex] = header ? header[1] : undefined;
}
return message._headerLookups[regex];
2014-12-12 18:19:00 +00:00
},
2014-12-22 22:40:24 +00:00
match_header: function (message, regex) {
2014-12-12 18:19:00 +00:00
var headers = message.headers;
var i = headers.length;
2014-12-22 22:40:24 +00:00
while (i--) {
if (regex.test(headers[i].join(" "))) {
2014-12-12 18:19:00 +00:00
return headers[i];
}
}
return false;
2014-09-18 23:35:36 +00:00
}
};
var defaultPorts = {
"http": 80,
"https": 443
};
var RequestUtils = _.extend(_MessageUtils, {
pretty_host: function (request) {
//FIXME: Add hostheader
return request.host;
},
pretty_url: function (request) {
var port = "";
if (defaultPorts[request.scheme] !== request.port) {
port = ":" + request.port;
}
return request.scheme + "://" + this.pretty_host(request) + port + request.path;
}
});
var ResponseUtils = _.extend(_MessageUtils, {});
function ListStore() {
EventEmitter.call(this);
2014-12-09 17:55:16 +00:00
this.reset();
}
_.extend(ListStore.prototype, EventEmitter.prototype, {
2014-12-09 17:55:16 +00:00
add: function (elem) {
if (elem.id in this._pos_map) {
return;
}
this._pos_map[elem.id] = this.list.length;
this.list.push(elem);
this.emit("add", elem);
2014-12-09 17:55:16 +00:00
},
update: function (elem) {
if (!(elem.id in this._pos_map)) {
return;
}
this.list[this._pos_map[elem.id]] = elem;
this.emit("update", elem);
2014-12-09 17:55:16 +00:00
},
remove: function (elem_id) {
if (!(elem.id in this._pos_map)) {
return;
}
this.list.splice(this._pos_map[elem_id], 1);
2014-12-09 17:55:16 +00:00
this._build_map();
this.emit("remove", elem_id);
2014-12-09 17:55:16 +00:00
},
reset: function (elems) {
this.list = elems || [];
2014-12-09 17:55:16 +00:00
this._build_map();
2014-12-12 18:33:06 +00:00
this.emit("recalculate");
2014-12-09 17:55:16 +00:00
},
_build_map: function () {
this._pos_map = {};
for (var i = 0; i < this.list.length; i++) {
var elem = this.list[i];
2014-12-09 17:55:16 +00:00
this._pos_map[elem.id] = i;
}
},
get: function (elem_id) {
return this.list[this._pos_map[elem_id]];
},
index: function (elem_id) {
return this._pos_map[elem_id];
2014-12-09 17:55:16 +00:00
}
});
function DictStore() {
EventEmitter.call(this);
this.reset();
}
_.extend(DictStore.prototype, EventEmitter.prototype, {
update: function (dict) {
_.merge(this.dict, dict);
2014-12-12 18:33:06 +00:00
this.emit("recalculate");
},
reset: function (dict) {
this.dict = dict || {};
2014-12-12 18:33:06 +00:00
this.emit("recalculate");
}
});
function LiveStoreMixin(type) {
2014-12-09 17:55:16 +00:00
this.type = type;
this._updates_before_fetch = undefined;
this._fetchxhr = false;
this.handle = this.handle.bind(this);
AppDispatcher.register(this.handle);
// Avoid double-fetch on startup.
if (!(window.ws && window.ws.readyState === WebSocket.CONNECTING)) {
this.fetch();
}
}
_.extend(LiveStoreMixin.prototype, {
2014-12-09 17:55:16 +00:00
handle: function (event) {
if (event.type === ActionTypes.CONNECTION_OPEN) {
return this.fetch();
}
if (event.type === this.type) {
if (event.cmd === StoreCmds.RESET) {
2014-12-13 00:56:04 +00:00
this.fetch(event.data);
2014-12-09 17:55:16 +00:00
} else if (this._updates_before_fetch) {
console.log("defer update", event);
this._updates_before_fetch.push(event);
} else {
this[event.cmd](event.data);
}
}
},
close: function () {
AppDispatcher.unregister(this.handle);
},
fetch: function (data) {
2014-12-09 17:55:16 +00:00
console.log("fetch " + this.type);
if (this._fetchxhr) {
this._fetchxhr.abort();
}
this._updates_before_fetch = []; // (JS: empty array is true)
if (data) {
this.handle_fetch(data);
} else {
this._fetchxhr = $.getJSON("/" + this.type)
.done(function (message) {
this.handle_fetch(message.data);
}.bind(this))
.fail(function () {
EventLogActions.add_event("Could not fetch " + this.type);
}.bind(this));
}
2014-12-09 17:55:16 +00:00
},
handle_fetch: function (data) {
this._fetchxhr = false;
console.log(this.type + " fetched.", this._updates_before_fetch);
this.reset(data);
2014-12-09 17:55:16 +00:00
var updates = this._updates_before_fetch;
this._updates_before_fetch = false;
for (var i = 0; i < updates.length; i++) {
this.handle(updates[i]);
}
},
});
2014-09-15 22:05:06 +00:00
function LiveListStore(type) {
ListStore.call(this);
LiveStoreMixin.call(this, type);
}
_.extend(LiveListStore.prototype, ListStore.prototype, LiveStoreMixin.prototype);
function LiveDictStore(type) {
DictStore.call(this);
LiveStoreMixin.call(this, type);
}
_.extend(LiveDictStore.prototype, DictStore.prototype, LiveStoreMixin.prototype);
2014-09-15 22:05:06 +00:00
2014-12-10 01:48:04 +00:00
function FlowStore() {
return new LiveListStore(ActionTypes.FLOW_STORE);
2014-12-10 01:48:04 +00:00
}
function SettingsStore() {
return new LiveDictStore(ActionTypes.SETTINGS_STORE);
}
2014-12-10 01:48:04 +00:00
function EventLogStore() {
LiveListStore.call(this, ActionTypes.EVENT_STORE);
2014-12-10 01:48:04 +00:00
}
_.extend(EventLogStore.prototype, LiveListStore.prototype, {
fetch: function(){
LiveListStore.prototype.fetch.apply(this, arguments);
2014-12-10 16:44:45 +00:00
// Make sure to display updates even if fetching all events failed.
// This way, we can send "fetch failed" log messages to the log.
if(this._fetchxhr){
this._fetchxhr.fail(function(){
this.handle_fetch(null);
}.bind(this));
}
}
});
function SortByStoreOrder(elem) {
return this.store.index(elem.id);
2014-09-16 09:06:30 +00:00
}
2014-09-15 16:08:26 +00:00
var default_sort = SortByStoreOrder;
var default_filt = function(elem){
return true;
};
2014-09-17 15:30:19 +00:00
function StoreView(store, filt, sortfun) {
2014-09-17 15:30:19 +00:00
EventEmitter.call(this);
filt = filt || default_filt;
2014-11-27 01:34:03 +00:00
sortfun = sortfun || default_sort;
2014-11-27 00:38:30 +00:00
this.store = store;
this.add = this.add.bind(this);
this.update = this.update.bind(this);
this.remove = this.remove.bind(this);
this.recalculate = this.recalculate.bind(this);
this.store.addListener("add", this.add);
this.store.addListener("update", this.update);
this.store.addListener("remove", this.remove);
this.store.addListener("recalculate", this.recalculate);
2014-12-12 18:33:06 +00:00
this.recalculate(filt, sortfun);
2014-09-17 15:30:19 +00:00
}
_.extend(StoreView.prototype, EventEmitter.prototype, {
2014-11-27 00:40:26 +00:00
close: function () {
this.store.removeListener("add", this.add);
this.store.removeListener("update", this.update);
this.store.removeListener("remove", this.remove);
this.store.removeListener("recalculate", this.recalculate);
2014-11-27 00:38:30 +00:00
},
2014-12-12 18:33:06 +00:00
recalculate: function (filt, sortfun) {
if (filt) {
2014-12-23 00:26:03 +00:00
this.filt = filt.bind(this);
}
2014-11-27 01:34:03 +00:00
if (sortfun) {
this.sortfun = sortfun.bind(this);
2014-11-27 01:34:03 +00:00
}
2014-12-12 18:33:06 +00:00
this.list = this.store.list.filter(this.filt);
this.list.sort(function (a, b) {
2014-11-28 18:16:47 +00:00
return this.sortfun(a) - this.sortfun(b);
}.bind(this));
this.emit("recalculate");
},
index: function (elem) {
return _.sortedIndex(this.list, elem, this.sortfun);
2014-11-28 18:16:47 +00:00
},
add: function (elem) {
if (this.filt(elem)) {
var idx = this.index(elem);
if (idx === this.list.length) { //happens often, .push is way faster.
this.list.push(elem);
} else {
this.list.splice(idx, 0, elem);
}
this.emit("add", elem, idx);
}
},
update: function (elem) {
var idx;
var i = this.list.length;
// Search from the back, we usually update the latest entries.
while (i--) {
if (this.list[i].id === elem.id) {
idx = i;
break;
}
}
if (idx === -1) { //not contained in list
this.add(elem);
} else if (!this.filt(elem)) {
this.remove(elem.id);
} else {
if (this.sortfun(this.list[idx]) !== this.sortfun(elem)) { //sortpos has changed
this.remove(this.list[idx]);
this.add(elem);
} else {
this.list[idx] = elem;
this.emit("update", elem, idx);
}
}
2014-09-17 15:30:19 +00:00
},
remove: function (elem_id) {
var idx = this.list.length;
while (idx--) {
if (this.list[idx].id === elem_id) {
this.list.splice(idx, 1);
this.emit("remove", elem_id, idx);
2014-09-17 15:30:19 +00:00
break;
}
2014-09-17 15:30:19 +00:00
}
}
});
2014-12-09 17:55:16 +00:00
function Connection(url) {
2014-12-09 17:18:14 +00:00
if (url[0] === "/") {
url = location.origin.replace("http", "ws") + url;
}
2014-12-09 17:18:14 +00:00
var ws = new WebSocket(url);
2014-11-27 00:40:26 +00:00
ws.onopen = function () {
2014-12-09 17:18:14 +00:00
ConnectionActions.open();
};
ws.onmessage = function (message) {
var m = JSON.parse(message.data);
AppDispatcher.dispatchServerAction(m);
};
2014-11-27 00:40:26 +00:00
ws.onerror = function () {
2014-12-09 17:18:14 +00:00
ConnectionActions.error();
EventLogActions.add_event("WebSocket connection error.");
};
2014-11-27 00:40:26 +00:00
ws.onclose = function () {
2014-12-09 17:18:14 +00:00
ConnectionActions.close();
EventLogActions.add_event("WebSocket connection closed.");
};
return ws;
}
2014-09-18 21:22:02 +00:00
//React utils. For other utilities, see ../utils.js
var Splitter = React.createClass({displayName: 'Splitter',
getDefaultProps: function () {
2014-09-19 15:56:54 +00:00
return {
axis: "x"
};
2014-09-18 21:22:02 +00:00
},
2014-11-27 00:40:26 +00:00
getInitialState: function () {
2014-09-18 21:22:02 +00:00
return {
applied: false,
startX: false,
startY: false
};
},
2014-11-27 00:40:26 +00:00
onMouseDown: function (e) {
2014-09-18 21:22:02 +00:00
this.setState({
startX: e.pageX,
startY: e.pageY
});
2014-11-27 00:40:26 +00:00
window.addEventListener("mousemove", this.onMouseMove);
window.addEventListener("mouseup", this.onMouseUp);
2014-09-18 21:47:54 +00:00
// Occasionally, only a dragEnd event is triggered, but no mouseUp.
2014-11-27 00:40:26 +00:00
window.addEventListener("dragend", this.onDragEnd);
2014-09-18 21:22:02 +00:00
},
2014-11-27 00:40:26 +00:00
onDragEnd: function () {
this.getDOMNode().style.transform = "";
window.removeEventListener("dragend", this.onDragEnd);
window.removeEventListener("mouseup", this.onMouseUp);
window.removeEventListener("mousemove", this.onMouseMove);
2014-09-18 21:47:54 +00:00
},
2014-11-27 00:40:26 +00:00
onMouseUp: function (e) {
2014-09-18 21:47:54 +00:00
this.onDragEnd();
2014-09-18 21:22:02 +00:00
var node = this.getDOMNode();
var prev = node.previousElementSibling;
var next = node.nextElementSibling;
2014-11-27 00:40:26 +00:00
var dX = e.pageX - this.state.startX;
var dY = e.pageY - this.state.startY;
2014-09-18 21:22:02 +00:00
var flexBasis;
2014-11-27 00:40:26 +00:00
if (this.props.axis === "x") {
2014-09-18 21:22:02 +00:00
flexBasis = prev.offsetWidth + dX;
} else {
flexBasis = prev.offsetHeight + dY;
}
2014-11-27 00:40:26 +00:00
prev.style.flex = "0 0 " + Math.max(0, flexBasis) + "px";
2014-09-18 21:22:02 +00:00
next.style.flex = "1 1 auto";
this.setState({
applied: true
});
2014-12-10 01:48:04 +00:00
this.onResize();
2014-09-18 21:22:02 +00:00
},
2014-11-27 00:40:26 +00:00
onMouseMove: function (e) {
2014-09-18 21:22:02 +00:00
var dX = 0, dY = 0;
2014-11-27 00:40:26 +00:00
if (this.props.axis === "x") {
dX = e.pageX - this.state.startX;
2014-09-18 21:22:02 +00:00
} else {
2014-11-27 00:40:26 +00:00
dY = e.pageY - this.state.startY;
2014-09-18 21:22:02 +00:00
}
2014-11-27 00:40:26 +00:00
this.getDOMNode().style.transform = "translate(" + dX + "px," + dY + "px)";
2014-09-18 21:22:02 +00:00
},
2014-12-10 01:48:04 +00:00
onResize: function () {
// Trigger a global resize event. This notifies components that employ virtual scrolling
// that their viewport may have changed.
window.setTimeout(function () {
window.dispatchEvent(new CustomEvent("resize"));
}, 1);
},
2014-11-27 00:40:26 +00:00
reset: function (willUnmount) {
2014-09-18 21:47:54 +00:00
if (!this.state.applied) {
2014-09-18 21:22:02 +00:00
return;
}
var node = this.getDOMNode();
var prev = node.previousElementSibling;
var next = node.nextElementSibling;
2014-11-27 00:40:26 +00:00
2014-09-18 21:22:02 +00:00
prev.style.flex = "";
next.style.flex = "";
2014-09-18 21:47:54 +00:00
2014-11-27 00:40:26 +00:00
if (!willUnmount) {
2014-09-18 21:47:54 +00:00
this.setState({
applied: false
});
}
2014-12-10 01:48:04 +00:00
this.onResize();
2014-09-18 21:47:54 +00:00
},
2014-11-27 00:40:26 +00:00
componentWillUnmount: function () {
2014-09-18 21:47:54 +00:00
this.reset(true);
2014-09-18 21:22:02 +00:00
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-18 21:22:02 +00:00
var className = "splitter";
2014-11-27 00:40:26 +00:00
if (this.props.axis === "x") {
2014-09-18 21:22:02 +00:00
className += " splitter-x";
} else {
className += " splitter-y";
}
2014-09-18 21:47:54 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", {className: className},
React.createElement("div", {onMouseDown: this.onMouseDown, draggable: "true"})
2014-09-18 21:47:54 +00:00
)
);
2014-09-18 21:22:02 +00:00
}
});
2014-11-28 18:16:47 +00:00
function getCookie(name) {
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined;
}
var xsrf = $.param({_xsrf: getCookie("_xsrf")});
//Tornado XSRF Protection.
2014-12-10 01:48:04 +00:00
$.ajaxPrefilter(function (options) {
2014-12-23 19:33:42 +00:00
if (["post","put","delete"].indexOf(options.type.toLowerCase()) >= 0 && options.url[0] === "/") {
2014-12-10 01:48:04 +00:00
if (options.data) {
2014-11-28 18:16:47 +00:00
options.data += ("&" + xsrf);
} else {
options.data = xsrf;
}
}
});
2014-11-28 19:03:04 +00:00
var VirtualScrollMixin = {
getInitialState: function () {
return {
start: 0,
stop: 0
2014-11-29 02:25:07 +00:00
};
2014-11-28 19:03:04 +00:00
},
2014-12-10 01:48:04 +00:00
componentWillMount: function () {
if (!this.props.rowHeight) {
2014-11-28 19:54:52 +00:00
console.warn("VirtualScrollMixin: No rowHeight specified", this);
}
},
getPlaceholderTop: function (total) {
2014-11-28 19:54:52 +00:00
var Tag = this.props.placeholderTagName || "tr";
// When a large trunk of elements is removed from the button, start may be far off the viewport.
// To make this issue less severe, limit the top placeholder to the total number of rows.
2014-11-28 19:03:04 +00:00
var style = {
2014-12-10 01:48:04 +00:00
height: Math.min(this.state.start, total) * this.props.rowHeight
2014-11-28 19:03:04 +00:00
};
2014-11-28 19:54:52 +00:00
var spacer = React.createElement(Tag, {key: "placeholder-top", style: style});
2014-11-28 19:03:04 +00:00
if (this.state.start % 2 === 1) {
// fix even/odd rows
2014-11-28 19:54:52 +00:00
return [spacer, React.createElement(Tag, {key: "placeholder-top-2"})];
2014-11-28 19:03:04 +00:00
} else {
return spacer;
}
},
getPlaceholderBottom: function (total) {
2014-11-28 19:54:52 +00:00
var Tag = this.props.placeholderTagName || "tr";
2014-11-28 19:03:04 +00:00
var style = {
height: Math.max(0, total - this.state.stop) * this.props.rowHeight
};
2014-11-28 19:54:52 +00:00
return React.createElement(Tag, {key: "placeholder-bottom", style: style});
},
componentDidMount: function () {
this.onScroll();
2014-12-10 01:48:04 +00:00
window.addEventListener('resize', this.onScroll);
},
componentWillUnmount: function(){
window.removeEventListener('resize', this.onScroll);
2014-11-28 19:03:04 +00:00
},
onScroll: function () {
var viewport = this.getDOMNode();
var top = viewport.scrollTop;
var height = viewport.offsetHeight;
var start = Math.floor(top / this.props.rowHeight);
2014-11-28 19:54:52 +00:00
var stop = start + Math.ceil(height / (this.props.rowHeightMin || this.props.rowHeight));
2014-11-28 19:03:04 +00:00
this.setState({
start: start,
stop: stop
});
2014-11-28 19:54:52 +00:00
},
2014-12-10 01:48:04 +00:00
renderRows: function (elems) {
2014-11-28 19:54:52 +00:00
var rows = [];
var max = Math.min(elems.length, this.state.stop);
for (var i = this.state.start; i < max; i++) {
var elem = elems[i];
rows.push(this.renderRow(elem));
}
return rows;
2014-11-28 19:03:04 +00:00
},
2014-12-10 01:48:04 +00:00
scrollRowIntoView: function (index, head_height) {
2014-11-28 19:03:04 +00:00
var row_top = (index * this.props.rowHeight) + head_height;
var row_bottom = row_top + this.props.rowHeight;
var viewport = this.getDOMNode();
var viewport_top = viewport.scrollTop;
var viewport_bottom = viewport_top + viewport.offsetHeight;
// Account for pinned thead
if (row_top - head_height < viewport_top) {
viewport.scrollTop = row_top - head_height;
} else if (row_bottom > viewport_bottom) {
viewport.scrollTop = row_bottom - viewport.offsetHeight;
}
},
};
2014-12-13 00:56:04 +00:00
var FilterInput = React.createClass({displayName: 'FilterInput',
getInitialState: function () {
2014-12-23 19:33:42 +00:00
// Consider both focus and mouseover for showing/hiding the tooltip,
// because onBlur of the input is triggered before the click on the tooltip
// finalized, hiding the tooltip just as the user clicks on it.
2014-12-13 00:56:04 +00:00
return {
value: this.props.value,
focus: false,
mousefocus: false
};
},
componentWillReceiveProps: function (nextProps) {
this.setState({value: nextProps.value});
},
onChange: function (e) {
var nextValue = e.target.value;
this.setState({
value: nextValue
});
2014-12-23 19:33:42 +00:00
// Only propagate valid filters upwards.
if (this.isValid(nextValue)) {
this.props.onChange(nextValue);
2014-12-13 00:56:04 +00:00
}
},
2014-12-23 19:33:42 +00:00
isValid: function (filt) {
2014-12-13 00:56:04 +00:00
try {
2014-12-23 19:33:42 +00:00
Filt.parse(filt || this.state.value);
2014-12-13 00:56:04 +00:00
return true;
} catch (e) {
return false;
}
},
getDesc: function () {
var desc;
try {
desc = Filt.parse(this.state.value).desc;
} catch (e) {
desc = "" + e;
}
if (desc !== "true") {
return desc;
} else {
return (
React.createElement("a", {href: "https://mitmproxy.org/doc/features/filters.html", target: "_blank"},
React.createElement("i", {className: "fa fa-external-link"}),
"Filter Documentation"
)
);
}
},
onFocus: function () {
this.setState({focus: true});
},
onBlur: function () {
this.setState({focus: false});
},
onMouseEnter: function () {
this.setState({mousefocus: true});
},
onMouseLeave: function () {
this.setState({mousefocus: false});
},
onKeyDown: function (e) {
2014-12-23 19:33:42 +00:00
if (e.keyCode === Key.ESC || e.keyCode === Key.ENTER) {
this.blur();
// If closed using ESC/ENTER, hide the tooltip.
this.setState({mousefocus: false});
2014-12-13 00:56:04 +00:00
}
},
2014-12-23 19:33:42 +00:00
blur: function () {
this.refs.input.getDOMNode().blur();
2014-12-13 00:56:04 +00:00
},
focus: function () {
this.refs.input.getDOMNode().select();
},
render: function () {
var isValid = this.isValid();
var icon = "fa fa-fw fa-" + this.props.type;
var groupClassName = "filter-input input-group" + (isValid ? "" : " has-error");
var popover;
if (this.state.focus || this.state.mousefocus) {
popover = (
React.createElement("div", {className: "popover bottom", onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave},
React.createElement("div", {className: "arrow"}),
React.createElement("div", {className: "popover-content"},
this.getDesc()
)
)
);
}
return (
React.createElement("div", {className: groupClassName},
React.createElement("span", {className: "input-group-addon"},
React.createElement("i", {className: icon, style: {color: this.props.color}})
),
2014-12-23 19:33:42 +00:00
React.createElement("input", {type: "text", placeholder: this.props.placeholder, className: "form-control",
2014-12-13 00:56:04 +00:00
ref: "input",
onChange: this.onChange,
onFocus: this.onFocus,
onBlur: this.onBlur,
onKeyDown: this.onKeyDown,
value: this.state.value}),
popover
)
);
}
});
2014-09-14 00:44:13 +00:00
var MainMenu = React.createClass({displayName: 'MainMenu',
2014-12-12 18:19:00 +00:00
mixins: [Navigation, State],
2014-09-18 19:13:50 +00:00
statics: {
title: "Traffic",
route: "flows"
},
2014-09-17 00:13:37 +00:00
toggleEventLog: function () {
2014-09-15 16:08:26 +00:00
SettingsActions.update({
2014-09-15 22:05:06 +00:00
showEventLog: !this.props.settings.showEventLog
2014-09-15 16:08:26 +00:00
});
},
2014-12-10 16:44:45 +00:00
clearFlows: function () {
2014-12-23 19:33:42 +00:00
jQuery.post("/clear");
2014-11-28 18:16:47 +00:00
},
2014-12-23 19:33:42 +00:00
onFilterChange: function (val) {
2014-12-13 00:56:04 +00:00
var d = {};
2014-12-23 19:33:42 +00:00
d[Query.FILTER] = val;
2014-12-13 00:56:04 +00:00
this.setQuery(d);
},
2014-12-23 00:13:34 +00:00
onHighlightChange: function (val) {
2014-12-23 19:33:42 +00:00
var d = {};
d[Query.HIGHLIGHT] = val;
this.setQuery(d);
},
onInterceptChange: function (val) {
SettingsActions.update({intercept: val});
2014-12-12 18:19:00 +00:00
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-12-23 19:33:42 +00:00
var filter = this.getQuery()[Query.FILTER] || "";
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
var intercept = this.props.settings.intercept || "";
2014-09-15 22:56:43 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", null,
React.createElement("button", {className: "btn " + (this.props.settings.showEventLog ? "btn-primary" : "btn-default"), onClick: this.toggleEventLog},
2014-12-10 16:44:45 +00:00
React.createElement("i", {className: "fa fa-database"}),
" Display Event Log"
),
2014-12-23 19:33:42 +00:00
React.createElement("span", null, " "),
2014-11-28 18:16:47 +00:00
React.createElement("button", {className: "btn btn-default", onClick: this.clearFlows},
2014-12-10 16:44:45 +00:00
React.createElement("i", {className: "fa fa-eraser"}),
" Clear Flows"
2014-12-12 18:19:00 +00:00
),
2014-12-23 19:33:42 +00:00
React.createElement("span", null, " "),
2014-12-23 00:13:34 +00:00
React.createElement("form", {className: "form-inline", style: {display: "inline"}},
2014-12-23 19:33:42 +00:00
React.createElement(FilterInput, {
placeholder: "Filter",
type: "filter",
color: "black",
value: filter,
onChange: this.onFilterChange}),
React.createElement("span", null, " "),
React.createElement(FilterInput, {
placeholder: "Highlight",
type: "tag",
color: "hsl(48, 100%, 50%)",
value: highlight,
onChange: this.onHighlightChange}),
React.createElement("span", null, " "),
React.createElement(FilterInput, {
placeholder: "Intercept",
type: "pause",
color: "hsl(208, 56%, 53%)",
value: intercept,
onChange: this.onInterceptChange})
2014-12-13 00:56:04 +00:00
)
2014-09-15 16:08:26 +00:00
)
2014-11-27 00:40:26 +00:00
);
2014-09-14 00:44:13 +00:00
}
});
2014-09-18 19:13:50 +00:00
2014-09-14 00:44:13 +00:00
var ToolsMenu = React.createClass({displayName: 'ToolsMenu',
2014-09-18 19:13:50 +00:00
statics: {
title: "Tools",
route: "flows"
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("div", null, "Tools Menu");
2014-09-14 00:44:13 +00:00
}
});
2014-09-18 19:13:50 +00:00
2014-09-14 00:44:13 +00:00
var ReportsMenu = React.createClass({displayName: 'ReportsMenu',
2014-09-18 19:13:50 +00:00
statics: {
title: "Visualization",
route: "reports"
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("div", null, "Reports Menu");
2014-09-14 00:44:13 +00:00
}
});
2014-12-10 16:44:45 +00:00
var FileMenu = React.createClass({displayName: 'FileMenu',
getInitialState: function () {
return {
showFileMenu: false
};
},
handleFileClick: function (e) {
e.preventDefault();
if (!this.state.showFileMenu) {
var close = function () {
this.setState({showFileMenu: false});
document.removeEventListener("click", close);
}.bind(this);
document.addEventListener("click", close);
this.setState({
showFileMenu: true
});
}
},
2014-12-12 18:19:00 +00:00
handleNewClick: function (e) {
2014-12-10 16:44:45 +00:00
e.preventDefault();
console.error("unimplemented: handleNewClick");
},
2014-12-12 18:19:00 +00:00
handleOpenClick: function (e) {
2014-12-10 16:44:45 +00:00
e.preventDefault();
console.error("unimplemented: handleOpenClick");
},
2014-12-12 18:19:00 +00:00
handleSaveClick: function (e) {
2014-12-10 16:44:45 +00:00
e.preventDefault();
console.error("unimplemented: handleSaveClick");
},
2014-12-12 18:19:00 +00:00
handleShutdownClick: function (e) {
2014-12-10 16:44:45 +00:00
e.preventDefault();
console.error("unimplemented: handleShutdownClick");
},
render: function () {
var fileMenuClass = "dropdown pull-left" + (this.state.showFileMenu ? " open" : "");
return (
React.createElement("div", {className: fileMenuClass},
React.createElement("a", {href: "#", className: "special", onClick: this.handleFileClick}, " File "),
React.createElement("ul", {className: "dropdown-menu", role: "menu"},
React.createElement("li", null,
React.createElement("a", {href: "#", onClick: this.handleNewClick},
React.createElement("i", {className: "fa fa-fw fa-file"}),
"New"
)
),
React.createElement("li", null,
React.createElement("a", {href: "#", onClick: this.handleOpenClick},
React.createElement("i", {className: "fa fa-fw fa-folder-open"}),
"Open"
)
),
React.createElement("li", null,
React.createElement("a", {href: "#", onClick: this.handleSaveClick},
React.createElement("i", {className: "fa fa-fw fa-save"}),
"Save"
)
),
React.createElement("li", {role: "presentation", className: "divider"}),
React.createElement("li", null,
React.createElement("a", {href: "#", onClick: this.handleShutdownClick},
React.createElement("i", {className: "fa fa-fw fa-plug"}),
"Shutdown"
)
)
)
)
);
}
});
2014-09-15 16:08:26 +00:00
2014-09-18 19:13:50 +00:00
var header_entries = [MainMenu, ToolsMenu, ReportsMenu];
2014-09-14 00:44:13 +00:00
var Header = React.createClass({displayName: 'Header',
2014-12-12 18:19:00 +00:00
mixins: [Navigation],
2014-09-17 00:13:37 +00:00
getInitialState: function () {
2014-09-15 16:08:26 +00:00
return {
2014-09-18 19:13:50 +00:00
active: header_entries[0]
2014-09-15 16:08:26 +00:00
};
2014-09-14 00:44:13 +00:00
},
2014-11-27 00:38:30 +00:00
handleClick: function (active, e) {
e.preventDefault();
2014-12-12 18:19:00 +00:00
this.replaceWith(active.route);
2014-09-14 00:44:13 +00:00
this.setState({active: active});
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-11-27 00:40:26 +00:00
var header = header_entries.map(function (entry, i) {
2014-09-18 19:13:50 +00:00
var classes = React.addons.classSet({
active: entry == this.state.active
});
return (
2014-11-27 00:38:30 +00:00
React.createElement("a", {key: i,
2014-11-27 00:40:26 +00:00
href: "#",
className: classes,
onClick: this.handleClick.bind(this, entry)
2014-09-18 19:13:50 +00:00
},
entry.title
)
2014-11-27 00:40:26 +00:00
);
2014-09-18 19:13:50 +00:00
}.bind(this));
2014-11-27 00:40:26 +00:00
2014-09-14 00:44:13 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("header", null,
React.createElement("div", {className: "title-bar"},
2014-12-10 16:44:45 +00:00
"mitmproxy ", this.props.settings.version
2014-09-15 16:08:26 +00:00
),
2014-11-27 00:38:30 +00:00
React.createElement("nav", {className: "nav-tabs nav-tabs-lg"},
2014-12-10 16:44:45 +00:00
React.createElement(FileMenu, null),
2014-09-15 16:08:26 +00:00
header
),
2014-11-27 00:38:30 +00:00
React.createElement("div", {className: "menu"},
React.createElement(this.state.active, {settings: this.props.settings})
2014-09-15 16:08:26 +00:00
)
2014-09-15 22:56:43 +00:00
)
2014-11-27 00:40:26 +00:00
);
2014-09-14 00:44:13 +00:00
}
});
var TLSColumn = React.createClass({displayName: 'TLSColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "tls", className: "col-tls"});
}
},
2014-11-27 00:40:26 +00:00
render: function () {
var flow = this.props.flow;
var ssl = (flow.request.scheme == "https");
2014-09-21 23:44:46 +00:00
var classes;
2014-11-27 00:40:26 +00:00
if (ssl) {
2014-09-21 23:44:46 +00:00
classes = "col-tls col-tls-https";
} else {
classes = "col-tls col-tls-http";
}
2014-11-27 00:38:30 +00:00
return React.createElement("td", {className: classes});
}
});
var IconColumn = React.createClass({displayName: 'IconColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "icon", className: "col-icon"});
}
},
2014-11-27 00:40:26 +00:00
render: function () {
var flow = this.props.flow;
2014-09-18 23:57:50 +00:00
var icon;
2014-11-27 00:40:26 +00:00
if (flow.response) {
2014-09-19 15:56:54 +00:00
var contentType = ResponseUtils.getContentType(flow.response);
//TODO: We should assign a type to the flow somewhere else.
2014-11-27 00:40:26 +00:00
if (flow.response.code == 304) {
2014-09-19 15:56:54 +00:00
icon = "resource-icon-not-modified";
2014-11-27 00:40:26 +00:00
} else if (300 <= flow.response.code && flow.response.code < 400) {
2014-09-19 15:56:54 +00:00
icon = "resource-icon-redirect";
2014-11-27 00:40:26 +00:00
} else if (contentType && contentType.indexOf("image") >= 0) {
2014-09-19 15:56:54 +00:00
icon = "resource-icon-image";
2014-09-19 22:25:40 +00:00
} else if (contentType && contentType.indexOf("javascript") >= 0) {
2014-09-19 15:56:54 +00:00
icon = "resource-icon-js";
2014-09-19 22:25:40 +00:00
} else if (contentType && contentType.indexOf("css") >= 0) {
2014-09-19 15:56:54 +00:00
icon = "resource-icon-css";
2014-09-19 22:25:40 +00:00
} else if (contentType && contentType.indexOf("html") >= 0) {
2014-09-19 15:56:54 +00:00
icon = "resource-icon-document";
}
}
2014-11-27 00:40:26 +00:00
if (!icon) {
2014-09-18 23:57:50 +00:00
icon = "resource-icon-plain";
}
2014-09-19 15:56:54 +00:00
2014-09-18 23:57:50 +00:00
icon += " resource-icon";
2014-11-27 00:40:26 +00:00
return React.createElement("td", {className: "col-icon"},
React.createElement("div", {className: icon})
);
}
});
2014-09-17 15:30:19 +00:00
var PathColumn = React.createClass({displayName: 'PathColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "path", className: "col-path"}, "Path");
2014-09-17 15:30:19 +00:00
}
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-17 15:30:19 +00:00
var flow = this.props.flow;
2014-11-27 00:38:30 +00:00
return React.createElement("td", {className: "col-path"}, flow.request.scheme + "://" + flow.request.host + flow.request.path);
2014-09-17 15:30:19 +00:00
}
});
2014-09-17 15:30:19 +00:00
var MethodColumn = React.createClass({displayName: 'MethodColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "method", className: "col-method"}, "Method");
2014-09-17 15:30:19 +00:00
}
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-17 15:30:19 +00:00
var flow = this.props.flow;
2014-11-27 00:38:30 +00:00
return React.createElement("td", {className: "col-method"}, flow.request.method);
2014-09-17 15:30:19 +00:00
}
});
2014-09-17 15:30:19 +00:00
var StatusColumn = React.createClass({displayName: 'StatusColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "status", className: "col-status"}, "Status");
2014-09-17 15:30:19 +00:00
}
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-17 15:30:19 +00:00
var flow = this.props.flow;
var status;
2014-11-27 00:40:26 +00:00
if (flow.response) {
status = flow.response.code;
2014-09-17 15:30:19 +00:00
} else {
status = null;
}
2014-11-27 00:38:30 +00:00
return React.createElement("td", {className: "col-status"}, status);
2014-09-17 15:30:19 +00:00
}
});
2014-09-18 23:35:36 +00:00
var SizeColumn = React.createClass({displayName: 'SizeColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "size", className: "col-size"}, "Size");
2014-09-18 23:35:36 +00:00
}
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-18 23:35:36 +00:00
var flow = this.props.flow;
2014-09-21 21:43:27 +00:00
2014-09-19 22:25:40 +00:00
var total = flow.request.contentLength;
2014-11-27 00:40:26 +00:00
if (flow.response) {
2014-09-21 21:43:27 +00:00
total += flow.response.contentLength || 0;
2014-09-19 22:25:40 +00:00
}
var size = formatSize(total);
2014-11-27 00:38:30 +00:00
return React.createElement("td", {className: "col-size"}, size);
2014-09-18 23:35:36 +00:00
}
});
2014-09-17 15:30:19 +00:00
var TimeColumn = React.createClass({displayName: 'TimeColumn',
statics: {
2014-11-27 00:40:26 +00:00
renderTitle: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("th", {key: "time", className: "col-time"}, "Time");
2014-09-17 15:30:19 +00:00
}
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-17 15:30:19 +00:00
var flow = this.props.flow;
var time;
2014-11-27 00:40:26 +00:00
if (flow.response) {
2014-09-19 15:56:54 +00:00
time = formatTimeDelta(1000 * (flow.response.timestamp_end - flow.request.timestamp_start));
2014-09-17 15:30:19 +00:00
} else {
time = "...";
}
2014-11-27 00:38:30 +00:00
return React.createElement("td", {className: "col-time"}, time);
2014-09-17 15:30:19 +00:00
}
});
2014-09-18 23:35:36 +00:00
var all_columns = [
TLSColumn,
IconColumn,
PathColumn,
MethodColumn,
StatusColumn,
SizeColumn,
TimeColumn];
2014-09-17 15:30:19 +00:00
var FlowRow = React.createClass({displayName: 'FlowRow',
2014-11-27 00:40:26 +00:00
render: function () {
var flow = this.props.flow;
2014-11-27 00:40:26 +00:00
var columns = this.props.columns.map(function (Column) {
2014-11-27 00:38:30 +00:00
return React.createElement(Column, {key: Column.displayName, flow: flow});
}.bind(this));
var className = "";
2014-11-27 00:40:26 +00:00
if (this.props.selected) {
2014-12-23 00:13:34 +00:00
className += " selected";
}
2014-12-23 00:13:34 +00:00
if (this.props.highlighted) {
className += " highlighted";
2014-12-22 22:40:24 +00:00
}
2014-12-23 19:33:42 +00:00
if (flow.intercepted) {
className += " intercepted";
}
if (flow.request) {
className += " has-request";
}
if (flow.response) {
className += " has-response";
}
2014-12-22 22:40:24 +00:00
return (
2014-12-23 00:13:34 +00:00
React.createElement("tr", {className: className, onClick: this.props.selectFlow.bind(null, flow)},
columns
));
2014-09-21 23:44:46 +00:00
},
2014-11-27 00:40:26 +00:00
shouldComponentUpdate: function (nextProps) {
2014-11-28 15:03:56 +00:00
return true;
// Further optimization could be done here
// by calling forceUpdate on flow updates, selection changes and column changes.
//return (
//(this.props.columns.length !== nextProps.columns.length) ||
//(this.props.selected !== nextProps.selected)
//);
}
});
var FlowTableHead = React.createClass({displayName: 'FlowTableHead',
2014-11-27 00:40:26 +00:00
render: function () {
var columns = this.props.columns.map(function (column) {
return column.renderTitle();
}.bind(this));
2014-11-27 00:40:26 +00:00
return React.createElement("thead", null,
React.createElement("tr", null, columns)
);
}
});
2014-11-28 15:03:56 +00:00
var ROW_HEIGHT = 32;
2014-09-17 15:30:19 +00:00
var FlowTable = React.createClass({displayName: 'FlowTable',
2014-11-28 19:03:04 +00:00
mixins: [StickyHeadMixin, AutoScrollMixin, VirtualScrollMixin],
2014-09-17 00:13:37 +00:00
getInitialState: function () {
2014-09-14 00:44:13 +00:00
return {
2014-11-28 19:03:04 +00:00
columns: all_columns
2014-09-14 00:44:13 +00:00
};
},
2014-11-28 15:03:56 +00:00
componentWillMount: function () {
if (this.props.view) {
this.props.view.addListener("add update remove recalculate", this.onChange);
}
},
componentWillReceiveProps: function (nextProps) {
if (nextProps.view !== this.props.view) {
if (this.props.view) {
this.props.view.removeListener("add update remove recalculate");
}
nextProps.view.addListener("add update remove recalculate", this.onChange);
}
},
2014-11-28 19:03:04 +00:00
getDefaultProps: function () {
return {
rowHeight: ROW_HEIGHT
};
},
2014-11-29 02:25:07 +00:00
onScrollFlowTable: function () {
2014-11-28 15:03:56 +00:00
this.adjustHead();
2014-11-28 19:03:04 +00:00
this.onScroll();
2014-11-28 15:03:56 +00:00
},
onChange: function () {
this.forceUpdate();
},
2014-11-27 00:40:26 +00:00
scrollIntoView: function (flow) {
2014-11-28 19:03:04 +00:00
this.scrollRowIntoView(
this.props.view.index(flow),
this.refs.body.getDOMNode().offsetTop
);
},
2014-11-28 19:54:52 +00:00
renderRow: function (flow) {
var selected = (flow === this.props.selected);
2014-12-23 00:26:03 +00:00
var highlighted =
(
this.props.view._highlight &&
this.props.view._highlight[flow.id]
);
2014-11-28 19:54:52 +00:00
return React.createElement(FlowRow, {key: flow.id,
ref: flow.id,
flow: flow,
columns: this.state.columns,
selected: selected,
2014-12-23 00:13:34 +00:00
highlighted: highlighted,
2014-11-28 19:54:52 +00:00
selectFlow: this.props.selectFlow}
);
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-11-29 02:25:07 +00:00
//console.log("render flowtable", this.state.start, this.state.stop, this.props.selected);
var flows = this.props.view ? this.props.view.list : [];
2014-11-28 19:54:52 +00:00
var rows = this.renderRows(flows);
2014-11-28 15:03:56 +00:00
2014-09-17 00:13:37 +00:00
return (
2014-11-29 02:25:07 +00:00
React.createElement("div", {className: "flow-table", onScroll: this.onScrollFlowTable},
2014-11-27 00:38:30 +00:00
React.createElement("table", null,
React.createElement(FlowTableHead, {ref: "head",
2014-11-27 00:40:26 +00:00
columns: this.state.columns}),
2014-11-28 18:16:47 +00:00
React.createElement("tbody", {ref: "body"},
this.getPlaceholderTop(flows.length),
2014-11-28 15:03:56 +00:00
rows,
2014-11-28 19:03:04 +00:00
this.getPlaceholderBottom(flows.length)
2014-11-28 15:03:56 +00:00
)
2014-09-18 19:13:50 +00:00
)
2014-09-17 15:30:19 +00:00
)
2014-11-27 00:40:26 +00:00
);
2014-09-15 22:56:43 +00:00
}
2014-09-14 00:44:13 +00:00
});
2014-09-18 19:13:50 +00:00
var FlowDetailNav = React.createClass({displayName: 'FlowDetailNav',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-18 19:13:50 +00:00
2014-11-27 00:38:30 +00:00
var items = this.props.tabs.map(function (e) {
2014-09-18 19:13:50 +00:00
var str = e.charAt(0).toUpperCase() + e.slice(1);
var className = this.props.active === e ? "active" : "";
2014-11-28 18:16:47 +00:00
var onClick = function (event) {
2014-09-18 19:13:50 +00:00
this.props.selectTab(e);
2014-11-28 18:16:47 +00:00
event.preventDefault();
2014-09-18 19:13:50 +00:00
}.bind(this);
2014-11-27 00:38:30 +00:00
return React.createElement("a", {key: e,
href: "#",
className: className,
onClick: onClick}, str);
2014-09-18 19:13:50 +00:00
}.bind(this));
return (
2014-11-27 00:38:30 +00:00
React.createElement("nav", {ref: "head", className: "nav-tabs nav-tabs-sm"},
2014-09-18 19:13:50 +00:00
items
)
);
2014-11-27 00:38:30 +00:00
}
2014-09-18 19:13:50 +00:00
});
2014-09-18 23:35:36 +00:00
var Headers = React.createClass({displayName: 'Headers',
2014-11-27 00:38:30 +00:00
render: function () {
var rows = this.props.message.headers.map(function (header, i) {
2014-09-18 23:35:36 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("tr", {key: i},
React.createElement("td", {className: "header-name"}, header[0] + ":"),
React.createElement("td", {className: "header-value"}, header[1])
2014-09-18 23:35:36 +00:00
)
);
2014-09-19 15:56:54 +00:00
});
2014-09-18 23:35:36 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("table", {className: "header-table"},
React.createElement("tbody", null,
2014-09-18 23:35:36 +00:00
rows
)
)
);
}
2014-09-19 15:56:54 +00:00
});
2014-09-18 23:35:36 +00:00
2014-09-18 19:13:50 +00:00
var FlowDetailRequest = React.createClass({displayName: 'FlowDetailRequest',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-18 23:35:36 +00:00
var flow = this.props.flow;
2014-09-18 23:57:50 +00:00
var first_line = [
2014-11-27 00:38:30 +00:00
flow.request.method,
RequestUtils.pretty_url(flow.request),
2014-11-29 02:25:07 +00:00
"HTTP/" + flow.request.httpversion.join(".")
2014-11-27 00:38:30 +00:00
].join(" ");
2014-09-18 23:35:36 +00:00
var content = null;
2014-11-27 00:38:30 +00:00
if (flow.request.contentLength > 0) {
content = "Request Content Size: " + formatSize(flow.request.contentLength);
2014-09-18 23:35:36 +00:00
} else {
2014-11-27 00:38:30 +00:00
content = React.createElement("div", {className: "alert alert-info"}, "No Content");
2014-09-18 23:35:36 +00:00
}
//TODO: Styling
return (
2014-11-27 00:38:30 +00:00
React.createElement("section", null,
React.createElement("div", {className: "first-line"}, first_line ),
React.createElement(Headers, {message: flow.request}),
React.createElement("hr", null),
2014-09-18 23:35:36 +00:00
content
)
);
2014-09-18 19:13:50 +00:00
}
});
var FlowDetailResponse = React.createClass({displayName: 'FlowDetailResponse',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-18 23:57:50 +00:00
var flow = this.props.flow;
var first_line = [
2014-11-27 00:38:30 +00:00
"HTTP/" + flow.response.httpversion.join("."),
flow.response.code,
flow.response.msg
].join(" ");
2014-09-18 23:57:50 +00:00
var content = null;
2014-11-27 00:38:30 +00:00
if (flow.response.contentLength > 0) {
content = "Response Content Size: " + formatSize(flow.response.contentLength);
2014-09-18 23:57:50 +00:00
} else {
2014-11-27 00:38:30 +00:00
content = React.createElement("div", {className: "alert alert-info"}, "No Content");
2014-09-18 23:57:50 +00:00
}
//TODO: Styling
return (
2014-11-27 00:38:30 +00:00
React.createElement("section", null,
React.createElement("div", {className: "first-line"}, first_line ),
React.createElement(Headers, {message: flow.response}),
React.createElement("hr", null),
2014-09-18 23:57:50 +00:00
content
)
);
2014-09-18 19:13:50 +00:00
}
});
2014-11-29 02:25:07 +00:00
var FlowDetailError = React.createClass({displayName: 'FlowDetailError',
render: function () {
var flow = this.props.flow;
return (
React.createElement("section", null,
React.createElement("div", {className: "alert alert-warning"},
flow.error.msg,
React.createElement("div", null, React.createElement("small", null, formatTimeStamp(flow.error.timestamp) ))
)
)
);
}
});
2014-09-19 15:56:54 +00:00
var TimeStamp = React.createClass({displayName: 'TimeStamp',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-19 15:56:54 +00:00
2014-11-27 00:38:30 +00:00
if (!this.props.t) {
2014-09-19 15:56:54 +00:00
//should be return null, but that triggers a React bug.
2014-11-27 00:38:30 +00:00
return React.createElement("tr", null);
2014-09-21 21:43:27 +00:00
}
2014-11-29 02:25:07 +00:00
var ts = formatTimeStamp(this.props.t);
2014-09-21 21:43:27 +00:00
var delta;
2014-11-27 00:38:30 +00:00
if (this.props.deltaTo) {
delta = formatTimeDelta(1000 * (this.props.t - this.props.deltaTo));
delta = React.createElement("span", {className: "text-muted"}, "(" + delta + ")");
2014-09-19 15:56:54 +00:00
} else {
2014-09-21 21:43:27 +00:00
delta = null;
2014-09-19 15:56:54 +00:00
}
2014-11-27 00:38:30 +00:00
return React.createElement("tr", null,
React.createElement("td", null, this.props.title + ":"),
React.createElement("td", null, ts, " ", delta)
);
2014-09-19 15:56:54 +00:00
}
});
var ConnectionInfo = React.createClass({displayName: 'ConnectionInfo',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-19 15:56:54 +00:00
var conn = this.props.conn;
var address = conn.address.address.join(":");
2014-11-27 00:38:30 +00:00
var sni = React.createElement("tr", {key: "sni"}); //should be null, but that triggers a React bug.
if (conn.sni) {
sni = React.createElement("tr", {key: "sni"},
React.createElement("td", null,
React.createElement("abbr", {title: "TLS Server Name Indication"}, "TLS SNI:")
),
React.createElement("td", null, conn.sni)
);
2014-09-19 15:56:54 +00:00
}
return (
2014-11-27 00:38:30 +00:00
React.createElement("table", {className: "connection-table"},
React.createElement("tbody", null,
React.createElement("tr", {key: "address"},
React.createElement("td", null, "Address:"),
React.createElement("td", null, address)
),
2014-09-21 21:43:27 +00:00
sni
2014-09-19 15:56:54 +00:00
)
)
);
}
});
var CertificateInfo = React.createClass({displayName: 'CertificateInfo',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-19 15:56:54 +00:00
//TODO: We should fetch human-readable certificate representation
// from the server
var flow = this.props.flow;
var client_conn = flow.client_conn;
var server_conn = flow.server_conn;
2014-09-21 21:43:27 +00:00
var preStyle = {maxHeight: 100};
2014-09-19 15:56:54 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", null,
client_conn.cert ? React.createElement("h4", null, "Client Certificate") : null,
client_conn.cert ? React.createElement("pre", {style: preStyle}, client_conn.cert) : null,
2014-09-19 15:56:54 +00:00
2014-11-27 00:38:30 +00:00
server_conn.cert ? React.createElement("h4", null, "Server Certificate") : null,
server_conn.cert ? React.createElement("pre", {style: preStyle}, server_conn.cert) : null
2014-09-21 21:43:27 +00:00
)
);
}
});
var Timing = React.createClass({displayName: 'Timing',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-21 21:43:27 +00:00
var flow = this.props.flow;
var sc = flow.server_conn;
var cc = flow.client_conn;
var req = flow.request;
var resp = flow.response;
var timestamps = [
{
title: "Server conn. initiated",
t: sc.timestamp_start,
deltaTo: req.timestamp_start
}, {
title: "Server conn. TCP handshake",
t: sc.timestamp_tcp_setup,
deltaTo: req.timestamp_start
}, {
title: "Server conn. SSL handshake",
t: sc.timestamp_ssl_setup,
deltaTo: req.timestamp_start
}, {
title: "Client conn. established",
t: cc.timestamp_start,
deltaTo: req.timestamp_start
}, {
title: "Client conn. SSL handshake",
t: cc.timestamp_ssl_setup,
deltaTo: req.timestamp_start
}, {
title: "First request byte",
t: req.timestamp_start,
}, {
title: "Request complete",
t: req.timestamp_end,
deltaTo: req.timestamp_start
}
];
if (flow.response) {
timestamps.push(
{
title: "First response byte",
t: resp.timestamp_start,
deltaTo: req.timestamp_start
}, {
title: "Response complete",
t: resp.timestamp_end,
deltaTo: req.timestamp_start
}
);
}
//Add unique key for each row.
2014-11-27 00:38:30 +00:00
timestamps.forEach(function (e) {
2014-09-21 21:43:27 +00:00
e.key = e.title;
});
timestamps = _.sortBy(timestamps, 't');
2014-11-27 00:38:30 +00:00
var rows = timestamps.map(function (e) {
return React.createElement(TimeStamp, React.__spread({}, e));
2014-09-21 21:43:27 +00:00
});
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", null,
React.createElement("h4", null, "Timing"),
React.createElement("table", {className: "timing-table"},
React.createElement("tbody", null,
2014-09-21 21:43:27 +00:00
rows
2014-11-27 00:38:30 +00:00
)
2014-09-21 21:43:27 +00:00
)
)
2014-09-19 15:56:54 +00:00
);
}
});
2014-09-18 19:13:50 +00:00
var FlowDetailConnectionInfo = React.createClass({displayName: 'FlowDetailConnectionInfo',
2014-11-27 00:38:30 +00:00
render: function () {
2014-09-19 15:56:54 +00:00
var flow = this.props.flow;
var client_conn = flow.client_conn;
var server_conn = flow.server_conn;
return (
2014-11-27 00:38:30 +00:00
React.createElement("section", null,
2014-09-19 15:56:54 +00:00
2014-11-27 00:38:30 +00:00
React.createElement("h4", null, "Client Connection"),
React.createElement(ConnectionInfo, {conn: client_conn}),
2014-09-19 15:56:54 +00:00
2014-11-27 00:38:30 +00:00
React.createElement("h4", null, "Server Connection"),
React.createElement(ConnectionInfo, {conn: server_conn}),
2014-09-19 15:56:54 +00:00
2014-11-27 00:38:30 +00:00
React.createElement(CertificateInfo, {flow: flow}),
2014-09-21 21:43:27 +00:00
2014-11-27 00:38:30 +00:00
React.createElement(Timing, {flow: flow})
2014-09-19 15:56:54 +00:00
)
);
2014-09-18 19:13:50 +00:00
}
2014-09-18 21:22:02 +00:00
});
2014-09-18 19:13:50 +00:00
2014-11-29 02:25:07 +00:00
var allTabs = {
2014-09-18 19:13:50 +00:00
request: FlowDetailRequest,
response: FlowDetailResponse,
2014-11-29 02:25:07 +00:00
error: FlowDetailError,
2014-09-18 19:13:50 +00:00
details: FlowDetailConnectionInfo
2014-09-18 21:22:02 +00:00
};
2014-09-18 19:13:50 +00:00
var FlowDetail = React.createClass({displayName: 'FlowDetail',
2014-12-12 18:19:00 +00:00
mixins: [StickyHeadMixin, Navigation, State],
2014-11-29 02:25:07 +00:00
getTabs: function (flow) {
var tabs = [];
["request", "response", "error"].forEach(function (e) {
if (flow[e]) {
tabs.push(e);
}
});
tabs.push("details");
return tabs;
},
2014-11-27 00:38:30 +00:00
nextTab: function (i) {
2014-12-09 17:18:14 +00:00
var tabs = this.getTabs(this.props.flow);
2014-11-29 02:25:07 +00:00
var currentIndex = tabs.indexOf(this.getParams().detailTab);
2014-09-19 15:56:54 +00:00
// JS modulo operator doesn't correct negative numbers, make sure that we are positive.
2014-11-29 02:25:07 +00:00
var nextIndex = (currentIndex + i + tabs.length) % tabs.length;
this.selectTab(tabs[nextIndex]);
2014-09-19 15:56:54 +00:00
},
2014-11-27 00:38:30 +00:00
selectTab: function (panel) {
this.replaceWith(
"flow",
{
flowId: this.getParams().flowId,
detailTab: panel
}
);
},
render: function () {
2014-11-29 02:25:07 +00:00
var flow = this.props.flow;
var tabs = this.getTabs(flow);
var active = this.getParams().detailTab;
if (!_.contains(tabs, active)) {
if (active === "response" && flow.error) {
active = "error";
} else if (active === "error" && flow.response) {
active = "response";
} else {
active = tabs[0];
}
this.selectTab(active);
}
var Tab = allTabs[active];
2014-09-18 19:13:50 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", {className: "flow-detail", onScroll: this.adjustHead},
React.createElement(FlowDetailNav, {ref: "head",
2014-11-29 02:25:07 +00:00
tabs: tabs,
active: active,
2014-11-27 00:38:30 +00:00
selectTab: this.selectTab}),
2014-11-29 02:25:07 +00:00
React.createElement(Tab, {flow: flow})
2014-09-18 19:13:50 +00:00
)
2014-11-27 00:38:30 +00:00
);
}
2014-09-18 19:13:50 +00:00
});
var MainView = React.createClass({displayName: 'MainView',
2014-12-12 18:19:00 +00:00
mixins: [Navigation, State],
2014-11-27 00:38:30 +00:00
getInitialState: function () {
2014-12-22 22:40:24 +00:00
this.onQueryChange(Query.FILTER, function () {
this.state.view.recalculate(this.getViewFilt(), this.getViewSort());
}.bind(this));
this.onQueryChange(Query.HIGHLIGHT, function () {
2014-12-12 18:33:06 +00:00
this.state.view.recalculate(this.getViewFilt(), this.getViewSort());
}.bind(this));
2014-09-18 19:13:50 +00:00
return {
2014-11-27 00:38:30 +00:00
flows: []
2014-09-18 19:13:50 +00:00
};
},
2014-12-22 22:40:24 +00:00
getViewFilt: function () {
2014-12-23 00:13:34 +00:00
try {
var filt = Filt.parse(this.getQuery()[Query.FILTER] || "");
var highlightStr = this.getQuery()[Query.HIGHLIGHT];
2014-12-23 00:26:03 +00:00
var highlight = highlightStr ? Filt.parse(highlightStr) : false;
2014-12-23 19:33:42 +00:00
} catch (e) {
2014-12-23 00:13:34 +00:00
console.error("Error when processing filter: " + e);
}
2014-12-22 22:40:24 +00:00
return function filter_and_highlight(flow) {
2014-12-23 19:33:42 +00:00
if (!this._highlight) {
2014-12-23 00:26:03 +00:00
this._highlight = {};
2014-12-22 22:40:24 +00:00
}
2014-12-23 00:26:03 +00:00
this._highlight[flow.id] = highlight && highlight(flow);
2014-12-22 22:40:24 +00:00
return filt(flow);
2014-12-23 00:26:03 +00:00
};
2014-12-12 18:33:06 +00:00
},
2014-12-22 22:40:24 +00:00
getViewSort: function () {
2014-12-12 18:33:06 +00:00
},
2014-11-27 00:38:30 +00:00
componentWillReceiveProps: function (nextProps) {
if (nextProps.flowStore !== this.props.flowStore) {
this.closeView();
this.openView(nextProps.flowStore);
}
},
openView: function (store) {
2014-12-12 18:33:06 +00:00
var view = new StoreView(store, this.getViewFilt(), this.getViewSort());
2014-11-27 00:38:30 +00:00
this.setState({
view: view
});
2014-11-29 02:25:07 +00:00
view.addListener("recalculate", this.onRecalculate);
view.addListener("add update remove", this.onUpdate);
},
2014-12-22 22:40:24 +00:00
onRecalculate: function () {
2014-11-29 02:25:07 +00:00
this.forceUpdate();
var selected = this.getSelected();
2014-12-22 22:40:24 +00:00
if (selected) {
2014-12-09 17:18:14 +00:00
this.refs.flowTable.scrollIntoView(selected);
2014-11-29 02:25:07 +00:00
}
},
onUpdate: function (flow) {
if (flow.id === this.getParams().flowId) {
this.forceUpdate();
}
2014-11-27 00:38:30 +00:00
},
closeView: function () {
this.state.view.close();
},
2014-11-28 15:03:56 +00:00
componentWillMount: function () {
2014-11-27 00:38:30 +00:00
this.openView(this.props.flowStore);
2014-09-18 19:13:50 +00:00
},
componentWillUnmount: function () {
2014-11-27 00:38:30 +00:00
this.closeView();
2014-09-18 19:13:50 +00:00
},
2014-11-27 00:38:30 +00:00
selectFlow: function (flow) {
if (flow) {
this.replaceWith(
"flow",
2014-09-18 19:13:50 +00:00
{
flowId: flow.id,
2014-11-27 00:38:30 +00:00
detailTab: this.getParams().detailTab || "request"
2014-09-18 19:13:50 +00:00
}
);
2014-11-28 18:16:47 +00:00
this.refs.flowTable.scrollIntoView(flow);
2014-09-18 19:13:50 +00:00
} else {
2014-12-12 18:19:00 +00:00
this.replaceWith("flows", {});
2014-09-18 19:13:50 +00:00
}
},
2014-11-27 01:34:03 +00:00
selectFlowRelative: function (shift) {
var flows = this.state.view.list;
2014-09-19 15:56:54 +00:00
var index;
2014-11-27 00:38:30 +00:00
if (!this.getParams().flowId) {
2014-11-27 01:34:03 +00:00
if (shift > 0) {
2014-11-27 00:38:30 +00:00
index = flows.length - 1;
2014-09-19 15:56:54 +00:00
} else {
index = 0;
2014-09-18 19:13:50 +00:00
}
2014-09-19 15:56:54 +00:00
} else {
2014-11-27 00:38:30 +00:00
var currFlowId = this.getParams().flowId;
2014-11-27 01:34:03 +00:00
var i = flows.length;
2014-11-27 00:38:30 +00:00
while (i--) {
if (flows[i].id === currFlowId) {
index = i;
break;
}
}
index = Math.min(
2014-11-27 01:34:03 +00:00
Math.max(0, index + shift),
2014-11-27 00:38:30 +00:00
flows.length - 1);
2014-09-19 15:56:54 +00:00
}
2014-11-27 00:38:30 +00:00
this.selectFlow(flows[index]);
2014-09-19 15:56:54 +00:00
},
2014-11-27 00:38:30 +00:00
onKeyDown: function (e) {
switch (e.keyCode) {
2014-09-19 15:56:54 +00:00
case Key.K:
case Key.UP:
this.selectFlowRelative(-1);
break;
case Key.J:
case Key.DOWN:
this.selectFlowRelative(+1);
break;
case Key.SPACE:
case Key.PAGE_DOWN:
this.selectFlowRelative(+10);
break;
case Key.PAGE_UP:
this.selectFlowRelative(-10);
break;
2014-12-13 00:56:04 +00:00
case Key.END:
this.selectFlowRelative(+1e10);
break;
case Key.HOME:
this.selectFlowRelative(-1e10);
break;
2014-09-19 15:56:54 +00:00
case Key.ESC:
this.selectFlow(null);
break;
case Key.H:
case Key.LEFT:
2014-11-27 00:38:30 +00:00
if (this.refs.flowDetails) {
2014-09-19 15:56:54 +00:00
this.refs.flowDetails.nextTab(-1);
}
break;
case Key.L:
case Key.TAB:
case Key.RIGHT:
2014-11-27 00:38:30 +00:00
if (this.refs.flowDetails) {
2014-09-19 15:56:54 +00:00
this.refs.flowDetails.nextTab(+1);
}
break;
2014-12-23 19:33:42 +00:00
case Key.A:
if (e.shiftKey) {
$.post("/flows/accept");
} else if(this.getSelected()) {
$.post("/flows/" + this.getSelected().id + "/accept");
}
break;
2014-09-19 15:56:54 +00:00
default:
console.debug("keydown", e.keyCode);
return;
}
2014-11-27 00:38:30 +00:00
e.preventDefault();
2014-09-18 19:13:50 +00:00
},
2014-12-22 22:40:24 +00:00
getSelected: function () {
2014-11-29 02:25:07 +00:00
return this.props.flowStore.get(this.getParams().flowId);
},
2014-11-27 00:38:30 +00:00
render: function () {
2014-11-29 02:25:07 +00:00
var selected = this.getSelected();
2014-09-18 19:13:50 +00:00
2014-09-19 15:56:54 +00:00
var details;
2014-11-27 00:38:30 +00:00
if (selected) {
2014-11-29 02:25:07 +00:00
details = [
React.createElement(Splitter, {key: "splitter"}),
React.createElement(FlowDetail, {key: "flowDetails", ref: "flowDetails", flow: selected})
];
2014-09-19 15:56:54 +00:00
} else {
details = null;
2014-09-18 19:13:50 +00:00
}
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", {className: "main-view", onKeyDown: this.onKeyDown, tabIndex: "0"},
React.createElement(FlowTable, {ref: "flowTable",
2014-11-28 15:03:56 +00:00
view: this.state.view,
2014-11-27 00:38:30 +00:00
selectFlow: this.selectFlow,
selected: selected}),
2014-09-18 19:13:50 +00:00
details
)
);
}
});
2014-09-22 01:06:19 +00:00
var LogMessage = React.createClass({displayName: 'LogMessage',
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-22 01:06:19 +00:00
var entry = this.props.entry;
var indicator;
2014-11-27 00:40:26 +00:00
switch (entry.level) {
2014-09-22 01:06:19 +00:00
case "web":
2014-11-27 00:38:30 +00:00
indicator = React.createElement("i", {className: "fa fa-fw fa-html5"});
2014-09-22 01:06:19 +00:00
break;
case "debug":
2014-11-27 00:38:30 +00:00
indicator = React.createElement("i", {className: "fa fa-fw fa-bug"});
2014-09-22 01:06:19 +00:00
break;
default:
2014-11-27 00:38:30 +00:00
indicator = React.createElement("i", {className: "fa fa-fw fa-info"});
2014-09-22 01:06:19 +00:00
}
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", null,
2014-09-22 01:06:19 +00:00
indicator, " ", entry.message
)
);
},
2014-11-27 00:40:26 +00:00
shouldComponentUpdate: function () {
2014-09-22 01:06:19 +00:00
return false; // log entries are immutable.
}
});
var EventLogContents = React.createClass({displayName: 'EventLogContents',
2014-11-28 19:54:52 +00:00
mixins: [AutoScrollMixin, VirtualScrollMixin],
getInitialState: function () {
2014-09-15 22:56:43 +00:00
return {
log: []
};
},
componentWillMount: function () {
this.openView(this.props.eventStore);
},
2014-09-17 00:13:37 +00:00
componentWillUnmount: function () {
this.closeView();
},
openView: function (store) {
var view = new StoreView(store, function (entry) {
return this.props.filter[entry.level];
}.bind(this));
this.setState({
view: view
});
view.addListener("add recalculate", this.onEventLogChange);
},
closeView: function () {
this.state.view.close();
2014-09-15 22:56:43 +00:00
},
2014-09-17 00:13:37 +00:00
onEventLogChange: function () {
2014-09-15 22:56:43 +00:00
this.setState({
log: this.state.view.list
2014-09-15 22:56:43 +00:00
});
},
componentWillReceiveProps: function (nextProps) {
if (nextProps.filter !== this.props.filter) {
this.props.filter = nextProps.filter; // Dirty: Make sure that view filter sees the update.
2014-12-12 18:33:06 +00:00
this.state.view.recalculate();
}
if (nextProps.eventStore !== this.props.eventStore) {
this.closeView();
this.openView(nextProps.eventStore);
2014-11-28 19:54:52 +00:00
}
},
getDefaultProps: function () {
return {
rowHeight: 45,
rowHeightMin: 15,
placeholderTagName: "div"
};
},
renderRow: function (elem) {
2014-11-28 19:54:52 +00:00
return React.createElement(LogMessage, {key: elem.id, entry: elem});
},
2014-09-22 01:06:19 +00:00
render: function () {
2014-11-28 19:54:52 +00:00
var rows = this.renderRows(this.state.log);
return React.createElement("pre", {onScroll: this.onScroll},
this.getPlaceholderTop(this.state.log.length),
2014-11-28 19:54:52 +00:00
rows,
this.getPlaceholderBottom(this.state.log.length)
);
2014-09-22 01:06:19 +00:00
}
});
var ToggleFilter = React.createClass({displayName: 'ToggleFilter',
2014-11-27 00:40:26 +00:00
toggle: function (e) {
2014-11-27 00:38:30 +00:00
e.preventDefault();
2014-09-22 01:06:19 +00:00
return this.props.toggleLevel(this.props.name);
},
2014-11-27 00:40:26 +00:00
render: function () {
2014-09-22 01:06:19 +00:00
var className = "label ";
if (this.props.active) {
className += "label-primary";
} else {
className += "label-default";
}
return (
2014-11-27 00:38:30 +00:00
React.createElement("a", {
2014-09-22 01:06:19 +00:00
href: "#",
className: className,
onClick: this.toggle},
this.props.name
)
);
2014-11-27 00:40:26 +00:00
}
2014-09-22 01:06:19 +00:00
});
var EventLog = React.createClass({displayName: 'EventLog',
2014-11-27 00:40:26 +00:00
getInitialState: function () {
2014-09-22 01:06:19 +00:00
return {
filter: {
"debug": false,
"info": true,
"web": true
}
};
},
2014-09-17 00:13:37 +00:00
close: function () {
2014-09-15 22:56:43 +00:00
SettingsActions.update({
showEventLog: false
});
},
2014-11-27 00:40:26 +00:00
toggleLevel: function (level) {
var filter = _.extend({}, this.state.filter);
2014-09-22 01:06:19 +00:00
filter[level] = !filter[level];
this.setState({filter: filter});
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-09-22 01:06:19 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", {className: "eventlog"},
React.createElement("div", null,
2014-11-28 19:54:52 +00:00
"Eventlog",
2014-11-27 00:38:30 +00:00
React.createElement("div", {className: "pull-right"},
React.createElement(ToggleFilter, {name: "debug", active: this.state.filter.debug, toggleLevel: this.toggleLevel}),
React.createElement(ToggleFilter, {name: "info", active: this.state.filter.info, toggleLevel: this.toggleLevel}),
React.createElement(ToggleFilter, {name: "web", active: this.state.filter.web, toggleLevel: this.toggleLevel}),
React.createElement("i", {onClick: this.close, className: "fa fa-close"})
2014-09-22 01:06:19 +00:00
)
),
React.createElement(EventLogContents, {filter: this.state.filter, eventStore: this.props.eventStore})
2014-09-22 01:06:19 +00:00
)
);
2014-09-15 16:08:26 +00:00
}
});
var Footer = React.createClass({displayName: 'Footer',
2014-09-17 00:13:37 +00:00
render: function () {
2014-09-15 23:05:29 +00:00
var mode = this.props.settings.mode;
2014-12-23 19:33:42 +00:00
var intercept = this.props.settings.intercept;
2014-09-15 16:08:26 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("footer", null,
2014-12-23 19:33:42 +00:00
mode != "regular" ? React.createElement("span", {className: "label label-success"}, mode, " mode") : null,
" ",
intercept ? React.createElement("span", {className: "label label-success"}, "Intercept: ", intercept) : null
2014-09-15 16:08:26 +00:00
)
2014-11-27 00:40:26 +00:00
);
2014-09-15 16:08:26 +00:00
}
});
2014-09-15 16:08:26 +00:00
//TODO: Move out of here, just a stub.
2014-09-14 00:44:13 +00:00
var Reports = React.createClass({displayName: 'Reports',
2014-09-17 00:13:37 +00:00
render: function () {
2014-11-27 00:38:30 +00:00
return React.createElement("div", null, "ReportEditor");
2014-09-15 22:56:43 +00:00
}
2014-09-14 00:44:13 +00:00
});
2014-09-15 16:08:26 +00:00
var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
2014-09-17 00:13:37 +00:00
getInitialState: function () {
var eventStore = new EventLogStore();
var flowStore = new FlowStore();
var settings = new SettingsStore();
2014-12-10 16:44:45 +00:00
// Default Settings before fetch
_.extend(settings.dict,{
showEventLog: true
});
2014-11-27 00:38:30 +00:00
return {
settings: settings,
flowStore: flowStore,
eventStore: eventStore
2014-11-27 00:38:30 +00:00
};
2014-09-15 22:05:06 +00:00
},
2014-09-17 00:13:37 +00:00
componentDidMount: function () {
this.state.settings.addListener("recalculate", this.onSettingsChange);
2014-12-12 18:19:00 +00:00
window.app = this;
2014-09-15 22:05:06 +00:00
},
2014-09-17 00:13:37 +00:00
componentWillUnmount: function () {
this.state.settings.removeListener("recalculate", this.onSettingsChange);
2014-09-15 22:05:06 +00:00
},
onSettingsChange: function(){
this.setState({
settings: this.state.settings
});
2014-09-15 22:05:06 +00:00
},
2014-09-17 00:13:37 +00:00
render: function () {
2014-12-10 01:48:04 +00:00
var eventlog;
if (this.state.settings.dict.showEventLog) {
2014-12-10 01:48:04 +00:00
eventlog = [
React.createElement(Splitter, {key: "splitter", axis: "y"}),
React.createElement(EventLog, {key: "eventlog", eventStore: this.state.eventStore})
2014-12-10 01:48:04 +00:00
];
} else {
eventlog = null;
}
2014-09-15 22:56:43 +00:00
return (
2014-11-27 00:38:30 +00:00
React.createElement("div", {id: "container"},
React.createElement(Header, {settings: this.state.settings.dict}),
React.createElement(RouteHandler, {settings: this.state.settings.dict, flowStore: this.state.flowStore}),
2014-12-10 01:48:04 +00:00
eventlog,
React.createElement(Footer, {settings: this.state.settings.dict})
2014-09-15 22:56:43 +00:00
)
2014-11-27 00:38:30 +00:00
);
2014-09-15 16:08:26 +00:00
}
});
2014-09-18 19:13:50 +00:00
var Route = ReactRouter.Route;
2014-11-27 00:38:30 +00:00
var RouteHandler = ReactRouter.RouteHandler;
2014-09-18 19:13:50 +00:00
var Redirect = ReactRouter.Redirect;
var DefaultRoute = ReactRouter.DefaultRoute;
var NotFoundRoute = ReactRouter.NotFoundRoute;
2014-11-27 00:38:30 +00:00
var routes = (
React.createElement(Route, {path: "/", handler: ProxyAppMain},
React.createElement(Route, {name: "flows", path: "flows", handler: MainView}),
React.createElement(Route, {name: "flow", path: "flows/:flowId/:detailTab", handler: MainView}),
React.createElement(Route, {name: "reports", handler: Reports}),
React.createElement(Redirect, {path: "/", to: "flows"})
2014-09-14 00:44:13 +00:00
)
2014-11-27 00:38:30 +00:00
);
2014-09-17 00:13:37 +00:00
$(function () {
2014-12-09 17:55:16 +00:00
window.ws = new Connection("/updates");
2014-12-09 17:18:14 +00:00
2014-11-27 00:38:30 +00:00
ReactRouter.run(routes, function (Handler) {
React.render(React.createElement(Handler, null), document.body);
});
2014-09-15 16:08:26 +00:00
});
2014-09-14 00:44:13 +00:00
//# sourceMappingURL=app.js.map