aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/store
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-03-17 03:05:59 +0100
committerMaximilian Hils <git@maximilianhils.com>2015-03-17 03:05:59 +0100
commit40c242c3f6e9de093f68ad3e1f8887ae49a28b84 (patch)
tree5094f259893167b6425a88c6709ed6135d573eaa /web/src/js/store
parent4a92c425175a4e592c8760f028be683f53ab9b90 (diff)
downloadmitmproxy-40c242c3f6e9de093f68ad3e1f8887ae49a28b84.tar.gz
mitmproxy-40c242c3f6e9de093f68ad3e1f8887ae49a28b84.tar.bz2
mitmproxy-40c242c3f6e9de093f68ad3e1f8887ae49a28b84.zip
add table sort
Diffstat (limited to 'web/src/js/store')
-rw-r--r--web/src/js/store/view.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/web/src/js/store/view.js b/web/src/js/store/view.js
index 9bf31c52..204d22da 100644
--- a/web/src/js/store/view.js
+++ b/web/src/js/store/view.js
@@ -1,7 +1,6 @@
var EventEmitter = require('events').EventEmitter;
var _ = require("lodash");
-
var utils = require("../utils.js");
function SortByStoreOrder(elem) {
@@ -40,17 +39,25 @@ _.extend(StoreView.prototype, EventEmitter.prototype, {
this.store.removeListener("recalculate", this.recalculate);
},
recalculate: function (filt, sortfun) {
- if (filt) {
- this.filt = filt.bind(this);
- }
- if (sortfun) {
- this.sortfun = sortfun.bind(this);
- }
+ filt = filt || default_filt;
+ sortfun = sortfun || default_sort;
+ filt = filt.bind(this);
+ sortfun = sortfun.bind(this)
+ this.filt = filt;
+ this.sortfun = sortfun;
- this.list = this.store.list.filter(this.filt);
+ this.list = this.store.list.filter(filt);
this.list.sort(function (a, b) {
- return this.sortfun(a) - this.sortfun(b);
- }.bind(this));
+ var akey = sortfun(a);
+ var bkey = sortfun(b);
+ if(akey < bkey){
+ return -1;
+ } else if(akey > bkey){
+ return 1;
+ } else {
+ return 0;
+ }
+ });
this.emit("recalculate");
},
index: function (elem) {