How to use the base/js/namespace.notebook function in base

To help you get started, we’ve selected a few base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github minrk / ipython_extensions / nbextensions / inorder.js View on Github external
function monkeypatch() {
    // patch Cell.execute and OutputArea.append_error for missing functionality

    // find the first code cell
    console.log("patching execute");

    // create and destroy code cell at end
    var nb = Jupyter.notebook;
    var ncells = nb.ncells();
    var cell = nb.insert_cell_at_index("code", ncells);

    var CodeCell = Object.getPrototypeOf(cell);
    var OutputArea = Object.getPrototypeOf(cell.output_area);
    Jupyter.notebook.delete_cells([ncells]);

    if (CodeCell.original_execute) {
      // already patched
      return;
    }
    CodeCell.original_execute = CodeCell.execute;
    CodeCell.execute = my_execute;

    // patch OutputArea.append_error because there is no event for errors
    OutputArea.original_append_error = OutputArea.append_error;
github krishnan-r / sparkmonitor / extension / js / SparkMonitor.js View on Github external
SparkMonitor.prototype.startComm = function () {
	if (this.comm) {
		this.comm.close()
	}
	console.log('SparkMonitor: Starting Comm with kernel.')
	var that = this;
	if (Jupyter.notebook.kernel) {
		this.comm = Jupyter.notebook.kernel.comm_manager.new_comm('SparkMonitor',
			{ 'msgtype': 'openfromfrontend' });
		// Register a message handler
		this.comm.on_msg($.proxy(that.on_comm_msg, that));
		this.comm.on_close($.proxy(that.on_comm_close, that));
	}
	else {
		console.log("SparkMonitor: No communication established, kernel null");
	}
}
github neptune-ml / neptune-notebooks / packages / neptune-extension / src / nbextension / utils / notebook.ts View on Github external
async saveWorkingCopyAndGetContent() {
    Jupyter.notebook.save_checkpoint();

    // The function below returns the (unsaved) working copy.
    return Jupyter.notebook.toJSON();
  }
github Anaconda-Platform / nb_conda / nb_conda / static / main.js View on Github external
function show_conda_view($view) {
        var d = dialog.modal({
            title: 'Conda Packages',
            body: $view,
            open: function() {
                $('#searchbox').focus();
            },
            keyboard_manager: Jupyter.notebook.keyboard_manager
        });
        d.on('hide.bs.modal', function() {
            // detach the conda view so it isn't destroyed with the dialog box
            $view.detach();
        });
        d.find('.modal-dialog').css({width: "80vw"});
    }
github minrk / ipython_extensions / nbextensions / inorder.js View on Github external
function handle_cell_creation(evt, data) {
    // the cell below the created one should be invalidated
    var idx = data.index;
    var cell = data.cell;
    var nb = Jupyter.notebook;
    var cells = Jupyter.notebook.get_cells();
    var ncells = nb.ncells();

    if (idx + 1 == ncells) return;

    if (cells[idx + 1].element.hasClass("inorder-executed")) {
      cell.element.addClass("inorder-executed");
      invalidate_below(idx);
    }
  }
github CermakM / jupyter-require / js / src / extension.js View on Github external
    function set_notebook_metadata(config) { Jupyter.notebook.metadata.require = config; }
github uber / manifold / bindings / jupyter / js / src / widgets / index.js View on Github external
() => {
        const segments = this.model.get('segments');
        if (segments) {
          const msgId = Jupyter.notebook.kernel.last_msg_id;
          const cell = Jupyter.notebook.get_msg_cell(msgId);
          const cellIndex = Jupyter.notebook.find_cell_index(cell);
          const newCell = Jupyter.notebook.insert_cell_below('code', cellIndex);
          newCell.set_text(`segments = ${segments}`);
          newCell.execute();
        }
      },
      this
github CermakM / jupyter-require / jupyter_require / static / loader.js View on Github external
function get_display_cells() {
        let cells = Jupyter.notebook.get_cells();

        return cells.filter(
            ( c ) => {
                return c.cell_type === 'code' &&
                    c.output_area.outputs &&
                    c.output_area.outputs.some( d => d.output_type === 'display_data' );
            } );
    }
github Anaconda-Platform / nbbrowserpdf / src / es6 / mode / notebook.es6 View on Github external
metadata(update){
    let md = Jupyter.notebook.metadata;
    if(update){
      md.nbpresent = {
        slides: this.slides.serialize()
      };
    }else{
      return md.nbpresent || {
        slides: {}
      }
    }
  }
github uber / manifold / bindings / jupyter / js / src / index.js View on Github external
window.addEventListener('error', event => {
  const msgId = Jupyter.notebook.kernel.last_msg_id;
  const cell = Jupyter.notebook.get_msg_cell(msgId);
  if (cell) {
    const {error} = event;
    cell.output_area.append_output({
      output_type: 'error',
      ename: error.name,
      evalue: error.message,
      traceback: ['Javascript Error', error.stack],
    });
    cell.output_area.element
      .find('.output_subarea.output_error')
      .css({'background-color': '#ff9999'});
  }
});