#!/usr/bin/env python # -*- coding: utf-8 -*- # # Custom Javascript Extension # # This notebook tests a couple of scenarios on how extension notebooks with javascript. **not complete** # In[1]: from jyquickhelper import add_notebook_menu add_notebook_menu() # ## Custom extension # In[2]: 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] # In[3]: os.listdir(dest) # In[4]: get_ipython().run_cell_magic('javascript', '', "Jupyter.utils.load_extensions('jyquickhelper_custom')\n") # In[5]: get_ipython().run_cell_magic('html', '', '\n
should be red
\n') # This does not really works. # ## Local extension # In[6]: from jyquickhelper.js import load_extension load_extension('renderjson') # In[7]: get_ipython().run_cell_magic('HTML', '', '\n') # In[8]: get_ipython().run_cell_magic('html', '', '\n') # In[9]: get_ipython().run_cell_magic('javascript', '', 'document.getElementById("testrjs").innerHTML = "Wait..
"\n') # In[10]: get_ipython().run_cell_magic('javascript', '', 'document.getElementById("testrjs").appendChild(\n renderjson({ hello: [1,2,3,4], there: { a:1, b:2, c:["hello", null] } })\n);\n') # In[11]: # In[12]: