www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 94619403ca1d918301b8387fd0235e1a4d7a7b05
parent 7ff11fdebb4e3f90a9bfb08b49cfd1e74cb84c39
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon, 21 Jan 2013 01:58:01 -0500

Tweak loading process

Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 2+-
Dchrome/content/zotero/xpcom/xregexp/init.js | 19-------------------
Mcomponents/zotero-service.js | 62+++++++++++++++++++++++++++++---------------------------------
3 files changed, 30 insertions(+), 53 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -1674,5 +1674,5 @@ Zotero.Utilities = { * Provides unicode support and other additional features for regular expressions * See https://github.com/slevithan/xregexp for usage */ - "XRegExp": Zotero.XRegExp + "XRegExp": XRegExp } diff --git a/chrome/content/zotero/xpcom/xregexp/init.js b/chrome/content/zotero/xpcom/xregexp/init.js @@ -1,18 +0,0 @@ -//List of files to be loaded by Zotero -var load = [ - /**Core functions**/ - 'xregexp', - - /**Addons**/ - 'addons/build', //adds ability to "build regular expressions using named subpatterns, for readability and pattern reuse" - 'addons/matchrecursive', //adds ability to "match recursive constructs using XRegExp pattern strings as left and right delimiters" - - /**Unicode support**/ - 'addons/unicode/unicode-base', //required for all other unicode packages. Adds \p{Letter} category - - //'addons/unicode/unicode-blocks', //adds support for all Unicode blocks (e.g. InArabic, InCyrillic_Extended_A, etc.) - 'addons/unicode/unicode-categories', //adds support for all Unicode categories (e.g. Punctuation, Lowercase_Letter, etc.) - //'addons/unicode/unicode-properties', //adds Level 1 Unicode properties (e.g. Uppercase, White_Space, etc.) - //'addons/unicode/unicode-scripts' //adds support for all Unicode scripts (e.g. Gujarati, Cyrillic, etc.) - 'addons/unicode/unicode-zotero' //adds support for some Unicode categories used in Zotero -]; -\ No newline at end of file diff --git a/components/zotero-service.js b/components/zotero-service.js @@ -195,37 +195,41 @@ function makeZoteroContext(isConnector) { zContext.Zotero = function() {}; } + var subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader); + // Load zotero.js first - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext); + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext); // Load CiteProc into Zotero.CiteProc namespace zContext.Zotero.CiteProc = {"Zotero":zContext.Zotero}; - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc); + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc); + + // Load XRegExp object into Zotero.XRegExp + const xregexpFiles = [ + /**Core functions**/ + 'xregexp', + + /**Addons**/ + 'addons/build', //adds ability to "build regular expressions using named subpatterns, for readability and pattern reuse" + 'addons/matchrecursive', //adds ability to "match recursive constructs using XRegExp pattern strings as left and right delimiters" - //Load XRegExp object into Zotero.XRegExp - //This needs to be loaded before Zotero.Utilities so it gets included in Zotero.Utilities.Translate - //The files that need to be loaded are defined in the init.js file - var xregexpContext = {}; - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/xregexp/init.js", xregexpContext); - for(var i=0; i<xregexpContext.load.length; i++) { - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpContext.load[i] + ".js", xregexpContext); + /**Unicode support**/ + 'addons/unicode/unicode-base', //required for all other unicode packages. Adds \p{Letter} category + + //'addons/unicode/unicode-blocks', //adds support for all Unicode blocks (e.g. InArabic, InCyrillic_Extended_A, etc.) + 'addons/unicode/unicode-categories', //adds support for all Unicode categories (e.g. Punctuation, Lowercase_Letter, etc.) + //'addons/unicode/unicode-properties', //adds Level 1 Unicode properties (e.g. Uppercase, White_Space, etc.) + //'addons/unicode/unicode-scripts' //adds support for all Unicode scripts (e.g. Gujarati, Cyrillic, etc.) + 'addons/unicode/unicode-zotero' //adds support for some Unicode categories used in Zotero + ]; + for (var i=0; i<xregexpFiles.length; i++) { + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpFiles[i] + ".js", zContext); } - zContext.Zotero.XRegExp = xregexpContext.XRegExp; // Load remaining xpcomFiles for (var i=1; i<xpcomFilesAll.length; i++) { try { - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[i] + ".js", zContext); + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[i] + ".js", zContext); } catch (e) { Components.utils.reportError("Error loading " + xpcomFilesAll[i] + ".js", zContext); @@ -236,9 +240,7 @@ function makeZoteroContext(isConnector) { // Load xpcomFiles for specific mode for each(var xpcomFile in (isConnector ? xpcomFilesConnector : xpcomFilesLocal)) { try { - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/" + xpcomFile + ".js", zContext); + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFile + ".js", zContext); } catch (e) { Components.utils.reportError("Error loading " + xpcomFile + ".js", zContext); @@ -259,22 +261,16 @@ function makeZoteroContext(isConnector) { ]; zContext.Zotero.RDF = {Zotero:zContext.Zotero}; for (var i=0; i<rdfXpcomFiles.length; i++) { - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF); + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF); } if(isStandalone()) { // If isStandalone, load standalone.js - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext); + subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext); } // load nsTransferable (query: do we still use this?) - Cc["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Ci.mozIJSSubScriptLoader) - .loadSubScript("chrome://global/content/nsTransferable.js", zContext); + subscriptLoader.loadSubScript("chrome://global/content/nsTransferable.js", zContext); // add connector-related properties zContext.Zotero.isConnector = isConnector;