From f4b2d74740a25a23a7e16597e2a1f0dcf9fb732d Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 25 Oct 2010 23:52:31 +0200 Subject: Move choice of particular content script objects to initialize(). --- lib/main.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/main.js') diff --git a/lib/main.js b/lib/main.js index 8e8aeaa..fbabd41 100644 --- a/lib/main.js +++ b/lib/main.js @@ -94,6 +94,14 @@ function initialize(callback) { return x.replace("show_bug.cgi.*","((process|post)_bug|attachment)\.cgi$"); }); + config.objConstructor = {}; + var bzType = config.gJSONData.configData.objectStyle; + if (bzType === "RH") { + config.objConstructor = require("rhbzpage").RHBugzillaPage; + } else if (bzType === "MoFo") { + config.objConstructor = require("mozillabzpage").MozillaBugzilla; + } + callback(config); } } @@ -107,16 +115,9 @@ exports.main = function main(options, callbacks) { // is this good for anything? if ("window" in window) { window = window.window; } - var construct = {}; - var bzType = config.gJSONData.configData.objectStyle; - if (bzType === "RH") { - construct = require("rhbzpage").RHBugzillaPage; - } else if (bzType === "MoFo") { - construct = require("mozillabzpage").MozillaBugzilla; - } if (isOurPage(window, config.matches)) { try { - var curPage = new construct(window, config); + var curPage = new config.objConstructor(window, config); } catch (ex) { if (ex instanceof require("bzpage").NotLoggedinException) { return ; // Bail out if the user is not logged in -- cgit