shuffle around initialization code
This commit is contained in:
parent
d6f0dc28ef
commit
492d3a8cb2
3 changed files with 19 additions and 7 deletions
|
@ -103,10 +103,6 @@ var Zotero_Browser = new function() {
|
|||
|
||||
Zotero_Browser.browserData = new Object();
|
||||
Zotero_Browser._scrapePopupShowing = false;
|
||||
Zotero.Proxies.init();
|
||||
Zotero.Ingester.MIMEHandler.init();
|
||||
Zotero.Cite.MIMEHandler.init();
|
||||
Zotero.Translators.init();
|
||||
|
||||
window.addEventListener("load",
|
||||
function(e) { Zotero_Browser.chromeLoad(e) }, false);
|
||||
|
|
|
@ -37,17 +37,21 @@ const BOMs = {
|
|||
* @namespace
|
||||
*/
|
||||
Zotero.Translators = new function() {
|
||||
var _cache = {"import":[], "export":[], "web":[], "search":[]};
|
||||
var _translators = {};
|
||||
var _cache, _translators;
|
||||
var _initialized = false;
|
||||
|
||||
/**
|
||||
* Initializes translator cache, loading all relevant translators into memory
|
||||
*/
|
||||
this.init = function() {
|
||||
if(_initialized) return;
|
||||
_initialized = true;
|
||||
|
||||
var start = (new Date()).getTime()
|
||||
|
||||
_cache = {"import":[], "export":[], "web":[], "search":[]};
|
||||
_translators = {};
|
||||
|
||||
var i = 0;
|
||||
var contents = Zotero.getTranslatorsDirectory().directoryEntries;
|
||||
while(contents.hasMoreElements()) {
|
||||
var file = contents.getNext().QueryInterface(Components.interfaces.nsIFile);
|
||||
|
@ -71,13 +75,17 @@ Zotero.Translators = new function() {
|
|||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
Zotero.debug("Cached "+i+" translators in "+((new Date()).getTime() - start)+" ms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the translator that corresponds to a given ID
|
||||
*/
|
||||
this.getTranslatorById = function(id) {
|
||||
if(!_initialized) this.init();
|
||||
return _translators[id] ? _translators[id] : false;
|
||||
}
|
||||
|
||||
|
@ -85,6 +93,7 @@ Zotero.Translators = new function() {
|
|||
* Gets all translators for a specific type of translation
|
||||
*/
|
||||
this.getTranslatorsByType = function(type) {
|
||||
if(!_initialized) this.init();
|
||||
return _cache[type].slice(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,8 @@ var Zotero = new function(){
|
|||
return false;
|
||||
}
|
||||
|
||||
var start = (new Date()).getTime()
|
||||
|
||||
// Register shutdown handler to call Zotero.shutdown()
|
||||
/*
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||
|
@ -273,7 +275,12 @@ var Zotero = new function(){
|
|||
Zotero.Sync.Runner.init();
|
||||
Zotero.Sync.Storage.init();
|
||||
|
||||
Zotero.Proxies.init();
|
||||
Zotero.Ingester.MIMEHandler.init();
|
||||
Zotero.Cite.MIMEHandler.init();
|
||||
|
||||
this.initialized = true;
|
||||
Zotero.debug("Initialized in "+((new Date()).getTime() - start)+" ms");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue