<commit_before>/*
    This is the javascript needed by Slyde itself.
    
    Do not include your own javascript. Use user.js for that instead.
 */

(function() {
    var slides = document.querySelectorAll("body > section"),
        numberOfSlides = slides.length;

    for (var i = 0; i < numberOfSlides; i++) {
        var slide = slides[i];
        slide.id = "slide" + (i + 1);

        var nav = document.createElement("nav");

        if (i > 0) {
            var prev = document.createElement("a");
            prev.appendChild(document.createTextNode("<"));
            prev.href = "#slide" + i;
            nav.appendChild(prev);
        }

        var current = document.createElement("span");
        current.appendChild(document.createTextNode(" " + (i + 1) + " "));
        nav.appendChild(current);

        if (i < numberOfSlides - 1) {
            var next = document.createElement("a");
            next.appendChild(document.createTextNode(">"));
            next.href = "#slide" + (i + 2);
            nav.appendChild(next);
        }

        slide.appendChild(nav);
    }

    function getHiddenIncrementElements(onCurrentSlideOnly) {
        var root = onCurrentSlideOnly ? document.querySelector(location.hash) : document.body;

        return Array.apply(null, root.querySelectorAll(".increment:not(.show)"));
    }

    function getShownIncrementElements(onCurrentSlideOnly) {
        var root = onCurrentSlideOnly ? document.querySelector(location.hash) : document.body;

        return Array.apply(null, root.querySelectorAll(".increment.show"));
    }

    function addClass(element, className) {
        if (element.classList) {
            element.classList.add(className);
        } else {
            element.className = element.className + " " + className;
        }
    }

    function removeClass(element, className) {
        if (element.classList) {
            element.classList.remove(className);
        } else {
            element.className = element.className.replace(className, "").trim();
        }
    }

    function forward() {
        var hidden, nextSlide;

        hidden = getHiddenIncrementElements(true);

        if (hidden.length) {
            hidden[0].classList.add("show");
        } else {
            nextSlide = +location.hash.substring(6) + 1;

            if (nextSlide <= numberOfSlides) {
                location.hash = "#slide" + (nextSlide);
            }
        }
    }

    function fastForward() {
        var hidden = getHiddenIncrementElements();

        if (hidden.length) {
            hidden.forEach(function(inc) {
                inc.classList.add("show");
            });
        }

        if (+location.hash.substring(6) < numberOfSlides) {
            location.hash = "#slide" + numberOfSlides;
        }
    }

    function rewind() {
        var shown, previousSlide;

        shown = getShownIncrementElements(true);

        if (shown.length) {
            shown.pop().classList.remove("show");
        } else {
            previousSlide = +location.hash.substring(6) - 1;

            if (previousSlide > 0) {
                location.hash = "#slide" + previousSlide;
            }
        }
    }

    function fastRewind() {
        var shown = getShownIncrementElements();

        if (shown.length) {
            shown.forEach(function(inc) {
                inc.classList.remove("show");
            });
        }

        if (location.hash !== "#slide1") {
            location.hash = "#slide1";
        }
    }


    document.addEventListener("keyup", function(event) {
        if (/input|textarea/i.test(event.target.nodeName) && !(event.ctrlKey && event.shiftKey)) {
            return;
        }

        var key = event.keyCode;

        // Home
        if (key === 36) {
            fastRewind();
        }
        // End
        else if (key === 35) {
            fastForward();
        }
        // left arrow or page up
        else if (key === 37 || key === 33) {
            rewind();
        }
        // right arrow or page down
        else if (key === 39 || key === 34) {
            forward();
        }
    }, false);

    if (location.hash.indexOf("#slide") !== 0) {
        location.hash = "#slide1";
    }
})();<commit_msg>use existing slide ids, generate only when neccessary<commit_after>/*
    This is the javascript needed by Slyde itself.
    
    Do not include your own javascript. Use user.js for that instead.
 */

