.. _notebookcustomextensionrst: =========================== Custom Javascript Extension =========================== .. only:: html **Links:** :download:`notebook `, :downloadlink:`html `, :download:`PDF `, :download:`python `, :downloadlink:`slides `, :githublink:`GitHub|_doc/notebooks/notebook_custom_extension.ipynb|*` This notebook tests a couple of scenarios on how extension notebooks with javascript. **not complete** .. code:: ipython3 from jyquickhelper import add_notebook_menu add_notebook_menu() .. contents:: :local: Custom extension ---------------- .. code:: ipython3 import os from notebook.nbextensions import install_nbextension from jyquickhelper.js.custom import __file__ as loc path = os.path.dirname(loc) dest = install_nbextension(path, user=True, destination="jyquickhelper_custom") dest.split('AppData')[-1] .. parsed-literal:: '\\Roaming\\jupyter\\nbextensions\\jyquickhelper_custom' .. code:: ipython3 os.listdir(dest) .. parsed-literal:: ['jyquickhelper_custom.css', 'main.js', '__init__.py', '__pycache__'] .. code:: javascript %%javascript Jupyter.utils.load_extensions('jyquickhelper_custom') .. parsed-literal:: .. code:: ipython3 %%html

should be red

.. raw:: html

should be red

This does not really works. Local extension --------------- .. code:: ipython3 from jyquickhelper.js import load_extension load_extension('renderjson') .. raw:: html

Loads extension 'renderjson'.

.. code:: ipython3 %%HTML .. raw:: html .. code:: ipython3 %%html
.. raw:: html
.. code:: javascript %%javascript document.getElementById("testrjs").innerHTML = "

Wait..

" .. parsed-literal:: .. code:: javascript %%javascript document.getElementById("testrjs").appendChild( renderjson({ hello: [1,2,3,4], there: { a:1, b:2, c:["hello", null] } }) ); .. parsed-literal::