-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbootstrap.js
More file actions
58 lines (48 loc) · 1.62 KB
/
bootstrap.js
File metadata and controls
58 lines (48 loc) · 1.62 KB
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
let ZoteroCitationCounts, itemObserver;
async function startup({ id, version, rootURI }) {
Services.scriptloader.loadSubScript(rootURI + "zoterocitationcounts.js");
ZoteroCitationCounts.init({ id, version, rootURI });
ZoteroCitationCounts.addToAllWindows();
Zotero.PreferencePanes.register({
pluginID: id,
label: await ZoteroCitationCounts.l10n.formatValue(
"citationcounts-preference-pane-label"
),
image: ZoteroCitationCounts.icon("edit-list-order", false),
src: "preferences.xhtml",
scripts: ["preferences.js"],
});
await Zotero.ItemTreeManager.registerColumns({
dataKey: "citationcounts",
label: await ZoteroCitationCounts.l10n.formatValue(
"citationcounts-column-title"
),
pluginID: id,
dataProvider: (item) => ZoteroCitationCounts.getCitationCount(item),
});
itemObserver = Zotero.Notifier.registerObserver(
{
notify: function (event, type, ids, extraData) {
if (event == "add") {
const pref = ZoteroCitationCounts.getPref("autoretrieve");
if (pref === "none") return;
const api = ZoteroCitationCounts.APIs.find((api) => api.key === pref);
if (!api) return;
ZoteroCitationCounts.updateItems(Zotero.Items.get(ids), api);
}
},
},
["item"]
);
}
function onMainWindowLoad({ window }) {
ZoteroCitationCounts.addToWindow(window);
}
function onMainWindowUnload({ window }) {
ZoteroCitationCounts.removeFromWindow(window);
}
function shutdown() {
ZoteroCitationCounts.removeFromAllWindows();
Zotero.Notifier.unregisterObserver(itemObserver);
ZoteroCitationCounts = undefined;
}