1// Copyright (c) Adam Fekete 2// Distributed under the terms of the Modified BSD License. 3 4// This file contains the javascript that is run when the notebook is loaded. 5// It contains some requirejs configuration and the `load_ipython_extension` 6// which is required for any notebook extension. 7 8// Some static assets may be required by the custom widget javascript. The base 9// url for the notebook is not known at build time and is therefore computed 10// dynamically. 11 12const base_url = document.querySelector('body')!.getAttribute('data-base-url'); 13(window as any).j2sPath = base_url + "nbextensions/jupyter_jsmol/jsmol/j2s"; 14 15// Configure requirejs 16if ((window as any).require) { 17 (window as any).require.config({ 18 map: { 19 "*": { 20 "jupyter-jsmol": "nbextensions/jupyter_jsmol/index", 21 }, 22 }, 23 }); 24} 25 26// Export the required load_ipython_extention 27export function load_ipython_extension() { 28 // Workaround for importing the JSmol 29 const script = document.createElement('script'); 30 script.src = base_url + 'nbextensions/jupyter_jsmol/jsmol/JSmol.min.nojq.js'; 31 script.async = false; 32 (document as any).querySelector('head').appendChild(script); 33} 34