<commit_before>function getCookie(name) {
    var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
    return r ? r[1] : undefined;
}

define(function(require) {
    var $ = require('jquery');
    var ui = require('jquery-ui');
    var IPython = require('base/js/namespace');
    var base_url = IPython.notebook_list.base_url;
    var utils = require('base/js/utils');
    var _ = require('underscore');
    var moduleavail = null;
    var modulelist = null;

    var lmod_tab_html = $([
        '<div id="lmod" class="tab-pane">',
        '  <div id="lmod_toolbar" class="row list_toolbar">',
        '    <div class="col-sm-8 no-padding">',
        '      <label id="running_list_info">Software modules</label>',
        '      <input id="modules" size="100">',
        '    </div>',
        '  </div>',
        '  <div class="panel-group" id="lmod_list" >',
        '     Place holder',
        '  </div>',
        '</div>'
    ].join('\n'));

    function refresh_view() {
        $.when($.get(base_url + 'lmod/avail/', {}, null, "json"),
        $.get(base_url + 'lmod/list/', {}, null, "json"))
        .done(function(avail, list) {
            moduleavail = new Set(avail[0]);
            modulelist = list[0];
            modulelist.map(function(item){ moduleavail.delete(item) });
            moduleavail = Array.from(moduleavail);
            update_list(modulelist);
        });
    }

    function module_change(modules, action) {
        $.ajax({
            url: base_url + 'lmod/' + action,
            type: "POST",
            dataType: "json",
            data: {"modules" : modules, "_xsrf" : getCookie("_xsrf")},
            success: refresh_view,
            traditional:true
        });
    }

    function update_list(data) {
        $("#lmod_list").html("");
        var list = $("#lmod_list").append('<ul>');
        data.map(function(item) {
            var li = $('<li>').text(item+ " ");
            li.append($('<a>').text('[ X ]')
                              .click(function(e) { module_change(item, 'unload') }));
            list.append(li);
        });
    }
 
    function split( val ) {
      return val.split( /,\s*/ );
    }
    function extractLast( term ) {
      return split( term ).pop();
    }
 
    function load() {
        if (!IPython.notebook_list) return;<commit_msg>Enhnace search bar and loaded module ui<commit_after>function getCookie(name) {
    var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
    return r ? r[1] : undefined;
}

define(function(require) {
    var $ = require('jquery');
    var ui = require('jquery-ui');
    var IPython = require('base/js/namespace');
    var base_url = IPython.notebook_list.base_url;
    var utils = require('base/js/utils');
    var _ = require('underscore');
    var moduleavail = null;
    var modulelist = null;

    var lmod_tab_html = $([
        '<div id="lmod" class="tab-pane">',
        '  <div id="lmod_toolbar" class="row list_toolbar">',
        '    <div class="col-sm-18 no-padding">',
        '      <input id="modules" class="form-control input-lg" placeholder="Search available modules..." style="width:100%">',
        '    </div>',
        '  </div>',
        '  <div class="list_container" id="lmod_list">',
        '     <div class="row list_header">Loaded module list</div>',
        '  </div>',
        '</div>'
    ].join('\n'));

    function refresh_view() {
        $.when($.get(base_url + 'lmod/avail/', {}, null, "json"),
        $.get(base_url + 'lmod/list/', {}, null, "json"))
        .done(function(avail, list) {
            moduleavail = new Set(avail[0]);
            modulelist = list[0];
            modulelist.map(function(item){ moduleavail.delete(item) });
            modulelist.sort();
            moduleavail = Array.from(moduleavail);
            update_list(modulelist);
        });
    }

    function module_change(modules, action) {
        $.ajax({
            url: base_url + 'lmod/' + action,
            type: "POST",
            dataType: "json",
            data: {"modules" : modules, "_xsrf" : getCookie("_xsrf")},
            success: refresh_view,
            traditional: true
        });
    }

    function update_list(data) {
        var list = $("#lmod_list");
        list.html("");
        list.append($('<div>').addClass('row').addClass('list_header')
                              .append($('<div>').addClass("col-md-12").text("Loaded modules")));
        data.map(function(item) {
            var li = $('<div>').addClass("list_item").addClass("row");
            var col = $('<div>').addClass("col-md-12");
            col.append($('<input>').attr('type', 'checkbox').attr('title', 'Click here to mark for unload'));
            col.append($('<a>').addClass('item_link')
                               .attr('href', "#lmod_list")
                               .text(item)
                               .click(function(e) { module_change(item, 'unload') }));
            li.append(col);
            list.append(li);
        });
    }
 
    function split( val ) {
      return val.split( /,\s*/ );
    }
    function extractLast( term ) {
      return split( term ).pop();
    }
 
    function load() {
        if (!IPython.notebook_list) return;
{'fraction_non_alphanumeric': 0.18574431492451748, 'fraction_numerical': 0.003630804509841391, 'mean_word_length': 2.0412550842533412, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '727833', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1624, 'n_words': 305}