1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-27 10:25:45 +01:00

Fix :back/:forward[!] commands.

This commit is contained in:
Doug Kearns
2008-12-30 00:53:58 +11:00
parent d65b57cf2d
commit 165a315204

View File

@@ -700,7 +700,7 @@ function History() //{{{
"Go back in the browser history", "Go back in the browser history",
function (args) function (args)
{ {
args = args.string; let url = args.literalArg;
if (args.bang) if (args.bang)
{ {
@@ -708,12 +708,12 @@ function History() //{{{
} }
else else
{ {
if (args) if (url)
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = window.getWebNavigation().sessionHistory;
for (let i = sh.index - 1; i >= 0; i--) for (let i in util.range(sh.index, 0, true))
{ {
if (sh.getEntryAtIndex(i, false).URI.spec == args) if (sh.getEntryAtIndex(i, false).URI.spec == url)
{ {
window.getWebNavigation().gotoIndex(i); window.getWebNavigation().gotoIndex(i);
return; return;
@@ -723,7 +723,7 @@ function History() //{{{
} }
else else
{ {
history.stepTo(args.count > 0 ? -1 * args.count : -1); history.stepTo(-Math.max(args.count, 1));
} }
} }
}, },
@@ -746,7 +746,7 @@ function History() //{{{
"Go forward in the browser history", "Go forward in the browser history",
function (args) function (args)
{ {
args = args.string; let url = args.literalArg;
if (args.bang) if (args.bang)
{ {
@@ -754,12 +754,12 @@ function History() //{{{
} }
else else
{ {
if (args) if (url)
{ {
let sh = window.getWebNavigation().sessionHistory; let sh = window.getWebNavigation().sessionHistory;
for (let i in util.range(sh.index + 1, sh.count)) for (let i in util.range(sh.index + 1, sh.count))
{ {
if (sh.getEntryAtIndex(i, false).URI.spec == args) if (sh.getEntryAtIndex(i, false).URI.spec == url)
{ {
window.getWebNavigation().gotoIndex(i); window.getWebNavigation().gotoIndex(i);
return; return;
@@ -769,7 +769,7 @@ function History() //{{{
} }
else else
{ {
history.stepTo(args.count > 0 ? args.count : 1); history.stepTo(Math.max(args.count, 1));
} }
} }
}, },
@@ -845,31 +845,30 @@ function History() //{{{
if (index >= 0 && index < window.getWebNavigation().sessionHistory.count) if (index >= 0 && index < window.getWebNavigation().sessionHistory.count)
window.getWebNavigation().gotoIndex(index); window.getWebNavigation().gotoIndex(index);
else else
liberator.beep(); liberator.beep(); // XXX: really wanted?
}, },
goToStart: function goToStart() goToStart: function goToStart()
{ {
let index = window.getWebNavigation().sessionHistory.index; let index = window.getWebNavigation().sessionHistory.index;
if (index == 0)
{
liberator.beep(); // XXX: really wanted?
return;
}
window.getWebNavigation().gotoIndex(0); if (index > 0)
window.getWebNavigation().gotoIndex(0);
else
liberator.beep(); // XXX: really wanted?
}, },
goToEnd: function goToEnd() goToEnd: function goToEnd()
{ {
let index = window.getWebNavigation().sessionHistory.index; let sh = window.getWebNavigation().sessionHistory;
if (index == window.getWebNavigation().sessionHistory.count - 1) let max = sh.count - 1;
{
liberator.beep(); if (sh.index < max)
return; window.getWebNavigation().gotoIndex(max);
} else
liberator.beep(); // XXX: really wanted?
window.getWebNavigation().gotoIndex(max);
}, },
// if openItems is true, open the matching history items in tabs rather than display // if openItems is true, open the matching history items in tabs rather than display