Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:client_coding:javascript_api [2020/10/17 21:10]– [API Methods]dstillman dev:client_coding:javascript_api [2024/08/21 03:55](current)188BET靠谱吗– [Zotero JavaScript API]dstillman
Line 3: Line 3:
188BET靠谱吗Whereas Zotero's [[dev:188BET靠谱吗web_api|Web API]] allows read and write access to online Zotero libraries, it is also possible to access the local Zotero client through the local JavaScript API.(It is also possible to [[dev/client_coding/direct_sqlite_database_access|directly access the local SQLite database]], but that approach is much more fragile.) 188BET靠谱吗Whereas Zotero's [[dev:188BET靠谱吗web_api|Web API]] allows read and write access to online Zotero libraries, it is also possible to access the local Zotero client through the local JavaScript API.(It is also possible to [[dev/client_coding/direct_sqlite_database_access|directly access the local SQLite database]], but that approach is much more fragile.)
- Note thatthe (mostly user-contributed)documentation of the JavaScript API is not comprehensive.If you use the JavaScript API in ways beyond what's described here, please consider expanding this wiki page. + Note thatthisdocumentation of the JavaScript API is not comprehensive.If you use the JavaScript API in ways beyond what's described here, please consider expanding this wiki page188金宝慱亚洲F1or suggesting changes in the forums.
- +
188BET靠谱吗===== Running Ad Hoc JavaScript in Zotero ===== 188BET靠谱吗===== Running Ad Hoc JavaScript in Zotero =====
Line 36: Line 34:
Non-window scope applies to lower-level code that doesn't have access to the DOM.This includes the core ''188BET靠谱吗Zotero''object, which contains all other non-window code, including the data layer used for retrieving and modifying library data.188BET靠谱吗In Zotero, non-window code is contained within the ''xpcom''subdirectory. Non-window scope applies to lower-level code that doesn't have access to the DOM.This includes the core ''188BET靠谱吗Zotero''object, which contains all other non-window code, including the data layer used for retrieving and modifying library data.188BET靠谱吗In Zotero, non-window code is contained within the ''xpcom''subdirectory.
- Overlays and windows188BET靠谱吗in Zotero can import the core ''188BET靠谱吗Zotero''object via the include.js script.188BET靠谱吗Zotero methods can then be called from anywhere within the window's scope simply by calling, for example, ''188BET靠谱吗var item = Zotero.Items.get(1);''. + Windows188BET靠谱吗in Zotero can import the core ''188BET靠谱吗Zotero''object via the include.js script.188BET靠谱吗Zotero methods can then be called from anywhere within the window's scope simply by calling, for example, ''188BET靠谱吗var item = Zotero.Items.get(1);''.
- 188BET靠谱吗To access Zotero functionality from your own extension, you will need access to the core ''188BET靠谱吗Zotero''object.If your extension operates within the mainbrowser overlay, you already have access to the ''188BET靠谱吗Zotero''object and don't need to take further steps.188BET靠谱吗Otherwise, you can import the Zotero object into other windows by including the script %%chrome://188BET靠谱吗zotero/content/include.js%% within an HTML or XUL file: + 188BET靠谱吗To access Zotero functionality from your own extension, you will need access to the core ''188BET靠谱吗Zotero''object.If your extension operates within the main188BET靠谱吗Zotero window, you already have access to the ''188BET靠谱吗Zotero''object and don't need to take further steps.188BET靠谱吗Otherwise, you can import the Zotero object into other windows by including the script %%chrome://188BET靠谱吗zotero/content/include.js%% within an HTML or XUL file:
Line 216: Line 214:
s.addCondition('collection','is',collectionKey);// e.g., 'C72FDAP2' s.addCondition('collection','is',collectionKey);// e.g., 'C72FDAP2'
s.addCondition('savedSearch','is',savedSearchKey); s.addCondition('savedSearch','is',savedSearchKey);
+ code>
+
+ === Search by creator ===
+
+
+ var name = 'smith';
+ s.addCondition('creator','contains',name);
code> code>
Line 236: Line 241:
results: results:
- varresults= await s.search(); code> + varitemIDs= await s.search(); code>
This returns the item ids in the search as an array.188BET靠谱吗The next thing to do is to get the Zotero items for the array of IDs: This returns the item ids in the search as an array.188BET靠谱吗The next thing to do is to get the Zotero items for the array of IDs:
- 188BET靠谱吗var items = await Zotero.Items.getAsync(results); code> + 188BET靠谱吗var items = await Zotero.Items.getAsync(itemIDs); code>
==== Managing citations and bibliographies ==== ==== Managing citations and bibliographies ====
Line 340: Line 345:
return fulltext; return fulltext;
code> code>
+
+ ==== File I/O ====
+
+ === Getting the contents of a file ===
+
+
+ var path = '/Users/user/Desktop/data.json';
+ 188BET靠谱吗var data = await Zotero.File.getContentsAsync(path);
+ code>
+
+ === Saving data to a file ===
+
+
+ var path = '/Users/user/Desktop/file.txt';
+ var data = "This is some text.";
+ 188BET靠谱吗await Zotero.File.putContentsAsync(path,data);
+ code>
+
==== To Do === ==== To Do ===
dev/client_coding/javascript_api.1602983449.txt.gz· Last modified: 2020/10/17 21:10 by dstillman
Baidu
map