Skip to content

Instantly share code, notes, and snippets.

@bollwyvl
Created October 2, 2015 21:26
Show Gist options
  • Save bollwyvl/1259dd3bb7cef8988e92 to your computer and use it in GitHub Desktop.
Save bollwyvl/1259dd3bb7cef8988e92 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loading [JS9](http://js9.si.edu/)\n",
"- based on [the basics](http://js9.si.edu/js9/js9basics.html)\n",
"- in response to [this thread](https://mail.scipy.org/pipermail/ipython-dev/2015-October/016879.html)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div class=\"JS9Menubar\"></div>\n",
"<div class=\"JS9\" id=\"JS9\"></div>\n",
"<style>\n",
" @import(\"//js9.si.edu/js9/js9support.css\");\n",
" @import(\"//js9.si.edu/js9/js9.css\");\n",
"</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%html\n",
"<div class=\"JS9Menubar\"></div>\n",
"<div class=\"JS9\" id=\"JS9\"></div>\n",
"<style>\n",
" @import(\"//js9.si.edu/js9/js9support.css\");\n",
" @import(\"//js9.si.edu/js9/js9.css\");\n",
"</style>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With the DOM nodes created, we can try to load js9... `requirejs` is how the notebook loads content, and we're going to hotlink the example assets (which you shouldn't do for reals)."
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<script>\n",
" requirejs({\n",
" paths: {\n",
" js9: \"//js9.si.edu/js9/js9\",\n",
" js9support: \"//js9.si.edu/js9/js9support.min\",\n",
" js9plugins: \"//js9.si.edu/js9/js9plugins\"\n",
" },\n",
" shim: {\n",
" js9plugins: {\n",
" deps: [\"js9\"]\n",
" },\n",
" js9: {\n",
" deps: [\"js9support\"],\n",
" exports: \"JS9\"\n",
" }\n",
" }\n",
"\n",
" }, [\n",
" \"js9\",\n",
" // drop these silently... we just need them for the call graph\n",
" \"js9plugins\"\n",
" ], function(JS9){\n",
" // the timeout is needed because there are some assumptions about load order and timing\n",
" setTimeout(function(){\n",
" JS9.Load(\"http://js9.si.edu/js9/png/casa.png\");\n",
" }, 1000);\n",
" })\n",
"</script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%html\n",
"<script>\n",
" requirejs({\n",
" paths: {\n",
" js9: \"//js9.si.edu/js9/js9\",\n",
" js9support: \"//js9.si.edu/js9/js9support.min\",\n",
" js9plugins: \"//js9.si.edu/js9/js9plugins\"\n",
" },\n",
" shim: {\n",
" js9plugins: {\n",
" deps: [\"js9\"]\n",
" },\n",
" js9: {\n",
" deps: [\"js9support\"],\n",
" exports: \"JS9\"\n",
" }\n",
" }\n",
"\n",
" }, [\n",
" \"js9\",\n",
" // drop these silently... we just need them for the call graph\n",
" \"js9plugins\"\n",
" ], function(JS9){\n",
" // the timeout is needed because there are some assumptions about load order and timing\n",
" setTimeout(function(){\n",
" JS9.Load(\"http://js9.si.edu/js9/png/casa.png\");\n",
" }, 1000);\n",
" })\n",
"</script>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to the `alert()` about not being able to load data, the errors I am seeing:\n",
"- `JS9 prefs file not available: js9Prefs.json`\n",
"- inability to connect to `socket.io`, which is unsurprising"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment