<commit_before>(function(w){
    var vtil = {};

    /**
     * Center normal image element in wrapper
     * @param  {object} elem  image DOM element
     */
    function centerImg (elem) {
        var pNode = elem.parentNode;
        pNode.style.position = 'relative';
        pNode.style.overflow = 'hidden';
        elem.style.position = 'absolute';
        elem.style.width = '100%';
        var pHeight = pNode.clientHeight;
        if (elem.height <= pHeight) {
            elem.style.width = null;
            elem.style.height = '100%';
            elem.style.left = (pNode.clientWidth - elem.clientWidth) / 2.0 + 'px';
        } else {
            elem.style.top = (pHeight - elem.clientHeight) / 2.0 + 'px';
        }
    };

    /**
     * Center image element with data-src attribute for lazy loading
     * @param  {object} elem  image DOM element
     * @param  {string} src  the src of image
     */
    function lazyCenterImg (elem, src) {
        var pNode = elem.parentNode;
        pNode.style.position = 'relative';
        pNode.style.overflow = 'hidden';
        var img = new Image();
        img.src = src;
        img.onload = function() {
            elem.style.position = 'absolute';
            var pHeight = pNode.clientHeight;
            var pWidth = pNode.clientWidth;
            var iHeight = img.height * pNode.clientWidth / img.width;
            var iWidth = img.width * pNode.clientHeight / img.height;
            if (iHeight <= pHeight) {
                elem.style.height = pHeight + 'px';
                elem.style.left = (pWidth - iWidth) / 2.0 + 'px';
            } else {
                elem.style.width = pWidth + 'px';
                elem.style.top = (pHeight - iHeight) / 2.0 + 'px';
            }
            elem.src = src;
        };
    };

    /**
     * Center one or multiple images
     * @param  {array} elems [description]
     * @return {[type]}       [description]
     */
    vtil.centerImgs = function(elems) {
        var len = elems.length;
        var elem = null;
        var src = '';
        for (var i = 0; i < len; i++) {
            elem = elems[i];
            src = elem.getAttribute('data-src');
            !src ? centerImg(elem) : lazyCenterImg(elem, src);
        }
    };
    w.vtil = vtil;
})(window);

<commit_msg>Update vtil.js<commit_after>(function(w){
    var vtil = {};

    /**
     * Center normal image element in wrapper
     * @param  {object} elem  image DOM element
     */
    function centerImg (elem) {
        var pNode = elem.parentNode;
        pNode.style.position = 'relative';
        pNode.style.overflow = 'hidden';
        elem.style.position = 'absolute';
        elem.style.width = '100%';
        var pHeight = pNode.clientHeight;
        if (elem.height <= pHeight) {
            elem.style.width = null;
            elem.style.height = '100%';
            elem.style.left = (pNode.clientWidth - elem.clientWidth) / 2.0 + 'px';
        } else {
            elem.style.top = (pHeight - elem.clientHeight) / 2.0 + 'px';
        }
    };

    /**
     * Center image element with data-src attribute for lazy loading
     * @param  {object} elem  image DOM element
     * @param  {string} src  the src of image
     */
    function lazyCenterImg (elem, src) {
        var pNode = elem.parentNode;
        pNode.style.position = 'relative';
        pNode.style.overflow = 'hidden';
        var img = new Image();
        img.src = src;
        img.onload = function() {
            elem.style.position = 'absolute';
            var pHeight = pNode.clientHeight;
            var pWidth = pNode.clientWidth;
            var iHeight = img.height * pNode.clientWidth / img.width;
            var iWidth = img.width * pNode.clientHeight / img.height;
            if (iHeight <= pHeight) {
                elem.style.height = pHeight + 'px';
                elem.style.left = (pWidth - iWidth) / 2.0 + 'px';
            } else {
                elem.style.width = pWidth + 'px';
                elem.style.top = (pHeight - iHeight) / 2.0 + 'px';
            }
            elem.src = src;
        };
    };

    /**
     * Center one or multiple images
     * @param  {array} elems [description]
     * @return {[type]}       [description]
     */
    vtil.centerImgs = function(elems) {
        var len = elems.length;
        var elem = null;
        var src = '';
        for (var i = 0; i < len; i++) {
            elem = elems[i];
            src = elem.getAttribute('data-src');
            !src ? centerImg(elem) : lazyCenterImg(elem, src);
        }
    };
    
    /**
     * Lazy load javascript outside
     * @param  {string} url requested URL
     */
    vtil.load: function(url) {
        var head = document.getElementsByTagName('head');
        var script = document.createElement('script');
        script.src = url;
        script.className = 'test';
        script.setAttribute('async', 'async');
        head[0].appendChild(script);
    }
    w.vtil = vtil;
})(window);


{'fraction_non_alphanumeric': 0.1326387497495492, 'fraction_numerical': 0.006211180124223602, 'mean_word_length': 1.653907496012759, 'pattern_counts': {'":': 0, '<': 9, '<?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': '299800', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1485, 'n_words': 367}