<commit_before>var pk = pk || {};
(function(pk) {
    pk.carousel = function(opt) {
        var el = opt.element,
            options = opt.options || [],
            value = opt.value || 0,
            delay = opt.delay || 4000,
            timer = true,
            inputTabIndex = opt.tabindex || el.getAttribute('tabindex') || 0;

        if (options.length === 0 && el.nodeName === "UL") {
            for (var i = 0; i < el.children.length; i++) {
                options.push(el.children[i].innerHTML);
            }
        }
        var tpl = "<div class='pk-carousel pk-noselect' tabindex='" + inputTabIndex + "'><ul>",
            navEl = [],
            optionEl = [];
        for (var o = 0; o < options.length; o++) {
            optionEl.push(pk.createEl("<li class='pk-option'>" + options[o] + "</li>"));
            navEl.push(pk.createEl("<span class='pk-nav-item' data-nav='=" + o + "'></span>"));
        }
        tpl += "</ul><span class='pk-nav-prev' data-nav='-1'></span><span data-nav='+1' class='pk-nav-next'></span></div>";

        el.innerHTML = '';
        el = pk.replaceEl(el, tpl);
        for (o = 0; o < options.length; o++) {
            el.children[0].appendChild(optionEl[o]);
            el.appendChild(navEl[o]);
        }

        function clickHandler(e) {
            obj.val(pk.attribute(e.target, 'data-nav'));
        }
        for (var c in el.children) {
            if (pk.attribute(el.children[c], 'data-nav')) {
                pk.bindEvent('click', el.children[c], clickHandler);
            }
        }

        pk.bindEvent("mousewheel", el, function(e) {
            pk.preventBubble(e);
            obj.val((e.wheelDelta > 0 || e.detail < 0) ? '-1' : '+1');
        });

        pk.bindEvent('keydown', el, function(e) {
            switch (e.keyCode) {
                case 34: //page down
                case 40: //down cursor
                case 37: //left cursor
                    obj.val('-1');
                    break;
                case 33: //page up
                case 32: //spacebar				
                case 38: //up cursor
                case 39: //right cursor
                    obj.val('+1');
                    break;
                case 36: //home
                    obj.val(0);
                    break;
                case 35: //end
                    obj.val(options.length - 1);
                    break;
            }
            pk.preventBubble(e);
        });
        var oldVal;
        var obj = {
            val: function(val) {
                val = val.toString();
                if (val === undefined) {
                    return value;
                }
                var inClass = '',
                    outClass = '';
                if (val.indexOf("-") !== -1) {
                    value = value - parseInt(val.replace('-', ''), 0) < 0 ? options.length - 1 : --value;
                    inClass = 'left';
                    outClass = 'right';
                } else if (val.indexOf("+") !== -1) {
                    value = value + parseInt(val.replace('+', ''), 0) > options.length - 1 ? 0 : ++value;
                    inClass = 'right';
                    outClass = 'left';
                } else {
                    value = parseInt(val.replace('=', ''), 0);
                    value = value < 0 ? 0 : value > options.length - 1 ? options.length - 1 : value;
                    if (oldVal !== undefined && value > oldVal) {
                        inClass = 'right';
                        outClass = 'left';
                    } else {
                        inClass = 'left';
                        outClass = 'right';
                    }
                }
                for (o = 0; o < options.length; o++) {
                    if (oldVal !== undefined && oldVal === o) {
                        pk.addClass(optionEl[o], 'pk-carousel-out-' + outClass);
                    } else if (oldVal !== undefined) {
                        pk.removeClass(optionEl[o], 'pk-carousel-out-left');
                        pk.removeClass(optionEl[o], 'pk-carousel-out-right');
                    }
                    if (parseInt(o, 0) === value) {
                        // add the selected class to the current iteration					
                        pk.addClass(optionEl[o], 'pk-selected');
                        pk.addClass(navEl[o], 'pk-selected');
                        if (oldVal !== undefined) {
                            pk.addClass(optionEl[o], 'pk-carousel-in-' + inClass);
                        }
                    } else {
                        pk.removeClass(optionEl[o], 'pk-selected');
                        pk.removeClass(optionEl[o], 'pk-carousel-in-right');
                        pk.removeClass(optionEl[o], 'pk-carousel-in-left');
                        pk.removeClass(navEl[o], 'pk-selected');
                    }
                }
                oldVal = value;
                timer = false;
            }
        };
        obj.val(value);

        if (delay) {
            setInterval(function() {
                if (timer) {
                    obj.val('+1');
                }
                timer = true;
            }, delay);
        }

        return obj;
    };
    return pk;
})(pk);
<commit_msg>Update carousel.js<commit_after>var pk = pk || {};
(function(pk) {
    pk.carousel = function(opt) {
        var el = opt.element,
            options = opt.options || [],
            value = opt.value || 0,
            delay = opt.delay || 4000,
            timer = true,
            inputTabIndex = opt.tabindex || el.getAttribute('tabindex') || 0;

        if (options.length === 0 && el.nodeName === "UL") {
            for (var i = 0; i < el.children.length; i++) {
                options.push(el.children[i].innerHTML);
            }
        }
        var tpl = "<div class='pk-carousel pk-noselect' tabindex='" + inputTabIndex + "'><ul>",
            navEl = [],
            optionEl = [];
        for (var o = 0; o < options.length; o++) {
            optionEl.push(pk.createEl("<li class='pk-option'>" + options[o] + "</li>"));
            navEl.push(pk.createEl("<span class='pk-nav-item' data-nav='=" + o + "'>" + o + "</span>"));
        }
        tpl += "</ul><span class='pk-nav-prev' data-nav='-1'></span><span data-nav='+1' class='pk-nav-next'></span></div>";

        el.innerHTML = '';
        el = pk.replaceEl(el, tpl);
        for (o = 0; o < options.length; o++) {
            el.children[0].appendChild(optionEl[o]);
            el.appendChild(navEl[o]);
        }

        function clickHandler(e) {
            obj.val(pk.attribute(e.target, 'data-nav'));
        }
        for (var c in el.children) {
            if (pk.attribute(el.children[c], 'data-nav')) {
                pk.bindEvent('click', el.children[c], clickHandler);
            }
        }

        pk.bindEvent("mousewheel", el, function(e) {
            pk.preventBubble(e);
            obj.val((e.wheelDelta > 0 || e.detail < 0) ? '-1' : '+1');
        });

        pk.bindEvent('keydown', el, function(e) {
            switch (e.keyCode) {
                case 34: //page down
                case 40: //down cursor
                case 37: //left cursor
                    obj.val('-1');
                    break;
                case 33: //page up
                case 32: //spacebar				
                case 38: //up cursor
                case 39: //right cursor
                    obj.val('+1');
                    break;
                case 36: //home
                    obj.val(0);
                    break;
                case 35: //end
                    obj.val(options.length - 1);
                    break;
            }
            pk.preventBubble(e);
        });
        var oldVal;
        var obj = {
            val: function(val) {
                val = val.toString();
                if (val === undefined) {
                    return value;
                }
                var inClass = '',
                    outClass = '';
                if (val.indexOf("-") !== -1) {
                    value = value - parseInt(val.replace('-', ''), 0) < 0 ? options.length - 1 : --value;
                    inClass = 'left';
                    outClass = 'right';
                } else if (val.indexOf("+") !== -1) {
                    value = value + parseInt(val.replace('+', ''), 0) > options.length - 1 ? 0 : ++value;
                    inClass = 'right';
                    outClass = 'left';
                } else {
                    value = parseInt(val.replace('=', ''), 0);
                    value = value < 0 ? 0 : value > options.length - 1 ? options.length - 1 : value;
                    if (oldVal !== undefined && value > oldVal) {
                        inClass = 'right';
                        outClass = 'left';
                    } else {
                        inClass = 'left';
                        outClass = 'right';
                    }
                }
                for (o = 0; o < options.length; o++) {
                    if (oldVal !== undefined && oldVal === o) {
                        pk.addClass(optionEl[o], 'pk-carousel-out-' + outClass);
                    } else if (oldVal !== undefined) {
                        pk.removeClass(optionEl[o], 'pk-carousel-out-left');
                        pk.removeClass(optionEl[o], 'pk-carousel-out-right');
                    }
                    if (parseInt(o, 0) === value) {
                        // add the selected class to the current iteration					
                        pk.addClass(optionEl[o], 'pk-selected');
                        pk.addClass(navEl[o], 'pk-selected');
                        if (oldVal !== undefined) {
                            pk.addClass(optionEl[o], 'pk-carousel-in-' + inClass);
                        }
                    } else {
                        pk.removeClass(optionEl[o], 'pk-selected');
                        pk.removeClass(optionEl[o], 'pk-carousel-in-right');
                        pk.removeClass(optionEl[o], 'pk-carousel-in-left');
                        pk.removeClass(navEl[o], 'pk-selected');
                    }
                }
                oldVal = value;
                timer = false;
            }
        };
        obj.val(value);

        if (delay) {
            setInterval(function() {
                if (timer) {
                    obj.val('+1');
                }
                timer = true;
            }, delay);
        }

        return obj;
    };
    return pk;
})(pk);

{'fraction_non_alphanumeric': 0.1511627906976744, 'fraction_numerical': 0.010398941198714312, 'mean_word_length': 1.086176296588444, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1845195', 'n_tokens_mistral': 3083, 'n_tokens_neox': 2813, 'n_words': 602}