This file is indexed.

/usr/lib/python2.7/dist-packages/notebook/static/tree/js/newnotebook.js is in python-notebook 5.2.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

define([
    'jquery',
    'base/js/namespace',
    'base/js/utils',
    'base/js/i18n',
    'base/js/dialog',
], function ($, IPython, utils, i18n, dialog) {
    "use strict";
    
    var NewNotebookWidget = function (selector, options) {
        this.selector = selector;
        this.base_url = options.base_url;
        this.notebook_path = options.notebook_path;
        this.contents = options.contents;
        this.events = options.events;
        this.default_kernel = null;
        this.kernelspecs = {};
        if (this.selector !== undefined) {
            this.element = $(selector);
            this.request_kernelspecs();
        }
        this.bind_events();
    };
    
    NewNotebookWidget.prototype.bind_events = function () {
        var that = this;
        this.element.find('#new_notebook').click(function () {
            that.new_notebook();
        });
    };
    
    NewNotebookWidget.prototype.request_kernelspecs = function () {
        /** request and then load kernel specs */
        var url = utils.url_path_join(this.base_url, 'api/kernelspecs');
        utils.promising_ajax(url).then($.proxy(this._load_kernelspecs, this));
    };
    
    NewNotebookWidget.prototype._load_kernelspecs = function (data) {
        /** load kernelspec list */
        var that = this;
        this.kernelspecs = data.kernelspecs;
        var menu = this.element.find("#notebook-kernels");
        var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
            var da = data.kernelspecs[a].spec.display_name;
            var db = data.kernelspecs[b].spec.display_name;
            if (da === db) {
                return 0;
            } else if (da > db) {
                return 1;
            } else {
                return -1;
            }
        });

        // Create the kernel list in reverse order because
        // the .after insertion causes each item to be added
        // to the top of the list.
        for (var i = keys.length - 1; i >= 0; i--) {
            var ks = this.kernelspecs[keys[i]];
            var li = $("<li>")
                .attr("id", "kernel-" +ks.name)
                .data('kernelspec', ks).append(
                    $('<a>')
                        .attr('href', '#')
                        .click($.proxy(this.new_notebook, this, ks.name))
                        .text(ks.spec.display_name)
                        .attr('title', i18n.sprintf(i18n._('Create a new notebook with %s'), ks.spec.display_name))
                );
            menu.after(li);
        }
        this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs);
    };
    
    NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
        /** create and open a new notebook */
        var that = this;
        kernel_name = kernel_name || this.default_kernel;
        var w = window.open(undefined, IPython._target);
        this.contents.new_untitled(that.notebook_path, {type: "notebook"}).then(
            function (data) {
                var url = utils.url_path_join(
                    that.base_url, 'notebooks',
                    utils.encode_uri_components(data.path)
                );
                if (kernel_name) {
                    url += "?kernel_name=" + kernel_name;
                }
                w.location = url;
        }).catch(function (e) {
            w.close();
            // This statement is used simply so that message extraction
            // will pick up the strings.  The actual setting of the text
            // for the button is in dialog.js.
            var button_labels = [ i18n._("OK")];
            dialog.modal({
                title : i18n._('Creating Notebook Failed'),
                body : $('<div/>')
                    .text(i18n._("An error occurred while creating a new notebook."))
                    .append($('<div/>')
                        .addClass('alert alert-danger')
                        .text(e.message || e)),
                buttons: {
                    OK: {'class' : 'btn-primary'}
                }
            });
        });
    };
    
    return {'NewNotebookWidget': NewNotebookWidget};
});