1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 07:27:58 +01:00

make use of our argsParser to handle commands with a fixed number of arguments.

Also added args.string to access the original string before it was parsed.
TODO: Always pass a parseArgs-like structure to commands, instead of only
when options or argCount is specified?
This commit is contained in:
Martin Stubenschrott
2008-08-13 21:53:56 +00:00
parent c49ed07af9
commit 1035a01ace
10 changed files with 76 additions and 146 deletions

View File

@@ -292,45 +292,35 @@ liberator.config = { //{{{
"Close the sidebar window",
function (args)
{
if (args)
{
liberator.echoerr("E488: Trailing characters");
return;
}
if (document.getElementById("sidebar-box").hidden == false)
toggleSidebar();
});
},
{ argCount: "0" });
liberator.commands.add(["sideb[ar]", "sb[ar]", "sbope[n]"],
"Open the sidebar window",
function (args)
{
if (!args)
{
liberator.echoerr("E471: Argument required");
return;
}
// do nothing if the requested sidebar is already open
if (document.getElementById("sidebar-title").value == args)
if (document.getElementById("sidebar-title").value == args.string)
{
document.getElementById("sidebar-box").contentWindow.focus();
return;
}
var menu = document.getElementById("viewSidebarMenu");
for (var i = 0; i < menu.childNodes.length; i++)
{
if (menu.childNodes[i].label == args)
if (menu.childNodes[i].label == args.string)
{
menu.childNodes[i].doCommand();
break;
return;
}
}
liberator.echoerr("No sidebar " + args.string + " found");
},
{
argCount: "+",
completer: function (filter)
{
var menu = document.getElementById("viewSidebarMenu");