<commit_before>/*!
 * Abricos Platform (http://abricos.org)
 * Copyright 2008-2014 <NAME> <<EMAIL>>
 * Licensed under the MIT license
 */

var Component = new Brick.Component();
Component.requires = {
    mod: [
        {name: '{C#MODNAME}', files: ['widget.js', 'io.js', 'appModel.js']},
        {name: 'widget', files: ['notice.js']}
    ]
};
Component.entryPoint = function(NS){

    var Y = Brick.YUI,
        L = Y.Lang,

        WAITING = 'waiting',
        BOUNDING_BOX = 'boundingBox',

        SLICE = Array.prototype.slice;

    NS.Application = Y.Base.create('application', Y.Base, [
        NS.AJAX,
        NS.Language
    ], {
        initializer: function(){
            var ns = this.get('component');
            ns.namespace.appInstance = this;

            this._appCache = {};
        },
        initCallbackFire: function(){
            var initCallback = this.get('initCallback');
            if (L.isFunction(initCallback)){
                initCallback(null, this);
            }
        },
        onAJAXError: function(err){
            Brick.mod.widget.notice.show(err.msg);
        },
        ajaxParseResponse: function(data, res){
        },
        _defaultAJAXCallback: function(err, res, details){
            res = res || {};

            var tRes = {},
                rData = res.data || {};

            if (!Y.Lang.isArray(rData)){
                rData = [rData];
            }
            for (var i = 0; i < rData.length; i++){
                var data = rData[i];

                for (var n in data){
                    var fName = n + 'ParseResponse';

                    if (Y.Lang.isFunction(this[fName])){
                        this[fName](data, tRes);
                    }
                }

                this.ajaxParseResponse(data, tRes);
            }

            if (Y.Lang.isFunction(details.callback)){
                details.callback.apply(details.context, [err, tRes]);
            }
        },
        ajaxa: function(rData, callback, context){
            if (this.get('isLoadAppStructure') && !this.get('appStructure')){
                if (!Y.Lang.isArray(rData)){
                    rData = [rData];
                }
                rData.splice(0, 0, {
                    do: 'appStructure'
                });
            }
            this.ajax(rData, this._defaultAJAXCallback, {
                arguments: {callback: callback, context: context}
            });
        }
    }, {
        ATTRS: {
            initCallback: {
                value: null
            },
            component: {
                value: null
            },
            moduleName: {
                value: null
            },
            appStructure: {
                value: null
            },
            isLoadAppStructure: {
                value: false
            }
        }
    });


    NS.Application.build = function(component, ajaxes, px, extensions, sx){
        extensions = extensions || [];
        sx = sx || {};

        ajaxes = Y.merge({
            appStructure: {
                cache: 'appStructure',
                response: function(d){
                    var appStructure = new NS.AppStructure(d);
                    this.set('appStructure', appStructure);
                    return appStructure
                }
            }
        }, ajaxes || {});

        var moduleName = component.moduleName;
        var ns = Brick.mod[moduleName];

        for (var n in ajaxes){
            (function(){
                var act = n,
                    info = ajaxes[act];

                if (Y.Lang.isFunction(info.response)){

                    px[act + 'ParseResponse'] = function(data, res){
                        res[act] = info.response.call(this, data[act]);

                        if (info.cache){
                            this._appCache[info.cache] = res[act];
                        }
                    };
                }

                px[act] = function(){
                    var funcArgs = SLICE.call(arguments),
                        funcArg,
                        defArgsOffset = 0;

                    var rData = {
                        'do': act
                    };

                    if (Y.Lang.isArray(info.args)){
                        defArgsOffset = info.args.length;
                        for (var i = 0; i < defArgsOffset; i++){
                            funcArg = funcArgs[i];
                            if (funcArg && Y.Lang.isFunction(funcArg.toJSON)){
                                funcArg = funcArg.toJSON();
                            }
                            rData[info.args[i]] = funcArg;
                        }
                    }

                    var callback, context;
                    if (funcArgs[defArgsOffset]){
                        callback = funcArgs[defArgsOffset];
                    }
                    if (funcArgs[defArgsOffset + 1]){
                        context = funcArgs[defArgsOffset + 1];
                    }

                    if (info.cache && this._appCache[info.cache]){
                        var ret = {};
                        ret[act] = this._appCache[info.cache];
                        return callback.apply(context, [null, ret]);
                    }

                    if (info.request){
                        var req = info.request;
                        if (Y.Lang.isString(req)){
                            req = req.split(',');
                        }
                        rData = [rData]<commit_msg>bugfix: set request from cache<commit_after>/*!
 * Abricos Platform (http://abricos.org)
 * Copyright 2008-2014 <NAME> <<EMAIL>>
 * Licensed under the MIT license
 */

var Component = new Brick.Component();
Component.requires = {
    mod: [
        {name: '{C#MODNAME}', files: ['widget.js', 'io.js', 'appModel.js']},
        {name: 'widget', files: ['notice.js']}
    ]
};
Component.entryPoint = function(NS){

    var Y = Brick.YUI,
        L = Y.Lang,

        WAITING = 'waiting',
        BOUNDING_BOX = 'boundingBox',

        SLICE = Array.prototype.slice;

    NS.Application = Y.Base.create('application', Y.Base, [
        NS.AJAX,
        NS.Language
    ], {
        initializer: function(){
            var ns = this.get('component');
            ns.namespace.appInstance = this;

            this._appCache = {};
        },
        initCallbackFire: function(){
            var initCallback = this.get('initCallback');
            if (L.isFunction(initCallback)){
                initCallback(null, this);
            }
        },
        onAJAXError: function(err){
            Brick.mod.widget.notice.show(err.msg);
        },
        ajaxParseResponse: function(data, res){
        },
        _defaultAJAXCallback: function(err, res, details){
            res = res || {};

            var tRes = {},
                rData = res.data || {};

            if (!Y.Lang.isArray(rData)){
                rData = [rData];
            }
            for (var i = 0; i < rData.length; i++){
                var data = rData[i];

                for (var n in data){
                    var fName = n + 'ParseResponse';

                    if (Y.Lang.isFunction(this[fName])){
                        this[fName](data, tRes);
                    }
                }

                this.ajaxParseResponse(data, tRes);
            }

            if (Y.Lang.isFunction(details.callback)){
                details.callback.apply(details.context, [err, tRes]);
            }
        },
        ajaxa: function(rData, callback, context){
            if (this.get('isLoadAppStructure') && !this.get('appStructure')){
                if (!Y.Lang.isArray(rData)){
                    rData = [rData];
                }
                rData.splice(0, 0, {
                    do: 'appStructure'
                });
            }
            this.ajax(rData, this._defaultAJAXCallback, {
                arguments: {callback: callback, context: context}
            });
        }
    }, {
        ATTRS: {
            initCallback: {
                value: null
            },
            component: {
                value: null
            },
            moduleName: {
                value: null
            },
            appStructure: {
                value: null
            },
            isLoadAppStructure: {
                value: false
            }
        }
    });


    NS.Application.build = function(component, ajaxes, px, extensions, sx){
        extensions = extensions || [];
        sx = sx || {};

        ajaxes = Y.merge({
            appStructure: {
                cache: 'appStructure',
                response: function(d){
                    var appStructure = new NS.AppStructure(d);
                    this.set('appStructure', appStructure);
                    return appStructure
                }
            }
        }, ajaxes || {});

        var moduleName = component.moduleName;
        var ns = Brick.mod[moduleName];

        for (var n in ajaxes){
            (function(){
                var act = n,
                    info = ajaxes[act];

                if (Y.Lang.isFunction(info.response)){

                    px[act + 'ParseResponse'] = function(data, res){
                        res[act] = info.response.call(this, data[act]);

                        if (info.cache){
                            this._appCache[info.cache] = res[act];
                        }
                    };
                }

                px[act] = function(){
                    var funcArgs = SLICE.call(arguments),
                        funcArg,
                        defArgsOffset = 0;

                    var rData = {
                        'do': act
                    };

                    if (Y.Lang.isArray(info.args)){
                        defArgsOffset = info.args.length;
                        for (var i = 0; i < defArgsOffset; i++){
                            funcArg = funcArgs[i];
                            if (funcArg && Y.Lang.isFunction(funcArg.toJSON)){
                                funcArg = funcArg.toJSON();
                            }
                            rData[info.args[i]] = funcArg;
                        }
                    }

                    var callback, context;
                    if (funcArgs[defArgsOffset]){
                        callback = funcArgs[defArgsOffset];
                    }
                    if (funcArgs[defArgsOffset + 1]){
                        context = funcArgs[defArgsOffset + 1];
                    }

                    if (info.cache && this._appCache[info.cache]){
                        var ret = {};
                        ret[act] = this._appCache[info.cache];

                        // TODO: develop - if request not in cache
                        if (info.request){
                            var req = info.request;
                            if (Y.Lang.isString(req)){
                                req = req.split(',');
                            }
                            for (var i = 0; i < req.length; i++){
                                var actr = req[i];
                                if (this._appCache[actr]){
                                    ret[actr] = this._appCache[actr];
                                }
                            }
                        }

                        return callback.apply(context, [null, ret]);
                    }

                    if (info.request){
                        var req = info.request;
                        if (Y.Lang.isString(req)){
                            req = req.split(',');
                        }
                        rData = [rData]
{'fraction_non_alphanumeric': 0.11635434412265758, 'fraction_numerical': 0.0026405451448040886, 'mean_word_length': 1.0049521857923498, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '344575', 'n_tokens_mistral': 3103, 'n_tokens_neox': 2857, 'n_words': 583}