Appendix E: JavaScript code snippets
====================================

CARTA provides an advanced feature for task automation - "Snippets". To enable this feature, go to "**File**" -> "**Preferences**" -> "**Global**". Once the "**Enable code snippets**" toggle is checked, a "Snippets" menu will appear in the menu bar. 

To learn more about the code snippets, please refer to the `tutorial <https://cartavis.org/carta-frontend/docs/category/code-snippet-tutorial>`_ and the `API <https://cartavis.org/carta-frontend/api>`_ documentation. In principle, most of the actions you can do with the graphical user interface can be programmed into a code snippet.

With the snippet editor, you can write code, save it, and execute it. The saved code snippets will appear in the "Snippets" menu for future usage. 


.. raw:: html

   <a href="_static/carta_fn_snippets.png" target="_blank">
        <img src="_static/carta_fn_snippets.png" 
            style="width:100%;height:auto;">
   </a>

.. tip::
   You may enable the browser's console to explore the syntax and objects interactively.

   .. raw:: html

      <a href="_static/carta_fn_snippets2.png" target="_blank">
        <img src="_static/carta_fn_snippets2.png" 
            style="width:90%;height:auto;">
      </a>
      