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 00:34] – [Zotero JavaScript API] dstillmandev:client_coding:javascript_api [2019/01/22 00:42] – [Helpful Resources] dstillman
Line 11: Line 11:
 Note that the (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 that the (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.
  
-===== Helpful Resources ===== 
  
-For this section, you’ll likely find the following helpful:+===== Running Ad Hoc JavaScript in Zotero =====
  
-  * A basic understanding of how to create a Firefox extension +Zotero 5.0.61 and later include an option to run arbitrary privileged JavaScript:
-    * [[http://developer.mozilla.org|The Mozilla Developer Center]] (including [[http://developer.mozilla.org/en/docs/Building_an_Extension|Building an Extension]]) +
-    * [[https://developer.mozilla.org/en/Setting_up_extension_development_environment|Setting up an extension development environment]] +
-  * A decent grasp of object-oriented JavaScript +
-    * [[http://javascript.crockford.com/private.html|public, private and privileged methods and members]]; object literal notation; closures +
-    * [[http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference|MDC Core JavaScript 1.Reference]] (also note [[http://developer.mozilla.org/en/docs/New_in_JavaScript_1.6|New in JavaScript 1.6]] and [[http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7|New in JavaScript 1.7]]) +
- +
-===== An Easy Debugging Environment ===== +
- +
-Various Firefox extensions create servers within Firefox that expose the internal Firefox environment, including Zotero internals. These can be used as shells for easy experimentation. These include+
- +
-  * [[https://addons.mozilla.org/en-US/firefox/addon/execute-js/|ExecuteJS]] +
-  * [[http://davidkellogg.com/wiki/Main_Page|Plain Old Webserver]] (POW) - [[http://github.com/singingfish/zotero-browser|Zotero Browser]] is an example of getting POW to interact with Zotero to create rich annotated bibliographies. +
-  * [[http://wiki.github.com/bard/mozrepl/|MozRepl]] - interactive shell, available by telnetting to localhost on port 4242 (by default). Linux and Mac OS X users can use the built in telnet client. Windows users should use [[http://www.chiark.greenend.org.uk/~sgtatham/putty/|Putty]]. There is also a Firefox plugin to provide MozRepl access [[http://ubik.cc/2009/09/mozrepl-in-a-panel.html|directly inside Firefox]]. +
-    * **Potential MozRepl Problems**: Longer scripts can time out non-deterministically. A solution to this is to either send the code to the terminal application in smaller sized chunks, or to keep pasting the code in until it works.  Use an external library (like CPAN's MozRepl module) for finer grained control.   Syntax errors can cause silent failure. Avoid this by avoiding excessively long blocks of procedural code - factor everything into smaller functions wherever possible. +
- +
-Perl programmers should be aware of the [[http://search.cpan.org/perldoc?MozRepl|MozRepl]] CPAN module, and the closely related [[http://search.cpan.org/perldoc?MozRepl::RemoteObject|MozRepl::RemoteObject]] which allows you to access JavaScript objects from inside Perl programs.+
  
 +  - In the Advanced pane of the Zotero preferences, select Config Editor, and then set ''devtools.chrome.enabled'' to ''true'' and restart Zotero.
 +  - In the Tools menu, select Run JavaScript. Open the Error Console, which also appears in Tools, will also be helpful.
 +  - In the window that opens, enter JavaScript in the Code textbox and click Run or press Cmd-R/Ctrl-R. The return value of the last line will appear in the textbox on the right.
  
 +(Before Zotero 5.0.61 is released, you'll need to install the [[:dev_builds|Zotero beta]] to use this feature.)
 ===== The Zotero Object ==== ===== The Zotero Object ====
  
dev/client_coding/javascript_api.txt · Last modified: 2022/07/02 18:22 by dstillman