{"size": 2806, "ext": "js", "max_stars_repo_path": "website/themes/redispwned/static/js/charts.js", "max_stars_repo_name": "mikeblum/redispwned", "max_stars_repo_stars_event_min_datetime": "2021-05-03T14:40:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-04T01:05:59.000Z", "max_issues_repo_path": "website/themes/redispwned/static/js/charts.js", "max_issues_repo_name": "mikeblum/redispwned", "max_issues_repo_issues_event_min_datetime": "2021-06-17T16:30:38.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-13T01:13:59.000Z", "max_forks_repo_path": "website/themes/redispwned/static/js/charts.js", "max_forks_repo_name": "mikeblum/redispwned", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 29.8510638298, "max_line_length": 82, "alphanum_fraction": 0.4754098361}
document.addEventListener("DOMContentLoaded", function(event) {
    serversByCountry();
    serversByVersion();
}, {once: true});

function serversByCountry() {
    var request = new XMLHttpRequest();
    request.open('GET', 'https://api.redispwned.app/v1/servers-by-country', true);

    request.onload = function() {
        if (this.status >= 200 && this.status < 400) {
            var jsonData = JSON.parse(this.response);
            const data = {
                labels: jsonData.labels,
                datasets: [{
                    label: 'Exposed Redis Servers By Country',
                    // Redis Labs red
                    backgroundColor: '#cd5d57',
                    borderColor: 'rgb(255, 99, 132)',
                    data: jsonData.data,
                }]
            };
            const config = {
                type: 'bar',
                data,
                // horizontal-bar-chart
                options: {
                    indexAxis: 'y',
                }
            };
            if (window.serversByCountryChart) {
                window.serversByCountryChart.destroy();
            }

            window.serversByCountryChart = new Chart(
                document.getElementById('servers-by-country'),
                config
            );
        } else {
            console.log("Failed to render report")
        }
    };

    request.onerror = reportError

    request.send();
}

function serversByVersion() {
    var request = new XMLHttpRequest();
    request.open('GET', 'https://api.redispwned.app/v1/servers-by-version', true);

    request.onload = function() {
        if (this.status >= 200 && this.status < 400) {
            var jsonData = JSON.parse(this.response);
            const data = {
                labels: jsonData.labels,
                datasets: [{
                    label: 'Exposed Redis Servers By Version',
                    // Redis Labs red
                    backgroundColor: '#cd5d57',
                    borderColor: 'rgb(255, 99, 132)',
                    data: jsonData.data,
                }]
            };
            const config = {
                type: 'bar',
                data,
                // horizontal-bar-chart
                options: {
                    indexAxis: 'y',
                }
            };
            if (window.serversByVersionChart) {
                window.serversByVersionChart.destroy();
            }
            window.serversByVersion = new Chart(
                document.getElementById('servers-by-version'),
                config
            );
        } else {
            console.log("Failed to render report")
        }
    };

    request.onerror = reportError

    request.send();
}

function reportError() {
    console.log("Failed to fetch report")
}
