Javascript API ============== Introduction ************ The ADia can also run flawlessly inside the browsers's web worker environment because we pass all tests with both ``CPython`` and `Brython `_ environments before each commit. This page aims to demonstrate how to use the ``adia`` inside your javascript project. For the first you have to grab the file: "adia-\ |version|\ .tar.gz" from the https://pylover.github.io/adia/about page or generate it using: .. code-block:: bash cd path/to/adia make jsdist The ``build/jsdist/adia-.tar.gz`` is what you need now. Archive contains: .. code-block:: adia.bundle.js adia.js adia.stdlib.js adia_worker.py adia/ __init__.py canvas.py constants.py container.py diagram.py exceptions.py interpreter.py lazyattr.py mutablestring.py renderer.py renderingplans.py sequence.py tokenizer.py token.py Extract the ``adia-.tar.gz`` file into Javascript project's static directory, where you can fetch it's content by URL. then modify your HTML file as the below: .. code-block:: html
The ``ADia`` class will listen for changes of source element and inform you by provided callbacks. Let's make and visit the pure javascript echo system of the ``ADia`` inside the ``webclinic`` directory: .. code-block:: bash cd path/to/adia make clean webclinic_serve Now browse the http://localhost:8000/index.html. adia-live Source Code ********************* The `ADia Live Demo `_ source code which exists at https://github.com/pylover/adia-live is a good example of how to use the Javascript API.