(function() {
    var slides = Array.apply(null, document.querySelectorAll('body > section'));

    function addId(slide, index) {
        if (!slide.id) {
            slide.id = 'slide' + (index + 1);
        }
    }

    function createLink(href, content) {
        var link = document.createElement('a');
        link.href = href;
        link.appendChild(document.createTextNode(content));

        return link;
    }

    function addNavigation(slide, i, slides) {
        var nav = document.createElement('nav');

        if (i > 0) {
            nav.appendChild(createLink('#' + slides[i - 1].id, '<'));
        }

        var current = document.createElement('span');
        current.appendChild(document.createTextNode(' ' + (i + 1) + ' '));
        nav.appendChild(current);

        if (i < slides.length - 1) {
            nav.appendChild(createLink('#' + slides[i + 1].id, '>'));
        }

        slide.appendChild(nav);        
    }

    function getCurrentSlide() {
        return document.querySelector(location.hash);
    }

    function getNextSlide(slide) {
        var index = slides.indexOf(slide);

        return slides[index + 1];
    }

    function getPreviousSlide(slide) {
        var index = slides.indexOf(slide);

        return slides[index - 1];
    }

    function getHiddenIncrementElements(onCurrentSlideOnly) {
        var root = onCurrentSlideOnly ? getCurrentSlide() : document.body;

        return Array.apply(null, root.querySelectorAll(".increment:not(.show)"));
    }

    function getShownIncrementElements(onCurrentSlideOnly) {
        var root = onCurrentSlideOnly ? getCurrentSlide() : document.body;

        return Array.apply(null, root.querySelectorAll(".increment.show"));
    }

    function forward() {
        var hidden, nextSlide, currentSlide;

        hidden = getHiddenIncrementElements(true);

        if (hidden.length) {
            hidden[0].classList.add("show");
        } else {
            currentSlide = getCurrentSlide();
            nextSlide = getNextSlide(currentSlide);

            if (nextSlide) {
                location.hash = nextSlide.id;
            }
        }
    }

    function fastForward() {
        var hidden = getHiddenIncrementElements();

        hidden.forEach(function(inc) {
            inc.classList.add("show");
        });

        location.hash = slides[slides.length - 1].id;
    }

    function rewind() {
        var shown, previousSlide, currentSlide;

        shown = getShownIncrementElements(true);

        if (shown.length) {
            shown[shown.length - 1].classList.remove('show');
        } else {
            currentSlide = getCurrentSlide();
            previousSlide = getPreviousSlide(currentSlide);

            if (previousSlide) {
                location.hash = previousSlide.id;
            }
        }
    }

    function fastRewind() {
        var shown = getShownIncrementElements();

        shown.forEach(function(inc) {
            inc.classList.remove('show');
        });

        location.hash = slides[0].id;
    }

    function getHash(slide) {
        return '#' + slide.id;
    }

    slides.forEach(addId);
    slides.forEach(addNavigation);

    document.addEventListener('keyup', function(event) {
        if (/input|textarea/i.test(event.target.nodeName) && !(event.ctrlKey && event.shiftKey)) {
            return;
        }

        var key = event.keyCode;

        // Home
        if (key === 36) {
            fastRewind();
        }
        // End
        else if (key === 35) {
            fastForward();
        }
        // left arrow or page up
        else if (key === 37 || key === 33) {
            rewind();
        }
        // right arrow or page down
        else if (key === 39 || key === 34) {
            forward();
        }
    }, false);

    if (slides.map(getHash).indexOf(location.hash) === -1) {
        location.hash = slides[0].id;
    }

})();
{'fraction_non_alphanumeric': 0.1321928460342146, 'fraction_numerical': 0.006579734417992583, 'mean_word_length': 1.8659581762084334, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '5839828', 'n_tokens_mistral': 2424, 'n_tokens_neox': 2308, 'n_words': 474}