1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-04 18:25:45 +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 *****/ }}} ***** END LICENSE BLOCK *****/
plugins.contexts = {}; plugins.contexts = {};
function Script(name) function Script(file)
{ {
let self = plugins.contexts[name] let self = plugins.contexts[file.path]
if (self) if (self)
{ {
if (self.onUnload) if (self.onUnload)
self.onUnload(); self.onUnload();
return self; return self;
} }
plugins.contexts[name] = this; plugins.contexts[file.path] = this;
this.NAME = name; this.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/, function (_0, _1) _1.toUpperCase());
this.PATH = file.path;
this.__context__ = this; 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; Script.prototype = plugins;
@@ -833,7 +841,7 @@ lookup:
{ {
try try
{ {
liberator.loadScript(uri.spec, new Script(file.path)); liberator.loadScript(uri.spec, new Script(file));
} }
catch (e) catch (e)
{ {