<commit_before>/* Javascript for ViaductXBlock. */
function ViaductXBlock(runtime, element) {
    var terminal_href;
    var status;

    function get_terminal_href() {
        $.ajax({
            type: 'POST',
            url: runtime.handlerUrl(element, 'get_terminal_href'),
            data: '{}',
            success: update_terminal_href,
            dataType: 'json'
        });
    }

    function update_terminal_href(result) {
        terminal_href = result.terminal_href;
        get_user_stack_status();
    }

    function get_user_stack_status() {
        $.ajax({
            type: 'POST',
            url: runtime.handlerUrl(element, 'get_user_stack_status'),
            data: '{}',
            success: update_user_stack_status,
            dataType: 'json'
        });
    }

    function update_user_stack_status(result) {
        var changed = false;
        if (status !== result.status) {
            changed = true;
            status = result.status;
        }

        /* Schedule a new check. */
        setTimeout(get_user_stack_status, 5000);

        /* If there was a change in status, update the screen. */
        if (changed) {
            $('.pending').hide();
            $('.error').hide();
            if (status == 'CREATE_COMPLETE' || status == 'RESUME_COMPLETE') {
                start_new_terminal(result.ip);
            } else if (status == 'CREATE_FAILED' || status == 'RESUME_FAILED') {
                $('.error').show();
            } else {
                $('.pending').show();
            }
        }
    }

    function start_new_terminal(ip) {
        GateOne.init({
            url: terminal_href,
            embedded: true,
            style: {
                'background-color': 'rgba(0, 0, 0, 0.85)',
                'box-shadow': '.5em .5em .5em black',
                'margin-bottom': '0.5em'
            }
        });

        GateOne.Base.superSandbox("GateOne.MyModule", ["GateOne.Terminal"], function(window, undefined) {
            var container = GateOne.Utils.getNode('#container');
            var settings = {'autoConnectUrl': 'ssh://training@' + ip};
            setTimeout(function() {
                var term_num = GateOne.Terminal.newTerminal(null, settings, container);
            }, 250);
        });
    }

    /* Called on page load. */
    $(function ($) {
        get_terminal_href();
    });
}<commit_msg>Set auto connect options on init<commit_after>/* Javascript for ViaductXBlock. */
function ViaductXBlock(runtime, element) {
    var terminal_href;
    var status;

    function get_terminal_href() {
        $.ajax({
            type: 'POST',
            url: runtime.handlerUrl(element, 'get_terminal_href'),
            data: '{}',
            success: update_terminal_href,
            dataType: 'json'
        });
    }

    function update_terminal_href(result) {
        terminal_href = result.terminal_href;
        get_user_stack_status();
    }

    function get_user_stack_status() {
        $.ajax({
            type: 'POST',
            url: runtime.handlerUrl(element, 'get_user_stack_status'),
            data: '{}',
            success: update_user_stack_status,
            dataType: 'json'
        });
    }

    function update_user_stack_status(result) {
        var changed = false;
        if (status !== result.status) {
            changed = true;
            status = result.status;
        }

        /* Schedule a new check. */
        setTimeout(get_user_stack_status, 5000);

        /* If there was a change in status, update the screen. */
        if (changed) {
            $('.pending').hide();
            $('.error').hide();
            if (status == 'CREATE_COMPLETE' || status == 'RESUME_COMPLETE') {
                start_new_terminal(result.ip);
            } else if (status == 'CREATE_FAILED' || status == 'RESUME_FAILED') {
                $('.error').show();
            } else {
                $('.pending').show();
            }
        }
    }

    function start_new_terminal(ip) {
        GateOne.init({
            url: terminal_href,
            embedded: true,
            style: {
                'background-color': 'rgba(0, 0, 0, 0.85)',
                'box-shadow': '.5em .5em .5em black',
                'margin-bottom': '0.5em'
            }
        });

        GateOne.Base.superSandbox("GateOne.MyModule", ["GateOne.Terminal"], function(window, undefined) {
            var container = GateOne.Utils.getNode('#container');
            var term_num = GateOne.Terminal.newTerminal(null, null, container);
            setTimeout(function() {
                GateOne.Terminal.sendString('ssh://training@' + ip + '\n');
            }, 500);
        });
    }

    /* Called on page load. */
    $(function ($) {
        get_terminal_href();
    });
}
{'fraction_non_alphanumeric': 0.13708333333333333, 'fraction_numerical': 0.0075, 'mean_word_length': 1.7078398195149465, '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': '5873537', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1339, 'n_words': 271}