-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbootstrap.js
122 lines (99 loc) · 3.71 KB
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// ZotMoov
// bootstrap.js
// Written by Wiley Yu
// Declare at top level
let zotmoov = null;
let zotmoovMenus = null;
let zotmoovBindings = null;
let chromeHandle = null;
function log(msg)
{
Zotero.debug('ZotMoov: ' + msg);
}
async function install()
{
log('ZotMoov: Installed');
// Fix for old version parity
let old_pref = Zotero.Prefs.get('extensions.zotmoov.dst_dir')
if (old_pref)
{
Zotero.Prefs.set('extensions.zotmoov.dst_dir', old_pref, true);
Zotero.Prefs.clear('extensions.zotmoov.dst_dir');
}
}
async function startup({ id, version, resourceURI, rootURI = resourceURI.spec })
{
// Only ones we need to load directly here
Services.scriptloader.loadSubScript(rootURI + 'init/00-script-definitions.js');
Services.scriptloader.loadSubScript(rootURI + 'init/01-script-loader.js');
let scriptPaths = new ScriptDefinitions().getScriptPaths();
let scriptLoader = new ScriptLoader(rootURI);
await scriptLoader.loadScripts(scriptPaths);
const directoryManager = new DirectoryManager();
const outputManager = new OutputManager(directoryManager);
const zotmoovDebugger = new ZotMoovDebugger('ZotMoov', outputManager);
const sanitizer = new Sanitizer();
const zotmoovWildcard = new ZotMoovWildcard(sanitizer, ZotMoovCWParser);
zotmoov = new ZotMoov(id, version, rootURI, zotmoovWildcard, sanitizer, zotmoovDebugger);
zotmoovBindings = new ZotMoovBindings(zotmoov);
zotmoovMenus = new ZotMoovMenus(zotmoov, zotmoovBindings, ZotMoovCMUParser);
Zotero.PreferencePanes.register(
{
id: 'zotmoov_basic',
pluginID: '[email protected]',
src: rootURI + 'preferences/prefs.xhtml',
scripts: [rootURI + 'preferences/zotmoov-prefs.js'],
helpURL: 'https://github.com/wileyyugioh/zotmoov/blob/master/docs/SETTINGS_INFO.md'
});
Zotero.PreferencePanes.register(
{
id: 'zotmoov_advanced',
pluginID: '[email protected]',
parent: 'zotmoov_basic',
src: rootURI + 'preferences/adv_prefs.xhtml',
scripts: [rootURI + 'preferences/zotmoov-adv-prefs.js'],
helpURL: 'https://github.com/wileyyugioh/zotmoov/blob/master/docs/SETTINGS_INFO.md#advanced-options'
});
Zotero.PreferencePanes.register(
{
id: 'zotmoov_keyboard',
pluginID: '[email protected]',
parent: 'zotmoov_basic',
src: rootURI + 'preferences/keyboard_shortcuts.xhtml',
scripts: [rootURI + 'preferences/zotmoov-keyboard-prefs.js']
});
zotmoovMenus.init();
zotmoovMenus.loadAll();
// Need to expose our addon to rest of Zotero
Zotero.ZotMoov = zotmoov;
Zotero.ZotMoov.Menus = zotmoovMenus;
Zotero.ZotMoov.Menus.Custom = { 'Parser': ZotMoovCMUParser, 'Commands': ZotMoovCMUParser.Commands };
Zotero.ZotMoov.Commands = { 'Parser': ZotMoovCWParser, 'Commands': ZotMoovCWParser.Commands };
let aomStartup = Cc['@mozilla.org/addons/addon-manager-startup;1'].getService(Ci.amIAddonManagerStartup);
let manifestURI = Services.io.newURI(rootURI + 'manifest.json');
chromeHandle = aomStartup.registerChrome(manifestURI, [
['content', 'zotmoov', 'chrome/content/']
]);
}
function onMainWindowLoad({ window }) {
zotmoovMenus.load(window);
}
function onMainWindowUnload({ window }) {
zotmoovMenus.unload(window);
}
function shutdown()
{
log('ZotMoov: Shutting down');
chromeHandle.destruct();
chromeHandle = null;
zotmoovMenus.destroy();
zotmoovBindings.destroy();
zotmoov = null;
zotmoovMenus = null;
zotmoovBindings = null;
Zotero.ZotMoov = null;
}
function uninstall()
{
log('ZotMoov: Uninstalled');
}