{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## IPython Notebook with in-browser Javascript Kernel" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With [this kernel](https://github.com/minrk/jskernel),\n", "kernel.js is patched to execute javascript in the browser rather than remotely via websockets.\n", "\n", "This is more of a toy / proof of concept than anything." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "2" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "hi\n" ] } ], "source": [ "console.log(\"hi\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "25\n", "100\n" ] } ], "source": [ "double = function (x) {\n", " return x * x;\n", "}\n", "console.log(double(5));\n", "console.log(double(10));\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "foo = 5" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "http://localhost:8888/notebooks/Javascript.ipynb#\n" ] } ], "source": [ "console.log(location)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "105" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "foo + double(10)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "ename": "ReferenceError", "evalue": "bar is not defined", "output_type": "error", "traceback": [ "ReferenceError: bar is not defined\n at eval (eval at (http://localhost:8888/kernelspecs/jskernel/kernel.js:53:22), :1:1)\n at execute (http://localhost:8888/kernelspecs/jskernel/kernel.js:53:17)\n at CodeCell.execute (http://localhost:8888/static/notebook/js/codecell.js:444:40)\n at Notebook.execute_cell_and_select_below (http://localhost:8888/static/notebook/js/notebook.js:1652:14)\n at _action.run-select-next.handler (http://localhost:8888/static/notebook/js/actions.js:45:30)\n at Object.final_actions.(anonymous function).handler (http://localhost:8888/static/notebook/js/actions.js:397:21)\n at ActionHandler.call (http://localhost:8888/static/notebook/js/actions.js:494:36)\n at ShortcutManager.call_handler (http://localhost:8888/static/base/js/keyboard.js:427:33)\n at KeyboardManager.handle_keydown (http://localhost:8888/static/notebook/js/keyboardmanager.js:169:43)\n at HTMLDocument. (http://localhost:8888/static/notebook/js/keyboardmanager.js:133:25)" ] } ], "source": [ "bar" ] } ], "metadata": { "kernelspec": { "display_name": "Javascript", "name": "jskernel" }, "language_info": { "file_extension": ".js", "mimetype": "text/javascript", "name": "javascript" } }, "nbformat": 4, "nbformat_minor": 0 }