<commit_before>(function() {
    z.page.on('fragmentloaded', function() {
        var $document = $(document),
            $lightbox = $('#lightbox'),
            $content = $lightbox.find('.content'),
            $caption = $lightbox.find('.caption span'),
            $previews = $('.previews'),
            current, $strip,
            lbImage = template('<img id="preview{0}" src="{1}">'),
            lbVideo = template('<video id="preview{0}" src="{1}" controls autoplay' +
                               'preload="auto" type="video/webm"></video>');
        if (!$lightbox.length) return;
        function showLightbox() {
            $lightbox.show();
            showImage(this);
            $(window).bind('keydown.lightboxDismiss', function(e) {
                switch (e.which) {
                    case z.keys.ESCAPE:
                        e.preventDefault();
                        hideLightbox();
                        break;
                    case z.keys.LEFT:
                        e.preventDefault();
                        showPrev();
                        break;
                    case z.keys.RIGHT:
                        e.preventDefault();
                        showNext();
                        break;
                }
            });
            //I want to ensure the lightbox is painted before fading it in.
            setTimeout(function() {
                $lightbox.addClass('show');
            }, 0);
        }
        function hideLightbox() {
            pauseVideo();
            $lightbox.removeClass('show');
            // We can't trust transitionend to fire in all cases.
            setTimeout(function() {
                $lightbox.hide();
            }, 500);
            $(window).unbind('keydown.lightboxDismiss');
        }
        function cookieCutter(values) {
            if (values[1].indexOf('.webm') > 0) {
                return lbVideo(values);
            } else {
                return lbImage(values);
            }
        }
        function pauseVideo() {
            var $video = $content.find('video:visible');
            if ($video.length) {
                $video.blur();
                $video[0].pause();
            }
        }
        function showImage(a) {
            var $a = $(a),
                $oldimg = $lightbox.find('img, video');
            current = $a.parent().index();
            $strip = $a.closest('ul').find('li');
            $previews.find('.panel').removeClass('active')
                     .eq(current).addClass('active');
            var $img = $('#preview'+current);
            if ($img.length) {
                $oldimg.removeClass('show');
                $img.addClass('show');
                $img.filter('video').focus();
            } else {
                $img = $(cookieCutter([current, $a.attr('href')]));
                $content.append($img);
                $img.bind('load loadstart', function(e) {
                    $oldimg.removeClass('show');
                    $img.addClass('show');
                    $img.filter('video').focus();
                    for (var i=0; i<$strip.length; i++) {
                        if (i != current) {
                            var $p = $strip.eq(i).find('a');
                            $content.append(cookieCutter([i, $p.attr('href')]));
                        }
                    }
                });
            }
            $caption.text($a.attr('title'))
                    .removeAttr('style oldtext')
                    .truncate({dir: 'v'});
            $lightbox.find('.control').removeClass('disabled');
            if (current < 1) {
                $lightbox.find('.control.prev').addClass('disabled');
            }
            if (current == $strip.length-1) {
                $lightbox.find('.control.next').addClass('disabled');
            }
        }
        function showNext() {
            if (current < $strip.length-1) {
                showImage($strip.eq(current + 1).find('a'));
                pauseVideo();
                if (!this.window) {
                    $(this).blur();
                }
            }
        }
        function showPrev() {
            if (current > 0) {
                showImage($strip.eq(current - 1).find('a'));
                pauseVideo();
                if (!this.window) {
                    $(this).blur();
                }
            }
        }<commit_msg>don't preload previews for the time being, trying to prevent duping<commit_after>(function() {
    z.page.on('fragmentloaded', function() {
        var $document = $(document),
            $lightbox = $('#lightbox'),
            $content = $lightbox.find('.content'),
            $caption = $lightbox.find('.caption span'),
            $previews = $('.previews'),
            current, $strip,
            lbImage = template('<img id="preview{0}" src="{1}">'),
            lbVideo = template('<video id="preview{0}" src="{1}" ' +
                               'preload="auto" controls type="video/webm"> ' +
                               '</video>');
        if (!$lightbox.length) return;
        function showLightbox() {
            $lightbox.show();
            showImage(this);
            $(window).bind('keydown.lightboxDismiss', function(e) {
                switch (e.which) {
                    case z.keys.ESCAPE:
                        e.preventDefault();
                        hideLightbox();
                        break;
                    case z.keys.LEFT:
                        e.preventDefault();
                        showPrev();
                        break;
                    case z.keys.RIGHT:
                        e.preventDefault();
                        showNext();
                        break;
                }
            });
            //I want to ensure the lightbox is painted before fading it in.
            setTimeout(function() {
                $lightbox.addClass('show');
            }, 0);
        }
        function hideLightbox() {
            pauseVideo();
            $lightbox.removeClass('show');
            // We can't trust transitionend to fire in all cases.
            setTimeout(function() {
                $lightbox.hide();
            }, 500);
            $(window).unbind('keydown.lightboxDismiss');
        }
        function cookieCutter(values) {
            if (values[1].indexOf('.webm') > 0) {
                return lbVideo(values);
            } else {
                return lbImage(values);
            }
        }
        function pauseVideo() {
            var $video = $content.find('video:visible');
            if ($video.length) {
                $video.blur();
                $video[0].pause();
            }
        }
        function showImage(a) {
            var $a = $(a),
                $oldimg = $lightbox.find('img, video');
            current = $a.parent().index();
            $strip = $a.closest('ul').find('li');
            $previews.find('.panel').removeClass('active')
                     .eq(current).addClass('active');
            var $img = $('#preview'+current);
            if ($img.length) {
                $oldimg.removeClass('show');
                $img.addClass('show');
                $img.filter('video').focus();
            } else {
                console.log('no match found!', '#preview'+current, $img);
                $img = $(cookieCutter([current, $a.attr('href')]));
                $content.append($img);
                $img.bind('load loadstart', function(e) {
                    $oldimg.removeClass('show');
                    $img.addClass('show');
                //     for (var i=0; i<$strip.length; i++) {
                //         if (i != current) {
                //             var $p = $strip.eq(i).find('a');
                //             $content.append(cookieCutter([i, $p.attr('href')]));
                //         }
                //     }
                });
            }
            $caption.text($a.attr('title'))
                    .removeAttr('style oldtext')
                    .truncate({dir: 'v'});
            $lightbox.find('.control').removeClass('disabled');
            if (current < 1) {
                $lightbox.find('.control.prev').addClass('disabled');
            }
            if (current == $strip.length-1) {
                $lightbox.find('.control.next').addClass('disabled');
            }
        }
        function showNext() {
            if (current < $strip.length-1) {
                showImage($strip.eq(current + 1).find('a'));
                pauseVideo();
                if (!this.window) {
                    $(this).blur();
                }
            }
        }
        function showPrev() {
            if (current > 0) {
                showImage($strip.eq(current - 1).find('a'));
                pauseVideo();
                if (!this.window) {
                    $(this).blur();
                }
            }
        }
{'fraction_non_alphanumeric': 0.15160317282985142, 'fraction_numerical': 0.00402189699474919, 'mean_word_length': 1.1539942252165545, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3677436', 'n_tokens_mistral': 2300, 'n_tokens_neox': 2182, 'n_words': 390}