<commit_before>/*global define,KBError,KBFatal,window*/
/*jslint white: true,browser: true*/

/**
 * This is the entry point for the Narrative's front-end. It initializes
 * the login session, fires up the data and function widgets, and creates
 * the kbaseNarrativeWorkspace wrapper around the Jupyter notebook that
 * does fun things like manage widgets and cells and kernel events to talk to them.
 *
 * To set global variables, use: Jupyter.narrative.<name> = value
 */

define(
    [
        'jquery',
        'bootstrap',
        'bluebird',
        'handlebars',
        'narrativeConfig',
        'kbaseNarrativeSidePanel',
        'kbaseNarrativeOutputCell',
        'kbaseNarrativeWorkspace',
        'kbaseNarrativeMethodCell',
        'kbaseAccordion',
        'kbaseLogin',
        'kbaseNarrativeSharePanel',
        'kbase-client-api',
        'kbaseNarrativePrestart',
        'ipythonCellMenu',
        'base/js/namespace',
        'base/js/events',
        'base/js/keyboard',
        'notebook/js/notebook',
        'util/display',
        'util/bootstrapDialog',
        'text!kbase/templates/update_dialog_body.html',
        'narrativeLogin',
        'common/ui',
        'common/html',
        'narrativeTour'
    ], function (
    $,
    Bootstrap,
    Promise,
    Handlebars,
    Config,
    KBaseNarrativeSidePanel,
    KBaseNarrativeOutputCell,
    KBaseNarrativeWorkspace,
    KBaseNarrativeMethodCell,
    KBaseAccordion,
    KBaseLogin,
    KBaseNarrativeSharePanel,
    KBaseClient,
    KBaseNarrativePrestart,
    KBaseCellToolbar,
    Jupyter,
    Events,
    Keyboard,
    Notebook,
    DisplayUtil,
    BootstrapDialog,
    UpdateDialogBodyTemplate,
    NarrativeLogin,
    UI,
    html,
    Tour
    ) {
    'use strict';

    KBaseNarrativePrestart.loadDomEvents();
    KBaseNarrativePrestart.loadGlobals();

    /**
     * @constructor
     * The base, namespaced Narrative object. This is mainly used at start-up time, and
     * gets injected into the Jupyter namespace.
     *
     * Most of its methods below - init, registerEvents, initAboutDialog, initUpgradeDialog,
     * checkVersion, updateVersion - are set up at startup time.
     * This is all done by an injection into static/notebook/js/main.js where the
     * Narrative object is set up, and Narrative.init is run.
     *
     * But, this also has a noteable 'Save' method, that implements another Narrative-
     * specific piece of functionality. See Narrative.prototype.saveNarrative below.
     */
    var Narrative = function () {
        // Maximum narrative size that can be stored in the workspace.
        // This is set by nginx on the backend - this variable is just for
        // communication on error.
        this.maxNarrativeSize = "10 MB";

        // the controller is an instance of kbaseNarrativeWorkspace, which
        // controls widget management and KBase method execution
        this.narrController = null;

        this.sidePanel = null;

        // If true, this narrative is read only
        this.readonly = false;

        // The user's current session token.
        this.authToken = null;

        // How often to check for a new version in ms (not currently used)
        this.versionCheckTime = 6000 * 60 * 1000;

        this.versionHtml = 'KBase Narrative';

        // The currently selected Jupyter cell.
        this.selectedCell = null;

        // The version of the Narrative UI (semantic version)
        this.currentVersion = Config.get('version');

        //
        this.dataViewers = null;

        // User Profile KBase client.
        this.profileClient = new UserProfile(Config.url('user_profile'));

        // Used for mapping from user id -> user name without having to it
        // up again every time.
        this.cachedUserIds = {};
        this.workspaceRef = null;
        this.workspaceId = null;
        this.sidePanel = null;

        // The set of currently instantiated KBase Widgets.
        // key = cell id, value = Widget object itself.
        this.kbaseWidgets = {};

        Jupyter.keyboard_manager.disable();
        return this;
    };

    /**
     * A wrapper around the Jupyter.notebook.kernel.execute() function.
     * If any KBase widget needs to make a kernel call, it should go through here.
     * ...when it's done.
     */
    Narrative.prototype.executeKernelCall = function () {
        console.info('no-op for now');
    };

    // Wrappers for the Jupyter/Jupyter function so we only maintain it in one place.
    Narrative.prototype.disableKeyboardManager = function () {
        // Jupyter.keyboard_manager.disable();

        var killTheseShortcuts = ['a', 'b', 'm', 'f', 'y', 'r',
                                  '1', '2', '3', '4', '5', '6',
                                  'k', 'j', 'b', 'x', 'c', 'v',
                                  'z', 'd,d', 's', 'l', 'o', 'h',
                                  'i', '0,0', 'q'];

        for (var i=0; i<killTheseShortcuts.length; i++) {
            var shortcut = killTheseShortcuts[i];
            try {<commit_msg>Squash a few more command-mode commands.<commit_after>/*global define,KBError,KBFatal,window*/
/*jslint white: true,browser: true*/

/**
 * This is the entry point for the Narrative's front-end. It initializes
 * the login session, fires up the data and function widgets, and creates
 * the kbaseNarrativeWorkspace wrapper around the Jupyter notebook that
 * does fun things like manage widgets and cells and kernel events to talk to them.
 *
 * To set global variables, use: Jupyter.narrative.<name> = value
 */

define(
    [
        'jquery',
        'bootstrap',
        'bluebird',
        'handlebars',
        'narrativeConfig',
        'kbaseNarrativeSidePanel',
        'kbaseNarrativeOutputCell',
        'kbaseNarrativeWorkspace',
        'kbaseNarrativeMethodCell',
        'kbaseAccordion',
        'kbaseLogin',
        'kbaseNarrativeSharePanel',
        'kbase-client-api',
        'kbaseNarrativePrestart',
        'ipythonCellMenu',
        'base/js/namespace',
        'base/js/events',
        'base/js/keyboard',
        'notebook/js/notebook',
        'util/display',
        'util/bootstrapDialog',
        'text!kbase/templates/update_dialog_body.html',
        'narrativeLogin',
        'common/ui',
        'common/html',
        'narrativeTour'
    ], function (
    $,
    Bootstrap,
    Promise,
    Handlebars,
    Config,
    KBaseNarrativeSidePanel,
    KBaseNarrativeOutputCell,
    KBaseNarrativeWorkspace,
    KBaseNarrativeMethodCell,
    KBaseAccordion,
    KBaseLogin,
    KBaseNarrativeSharePanel,
    KBaseClient,
    KBaseNarrativePrestart,
    KBaseCellToolbar,
    Jupyter,
    Events,
    Keyboard,
    Notebook,
    DisplayUtil,
    BootstrapDialog,
    UpdateDialogBodyTemplate,
    NarrativeLogin,
    UI,
    html,
    Tour
    ) {
    'use strict';

    KBaseNarrativePrestart.loadDomEvents();
    KBaseNarrativePrestart.loadGlobals();

    /**
     * @constructor
     * The base, namespaced Narrative object. This is mainly used at start-up time, and
     * gets injected into the Jupyter namespace.
     *
     * Most of its methods below - init, registerEvents, initAboutDialog, initUpgradeDialog,
     * checkVersion, updateVersion - are set up at startup time.
     * This is all done by an injection into static/notebook/js/main.js where the
     * Narrative object is set up, and Narrative.init is run.
     *
     * But, this also has a noteable 'Save' method, that implements another Narrative-
     * specific piece of functionality. See Narrative.prototype.saveNarrative below.
     */
    var Narrative = function () {
        // Maximum narrative size that can be stored in the workspace.
        // This is set by nginx on the backend - this variable is just for
        // communication on error.
        this.maxNarrativeSize = "10 MB";

        // the controller is an instance of kbaseNarrativeWorkspace, which
        // controls widget management and KBase method execution
        this.narrController = null;

        this.sidePanel = null;

        // If true, this narrative is read only
        this.readonly = false;

        // The user's current session token.
        this.authToken = null;

        // How often to check for a new version in ms (not currently used)
        this.versionCheckTime = 6000 * 60 * 1000;

        this.versionHtml = 'KBase Narrative';

        // The currently selected Jupyter cell.
        this.selectedCell = null;

        // The version of the Narrative UI (semantic version)
        this.currentVersion = Config.get('version');

        //
        this.dataViewers = null;

        // User Profile KBase client.
        this.profileClient = new UserProfile(Config.url('user_profile'));

        // Used for mapping from user id -> user name without having to it
        // up again every time.
        this.cachedUserIds = {};
        this.workspaceRef = null;
        this.workspaceId = null;
        this.sidePanel = null;

        // The set of currently instantiated KBase Widgets.
        // key = cell id, value = Widget object itself.
        this.kbaseWidgets = {};

        Jupyter.keyboard_manager.disable();
        return this;
    };

    /**
     * A wrapper around the Jupyter.notebook.kernel.execute() function.
     * If any KBase widget needs to make a kernel call, it should go through here.
     * ...when it's done.
     */
    Narrative.prototype.executeKernelCall = function () {
        console.info('no-op for now');
    };

    // Wrappers for the Jupyter/Jupyter function so we only maintain it in one place.
    Narrative.prototype.disableKeyboardManager = function () {
        var killTheseShortcuts = ['a', 'b', 'm', 'f', 'y', 'r',
                                  '1', '2', '3', '4', '5', '6',
                                  'k', 'j', 'b', 'x', 'c', 'v',
                                  'z', 'd,d', 's', 'l', 'o', 'h',
                                  'i', '0,0', 'q', 'shift-j', 'shift-k',
                                  'shift-h', 'shift-m', 'shift-o', 'shift-v'];

        for (var i=0; i<killTheseShortcuts.length; i++) {
            var shortcut = killTheseShortcuts[i];
            try {
{'fraction_non_alphanumeric': 0.10267201722619164, 'fraction_numerical': 0.004110795732602525, 'mean_word_length': 2.1605320136096506, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5318761', 'n_tokens_mistral': 3038, 'n_tokens_neox': 2966, 'n_words': 868}