diff --git a/chrome/chromeFiles/content/scholar/include.js b/chrome/chromeFiles/content/scholar/include.js index de0c6d71c8..2ab2956790 100644 --- a/chrome/chromeFiles/content/scholar/include.js +++ b/chrome/chromeFiles/content/scholar/include.js @@ -1,6 +1,5 @@ -var Scholar_browserWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator) - .getMostRecentWindow("navigator:browser"); - -const SCHOLAR_CONFIG = Scholar_browserWindow.SCHOLAR_CONFIG; -var Scholar = Scholar_browserWindow.Scholar; +var Scholar = Components.classes["@chnm.gmu.edu/Scholar;1"] + // Currently uses only nsISupports + //.getService(Components.interfaces.chnmIScholarService). + .getService(Components.interfaces.nsISupports) + .wrappedJSObject; diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index e763982200..14c71e5197 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -11,29 +11,42 @@ const SCHOLAR_CONFIG = { * Core functions */ var Scholar = new function(){ - var _initialized = false + var _initialized = false; + var _localizedStringBundle; - this.testString = 'Sidebar is not registered'; - this.LocalizedStrings; + // Privileged (public) methods this.init = init; this.debug = debug; this.varDump = varDump; + this.getString = getString; this.flattenArguments = flattenArguments; this.join = join; + this.Hash = Hash; /* * Initialize the extension */ function init(){ - this.LocalizedStrings = document.getElementById('scholar-strings'); - - if (!_initialized){ - Scholar.DB.updateSchema(); - _initialized = true; - return true; + if (_initialized){ + return false; } - return false; + + Scholar.DB.updateSchema(); + + // Load in the localization stringbundle for use by getString(name) + var src = 'chrome://scholar/locale/scholar.properties'; + var localeService = + Components.classes["@mozilla.org/intl/nslocaleservice;1"] + .getService(Components.interfaces.nsILocaleService); + var appLocale = localeService.getApplicationLocale(); + var stringBundleService = + Components.classes["@mozilla.org/intl/stringbundle;1"] + .getService(Components.interfaces.nsIStringBundleService); + _localizedStringBundle = stringBundleService.createBundle(src, appLocale); + + _initialized = true; + return true; } @@ -117,6 +130,11 @@ var Scholar = new function(){ } + function getString(name){ + return _localizedStringBundle.GetStringFromName(name); + } + + /* * Flattens mixed arrays/values in a passed _arguments_ object and returns * an array of values -- allows for functions to accept both arrays of @@ -226,5 +244,3 @@ Scholar.Hash.prototype.remove = function(in_key){ Scholar.Hash.prototype.has = function(in_key){ return typeof(this.items[in_key]) != 'undefined'; } - -window.addEventListener("load", function(e) { Scholar.init(e); }, false); diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul index b9eb20525d..9d0a9b53f7 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -5,18 +5,21 @@ - +