aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/web/static/js/app.js225
-rw-r--r--web/src/js/app.js2
-rw-r--r--web/src/js/components/proxyapp.jsx2
-rw-r--r--web/src/js/components/traffictable.jsx2
-rw-r--r--web/src/js/connection.js48
-rw-r--r--web/src/js/dispatcher.js34
-rw-r--r--web/src/js/stores/base.js48
-rw-r--r--web/src/js/stores/eventlogstore.js54
-rw-r--r--web/src/js/stores/settingstore.js31
9 files changed, 232 insertions, 214 deletions
diff --git a/libmproxy/web/static/js/app.js b/libmproxy/web/static/js/app.js
index 991f9af3..047672e4 100644
--- a/libmproxy/web/static/js/app.js
+++ b/libmproxy/web/static/js/app.js
@@ -4,24 +4,24 @@ const PayloadSources = {
};
- function Dispatcher() {"use strict";
- this.callbacks = [];
+function Dispatcher() {"use strict";
+ this.callbacks = [];
+}
+Dispatcher.prototype.register=function(callback) {"use strict";
+ this.callbacks.push(callback);
+};
+Dispatcher.prototype.unregister=function(callback) {"use strict";
+ var index = this.callbacks.indexOf(f);
+ if (index >= 0) {
+ this.callbacks.splice(this.callbacks.indexOf(f), 1);
}
- Dispatcher.prototype.register=function(callback) {"use strict";
- this.callbacks.push(callback);
- };
- Dispatcher.prototype.unregister=function(callback) {"use strict";
- var index = this.callbacks.indexOf(f);
- if (index >= 0) {
- this.callbacks.splice(this.callbacks.indexOf(f), 1);
- }
- };
- Dispatcher.prototype.dispatch=function(payload) {"use strict";
- console.debug("dispatch", payload);
- this.callbacks.forEach(function(callback) {
- callback(payload);
- });
- };
+};
+Dispatcher.prototype.dispatch=function(payload) {"use strict";
+ console.debug("dispatch", payload);
+ this.callbacks.forEach(function(callback) {
+ callback(payload);
+ });
+};
AppDispatcher = new Dispatcher();
@@ -52,46 +52,50 @@ var SettingsActions = {
}
};
-function EventEmitter() {"use strict";
- this.listeners = {};
+"use strict";
+
+function EventEmitter() {
+ this.listeners = {};
+}
+EventEmitter.prototype.emit=function(event) {
+ if (!(event in this.listeners)) {
+ return;
}
- EventEmitter.prototype.emit=function(event) {"use strict";
- if (!(event in this.listeners)) {
- return;
- }
- this.listeners[event].forEach(function(listener) {
- listener.apply(this, arguments);
- }.bind(this));
- };
- EventEmitter.prototype.addListener=function(event, f) {"use strict";
- this.listeners[event] = this.listeners[event] || [];
- this.listeners[event].push(f);
- };
- EventEmitter.prototype.removeListener=function(event, f) {"use strict";
- if (!(event in this.listeners)) {
- return false;
- }
- var index = this.listeners[event].indexOf(f);
- if (index >= 0) {
- this.listeners[event].splice(index, 1);
- }
- };
-
-for(var EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmitter____Key)){_SettingsStore[EventEmitter____Key]=EventEmitter[EventEmitter____Key];}}var ____SuperProtoOfEventEmitter=EventEmitter===null?null:EventEmitter.prototype;_SettingsStore.prototype=Object.create(____SuperProtoOfEventEmitter);_SettingsStore.prototype.constructor=_SettingsStore;_SettingsStore.__superConstructor__=EventEmitter;
- function _SettingsStore() {"use strict";
- EventEmitter.call(this);
-
- //FIXME: What do we do if we haven't requested anything from the server yet?
- this.settings = {
- version: "0.12",
- showEventLog: true,
- mode: "transparent",
- };
+ this.listeners[event].forEach(function(listener) {
+ listener.apply(this, arguments);
+ }.bind(this));
+};
+EventEmitter.prototype.addListener=function(event, f) {
+ this.listeners[event] = this.listeners[event] || [];
+ this.listeners[event].push(f);
+};
+EventEmitter.prototype.removeListener=function(event, f) {
+ if (!(event in this.listeners)) {
+ return false;
+ }
+ var index = this.listeners[event].indexOf(f);
+ if (index >= 0) {
+ this.listeners[event].splice(index, 1);
}
- _SettingsStore.prototype.getAll=function() {"use strict";
+};
+
+"use strict";
+
+function _SettingsStore() {
+ EventEmitter.call(this);
+
+ //FIXME: What do we do if we haven't requested anything from the server yet?
+ this.settings = {
+ version: "0.12",
+ showEventLog: true,
+ mode: "transparent",
+ };
+}
+_.extend(_SettingsStore.prototype, EventEmitter.prototype, {
+ getAll: function() {
return this.settings;
- };
- _SettingsStore.prototype.handle=function(action) {"use strict";
+ },
+ handle: function(action) {
switch (action.actionType) {
case ActionTypes.SETTINGS_UPDATE:
this.settings = action.settings;
@@ -100,11 +104,13 @@ for(var EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(Even
default:
return;
}
- };
+ }
+});
var SettingsStore = new _SettingsStore();
AppDispatcher.register(SettingsStore.handle.bind(SettingsStore));
+"use strict";
//
// We have an EventLogView and an EventLogStore:
// The basic architecture is that one can request views on the event log
@@ -112,41 +118,44 @@ AppDispatcher.register(SettingsStore.handle.bind(SettingsStore));
// The view object is accessed by React components and distributes updates etc.
//
// See also: components/EventLog.react.js
+function EventLogView(store, live) {
+ EventEmitter.call(this);
+ this.$EventLogView_store = store;
+ this.live = live;
+ this.log = [];
-for(var EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmitter____Key)){EventLogView[EventEmitter____Key]=EventEmitter[EventEmitter____Key];}}var ____SuperProtoOfEventEmitter=EventEmitter===null?null:EventEmitter.prototype;EventLogView.prototype=Object.create(____SuperProtoOfEventEmitter);EventLogView.prototype.constructor=EventLogView;EventLogView.__superConstructor__=EventEmitter;
- function EventLogView(store, live) {"use strict";
- EventEmitter.call(this);
- this.$EventLogView_store = store;
- this.live = live;
- this.log = [];
-
- this.add = this.add.bind(this);
+ this.add = this.add.bind(this);
- if (live) {
- this.$EventLogView_store.addListener("new_entry", this.add);
- }
+ if (live) {
+ this.$EventLogView_store.addListener("new_entry", this.add);
}
- EventLogView.prototype.close=function() {"use strict";
+}
+_.extend(EventLogView.prototype, EventEmitter.prototype, {
+ close: function() {
this.$EventLogView_store.removeListener("new_entry", this.add);
- };
- EventLogView.prototype.getAll=function() {"use strict";
+ },
+ getAll: function() {
return this.log;
- };
- EventLogView.prototype.add=function(entry) {"use strict";
+ },
+ add: function(entry) {
this.log.push(entry);
this.emit("change");
- };
- EventLogView.prototype.add_bulk=function(messages) {"use strict";
+ },
+ add_bulk: function(messages) {
var log = messages;
var last_id = log[log.length - 1].id;
var to_add = _.filter(this.log, function(entry) {return entry.id > last_id;});
this.log = log.concat(to_add);
this.emit("change");
- };
+ }
+});
-for(EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmitter____Key)){_EventLogStore[EventEmitter____Key]=EventEmitter[EventEmitter____Key];}}_EventLogStore.prototype=Object.create(____SuperProtoOfEventEmitter);_EventLogStore.prototype.constructor=_EventLogStore;_EventLogStore.__superConstructor__=EventEmitter;function _EventLogStore(){"use strict";if(EventEmitter!==null){EventEmitter.apply(this,arguments);}}
- _EventLogStore.prototype.getView=function(since) {"use strict";
+function _EventLogStore(){
+ EventEmitter.call(this);
+}
+_.extend(_EventLogStore.prototype, EventEmitter.prototype, {
+ getView: function(since) {
var view = new EventLogView(this, !since);
//TODO: Really do bulk retrieval of last messages.
@@ -176,8 +185,8 @@ for(EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmi
});
}, 1000);
return view;
- };
- _EventLogStore.prototype.handle=function(action) {"use strict";
+ },
+ handle: function(action) {
switch (action.actionType) {
case ActionTypes.EVENTLOG_ADD:
this.emit("new_message", action.message);
@@ -185,7 +194,9 @@ for(EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmi
default:
return;
}
- };
+ }
+});
+
var EventLogStore = new _EventLogStore();
AppDispatcher.register(EventLogStore.handle.bind(EventLogStore));
@@ -196,31 +207,31 @@ function _Connection(root) {"use strict";
}
this.root = root;
}
- _Connection.prototype.init=function() {"use strict";
- this.openWebSocketConnection();
- };
- _Connection.prototype.openWebSocketConnection=function() {"use strict";
- this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws");
- var ws = this.ws;
-
- ws.onopen = this.onopen.bind(this);
- ws.onmessage = this.onmessage.bind(this);
- ws.onerror = this.onerror.bind(this);
- ws.onclose = this.onclose.bind(this);
- };
- _Connection.prototype.onopen=function(open) {"use strict";
- console.log("onopen", this, arguments);
- };
- _Connection.prototype.onmessage=function(message) {"use strict";
- //AppDispatcher.dispatchServerAction(...);
- console.log("onmessage", this, arguments);
- };
- _Connection.prototype.onerror=function(error) {"use strict";
- console.log("onerror", this, arguments);
- };
- _Connection.prototype.onclose=function(close) {"use strict";
- console.log("onclose", this, arguments);
- };
+_Connection.prototype.init=function() {"use strict";
+ this.openWebSocketConnection();
+};
+_Connection.prototype.openWebSocketConnection=function() {"use strict";
+ this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws");
+ var ws = this.ws;
+
+ ws.onopen = this.onopen.bind(this);
+ ws.onmessage = this.onmessage.bind(this);
+ ws.onerror = this.onerror.bind(this);
+ ws.onclose = this.onclose.bind(this);
+};
+_Connection.prototype.onopen=function(open) {"use strict";
+ console.log("onopen", this, arguments);
+};
+_Connection.prototype.onmessage=function(message) {"use strict";
+ //AppDispatcher.dispatchServerAction(...);
+ console.log("onmessage", this, arguments);
+};
+_Connection.prototype.onerror=function(error) {"use strict";
+ console.log("onerror", this, arguments);
+};
+_Connection.prototype.onclose=function(close) {"use strict";
+ console.log("onclose", this, arguments);
+};
var Connection = new _Connection();
@@ -344,7 +355,7 @@ var TrafficTable = React.createClass({displayName: 'TrafficTable',
i = 12;
while (i--) x += x;
return (
- React.DOM.div(null, React.DOM.pre(null, " ", x, " "))
+ React.DOM.div(null, "Flow")
);
}
});
@@ -434,7 +445,7 @@ var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
this.state.settings.showEventLog ? EventLog(null) : null,
Footer({settings: this.state.settings})
)
- );
+ );
}
});
@@ -450,9 +461,7 @@ var ProxyApp = (
);
$(function() {
-
Connection.init();
app = React.renderComponent(ProxyApp, document.body);
-
});
//# sourceMappingURL=app.js.map \ No newline at end of file
diff --git a/web/src/js/app.js b/web/src/js/app.js
index 3af4c79c..ddf7a69a 100644
--- a/web/src/js/app.js
+++ b/web/src/js/app.js
@@ -1,6 +1,4 @@
$(function() {
-
Connection.init();
app = React.renderComponent(ProxyApp, document.body);
-
}); \ No newline at end of file
diff --git a/web/src/js/components/proxyapp.jsx b/web/src/js/components/proxyapp.jsx
index c0196461..14c338e3 100644
--- a/web/src/js/components/proxyapp.jsx
+++ b/web/src/js/components/proxyapp.jsx
@@ -30,7 +30,7 @@ var ProxyAppMain = React.createClass({
{this.state.settings.showEventLog ? <EventLog/> : null}
<Footer settings={this.state.settings}/>
</div>
- );
+ );
}
});
diff --git a/web/src/js/components/traffictable.jsx b/web/src/js/components/traffictable.jsx
index 1ed6fbc8..69b89a64 100644
--- a/web/src/js/components/traffictable.jsx
+++ b/web/src/js/components/traffictable.jsx
@@ -28,7 +28,7 @@ var TrafficTable = React.createClass({
i = 12;
while (i--) x += x;
return (
- <div><pre> { x } </pre></div>
+ <div>Flow</div>
);
}
});
diff --git a/web/src/js/connection.js b/web/src/js/connection.js
index 1f2daeef..3911d3f2 100644
--- a/web/src/js/connection.js
+++ b/web/src/js/connection.js
@@ -4,30 +4,30 @@ function _Connection(root) {"use strict";
}
this.root = root;
}
- _Connection.prototype.init=function() {"use strict";
- this.openWebSocketConnection();
- };
- _Connection.prototype.openWebSocketConnection=function() {"use strict";
- this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws");
- var ws = this.ws;
+_Connection.prototype.init=function() {"use strict";
+ this.openWebSocketConnection();
+};
+_Connection.prototype.openWebSocketConnection=function() {"use strict";
+ this.ws = new WebSocket(this.root.replace("http", "ws") + "/ws");
+ var ws = this.ws;
- ws.onopen = this.onopen.bind(this);
- ws.onmessage = this.onmessage.bind(this);
- ws.onerror = this.onerror.bind(this);
- ws.onclose = this.onclose.bind(this);
- };
- _Connection.prototype.onopen=function(open) {"use strict";
- console.log("onopen", this, arguments);
- };
- _Connection.prototype.onmessage=function(message) {"use strict";
- //AppDispatcher.dispatchServerAction(...);
- console.log("onmessage", this, arguments);
- };
- _Connection.prototype.onerror=function(error) {"use strict";
- console.log("onerror", this, arguments);
- };
- _Connection.prototype.onclose=function(close) {"use strict";
- console.log("onclose", this, arguments);
- };
+ ws.onopen = this.onopen.bind(this);
+ ws.onmessage = this.onmessage.bind(this);
+ ws.onerror = this.onerror.bind(this);
+ ws.onclose = this.onclose.bind(this);
+};
+_Connection.prototype.onopen=function(open) {"use strict";
+ console.log("onopen", this, arguments);
+};
+_Connection.prototype.onmessage=function(message) {"use strict";
+ //AppDispatcher.dispatchServerAction(...);
+ console.log("onmessage", this, arguments);
+};
+_Connection.prototype.onerror=function(error) {"use strict";
+ console.log("onerror", this, arguments);
+};
+_Connection.prototype.onclose=function(close) {"use strict";
+ console.log("onclose", this, arguments);
+};
var Connection = new _Connection();
diff --git a/web/src/js/dispatcher.js b/web/src/js/dispatcher.js
index 310f9a7f..4f3cce0c 100644
--- a/web/src/js/dispatcher.js
+++ b/web/src/js/dispatcher.js
@@ -4,24 +4,24 @@ const PayloadSources = {
};
- function Dispatcher() {"use strict";
- this.callbacks = [];
+function Dispatcher() {"use strict";
+ this.callbacks = [];
+}
+Dispatcher.prototype.register=function(callback) {"use strict";
+ this.callbacks.push(callback);
+};
+Dispatcher.prototype.unregister=function(callback) {"use strict";
+ var index = this.callbacks.indexOf(f);
+ if (index >= 0) {
+ this.callbacks.splice(this.callbacks.indexOf(f), 1);
}
- Dispatcher.prototype.register=function(callback) {"use strict";
- this.callbacks.push(callback);
- };
- Dispatcher.prototype.unregister=function(callback) {"use strict";
- var index = this.callbacks.indexOf(f);
- if (index >= 0) {
- this.callbacks.splice(this.callbacks.indexOf(f), 1);
- }
- };
- Dispatcher.prototype.dispatch=function(payload) {"use strict";
- console.debug("dispatch", payload);
- this.callbacks.forEach(function(callback) {
- callback(payload);
- });
- };
+};
+Dispatcher.prototype.dispatch=function(payload) {"use strict";
+ console.debug("dispatch", payload);
+ this.callbacks.forEach(function(callback) {
+ callback(payload);
+ });
+};
AppDispatcher = new Dispatcher();
diff --git a/web/src/js/stores/base.js b/web/src/js/stores/base.js
index 55808deb..c02c77b6 100644
--- a/web/src/js/stores/base.js
+++ b/web/src/js/stores/base.js
@@ -1,24 +1,26 @@
-function EventEmitter() {"use strict";
- this.listeners = {};
+"use strict";
+
+function EventEmitter() {
+ this.listeners = {};
+}
+EventEmitter.prototype.emit=function(event) {
+ if (!(event in this.listeners)) {
+ return;
}
- EventEmitter.prototype.emit=function(event) {"use strict";
- if (!(event in this.listeners)) {
- return;
- }
- this.listeners[event].forEach(function(listener) {
- listener.apply(this, arguments);
- }.bind(this));
- };
- EventEmitter.prototype.addListener=function(event, f) {"use strict";
- this.listeners[event] = this.listeners[event] || [];
- this.listeners[event].push(f);
- };
- EventEmitter.prototype.removeListener=function(event, f) {"use strict";
- if (!(event in this.listeners)) {
- return false;
- }
- var index = this.listeners[event].indexOf(f);
- if (index >= 0) {
- this.listeners[event].splice(index, 1);
- }
- };
+ this.listeners[event].forEach(function(listener) {
+ listener.apply(this, arguments);
+ }.bind(this));
+};
+EventEmitter.prototype.addListener=function(event, f) {
+ this.listeners[event] = this.listeners[event] || [];
+ this.listeners[event].push(f);
+};
+EventEmitter.prototype.removeListener=function(event, f) {
+ if (!(event in this.listeners)) {
+ return false;
+ }
+ var index = this.listeners[event].indexOf(f);
+ if (index >= 0) {
+ this.listeners[event].splice(index, 1);
+ }
+};
diff --git a/web/src/js/stores/eventlogstore.js b/web/src/js/stores/eventlogstore.js
index f9d8cf27..dbecc749 100644
--- a/web/src/js/stores/eventlogstore.js
+++ b/web/src/js/stores/eventlogstore.js
@@ -1,3 +1,4 @@
+"use strict";
//
// We have an EventLogView and an EventLogStore:
// The basic architecture is that one can request views on the event log
@@ -5,41 +6,44 @@
// The view object is accessed by React components and distributes updates etc.
//
// See also: components/EventLog.react.js
+function EventLogView(store, live) {
+ EventEmitter.call(this);
+ this.$EventLogView_store = store;
+ this.live = live;
+ this.log = [];
-for(var EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmitter____Key)){EventLogView[EventEmitter____Key]=EventEmitter[EventEmitter____Key];}}var ____SuperProtoOfEventEmitter=EventEmitter===null?null:EventEmitter.prototype;EventLogView.prototype=Object.create(____SuperProtoOfEventEmitter);EventLogView.prototype.constructor=EventLogView;EventLogView.__superConstructor__=EventEmitter;
- function EventLogView(store, live) {"use strict";
- EventEmitter.call(this);
- this.$EventLogView_store = store;
- this.live = live;
- this.log = [];
+ this.add = this.add.bind(this);
- this.add = this.add.bind(this);
-
- if (live) {
- this.$EventLogView_store.addListener("new_entry", this.add);
- }
+ if (live) {
+ this.$EventLogView_store.addListener("new_entry", this.add);
}
- EventLogView.prototype.close=function() {"use strict";
+}
+_.extend(EventLogView.prototype, EventEmitter.prototype, {
+ close: function() {
this.$EventLogView_store.removeListener("new_entry", this.add);
- };
- EventLogView.prototype.getAll=function() {"use strict";
+ },
+ getAll: function() {
return this.log;
- };
- EventLogView.prototype.add=function(entry) {"use strict";
+ },
+ add: function(entry) {
this.log.push(entry);
this.emit("change");
- };
- EventLogView.prototype.add_bulk=function(messages) {"use strict";
+ },
+ add_bulk: function(messages) {
var log = messages;
var last_id = log[log.length - 1].id;
var to_add = _.filter(this.log, function(entry) {return entry.id > last_id;});
this.log = log.concat(to_add);
this.emit("change");
- };
+ }
+});
-for(EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmitter____Key)){_EventLogStore[EventEmitter____Key]=EventEmitter[EventEmitter____Key];}}_EventLogStore.prototype=Object.create(____SuperProtoOfEventEmitter);_EventLogStore.prototype.constructor=_EventLogStore;_EventLogStore.__superConstructor__=EventEmitter;function _EventLogStore(){"use strict";if(EventEmitter!==null){EventEmitter.apply(this,arguments);}}
- _EventLogStore.prototype.getView=function(since) {"use strict";
+function _EventLogStore(){
+ EventEmitter.call(this);
+}
+_.extend(_EventLogStore.prototype, EventEmitter.prototype, {
+ getView: function(since) {
var view = new EventLogView(this, !since);
//TODO: Really do bulk retrieval of last messages.
@@ -69,8 +73,8 @@ for(EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmi
});
}, 1000);
return view;
- };
- _EventLogStore.prototype.handle=function(action) {"use strict";
+ },
+ handle: function(action) {
switch (action.actionType) {
case ActionTypes.EVENTLOG_ADD:
this.emit("new_message", action.message);
@@ -78,7 +82,9 @@ for(EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmi
default:
return;
}
- };
+ }
+});
+
var EventLogStore = new _EventLogStore();
AppDispatcher.register(EventLogStore.handle.bind(EventLogStore));
diff --git a/web/src/js/stores/settingstore.js b/web/src/js/stores/settingstore.js
index 5ceed7db..9139076e 100644
--- a/web/src/js/stores/settingstore.js
+++ b/web/src/js/stores/settingstore.js
@@ -1,18 +1,20 @@
-for(var EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(EventEmitter____Key)){_SettingsStore[EventEmitter____Key]=EventEmitter[EventEmitter____Key];}}var ____SuperProtoOfEventEmitter=EventEmitter===null?null:EventEmitter.prototype;_SettingsStore.prototype=Object.create(____SuperProtoOfEventEmitter);_SettingsStore.prototype.constructor=_SettingsStore;_SettingsStore.__superConstructor__=EventEmitter;
- function _SettingsStore() {"use strict";
- EventEmitter.call(this);
+"use strict";
- //FIXME: What do we do if we haven't requested anything from the server yet?
- this.settings = {
- version: "0.12",
- showEventLog: true,
- mode: "transparent",
- };
- }
- _SettingsStore.prototype.getAll=function() {"use strict";
+function _SettingsStore() {
+ EventEmitter.call(this);
+
+ //FIXME: What do we do if we haven't requested anything from the server yet?
+ this.settings = {
+ version: "0.12",
+ showEventLog: true,
+ mode: "transparent",
+ };
+}
+_.extend(_SettingsStore.prototype, EventEmitter.prototype, {
+ getAll: function() {
return this.settings;
- };
- _SettingsStore.prototype.handle=function(action) {"use strict";
+ },
+ handle: function(action) {
switch (action.actionType) {
case ActionTypes.SETTINGS_UPDATE:
this.settings = action.settings;
@@ -21,7 +23,8 @@ for(var EventEmitter____Key in EventEmitter){if(EventEmitter.hasOwnProperty(Even
default:
return;
}
- };
+ }
+});
var SettingsStore = new _SettingsStore();
AppDispatcher.register(SettingsStore.handle.bind(SettingsStore));