<commit_before>var CloudCmd, Util, DOM, CloudFunc, $;
(function(CloudCmd, Util, DOM, CloudFunc) {
    'use strict';
    
    var Buffer   = {
            log     : '',
            error   : ''
        };
    
    CloudCmd.Console = ConsoleProto;
        
    function ConsoleProto(CallBack) {
        var Name    = 'Console',
            Loading,
            jqconsole,
            Element,
            MouseBinded,
            Key     = CloudCmd.Key,
            Images  = DOM.Images,
            Notify  = DOM.Notify,
            Console = this;
            
        function init() {
            Loading = true;
            
            Util.loadOnLoad([
                Console.show,
                load,
                CloudCmd.View,
                DOM.jqueryLoad,
                DOM.socketLoad
            ]);
        }
        
        this.show                       = function() {
            if (!Loading) {
                Images.showLoad({top:true});
                
                if (!Element) {
                    Element         = DOM.anyload({
                        name        : 'div',
                        className   : 'console'
                    });
                    
                    jqconsole           = $(Element).jqconsole('', '> ');
                    // Abort prompt on Ctrl+Z.
                    jqconsole.RegisterShortcut('Z', function() {
                        jqconsole.AbortPrompt();
                        handler();
                    });
                    
                    // Handle a command.
                    var handler = function(command) {
                        var socket = CloudCmd.Socket;
                        
                        if (command && socket) {
                            Images.showLoad({ top:true });
                            socket.send(command);
                        }
                        
                        jqconsole.Prompt(true, handler);
                    };
                    
                    // Initiate the first prompt.
                    handler();
                }
                
                CloudCmd.View.show(Element, function() {
                    var l$Console   = jqconsole.$console,
                        l$Input     = jqconsole.$input_source,
                        lFocus      = function() {
                            var x   = window.scrollX,
                                y   = window.scrollY;
                            
                            l$Input.focus();
                            window.scrollTo(x,y);
                        };
                    
                    lFocus();
                    
                    if (!MouseBinded) {
                        MouseBinded = true;
                        
                        $(l$Console).unbind('mouseup');
                        $(l$Console).mouseup(function() {
                            var top,
                                isSelection = window.getSelection().toString();
                            
                            if (!isSelection) {
                                top        = l$Console.scrollTop();
                                
                                lFocus();
                                l$Console.scrollTop(lTop);
                            }
                        });
                    }
                });
            }
        };
        
        this.log                        = function(pText) {
            log(pText, 'log');
        };
        
        this.error                      = function(pText) {
           log(pText, 'error');
        };
        
        function log(msg, status) {
            var ret;
            
            if (msg) {<commit_msg>refactor(console) show<commit_after>var CloudCmd, Util, DOM, CloudFunc, $;
(function(CloudCmd, Util, DOM, CloudFunc) {
    'use strict';
    
    var Buffer   = {
            log     : '',
            error   : ''
        };
    
    CloudCmd.Console = ConsoleProto;
        
    function ConsoleProto(CallBack) {
        var Name    = 'Console',
            Loading,
            jqconsole,
            Element,
            MouseBinded,
            Key     = CloudCmd.Key,
            Images  = DOM.Images,
            Notify  = DOM.Notify,
            Console = this;
            
        function init() {
            Loading = true;
            
            Util.loadOnLoad([
                Console.show,
                load,
                CloudCmd.View,
                DOM.jqueryLoad,
                DOM.socketLoad
            ]);
        }
        
        this.show                       = function() {
            if (!Loading) {
                Images.showLoad({top:true});
                
                if (!Element) {
                    Element         = DOM.anyload({
                        name        : 'div',
                        className   : 'console'
                    });
                    
                    jqconsole           = $(Element).jqconsole('', '> ');
                    // Abort prompt on Ctrl+Z.
                    jqconsole.RegisterShortcut('Z', function() {
                        jqconsole.AbortPrompt();
                        handler();
                    });
                    
                    // Handle a command.
                    var handler = function(command) {
                        var socket = CloudCmd.Socket;
                        
                        if (command && socket) {
                            Images.showLoad({ top:true });
                            socket.send(command);
                        }
                        
                        jqconsole.Prompt(true, handler);
                    };
                    
                    // Initiate the first prompt.
                    handler();
                }
                
                CloudCmd.View.show(Element, function() {
                    var console   = jqconsole.$console,
                        input     = jqconsole.$input_source,
                        
                        focus      = function() {
                            var x   = window.scrollX,
                                y   = window.scrollY;
                            
                            input.focus();
                            window.scrollTo(x,y);
                        };
                    
                    focus();
                    
                    if (!MouseBinded) {
                        MouseBinded = true;
                        
                        console.unbind('mouseup');
                        console.mouseup(function() {
                            var top,
                                isSelection = window.getSelection().toString();
                            
                            if (!isSelection) {
                                top        = console.scrollTop();
                                
                                focus();
                                console.scrollTop(top);
                            }
                        });
                    }
                });
            }
        };
        
        this.log                        = function(pText) {
            log(pText, 'log');
        };
        
        this.error                      = function(pText) {
           log(pText, 'error');
        };
        
        function log(msg, status) {
            var ret;
            
            if (msg) {
{'fraction_non_alphanumeric': 0.0848380244291025, 'fraction_numerical': 0.0, 'mean_word_length': 0.614790996784566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '76217', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1515, 'n_words': 275}