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

Automatically add plugins context to plugins[file.leafName]

This commit is contained in:
Kris Maglione
2008-12-03 09:55:50 -05:00
parent 5eb5310ec5
commit ec8ef3ca69

View File

@@ -28,18 +28,26 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
plugins.contexts = {};
function Script(name)
function Script(file)
{
let self = plugins.contexts[name]
let self = plugins.contexts[file.path]
if (self)
{
if (self.onUnload)
self.onUnload();
return self;
}
plugins.contexts[name] = this;
this.NAME = name;
plugins.contexts[file.path] = this;
this.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/, function (_0, _1) _1.toUpperCase());
this.PATH = file.path;
this.__context__ = this;
// This belongs elsewhere
for (let [,dir] in Iterator(io.getRuntimeDirectories("plugin")))
{
if (dir.contains(file, false))
plugins[name] = this.NAME;
}
}
Script.prototype = plugins;
@@ -833,7 +841,7 @@ lookup:
{
try
{
liberator.loadScript(uri.spec, new Script(file.path));
liberator.loadScript(uri.spec, new Script(file));
}
catch (e)
{