<commit_before>// shuffle Array
Array.prototype.shuffle = function() {
    var i = this.length, p, t;
    while (i --) {
        p = Math.floor(Math.random() * i);
        if (p > 0) {
            t = this[i];
            this[i] = this[p];
            this[p] = t;
        }
    }
    return this
}

// random number
function R(a, b) {
    return Math.floor(Math.random() * (b - a) + a)
}

function template(cover) {
    var s = '<ul>';

    var w = $('#container').width(), 
        h = 400, 
        _w = 200, 
        _h = 200; 

    cover = cover.split('@@').shuffle();

    for (var i = 0; i < cover.length; i ++) {
        var t, l;

        // margin top
        t = R(- _h / 8, h - _h / 8 * 7);

        // margin left
        if (i % 3 === 0) {
            l = R(0, w / 3 - _w / 8 * 7)
        }
        if (i % 3 === 1) {
            l = R(- _w / 8, w / 3 - _w / 8 * 7)
        }
        if (i % 3 === 2) {
            l = R(- _w / 8, w / 3 - _w)
        }

        cover[i] = cover[i].split(',');

        if (cover[i].length == 1) {
            if (t > 70) {
                t = 70
            }
            if (l > 37) {
                l = 37
            }

            s += '<li style="margin-top:'+ t +'px;margin-left:'+ l +'px">'+
                 '<h2>'+ cover[i][0].split('##')[0] +'</h2>'+
                 '<p>'+ cover[i][0].split('##')[1] +'</p>'+
                 '</li>';
        } else {
            s += '<li data-u="'+ cover[i][0] +'" data-c="'+ cover[i][1] +'" data-m="'+ cover[i][4] +'" data-r="'+ cover[i][5] +'" style="margin-top:'+ t +'px;margin-left:'+ l +'px">'+
                 '<img src="thumbnails/'+ cover[i][0] +'.jpg" />'+
                 '<div style="background-color:'+ cover[i][1] +'"></div>'+
                 '</li>';
        }

        if ((i + 1) % 3 === 0) {
            s += '</ul><ul>'
        }
    }

    s += '</ul>';

    return s.split('<ul></ul>')[0];
}

$(function($) {

    var container = $('#container'), mark = $('#mark');

    // current image
    var target;

    container.html(template(cover0)).on('click', function(e) {
        if (container.data('click') == 1) {
            return
        }

        if (e.target.tagName == 'IMG') {

            target = $(e.target).parent();

            target.css('z-index', '1')

            container.data('click', 1)

            var cover = 'covers/'+ target.data('u') +'.jpg';
            
            $('#canvas').attr('src', cover)

            new CBFimage($('#canvas')[0], {
                start: function() {
                    target.find('div').css('width', '3%')
                },
                progress: function(loaded, total) {
                    target.find('div').css('width', (loaded / total) * 100 +'%')
                },
                complete: function(image) {
                    mark.addClass('show')

                    mark.find('.inner').width(600).height(600)
                    mark.find('.bg').css('background-color', target.data('c'))
                    mark.find('.info').html('<h2>'+ target.data('m') +'</h2><h3>'+ target.data('r') +'</h3>')
                }
            })    
        }
    })

    // close mark
    mark.on('click', function(e) {
        mark.removeClass('show').addClass('loading')
        container.data('click', 0)
        target.find('div').css('width', 0)
        target.css('z-index', '')
    })

    $(window).on('DOMMouseScroll mousewheel', function(e) {
        if (mark.hasClass('show')) {
            e.preventDefault()
        }
    })

})

/*
 * https://github.com/LoeiFy/CBFimage/blob/master/README.md
 *
 * @version 1.0.0
 * @author <EMAIL>
 * http://lorem.in/ | under MIT license
 */

