<commit_before>/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2015, Jupyter Development Team.
|
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
'use strict';

import {
  NotebookModel, NotebookWidget,
  NotebookContent, populateNotebookModel, getNotebookContent
} from 'jupyter-js-notebook';

import {
  isMarkdownCellModel
} from 'jupyter-js-notebook/lib/cells'

import {
  ContentsManager, IContentsModel, startNewSession
} from 'jupyter-js-services';

import {
  getBaseUrl
} from 'jupyter-js-utils';

import {
  IKeyBinding, KeymapManager, keystrokeForKeydownEvent
} from 'phosphor-keymap';

import {
  BoxPanel
} from 'phosphor-boxpanel';

import 'jupyter-js-notebook/lib/index.css';
import 'jupyter-js-notebook/lib/theme.css';


let SERVER_URL = getBaseUrl();
let NOTEBOOK = 'test.ipynb';


function bindings(nbModel: NotebookModel) {
  let bindings: IKeyBinding[] = [{
    selector: '.jp-Notebook-cell',
    sequence: ["Shift Enter"],
    handler: () => {
      nbModel.runSelectedCell();
      return true;
    }
  }];
  return bindings;
}


function main(): void {
  // Initialize the keymap manager with the bindings.
  var keymap = new KeymapManager();

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  });
  // TODO: check out static example from the history
  // and make that a separate example.

  let contents = new ContentsManager(SERVER_URL);
  contents.get(NOTEBOOK, {}).then(data => {
    let nbModel = new NotebookModel();
    nbModel.readOnly = true;
    populateNotebookModel(nbModel, data.content as NotebookContent);
    let nbWidget = new NotebookWidget(nbModel);
    nbWidget.title.text = NOTEBOOK;

    keymap.add(bindings(nbModel));

    let box = new BoxPanel();
    box.id = 'main';
    box.attach(document.body);
    box.addChild(nbWidget);
<commit_msg>Make example writeable<commit_after>/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2015, Jupyter Development Team.
|
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
'use strict';

import {
  NotebookModel, NotebookWidget,
  NotebookContent, populateNotebookModel, getNotebookContent
} from 'jupyter-js-notebook';

import {
  isMarkdownCellModel
} from 'jupyter-js-notebook/lib/cells'

import {
  ContentsManager, IContentsModel, startNewSession
} from 'jupyter-js-services';

import {
  getBaseUrl
} from 'jupyter-js-utils';

import {
  IKeyBinding, KeymapManager, keystrokeForKeydownEvent
} from 'phosphor-keymap';

import {
  BoxPanel
} from 'phosphor-boxpanel';

import 'jupyter-js-notebook/lib/index.css';
import 'jupyter-js-notebook/lib/theme.css';


let SERVER_URL = getBaseUrl();
let NOTEBOOK = 'test.ipynb';


function bindings(nbModel: NotebookModel) {
  let bindings: IKeyBinding[] = [{
    selector: '.jp-Notebook-cell',
    sequence: ["Shift Enter"],
    handler: () => {
      nbModel.runSelectedCell();
      return true;
    }
  }];
  return bindings;
}


function main(): void {
  // Initialize the keymap manager with the bindings.
  var keymap = new KeymapManager();

  // Setup the keydown listener for the document.
  document.addEventListener('keydown', event => {
    keymap.processKeydownEvent(event);
  });
  // TODO: check out static example from the history
  // and make that a separate example.

  let contents = new ContentsManager(SERVER_URL);
  contents.get(NOTEBOOK, {}).then(data => {
    let nbModel = new NotebookModel();
    populateNotebookModel(nbModel, data.content as NotebookContent);
    let nbWidget = new NotebookWidget(nbModel);
    nbWidget.title.text = NOTEBOOK;

    keymap.add(bindings(nbModel));

    let box = new BoxPanel();
    box.id = 'main';
    box.attach(document.body);
    box.addChild(nbWidget);

{'fraction_non_alphanumeric': 0.1886182902584493, 'fraction_numerical': 0.003976143141153081, 'mean_word_length': 2.8369876072449953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2316733', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1217, 'n_words': 292}