1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-14 15:15:45 +01:00

made action public to change .execute() to be a prototype

This commit is contained in:
Martin Stubenschrott
2007-05-31 17:58:37 +00:00
parent 6d28fd6107
commit 4a24289ab9

View File

@@ -4,10 +4,9 @@ function Map(mode, cmds, act, extra_info) //{{{
if (!mode || (!cmds || !cmds.length) || !act) if (!mode || (!cmds || !cmds.length) || !act)
return null; return null;
var action = act;
this.mode = mode; this.mode = mode;
this.commands = cmds; this.commands = cmds;
this.action = act;
if (extra_info) if (extra_info)
{ {
@@ -20,7 +19,7 @@ function Map(mode, cmds, act, extra_info) //{{{
this.usage = ""; this.usage = "";
if (flags & Mappings.flags.COUNT) if (flags & Mappings.flags.COUNT)
this.usage = "{count}"; this.usage = "{count}";
this.usage += this.commands[0]; //XXX: or sth. like .join("<br/>"); this.usage += this.commands[0]; // only the first command name
if (flags & Mappings.flags.ARGUMENT) if (flags & Mappings.flags.ARGUMENT)
this.usage += " {arg}"; this.usage += " {arg}";
} }
@@ -36,24 +35,25 @@ function Map(mode, cmds, act, extra_info) //{{{
this.short_help = null; this.short_help = null;
} }
// XXX: can we move this to Map.prototype.execute, or don't we have access to this in a prototype? }
this.execute = function() // Since we will add many Map-objects, we add some functions as prototypes
{ // this will ensure we only have one copy of each function, not one for each object
action.call(this); Map.prototype.execute = function()
} {
this.action.call(this);
}
this.toString = function() Map.prototype.toString = function()
{ {
// FIXME: -- djk // FIXME: -- djk
return "Map {" + return "Map {" +
"\nmode: " + this.mode + "\nmode: " + this.mode +
"\ncommands: " + this.commands + "\ncommands: " + this.commands +
"\naction: " + action + "\naction: " + this.action +
"\nusage: " + this.usage + "\nusage: " + this.usage +
"\nshort_help: " + this.short_help + "\nshort_help: " + this.short_help +
"\nhelp: " + this.help + "\nhelp: " + this.help +
"\n}" "\n}"
}
} //}}} } //}}}
function Mappings()//{{{ function Mappings()//{{{