mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-20 11:45:47 +01:00
Don't reload the page on gU when we're already there.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||||
// Copyright (c) 2007-2009 by Doug Kearns <dougkearns@gmail.com>
|
// Copyright (c) 2007-2010 by Doug Kearns <dougkearns@gmail.com>
|
||||||
// Copyright (c) 2008-2010 by Kris Maglione <maglione.k at Gmail>
|
// Copyright (c) 2008-2010 by Kris Maglione <maglione.k at Gmail>
|
||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
@@ -13,6 +13,20 @@
|
|||||||
*/
|
*/
|
||||||
const Browser = Module("browser", {
|
const Browser = Module("browser", {
|
||||||
}, {
|
}, {
|
||||||
|
climbUrlPath: function (count) {
|
||||||
|
try {
|
||||||
|
var url = util.newURI(buffer.URL).QueryInterface(Ci.nsIURL);
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
dactyl.assert(url);
|
||||||
|
|
||||||
|
while (count-- && url.path != "/")
|
||||||
|
url.path = url.path.replace(/[^\/]+\/?$/, "")
|
||||||
|
|
||||||
|
dactyl.assert(url.spec != buffer.URL);
|
||||||
|
dactyl.open(url.spec);
|
||||||
|
},
|
||||||
|
|
||||||
incrementURL: function (count) {
|
incrementURL: function (count) {
|
||||||
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
|
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
|
||||||
dactyl.assert(matches);
|
dactyl.assert(matches);
|
||||||
@@ -109,27 +123,12 @@ const Browser = Module("browser", {
|
|||||||
|
|
||||||
mappings.add([modes.NORMAL], ["gu"],
|
mappings.add([modes.NORMAL], ["gu"],
|
||||||
"Go to parent directory",
|
"Go to parent directory",
|
||||||
function (count) {
|
function (count) { Browser.climbUrlPath(Math.max(count, 1)); },
|
||||||
count = Math.max(count, 1);
|
|
||||||
let url = util.newURI(buffer.URL);
|
|
||||||
|
|
||||||
while (count-- && url.path != "/")
|
|
||||||
url.path = url.path.replace(/[^\/]+\/?$/, "")
|
|
||||||
|
|
||||||
if (url.spec != buffer.URL)
|
|
||||||
dactyl.open(url.spec);
|
|
||||||
else
|
|
||||||
dactyl.beep();
|
|
||||||
},
|
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add([modes.NORMAL], ["gU"],
|
mappings.add([modes.NORMAL], ["gU"],
|
||||||
"Go to the root of the website",
|
"Go to the root of the website",
|
||||||
function () {
|
function () { Browser.climbUrlPath(-1); });
|
||||||
let uri = window.content.document.location;
|
|
||||||
dactyl.assert(!/(about|mailto):/.test(uri.protocol)); // exclude these special protocols for now
|
|
||||||
dactyl.open(uri.protocol + "//" + (uri.host || "") + "/");
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.NORMAL], ["<C-l>"],
|
mappings.add([modes.NORMAL], ["<C-l>"],
|
||||||
"Redraw the screen",
|
"Redraw the screen",
|
||||||
|
|||||||
Reference in New Issue
Block a user