From 33f1d90438b3a4a20ce354f2d080a1d1d770487f Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 12 Jun 2010 23:25:17 +0200 Subject: Trying solutions from Felipe Gomes --- lib/bzpage.js | 5 ++++- lib/main.js | 3 ++- lib/rhbzpage.js | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/bzpage.js b/lib/bzpage.js index fb242d2..aec6632 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -4,17 +4,20 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; var util = require("util"); +var apiUtils = require("api-utils"); var simpleStorage = require("simple-storage"); // ==================================================================================== // BZPage's methods -var BZPage = exports.BZPage = function BZPage(doc, config) { +var BZPage = function BZPage(doc, config) { // initialize dynamic properties this.doc = doc; console.log("Now we are inside!"); }; +exports.BZPage = apiUtils.publicConstructor(BZPage); + BZPage.prototype.getURL = function getURL () { console.log("url = " + this.doc.location.href); return this.doc.location.href; diff --git a/lib/main.js b/lib/main.js index b298829..e8d69c6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -49,8 +49,9 @@ exports.main = function main(options, callbacks) { browser.whenContentLoaded( function(window) { var doc = window.document; + var construct = require("rhbzpage").RHBugzillaPage; if (isOurPage(window, matches)) { - var curPage = new require("rhbzpage").RHBugzillaPage(doc, config); + var curPage = construct(doc, config); } else { console.log("Not our page: " + window.location.href); } diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index 70186c9..da3bf92 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -4,12 +4,13 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; var util = require("util"); +var apiUtils = require("api-utils"); var BZPage = require("bzpage").BZPage; // ==================================================================================== // RHBugzillaPage object -var RHBugzillaPage = exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { +var RHBugzillaPage = function RHBugzillaPage(doc, config) { // inheritance ... call superobject's constructor BZPage.call(this, doc, config); @@ -30,3 +31,5 @@ var RHBugzillaPage = exports.RHBugzillaPage = function RHBugzillaPage(doc, confi RHBugzillaPage.prototype = util.heir(BZPage.prototype); RHBugzillaPage.prototype.constructor = RHBugzillaPage; + +exports.RHBugzillaPage = apiUtils.publicConstructor(RHBugzillaPage); \ No newline at end of file -- cgit