<commit_before>
require('./polyfills');

var reqwest = require('reqwest');
var z = {};

z.components = Object.create({
    _all:[],
    getByName:function(){
        
    }
});

z.utils = {
    extend: function(child) {
        var superPrototype = this;

        var subPrototype = function(){
            superPrototype.apply(this,arguments);
        };
        subPrototype.prototype = Object.create(superPrototype.prototype);

        for (var p in child) {
            subPrototype.prototype[p] = child[p];
        }

        return subPrototype;
    }
}
z.Component = function(config) {
    z.components._all.push(this);
    config = config || {};

    this.el = config.el || null;
    this.id = config.id || null;
    this.template = config.template || '';

    this.init();
}
z.Component.prototype = {
    init:function(){},
    onRender:function(){},
    find: function(query) {
        return this.el.querySelector(query);
    },
    findAll: function(query) {
        return this.el.querySelectorAll(query);
    },
    pullTemplate:function(cb){
        var that = this;
        reqwest({
            url: 'components/'+this.name+'/template', 
            method: 'get', 
            success: function (template) {
              that.template = template;
              that.onPullTemplate.call(that);
              cb(template);
            }
        })
    },
    controller:function(methodName,config,cb){
        if(typeof config == 'function'){
            cb = config;
            config = {};
        }
        
        reqwest({
            url: 'components/'+this.name+'/'+methodName, 
            data: config,
            method: 'get', 
            success: function (response) {
              try { var r = JSON.parse(response); cb(r) }catch(e){ cb(response) };
            }
        })
    },
    onPullTemplate:function(){}
}
z.Component.extend = z.utils.extend;

z.registerComponent = function(child) {
    z.components[child.name] = z.Component.extend(child);
}

z.initDomComponents = function() {
    var domComponents = document.querySelectorAll('[data-component]');

    for (var i = 0; i < domComponents.length; i++) {
        var componentName = domComponents[i].getAttribute('data-component');
        if (componentName in z.components) {
            var newComponent = new z.components[componentName]({
                el: domComponents[i],
                id: domComponents[i].getAttribute('id')
            });
        }
    };
};

if(window){
    window.z = z;
}

module.exports = z;

<commit_msg>bind events<commit_after>require('./polyfills');

var reqwest = require('reqwest');
var z = {};

z.components = Object.create({
    _all:[],
    getByName:function(){
        
    }
});

z.utils = {
    extend: function(child) {
        var superPrototype = this;

        var subPrototype = function(){
            superPrototype.apply(this,arguments);
        };
        subPrototype.prototype = Object.create(superPrototype.prototype);

        for (var p in child) {
            subPrototype.prototype[p] = child[p];
        }

        return subPrototype;
    }
}
z.Component = function(config) {
    z.components._all.push(this);
    config = config || {};

    this.el = config.el || null;
    this.id = config.id || null;
    this.template = config.template || '';

    this.init();
}
z.Component.prototype = {
    init:function(){},
    onRender:function(){},
    find: function(query) {
        return this.el.querySelector(query);
    },
    findAll: function(query) {
        return this.el.querySelectorAll(query);
    },
    pullTemplate:function(cb){
        var that = this;
        reqwest({
            url: 'components/'+this.name+'/template', 
            method: 'get', 
            success: function (template) {
              that.template = template;
              that.onPullTemplate.call(that);
              cb(template);
            }
        })
    },
    bindEvent:function(selector,eventName,methodName){
        var that = this;
        var nodes = this.findAll(selector);
        for (var i = 0; i < nodes.length; i++) {
            nodes[i].addEventListener(eventName,function(e){
                that[methodName].call(that,e,this);
            });
        };
        return true;
    },
    controller:function(methodName,config,cb){
        if(typeof config == 'function'){
            cb = config;
            config = {};
        }
        
        reqwest({
            url: 'components/'+this.name+'/'+methodName, 
            data: config,
            method: 'get', 
            success: function (response) {
              try { var r = JSON.parse(response); cb(r) }catch(e){ cb(response) };
            }
        })
    },
    onPullTemplate:function(){}
}
z.Component.extend = z.utils.extend;

z.registerComponent = function(child) {
    z.components[child.name] = z.Component.extend(child);
}

z.initDomComponents = function() {
    var domComponents = document.querySelectorAll('[data-component]');

    for (var i = 0; i < domComponents.length; i++) {
        var componentName = domComponents[i].getAttribute('data-component');
        if (componentName in z.components) {
            var newComponent = new z.components[componentName]({
                el: domComponents[i],
                id: domComponents[i].getAttribute('id')
            });
        }
    };
};

if(window){
    window.z = z;
}

module.exports = z;


{'fraction_non_alphanumeric': 0.14520902700702923, 'fraction_numerical': 0.0005549389567147614, 'mean_word_length': 2.025741466144376, 'pattern_counts': {'":': 0, '<': 6, '<?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': '1927996', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1555, 'n_words': 290}