<commit_before>// Sketch of browsercast / revealjs integration.
(function (global, document, $, deck, window, undefined) {

    var $document = $(document);

    function SlideCue(time, slideIndex) {
        this.time = time;
        this.slideIndex = slideIndex;
    }

    SlideCue.prototype = {
        focus: function () {
            $.deck('go', this.slideIndex);
        }
    };

    function parseCueTime(tag) {
        return parseFloat($(tag).attr('data-bccue'));
    }

    function getSlideCues() {
        var slides, slideCues, cue, cueTime, subCues;
        // Get a list of the slides and their cue tnimes.
        slides = $.deck('getSlides');
        slideCues = [];
        for (i = 0; i < slides.length; i += 1) {
            if (typeof slides[i].attr('data-bccue') !== 'undefined') {
                cueTime = parseCueTime(slides[i]);
                cue = new SlideCue(cueTime, i);
                slideCues.push(cue);
            }
        }
        return slideCues;
    }

    function setCueLength() {
        var markers, markerLength, divs, slideCues, borderWidth;
        slideCues = getSlideCues();
        markers = document.getElementById('markers');
        borderWidth = 2;
        markerLength = markers.offsetWidth / slideCues.length - borderWidth;
        divs = document.getElementsByClassName('cue');
        for (var i = 0; i < divs.length; i++) {
            divs[i].setAttribute("style","width:" + markerLength + "px");
        };
    }

    function onCueClick(cue, popcorn) {
       popcorn.currentTime(cue.time);
    }

    // Use the audio timeupdates to drive existing slides.
    function playBrowserCast() {
        var audio, slideCues, popcorn, markers, div;

        slideCues = getSlideCues();

        // Look for the browsercast audio element.
        audio = document.getElementById('browsercast-audio');
        markers = document.getElementById('markers');

        popcorn = Popcorn(audio);

        var i = 0;
        slideCues.forEach(function (cue) {
            div = document.createElement('div');
            div.className = 'cue';
            div.setAttribute('data', "time:"+cue.time);
            cue.div = div;
            div.onclick = function(event) {
                        return onCueClick.call(this, cue, popcorn);
                    };
            markers.appendChild(div);

            popcorn.cue(i++, cue.time, function () {
                transitionLock = true;
                cue.focus();
                var active = document.querySelector(".active");
                if (active != null) active.classList.remove("active");
                cue.div.classList.add("active");
                transitionLock = false;
            });
        });
        setCueLength();

        window.onresize = setCueLength;

        // lock for preventing slidechanged event handler during timeupdate handler.
        // TODO using a mutex seems clunky.
        var transitionLock = false;<commit_msg>cues/markers now have a size that is proportionnal to their duration<commit_after>// Sketch of browsercast / revealjs integration.
(function (global, document, $, deck, window, undefined) {

    var $document = $(document);

    function SlideCue(time, slideIndex) {
        this.time = time;
        this.slideIndex = slideIndex;
    }

    SlideCue.prototype = {
        focus: function () {
            $.deck('go', this.slideIndex);
        }
    };

    function parseCueTime(tag) {
        return parseFloat($(tag).attr('data-bccue'));
    }

    function getSlideCues() {
        var slides, slideCues, cue, cueTime, subCues;
        // Get a list of the slides and their cue tnimes.
        slides = $.deck('getSlides');
        slideCues = [];
        for (i = 0; i < slides.length; i += 1) {
            if (typeof slides[i].attr('data-bccue') !== 'undefined') {
                cueTime = parseCueTime(slides[i]);
                cue = new SlideCue(cueTime, i);
                slideCues.push(cue);
            }
        }
        return slideCues;
    }

    function estimateTotalDuration(popcorn) {
        return popcorn.duration();
    }

    function setCueLength(slideCues, totalDuration) {
        var markers, markerLength, divs;
        markers = document.getElementById('markers');
        var from = 0;
        for (i in slideCues) {
            var to = i == slideCues.length - 1 ? totalDuration : slideCues[parseInt(i)+1].time;
            var pc = 100 * (to - from) / totalDuration;
            from = to;
            slideCues[i].div.setAttribute("style", "width:" + pc + "%; box-sizing: border-box;");
        }
    }

    function onCueClick(cue, popcorn) {
       popcorn.currentTime(cue.time);
    }

    // Use the audio timeupdates to drive existing slides.
    function playBrowserCast() {
        var audio, slideCues, popcorn, markers, div;

        slideCues = getSlideCues();

        // Look for the browsercast audio element.
        audio = document.getElementById('browsercast-audio');
        markers = document.getElementById('markers');

        popcorn = Popcorn(audio);

        var i = 0;
        slideCues.forEach(function (cue) {
            div = document.createElement('div');
            div.className = 'cue';
            div.setAttribute('data', "time:"+cue.time);
            cue.div = div;
            div.onclick = function(event) {
                        return onCueClick.call(this, cue, popcorn);
                    };
            markers.appendChild(div);

            popcorn.cue(i++, cue.time, function () {
                transitionLock = true;
                cue.focus();
                var active = document.querySelector(".active");
                if (active != null) active.classList.remove("active");
                cue.div.classList.add("active");
                transitionLock = false;
            });
        });
        setCueLength(slideCues, estimateTotalDuration(popcorn));

        window.onresize = setCueLength;

        // lock for preventing slidechanged event handler during timeupdate handler.
        // TODO using a mutex seems clunky.
        var transitionLock = false;
{'fraction_non_alphanumeric': 0.12096511248777307, 'fraction_numerical': 0.0022823606129768505, 'mean_word_length': 1.9256080114449212, 'pattern_counts': {'":': 0, '<': 6, '<?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': '1844390', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1681, 'n_words': 406}