;(function(window, undefined) {

    function CBFimage(element, option) {

        this.option = {
            start:      function() {},
            progress:   function(loaded, total) {},
            complete:   function(image) {}
        }

        if (option && typeof option === 'object') {
            for (var key in option) {
                this.option[key] = option[key]
            }
        }

        if (element && element.getAttribute('src') !== '') {
            this.element = element;

            this.src = element.getAttribute('src');<commit_msg>make better<commit_after>// shuffle Array
Array.prototype.shuffle = function() {
    var i = this.length, p, t;
    while (i --) {
        p = Math.floor(Math.random() * i);
        if (p > 0) {
            t = this[i];
            this[i] = this[p];
            this[p] = t;
        }
    }
    return this
}

// random number
function R(a, b) {
    return Math.floor(Math.random() * (b - a) + a)
}

function template(cover) {
    var s = '<ul>';

    var w = $('#container').width(), 
        h = 400, 
        _w = 200, 
        _h = 200; 

    cover = cover.split('@@').shuffle();

    for (var i = 0; i < cover.length; i ++) {
        var t, l;

        // margin top
        t = R(- _h / 8, h - _h / 8 * 7);

        // margin left
        if (i % 3 === 0) {
            l = R(0, w / 3 - _w / 8 * 7)
        }
        if (i % 3 === 1) {
            l = R(- _w / 8, w / 3 - _w / 8 * 7)
        }
        if (i % 3 === 2) {
            l = R(- _w / 8, w / 3 - _w)
        }

        cover[i] = cover[i].split(',');

        if (cover[i].length == 1) {
            if (t > 70) {
                t = 70
            }
            if (l > 37) {
                l = 37
            }

            s += '<li style="margin-top:'+ t +'px;margin-left:'+ l +'px">'+
                 '<h2>'+ cover[i][0].split('##')[0] +'</h2>'+
                 '<p>'+ cover[i][0].split('##')[1] +'</p>'+
                 '</li>';
        } else {
            s += '<li data-u="'+ cover[i][0] +'" data-w="'+ cover[i][2] +'" data-h="'+ cover[i][3] +'" data-c="'+ cover[i][1] +'" data-m="'+ cover[i][4] +'" data-r="'+ cover[i][5] +'" style="margin-top:'+ t +'px;margin-left:'+ l +'px">'+
                 '<img src="thumbnails/'+ cover[i][0] +'.jpg" />'+
                 '<div style="background-color:'+ cover[i][1] +'"></div>'+
                 '</li>';
        }

        if ((i + 1) % 3 === 0) {
            s += '</ul><ul>'
        }
    }

    s += '</ul>';

    return s.split('<ul></ul>')[0];
}

$(function($) {
    var container = $('#container'), mark = $('#mark'),
        target;     // current image

    // page 0
    container.html(template(cover0))

    // scroll
    $(window).on('DOMMouseScroll mousewheel', function(e) {
        if (mark.hasClass('show')) {
            e.preventDefault()
        }
    })

    // show cover
    container.on('click', function(e) {
        if (container.data('loading') == 1) {
            return
        }

        if (e.target.tagName == 'IMG' || e.target.tagName == 'LI') {
            container.data('loading', 1)

            target = e.target.tagName == 'LI' ? $(e.target) : $(e.target).parent();
            target.css('z-index', '1')

            var cover = 'covers/'+ target.data('u') +'.jpg';
            $('#canvas').attr('src', cover)

            new CBFimage($('#canvas')[0], {
                start: function() {
                    target.find('div').css('width', '2.7%')
                },
                progress: function(loaded, total) {
                    target.find('div').css('width', (loaded / total) * 100 +'%')
                },
                complete: function(image) {
                    mark.addClass('show')

                    mark.find('.inner').width(target.data('w')).height(target.data('h'))
                    mark.find('.bg').css('background-color', target.data('c'))
                    mark.find('.info').html('<h2>'+ target.data('m') +'</h2><h3>'+ target.data('r') +'</h3>')
                }
            })    
        }
    })

    // close cover
    mark.on('click', function(e) {
        container.data('loading', 0)
        mark.removeClass('show').addClass('loading')
        target.find('div').css('width', 0)
        target.css('z-index', '')
    })
})

/*
 * https://github.com/LoeiFy/CBFimage/blob/master/README.md
 *
 * @version 1.0.0
 * @author <EMAIL>
 * http://lorem.in/ | under MIT license
 */

;(function(window, undefined) {

    function CBFimage(element, option) {

        this.option = {
            start:      function() {},
            progress:   function(loaded, total) {},
            complete:   function(image) {}
        }

        if (option && typeof option === 'object') {
            for (var key in option) {
                this.option[key] = option[key]
            }
        }

        if (element && element.getAttribute('src') !== '') {
            this.element = element;

            this.src = element.getAttribute('src');
{'fraction_non_alphanumeric': 0.21248416445928828, 'fraction_numerical': 0.017966140734769088, 'mean_word_length': 1.4441317196735153, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 53, 'https://': 2, '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': '1839241', 'n_tokens_mistral': 2985, 'n_tokens_neox': 2811, 'n_words': 588}