diff options
-rw-r--r-- | cookie.js | 13 | ||||
-rw-r--r-- | walk-input.js | 25 |
2 files changed, 18 insertions, 20 deletions
@@ -1,4 +1,4 @@ -/* +/** * ==VimperatorPlugin== * @name cookie.js * @description display cookie in ':pageinfo'. @@ -68,7 +68,7 @@ CookieManager.prototype = { }, _deserializeCookie: function (cookieString) { - let cookies = cookieString.split('; '); + let cookies = cookieString.split(/; */); let cookie = {}; let key, val; for (let i=0, max=cookies.length ; i<max ; ++i) { @@ -83,6 +83,8 @@ CookieManager.prototype = { }, properties: function () { + liberator.log('debug', 0); + liberator.log(this.cookie, 0); return [k for ([k, v] in Iterator(this.cookie))]; }, @@ -92,7 +94,7 @@ CookieManager.prototype = { obj.key + '=' + obj.value, 'domain=' + obj.domain, 'expires=' + new Date(new Date().getTime() + obj.expires), - ].join(';'); + ].join('; '); this._setCookieString(string); }, }; @@ -101,7 +103,8 @@ liberator.modules.buffer.addPageInfoSection( 'c', 'Cookie', function (verbose) { - if (verbose) { + if(verbose) { + let p; let c = new CookieManager(liberator.modules.buffer.URL); for ([, p] in Iterator(c.properties())) { yield [p, c.getCookie(p)]; @@ -110,6 +113,6 @@ liberator.modules.buffer.addPageInfoSection( } ); -})() +})(); // vim: set sw=4 ts=4 et; diff --git a/walk-input.js b/walk-input.js index eb0b8ea..885a96c 100644 --- a/walk-input.js +++ b/walk-input.js @@ -19,38 +19,33 @@ // </html> (function() { -var walkinput = function(forward) { +var walkinput = function() { var win = document.commandDispatcher.focusedWindow; var d = win.document; var xpath = '//input[@type="text" or @type="password" or @type="search" or not(@type)] | //textarea'; var list = d.evaluate(xpath, d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - if (list.snapshotLength == 0) - return; + if (list.snapshotLength == 0) return; var focused = document.commandDispatcher.focusedElement; var current = null; var next = null; - var prev = null; for (let i = 0; i < list.snapshotLength; ++i) { let e = list.snapshotItem(i); if (e == focused) { current = e; - } else if (current && !next) { + } else if (current && next == null) { next = e; - } else if (!current) { - prev = e; } } - - if (forward) { - (next || list.snapshotItem(0)).focus(); + if (next) { + next.focus(); } else { - (prev || list.snapshotItem(list.snapshotLength - 1)).focus(); + list.snapshotItem(0).focus(); } }; -mappings.add([modes.NORMAL, modes.INSERT], ['<M-i>', '<A-i>'], - 'Walk Input Fields (Forward)', function () walkinput(true)); -mappings.add([modes.NORMAL, modes.INSERT], ['<M-I>', '<A-I>'], - 'Walk Input Fields (Backward)', function () walkinput(false)); +liberator.modules.mappings.add([liberator.modules.modes.NORMAL], ['<M-i>'], 'Walk Input Fields', walkinput); +liberator.modules.mappings.add([liberator.modules.modes.INSERT], ['<M-i>'], 'Walk Input Fields', walkinput); +liberator.modules.mappings.add([liberator.modules.modes.NORMAL], ['<A-i>'], 'Walk Input Fields', walkinput); +liberator.modules.mappings.add([liberator.modules.modes.INSERT], ['<A-i>'], 'Walk Input Fields', walkinput); })(); |