<commit_before>/**
 * Sleep charter, main program
 * <NAME>, MIT license, 2017
 */

/*
 * Global state
 */

/**
 * Regex pattern for Google Sheets default date/time format (DD/MM/YYYY HH:mm:ss).
 *
 * Capture groups:
 * 1: DD (day)
 * 2: MM (month)
 * 3: YYYY (year)
 * 4: HH (24 hour)
 * 5: mm (minute)
 * 6: ss (second)
 * @type {RegExp}
 */
var GOOGLE_DATETIME_REGEX =
    /(\d{2}).(\d{2}).(\d{4}) (\d{2}):(\d{2}):(\d{2})/;

var DOM = {
    /** @type HTMLElement */
    sleepChart: null,
    dayBars:    {},
    sleepBars:  []
};

var STATE = {
    entries:    [],
    /** @type HTMLElement */
    selected:   null,
    rescaleIdx: 0,
    rescaling:  false
};

/*
 * Program logic
 */

function main()
{
    DOM.sleepChart = document.querySelector("#sleepChart");

    DOM.sleepChart.onmouseover = function (evt)
    {
        /** @type HTMLElement */
        var selected = evt.target;

        // Do nothing if already hovering over same bar
        if (STATE.selected === selected)
            return;

        // Remove selection class from previously selected bar
        if (STATE.selected !== null)
        {
            STATE.selected.classList.remove("selected");

            if (STATE.selected.pairedBar)
                STATE.selected.pairedBar.classList.remove("selected");

            STATE.selected = null;
        }

        // If started hovering over a(nother) bar
        if ( selected.classList.contains("bar") )
        {
            STATE.selected = selected;
            selected.classList.add("selected");

            if (STATE.selected.pairedBar)
                STATE.selected.pairedBar.classList.add("selected");

            console.log(selected.from, selected.to);
        }
    };

    fetch('sleepData.csv')
        .then(processResponse)
        .then(processData)
        .then(generateDOM)
        .then(finalize)
        .catch(processError);
}

function processResponse(response)
{
    if (!response.ok)
        throw new Error("Response is not OK", response);
    else
        return response.text();
}
<commit_msg>Implement horizontal scroll wheel<commit_after>/**
 * Sleep charter, main program
 * <NAME>, MIT license, 2017
 */

/*
 * Global state
 */

/**
 * Regex pattern for Google Sheets default date/time format (DD/MM/YYYY HH:mm:ss).
 *
 * Capture groups:
 * 1: DD (day)
 * 2: MM (month)
 * 3: YYYY (year)
 * 4: HH (24 hour)
 * 5: mm (minute)
 * 6: ss (second)
 * @type {RegExp}
 */
var GOOGLE_DATETIME_REGEX =
    /(\d{2}).(\d{2}).(\d{4}) (\d{2}):(\d{2}):(\d{2})/;

var DOM = {
    /** @type HTMLElement */
    sleepChart: null,
    dayBars:    {},
    sleepBars:  []
};

var STATE = {
    entries:    [],
    /** @type HTMLElement */
    selected:   null,
    rescaleIdx: 0,
    rescaling:  false
};

/*
 * Program logic
 */

function main()
{
    DOM.sleepChart = document.querySelector("#sleepChart");

    DOM.sleepChart.onmouseover = function (evt)
    {
        /** @type HTMLElement */
        var selected = evt.target;

        // Do nothing if already hovering over same bar
        if (STATE.selected === selected)
            return;

        // Remove selection class from previously selected bar
        if (STATE.selected !== null)
        {
            STATE.selected.classList.remove("selected");

            if (STATE.selected.pairedBar)
                STATE.selected.pairedBar.classList.remove("selected");

            STATE.selected = null;
        }

        // If started hovering over a(nother) bar
        if ( selected.classList.contains("bar") )
        {
            STATE.selected = selected;
            selected.classList.add("selected");

            if (STATE.selected.pairedBar)
                STATE.selected.pairedBar.classList.add("selected");

            console.log(selected.from, selected.to);
        }
    };

    document.onwheel = function(e)
    {
        if (e.ctrlKey || e.shiftKey)
            return;

        window.scrollBy(e.deltaY, 0);
        e.preventDefault();
    };

    fetch('sleepData.csv')
        .then(processResponse)
        .then(processData)
        .then(generateDOM)
        .then(finalize)
        .catch(processError);
}

function processResponse(response)
{
    if (!response.ok)
        throw new Error("Response is not OK", response);
    else
        return response.text();
}

{'fraction_non_alphanumeric': 0.14580914789876945, 'fraction_numerical': 0.009055026700719759, 'mean_word_length': 2.0531537916371367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3157220', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1322, 'n_words': 302}