add removeCommand function

This commit is contained in:
Fabian Jakobs 2011-11-10 17:14:17 +01:00
commit 44c019871c

View file

@ -20,6 +20,22 @@ var CommandManager = function(commands) {
this._buildKeyHash(command);
}
};
function removeCommand(command) {
var name = (typeof command === 'string' ? command : command.name);
command = this.commands[name];
delete commands[name];
// exaustive search is a little bit brute force but since removeCommand is
// not a performance critical operation this should be OK
var ckb = this.commmandKeyBinding;
for (var hashId in ckb) {
for (var key in ckb[hashId]) {
if (ckb[hashId][key] == command)
delete ckb[hashId][key];
}
}
};
var platform = useragent.isMac ? "mac" : "win";