<commit_before>var adapters = null;
var owners = null;
var connects = null;

function connect_dlg()
{
    var dlg = $('<div>')
    .attr('title', "Connect to Database");

    var connect_common = $('<table>')
    .attr({border: 0, width: '100%', height: '85%', cellpadding: 0, cellspacing: 2})
    .appendTo(dlg);
    
    dlg.append($('<hr>'));

    var connect_options = $('<div>')
    .css({width: '100%', height: '100%'})
    .appendTo(dlg);
    
    var adapter_list = $('<select class="ui-widget-content ui-corner-all">');
    var owners_list = $('<select class="ui-widget-content ui-corner-all">');
    var connection_list = $('<select class="ui-widget-content ui-corner-all">');

    connect_common.append(
        $('<tr>').append(
            $('<td>').attr({align: 'right', valign: 'center'})
                .append("DB Type"),
            $('<td>').attr({valign: 'bottom'})
                .append(adapter_list)
        ),
        $('<tr>').append(
            $('<td>').attr({align: 'right', valign: 'center'})
                .append("Ownership"),
            $('<td>').attr({valign: 'bottom'})
                .append(owners_list)
        ),
        $('<tr>').append(
            $('<td>').attr({align: 'right', valign: 'center'})
                .append("Connection Name"),
            $('<td>').attr({valign: 'bottom'})
                .append(connection_list)
        )
    );


    dlg = dlg.appendTo(document.body)
    .dialog({
        autoOpen: false,
        height: 'auto',
        width: 'auto',
        resizable: false,
        modal: true,
        position: { my: "left top", at: "left+50 top+20", of: "#main-body" },
        close: function() {
            $(this).dialog('destroy');
            $(this).remove();
        },
        open: function(evt, ui) {
            $(this).dialog("widget").appendTo("#main-body");
        },
        buttons: {
            'Login / Save': function() {
                login_save($(this), connection_list, adapter_list, owners_list);
            },
            'Delete': function() {
                var conn = connection_list.find("option:selected");
                var connData = conn.data('connect');
                var dlg = $(this);
                confirm_jq(
                        {title: "Confirm delete connection",
                         content: connData.name+' ('+connData.adapter+')'},
                         function() {
                             ajaxCall(null,'del_con', {del_con: {conid: connData.id}}, 'del_con', function(data) {
                                 if(data.hasOwnProperty('error')) {
                                     alert_jq(JSON.stringify(data.error));
                                 } else {
                                     conn.remove();
                                     if(connection_list.find("option:selected").length == 0) {
                                         dlg.dialog("close");
                                         loginAjax(null);
                                     } else {
                                         connection_list.parent().find('input').val(
                                             connection_list.find("option:selected").data('connect').name);
                                         connection_list.change();
                                     }
                                 }
                             });
                         });
            },
            'Clear' : function() {
                connect_options.find('input').val('');
                connect_options.find('textarea').val('');
                $("input:radio[name=method]:checked").val("local");
                console.log($("input:radio[name=method]:checked").val());
            }
        }
    })
    .dialog('open');
    
    adapter_list.change(function() {<commit_msg>Changed definition of buttons to array<commit_after>var adapters = null;
var owners = null;
var connects = null;

function connect_dlg()
{
    var dlg = $('<div>')
    .attr('title', "Connect to Database");

    var connect_common = $('<table>')
    .attr({border: 0, width: '100%', height: '85%', cellpadding: 0, cellspacing: 2})
    .appendTo(dlg);
    
    dlg.append($('<hr>'));

    var connect_options = $('<div>')
    .css({width: '100%', height: '100%'})
    .appendTo(dlg);
    
    var adapter_list = $('<select class="ui-widget-content ui-corner-all">');
    var owners_list = $('<select class="ui-widget-content ui-corner-all">');
    var connection_list = $('<select class="ui-widget-content ui-corner-all">');

    connect_common.append(
        $('<tr>').append(
            $('<td>').attr({align: 'right', valign: 'center'})
                .append("DB Type"),
            $('<td>').attr({valign: 'bottom'})
                .append(adapter_list)
        ),
        $('<tr>').append(
            $('<td>').attr({align: 'right', valign: 'center'})
                .append("Ownership"),
            $('<td>').attr({valign: 'bottom'})
                .append(owners_list)
        ),
        $('<tr>').append(
            $('<td>').attr({align: 'right', valign: 'center'})
                .append("Connection Name"),
            $('<td>').attr({valign: 'bottom'})
                .append(connection_list)
        )
    );


    dlg = dlg.appendTo(document.body)
    .dialog({
        autoOpen: false,
        height: 'auto',
        width: 'auto',
        resizable: false,
        modal: true,
        position: { my: "left top", at: "left+50 top+20", of: "#main-body" },
        close: function() {
            $(this).dialog('destroy');
            $(this).remove();
        },
        open: function(evt, ui) {
            $(this).dialog("widget").appendTo("#main-body");
        },
        buttons: [
            {
                text:'Login / Save',
                click: function() {
                    login_save($(this), connection_list, adapter_list, owners_list);
                },
                icons: {
                    primary: "ui-icon-heart"
                },
                showText: false
            },
            {   text:'Delete',
                click:function() {
                    var conn = connection_list.find("option:selected");
                    var connData = conn.data('connect');
                    var dlg = $(this);
                    confirm_jq(
                        {title: "Confirm delete connection",
                            content: connData.name+' ('+connData.adapter+')'},
                        function() {
                            ajaxCall(null,'del_con', {del_con: {conid: connData.id}}, 'del_con', function(data) {
                                if(data.hasOwnProperty('error')) {
                                    alert_jq(JSON.stringify(data.error));
                                } else {
                                    conn.remove();
                                    if(connection_list.find("option:selected").length == 0) {
                                        dlg.dialog("close");
                                        loginAjax(null);
                                    } else {
                                        connection_list.parent().find('input').val(
                                            connection_list.find("option:selected").data('connect').name);
                                        connection_list.change();
                                    }
                                }
                            });
                        });
                }
            },
            {   text:'Clear',
                click: function() {
                    connect_options.find('input').val('');
                    connect_options.find('textarea').val('');
                    $("input:radio[name=method]:checked").val("local");
                    console.log($("input:radio[name=method]:checked").val());
                }
            }
        ]

        /*{
            'Login / Save': function() {
                login_save($(this), connection_list, adapter_list, owners_list);
            },
            'Delete': function() {
                var conn = connection_list.find("option:selected");
                var connData = conn.data('connect');
                var dlg = $(this);
                confirm_jq(
                        {title: "Confirm delete connection",
                         content: connData.name+' ('+connData.adapter+')'},
                         function() {
                             ajaxCall(null,'del_con', {del_con: {conid: connData.id}}, 'del_con', function(data) {
                                 if(data.hasOwnProperty('error')) {
                                     alert_jq(JSON.stringify(data.error));
                                 } else {
                                     conn.remove();
                                     if(connection_list.find("option:selected").length == 0) {
                                         dlg.dialog("close");
                                         loginAjax(null);
                                     } else {
                                         connection_list.parent().find('input').val(
                                             connection_list.find("option:selected").data('connect').name);
                                         connection_list.change();
                                     }
                                 }
                             });
                         });
            },
            'Clear' : function() {
                connect_options.find('input').val('');
                connect_options.find('textarea').val('');
                $("input:radio[name=method]:checked").val("local");
                console.log($("input:radio[name=method]:checked").val());
            }
        }*/
    })
    .dialog('open');
    
    adapter_list.change(function() {
{'fraction_non_alphanumeric': 0.15645569620253164, 'fraction_numerical': 0.003949367088607595, 'mean_word_length': 1.2348947725729804, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '752810', 'n_tokens_mistral': 2537, 'n_tokens_neox': 2398, 'n_words': 403}