{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "## Customizing the Notebook interface with JavaScript" }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": "%%javascript\n\n// This function allows us to add buttons\n// to the Notebook toolbar.\nIPython.toolbar.add_buttons_group([\n{\n\n // The button's label.\n 'label': 'Renumber all code cells',\n\n // The button's icon.\n // See a list of Font-Awesome icons here:\n // http://fortawesome.github.io/Font-Awesome/icons/\n 'icon': 'fa-list-ol',\n\n // The callback function called when the button is pressed.\n 'callback': function () {\n\n // We retrieve the lists of all cells.\n var cells = IPython.notebook.get_cells();\n\n // We only keep the code cells.\n cells = cells.filter(function(c)\n {\n return c instanceof IPython.CodeCell;\n })\n\n // We set the input prompt of all code cells.\n for (var i = 0; i < cells.length; i++) {\n cells[i].set_input_prompt(i + 1);\n }\n }\n}]);" } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 0 }