How to use the base/js/utils.get_body_data 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 jupyter / notebook / notebook / static-src / terminal / js / main.js View on Github external
var configmod = require('services/config');
    var terminado = require('terminal/js/terminado');
    requirejs(['custom/custom'], function() {});

    page = new page.Page();

    var common_config = new configmod.ConfigSection('common', 
                                    {base_url: utils.get_body_data('baseUrl')});
    common_config.load();

    // Test size: 25x80
    var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
        // 1.02 here arrived at by trial and error to make the spacing look right
    var termColWidth =  function() { return 1.02 * $("#dummy-screen-rows")[0].offsetWidth / 80;};

    var base_url = utils.get_body_data('baseUrl');
    var ws_path = utils.get_body_data('wsPath');
    var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host
                                    + base_url + ws_path;

    var header = $("#header")[0]
    function calculate_size() {
        var height = $(window).height() - header.offsetHeight;
        var width = $('#terminado-container').width();
        var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1));
        var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1));
        console.log("resize to :", rows , 'rows by ', cols, 'columns');
        return {rows: rows, cols: cols};
    }

    page.show_header();
github jupyterhub / jupyter-server-proxy / nbrsessionproxy / static / tree.js View on Github external
define(function(require) {
    var $ = require('jquery');
    var Jupyter = require('base/js/namespace');
    var utils = require('base/js/utils');

    var ajax = utils.ajax || $.ajax;

    var base_url = utils.get_body_data('baseUrl');

    function open_rsession(w) {
        /* the url we POST to to start rsession */
        var rsp_url = base_url + 'rsessionproxy';

        /* prepare ajax */
        var settings = {
            type: "POST",
            data: {},
            dataType: "json",
            success: function(data) {
                if (!("url" in data)) {
                    /* FIXME: visit some template */
                    return;
                }
                w.location = data['url'];
github jupyter / notebook / notebook / static-src / tree / js / notebooklist.js View on Github external
*          notebook_path: string
         *          contents: Contents instance
         */
        var that = this;
        this.session_list = options.session_list;
        // allow code re-use by just changing element_name in kernellist.js
        this.element_name = options.element_name || 'notebook';
        this.selector = selector;
        if (this.selector !== undefined) {
            this.element = $(selector);
            this.style();
            this.bind_events();
        }
        this.notebooks_list = [];
        this.sessions = {};
        this.base_url = options.base_url || utils.get_body_data("baseUrl");
        this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
        this.contents = options.contents;
        if (this.session_list && this.session_list.events) {
            this.session_list.events.on('sessions_loaded.Dashboard', 
                function(e, d) { that.sessions_loaded(d); });
        }
        this.selected = [];
    };
github ryanlovett / nbnovnc / nbnovnc / static / tree.js View on Github external
define(function(require) {
    var $ = require('jquery');
    var Jupyter = require('base/js/namespace');
    var utils = require('base/js/utils');

    var base_url = utils.get_body_data('baseUrl');


    function load() {
        if (!Jupyter.notebook_list) return;

        /* locate the right-side dropdown menu of apps and notebooks */
        var menu = $('.tree-buttons').find('.dropdown-menu');

        /* create our list item */
        var vnc_item = $('<li>')
            .attr('role', 'presentation')
            .addClass('new-vnc');

        /* create our list item's link */
        var vnc_link = $('<a>')
            .attr('role', 'menuitem')</a></li>
github jupyter / notebook / notebook / static-src / notebook / js / main.js View on Github external
requirejs(['contents', 'custom/custom'], function(contents_service) {

    var common_options = {
        ws_url : utils.get_body_data("wsUrl"),
        base_url : utils.get_body_data("baseUrl"),
        notebook_path : utils.get_body_data("notebookPath"),
        notebook_name : utils.get_body_data('notebookName')
    };

    var config_section = new configmod.ConfigSection('notebook', common_options);
    config_section.load();
    var common_config = new configmod.ConfigSection('common', common_options);
    common_config.load();
    page = new page.Page();
    pager = new pager.Pager('div#pager', {
        events: events});
    var acts = new actions.init();
    var keyboard_manager = new keyboardmanager.KeyboardManager({
        pager: pager, 
        events: events, 
        actions: acts });
    var save_widget = new savewidget.SaveWidget('span#save_widget', {
        events: events,
github jupyter / notebook / notebook / static-src / notebook / js / menubar.js View on Github external
*
         * Parameters:
         *  selector: string
         *  options: dictionary
         *      Dictionary of keyword arguments.
         *          notebook: Notebook instance
         *          contents: ContentManager instance
         *          events: $(Events) instance
         *          save_widget: SaveWidget instance
         *          quick_help: QuickHelp instance
         *          base_url : string
         *          notebook_path : string
         *          notebook_name : string
         */
        options = options || {};
        this.base_url = options.base_url || utils.get_body_data("baseUrl");
        this.selector = selector;
        this.notebook = options.notebook;
        this.contents = options.contents;
        this.events = options.events;
        this.save_widget = options.save_widget;
        this.quick_help = options.quick_help;

        try {
            this.tour = new tour.NotebookTour(this.notebook, this.events);
        } catch (e) {
            this.tour = undefined;
            console.log("Failed to instantiate Notebook Tour", e);
        }

        if (this.selector !== undefined) {
            this.element = $(selector);
github jupyter / notebook / notebook / static-src / tree / js / terminallist.js View on Github external
var TerminalList = function (selector, options) {
        /**
         * Constructor
         *
         * Parameters:
         *  selector: string
         *  options: dictionary
         *      Dictionary of keyword arguments.
         *          base_url: string
         */
        this.base_url = options.base_url || utils.get_body_data("baseUrl");
        this.element_name = options.element_name || 'running';
        this.selector = selector;
        this.terminals = [];
        if (this.selector !== undefined) {
            this.element = $(selector);
            this.style();
            this.bind_events();
            this.load_terminals();
        }
    };
github jupyter / notebook / notebook / static-src / tree / js / main.js View on Github external
var utils = require('base/js/utils');
    var config = require('services/config');
    var notebooklist = require('tree/js/notebooklist');
    var sesssionlist = require('tree/js/sessionlist');
    var kernellist = require('tree/js/kernellist');
    var terminallist = require('tree/js/terminallist');
    var newnotebook = require('tree/js/newnotebook');
    var loginwidget = require('auth/js/loginwidget');
    requirejs(['custom/custom'], function() {});
    
    IPython.NotebookList = notebooklist.NotebookList;

    page = new page.Page();

    var common_options = {
        base_url: utils.get_body_data("baseUrl"),
        notebook_path: utils.get_body_data("notebookPath"),
    };
    var cfg = new config.ConfigSection('tree', common_options);
    cfg.load();
    common_options.config = cfg;
    var common_config = new config.ConfigSection('common', common_options);
    common_config.load();

    var session_list = new sesssionlist.SesssionList($.extend({
        events: events},
        common_options));
    var contents = new contents_service.Contents({
        base_url: common_options.base_url,
        common_config: common_config
    });
    var notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
github jupyter / notebook / notebook / static-src / auth / js / loginwidget.js View on Github external
var LoginWidget = function (selector, options) {
        options = options || {};
        this.base_url = options.base_url || utils.get_body_data("baseUrl");
        this.selector = selector;
        if (this.selector !== undefined) {
            this.element = $(selector);
            this.bind_events();
        }
    };
github jupyter / notebook / notebook / static-src / tree / js / main.js View on Github external
var config = require('services/config');
    var notebooklist = require('tree/js/notebooklist');
    var sesssionlist = require('tree/js/sessionlist');
    var kernellist = require('tree/js/kernellist');
    var terminallist = require('tree/js/terminallist');
    var newnotebook = require('tree/js/newnotebook');
    var loginwidget = require('auth/js/loginwidget');
    requirejs(['custom/custom'], function() {});
    
    IPython.NotebookList = notebooklist.NotebookList;

    page = new page.Page();

    var common_options = {
        base_url: utils.get_body_data("baseUrl"),
        notebook_path: utils.get_body_data("notebookPath"),
    };
    var cfg = new config.ConfigSection('tree', common_options);
    cfg.load();
    common_options.config = cfg;
    var common_config = new config.ConfigSection('common', common_options);
    common_config.load();

    var session_list = new sesssionlist.SesssionList($.extend({
        events: events},
        common_options));
    var contents = new contents_service.Contents({
        base_url: common_options.base_url,
        common_config: common_config
    });
    var notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
        contents: contents,