<commit_before>$(function() {
    var SLIDE_WIDTH = 400;

    var findSlider = function(event) {
        return $(event.target).closest('.slider');
    }

    var isFirstSlide = function($slider, marginLeft) {
        return marginLeft == 0;
    }

    var isLastSlide = function($slider, marginLeft) {
        return marginLeft == lastSlideMarginLeft($slider);
    }

    var lastSlideMarginLeft = function($slider) {
        var numberOfSlides = $slider.find('.slide').length;
        return -1 * SLIDE_WIDTH * (numberOfSlides - 1);
    }

    $('.slider-prev').on('click', function(event) {
        var $slider = findSlider(event);
        var $slideWindow = $slider.find('.slide-window');

        var marginLeftPx = $slideWindow.css('marginLeft');
        var marginLeft = parseInt(marginLeftPx, 10);

        if (marginLeft % SLIDE_WIDTH != 0)
            return;

        if (isFirstSlide($slider, marginLeft))
            $slideWindow.css({ marginLeft: lastSlideMarginLeft($slider) });
        else
            $slideWindow.css({ marginLeft: marginLeft + SLIDE_WIDTH });
    });

    $('.slider-next').on('click', function(event) {
        var $slider = findSlider(event);
        var $slideWindow = $slider.find('.slide-window');

        var marginLeftPx = $slideWindow.css('marginLeft');
        var marginLeft = parseInt(marginLeftPx, 10);

        if (marginLeft % SLIDE_WIDTH != 0)
            return;

        if (isLastSlide($slider, marginLeft))
            $slideWindow.css({ marginLeft: '0px' });
        else
            $slideWindow.css({ marginLeft: marginLeft - SLIDE_WIDTH + 'px' });
    });
});<commit_msg>Revise slider<commit_after>$(function() {
    var currentSlide = 0;

    var findSlider = function(event) {
        return $(event.target).closest('.slider');
    }

    var isFirstSlide = function() {
        return currentSlide == 0;
    }

    var isLastSlide = function($slider) {
        return currentSlide == lastSlide($slider);
    }

    var lastSlide = function($slider) {
        return $slider.find('.slide').length - 1;
    }

    var slideWidth = function($slider) {
        return $slider.width();
    }

    $('.slider-prev').on('click', function(event) {
        var $slider = findSlider(event);
        var $slideWindow = $slider.find('.slide-window');

        if (isFirstSlide())
            currentSlide = lastSlide($slider);
        else
            currentSlide -= 1;

        $slideWindow.css({ marginLeft: -1 * currentSlide * slideWidth($slider) });
    });

    $('.slider-next').on('click', function(event) {
        var $slider = findSlider(event);
        var $slideWindow = $slider.find('.slide-window');

        if (isLastSlide($slider))
            currentSlide = 0;
        else
            currentSlide += 1;

        $slideWindow.css({ marginLeft: -1 * currentSlide * slideWidth($slider) });
    });
});
{'fraction_non_alphanumeric': 0.14947735191637632, 'fraction_numerical': 0.007317073170731708, 'mean_word_length': 2.454873646209386, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1618569', 'n_tokens_mistral': 871, 'n_tokens_neox': 840, 'n_words': 170}