diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-03-17 03:05:59 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-03-17 03:05:59 +0100 |
commit | 40c242c3f6e9de093f68ad3e1f8887ae49a28b84 (patch) | |
tree | 5094f259893167b6425a88c6709ed6135d573eaa /web/src/js/utils.js | |
parent | 4a92c425175a4e592c8760f028be683f53ab9b90 (diff) | |
download | mitmproxy-40c242c3f6e9de093f68ad3e1f8887ae49a28b84.tar.gz mitmproxy-40c242c3f6e9de093f68ad3e1f8887ae49a28b84.tar.bz2 mitmproxy-40c242c3f6e9de093f68ad3e1f8887ae49a28b84.zip |
add table sort
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r-- | web/src/js/utils.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js index 21b7a868..bcd3958d 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -1,5 +1,5 @@ var $ = require("jquery"); - +var _ = require("lodash"); var Key = { UP: 38, @@ -59,6 +59,18 @@ var formatTimeStamp = function (seconds) { }; +// At some places, we need to sort strings alphabetically descending, +// but we can only provide a key function. +// This beauty "reverses" a JS string. +var end = String.fromCharCode(0xffff); +function reverseString(s){ + return String.fromCharCode.apply(String, + _.map(s.split(""), function (c) { + return 0xffff - c.charCodeAt(); + }) + ) + end; +} + function getCookie(name) { var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); return r ? r[1] : undefined; @@ -87,5 +99,6 @@ module.exports = { formatSize: formatSize, formatTimeDelta: formatTimeDelta, formatTimeStamp: formatTimeStamp, + reverseString: reverseString, Key: Key };
\ No newline at end of file |