{"size": 1796, "ext": "js", "max_stars_repo_path": "src/js/index.js", "max_stars_repo_name": "suryaprakashs/what-am-i-doing", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/js/index.js", "max_issues_repo_name": "suryaprakashs/what-am-i-doing", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/js/index.js", "max_forks_repo_name": "suryaprakashs/what-am-i-doing", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.9444444444, "max_line_length": 97, "alphanum_fraction": 0.4432071269}
var today = getTodayKey();

chrome.storage.local.get(today, function (result) {
    todayData = result[today] || [];

    var sitelist = {};
    for (var i = 0; i < todayData.length; i++) {
        var h = getHost(todayData[i].url);
        if (sitelist[h])
            sitelist[h]++;
        else
            sitelist[h] = 1;
    }

    var sites = Object.keys(sitelist).sort(function (a, b) { return sitelist[b] - sitelist[a] });

    var siteCount = [];

    for (var i = 0; i < sites.length; i++) {
        siteCount.push(sitelist[sites[i]]);
    }

    var chartData = {
        labels: sites,
        datasets: [{
            label: 'Site usage',
            backgroundColor: "rgb(33, 150, 243)",
            borderWidth: 1,
            data: siteCount
        }]

    };

    function loadChart() {
        var ctx = document.getElementById('canvas').getContext('2d');
        window.myHorizontalBar = new Chart(ctx, {
            type: 'horizontalBar',
            data: chartData,
            options: {
                elements: {
                    rectangle: {
                        borderWidth: 2,
                    }
                },
                responsive: true,
                legend: {
                    position: 'right',
                },
                title: {
                    display: true,
                    text: 'What am I doing?'
                }
            }
        });

    };

    loadChart();

    var visual = document.getElementById("reset-stat");
    visual.onclick = function () {
        chrome.storage.local.clear(function () {
            var error = chrome.runtime.lastError;
            if (error) {
                console.error(error);
                return;
            }

            chrome.tabs.reload();
        });
    }
});