<commit_before>import $ from 'jquery';
import _ from 'underscore';
import Backbone from 'backbone';

import events from 'girder/events';
import eventStream from 'girder/utilities/EventStream';
import LayoutFooterView from 'girder/views/layout/FooterView';
import LayoutGlobalNavView from 'girder/views/layout/GlobalNavView';
import LayoutHeaderView from 'girder/views/layout/HeaderView';
import LoginView from 'girder/views/layout/LoginView';
import ProgressListView from 'girder/views/layout/ProgressListView';
import RegisterView from 'girder/views/layout/RegisterView';
import ResetPasswordView from 'girder/views/layout/ResetPasswordView';
import router from 'girder/router';
import UserModel from 'girder/models/UserModel';
import View from 'girder/views/View';
import { fetchCurrentUser, setCurrentUser, getCurrentUser } from 'girder/auth';
import { Layout } from 'girder/constants';
import { splitRoute } from 'girder/misc';

import AlertTemplate from 'girder/templates/layout/alert.pug';
import LayoutTemplate from 'girder/templates/layout/layout.pug';

import 'girder/routes';

import 'girder/stylesheets/layout/global.styl';
import 'girder/stylesheets/layout/layout.styl';

import 'girder/utilities/jquery/girderModal';

import 'bootstrap/dist/css/bootstrap.css';

var App = View.extend({
    /**
     * @param {object} [settings]
     * @param {bool} [settings.start=true] Run start after initialization
     */
    initialize: function (settings) {
        this._started = false;
        settings = settings || {};
        if (settings.start === undefined || settings.start) {
            this.start();
        }
    },

    /**
     * Start the application with optional components.
     * @param {object} [settings]
     * @param {bool} [settings.fetch=true] Fetch the current user modal
     * @param {bool} [settings.render=true] Render the layout after starting
     * @param {bool} [settings.history=true] Start backbone's history api
     * @returns {$.Deferred} A promise-like object that resolves when the app is ready
     */
    start: function (settings) {
        // start is a noop if the app is already running
        var promise = new $.Deferred().resolve(null).promise();
        if (this._started) {
            return promise;
        }
        this._started = true;

        // set defaults
        settings = _.defaults(settings || {}, {
            fetch: true,
            render: true,
            history: true
        });

        // define a function to be run after fetching the user model
        var afterFetch = _.bind(function (user) {
            // TODO: this below is the old, pre-webpack code. eventStream is now a singleton
            // imported from 'girder/utilities/EventStream'. This mean it is not "re-newed" if
            // start is called another time (is it, ever)
            // girder.eventStream = new girder.EventStream({
            //     timeout: girder.sseTimeout || null
            // });

            this._createLayout();

            if (user) {
                setCurrentUser(new UserModel(user));
                eventStream.open();
            }

            if (settings.render) {
                this.render();
            }

            if (settings.history) {
                Backbone.history.stop();
                Backbone.history.start({
                    pushState: false
                });
            }
        }, this);

        // If fetching the user from the server then we return the jqxhr object
        // from the request, otherwise just call the callback.
        if (settings.fetch) {
            promise = fetchCurrentUser()
                .done(afterFetch);
        } else {
            afterFetch(null);
        }

        this.bindGirderEvents();<commit_msg>Fix error in console during startup<commit_after>import $ from 'jquery';
import _ from 'underscore';
import Backbone from 'backbone';

import events from 'girder/events';
import eventStream from 'girder/utilities/EventStream';
import LayoutFooterView from 'girder/views/layout/FooterView';
import LayoutGlobalNavView from 'girder/views/layout/GlobalNavView';
import LayoutHeaderView from 'girder/views/layout/HeaderView';
import LoginView from 'girder/views/layout/LoginView';
import ProgressListView from 'girder/views/layout/ProgressListView';
import RegisterView from 'girder/views/layout/RegisterView';
import ResetPasswordView from 'girder/views/layout/ResetPasswordView';
import router from 'girder/router';
import UserModel from 'girder/models/UserModel';
import View from 'girder/views/View';
import { fetchCurrentUser, setCurrentUser, getCurrentUser } from 'girder/auth';
import { Layout } from 'girder/constants';
import { splitRoute } from 'girder/misc';

import AlertTemplate from 'girder/templates/layout/alert.pug';
import LayoutTemplate from 'girder/templates/layout/layout.pug';

import 'girder/routes';

import 'girder/stylesheets/layout/global.styl';
import 'girder/stylesheets/layout/layout.styl';

import 'girder/utilities/jquery/girderModal';

import 'bootstrap/dist/css/bootstrap.css';

var App = View.extend({
    /**
     * @param {object} [settings]
     * @param {bool} [settings.start=true] Run start after initialization
     */
    initialize: function (settings) {
        this._started = false;
        settings = settings || {};
        if (settings.start === undefined || settings.start) {
            this.start();
        }
    },

    /**
     * Start the application with optional components.
     * @param {object} [settings]
     * @param {bool} [settings.fetch=true] Fetch the current user modal
     * @param {bool} [settings.render=true] Render the layout after starting
     * @param {bool} [settings.history=true] Start backbone's history api
     * @returns {$.Deferred} A promise-like object that resolves when the app is ready
     */
    start: function (settings) {
        // start is a noop if the app is already running
        var promise = new $.Deferred().resolve(null).promise();
        if (this._started) {
            return promise;
        }

        // set defaults
        settings = _.defaults(settings || {}, {
            fetch: true,
            render: true,
            history: true
        });

        // define a function to be run after fetching the user model
        var afterFetch = _.bind(function (user) {
            // TODO: this below is the old, pre-webpack code. eventStream is now a singleton
            // imported from 'girder/utilities/EventStream'. This mean it is not "re-newed" if
            // start is called another time (is it, ever)
            // girder.eventStream = new girder.EventStream({
            //     timeout: girder.sseTimeout || null
            // });

            this._createLayout();

            if (user) {
                setCurrentUser(new UserModel(user));
                eventStream.open();
            }

            this._started = true;

            if (settings.render) {
                this.render();
            }

            if (settings.history) {
                Backbone.history.stop();
                Backbone.history.start({
                    pushState: false
                });
            }
        }, this);

        // If fetching the user from the server then we return the jqxhr object
        // from the request, otherwise just call the callback.
        if (settings.fetch) {
            promise = fetchCurrentUser()
                .done(afterFetch);
        } else {
            afterFetch(null);
        }

        this.bindGirderEvents();
{'fraction_non_alphanumeric': 0.10824401217414317, 'fraction_numerical': 0.0, 'mean_word_length': 2.384684281236005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5974103', 'n_tokens_mistral': 2083, 'n_tokens_neox': 2029, 'n_words': 582}