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
Next revisionBoth sides next revision
dev:client_coding:javascript_api [2019/01/22 04:23] – [The Zotero Object] dstillmandev:client_coding:javascript_api [2019/01/22 04:27] dstillman
Line 22: Line 22:
  
 (Before Zotero 5.0.61 is released, you'll need to install the [[:dev_builds|Zotero beta]] to use this feature.) (Before Zotero 5.0.61 is released, you'll need to install the [[:dev_builds|Zotero beta]] to use this feature.)
-===== Window Scope vs. Non-Window Scope ====+ 
 +===== Zotero Code Architecture ===== 
 + 
 +==== Window Scope vs. Non-Window Scope ===
  
 Zotero code exists in either window scope and non-window scope. Zotero code exists in either window scope and non-window scope.
Line 44: Line 47:
 </code>  </code> 
 (The Zotero pane will always be available unless the main window is closed, as is possible on macOS.) (The Zotero pane will always be available unless the main window is closed, as is possible on macOS.)
-===== Notification System ===== 
  
-Zotero has a built-in notification system that allows other privileged code to be notified when a change is made via the data layer---for example, when an item is added to the library. Within Zotero itself, this is used mostly to update the UI when items change, but external extensions can use the system to perform additional operations when specific events occur---say, to sync item metadata with a web-based tool.+==== Notification System ==== 
 + 
 +Zotero has a built-in notification system that allows other privileged code to be notified when a change is made via the data layer — for example, when an item is added to the library. Within Zotero itself, this is used mostly to update the UI when items change, but extensions can use the system to perform additional operations when specific events occur — say, to sync item metadata with a web-based API.
  
 Available events: Available events:
Line 63: Line 67:
  
 //The Zotero JavaScript API is under-documented, and at present requires a lot of looking around in the source code.  The most useful parts of the source code are in chrome/content/zotero/xpcom and xpcom/data, and the chrome/content/zotero (particularly zoteroPane.js and fileInterface.js).// //The Zotero JavaScript API is under-documented, and at present requires a lot of looking around in the source code.  The most useful parts of the source code are in chrome/content/zotero/xpcom and xpcom/data, and the chrome/content/zotero (particularly zoteroPane.js and fileInterface.js).//
- 
-Once you have access to the core Zotero object, you can use the objects and methods provided by the Zotero JavaScript API. 
- 
-Zotero uses a combination of instantiatable objects (e.g. ''Zotero.Item = function(){...}'') and singletons (''Zotero.Items = **new** function(){...}''). The most important example of the former is ''Zotero.Item'', which represents a single item in the database. Singletons are used mostly to group related static methods into a single namespace. 
  
 ==== Adding items and modifying data ==== ==== Adding items and modifying data ====
  
-A typical operation might include a call to ''Items.get()'' to retrieve an ''Item'' instance, calls to ''Item'' methods on the retrieved object to modify data, and finally a ''save()'' to save the modified data to the database.+A typical operation might include a call to ''Zotero.Items.get()'' to retrieve ''Zotero.Item'' instance, calls to ''Zotero.Item'' methods on the retrieved object to modify data, and finally a ''save()'' (within a transaction) or ''saveTx()'' (outside a transaction) to save the modified data to the database.
  
 <code javascript> <code javascript>
dev/client_coding/javascript_api.txt · Last modified: 2022/07/02 18:22 by dstillman