📄 moz0804ex.txt
字号:
SimpleComponent.prototype = {
mName: "a default value"
get yourName() { return this.mName; },
set yourName(aName) { return this.mName = aName; },
write: function () { dump("Hello " + this.mName + "\n"); },
change: function (aValue) { this.mName = aValue; },
QueryInterface: function (iid) {
if (!iid.equals(Components.interfaces.nsISimple)
&& !iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
}
var Module = {
firstTime: true,
registerSelf: function (compMgr, fileSpec, location, type) {
if (this.firstTime) {
dump("*** first time registration of Simple JS component\n");
this.firstTime = false;
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
}
dump(" ***** Registering: Simple JS component! ****\n");
dump(" ***** Registering: Simple JS component! ****\n");
this.myCID,
"My JS Component",
this.myProgID, fileSpec,
location, true, true,
type);
},
getClassObject : function (compMgr, cid, iid) {
if (!cid.equals(this.myCID))
throw Components.results.NS_ERROR_NO_INTERFACE
if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
return this.myFactory;
},
myCID: Components.ID("{98aa9afd-8b08-415b-91ed-01916a130d16}"),
myProgID: "@mozilla.org/js_simple_component;1",
myFactory: {
createInstance: function (outer, iid) {
dump("CI: " + iid + "\n");
if (outer != null)
if (outer != null)
return (new SimpleComponent()).QueryInterface(iid);
}
},
canUnload: function(compMgr) {
dump("****** Unloading: Simple JS component! ****** \n");
return true;
}
}; // END Module
function NSGetModule(compMgr, fileSpec) { return Module; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -