<commit_before>{% extends "base.html" %}

{% block custom_js %}
    <script src="{{ url_for("static", filename="vendor/jquery-1.10.2.min.js") }}"></script>
    <script src="{{ url_for("static", filename="vendor/Chart-0.2.0.min.js") }}"></script>
    <script src="{{ url_for("static", filename="language_chart.js") }}"></script>
    <script src="{{ url_for("static", filename="vendor/jquery.dataTables.min.js") }}"></script>
    <script src="{{ url_for("static", filename="vendor/datatables-bootstrap3/assets/js/datatables.js") }}"></script>
    <script src="{{ url_for("static", filename="table.js") }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            {# Need list filter because reverse returns an iterator. #}
            var byte_stats = {{ language_bytes|dictsort(by="value")|reverse|list|tojson }};
            var developer_stats = {{ developer_counts|dictsort(by="value")|reverse|list|tojson }};

            if (byte_stats.length == 0) {
                $("#languages_chart").remove();
                $("#by_code_btn").remove();
                $("#by_dev_btn").remove();
                $("#chart_container").append(
                        "<br><h1 class='text-center'>" +
                                "No code found for this location." +
                                "</h1><br>");
                return;
            }

            // Only show the 10 most popular languages
            createBarChart("languages_chart", byte_stats.slice(0, 10));

            // Sort by developer count by default
            createDataTable("language_table", 2, "desc");

            // TODO clean up duplication
            $("#by_code_btn").click(function (event) {
                $("#by_code_btn").removeClass("btn-default");
                $("#by_dev_btn").removeClass("btn-success");
                $("#by_code_btn").addClass("btn-success");
                $("#by_dev_btn").addClass("btn-default");

                createBarChart("languages_chart", byte_stats.slice(0, 10));
            });

            $("#by_dev_btn").click(function (event) {
                $("#by_code_btn").removeClass("btn-success");
                $("#by_dev_btn").removeClass("btn-default");
                $("#by_code_btn").addClass("btn-default");
                $("#by_dev_btn").addClass("btn-success");

                createBarChart("languages_chart", developer_stats.slice(0, 10));
            });
        });
    </script>
{% endblock %}

{% block custom_nav_items %}
    <a href="{{ url_for("users_by_location", location=location) }}"
       class="btn btn-default navbar-btn">Back to User List</a>
{% endblock %}

{% block body %}

    <h1 class="text-center">Language usage in <b>{{ location }}</b></h1>

    <div class="text-center">
        <div class="btn-group">
            <button type="button" class="btn btn-success" id="by_code_btn">By Code Size (Bytes)</button>
            <button type="button" class="btn btn-default" id="by_dev_btn">By Number of Developers</button>
        </div>
    </div>

    <br>

    <div class="container-canvas" id="chart_container">
        <canvas id="languages_chart" width="800" height="400"></canvas>
    </div>

    <br><br>
    <h1 class="text-center">Click on a language below to find developers.</h1>
        <br>

        <div class="container">
            <div class="col-lg-offset-2 col-lg-8">
                <table class="table table-striped table-bordered" id="language_table">
                    <thead>
                    <tr>
                        <th>Programming Language</th><commit_msg>Made language stats by developer count by default.<commit_after>{% extends "base.html" %}

{% block custom_js %}
    <script src="{{ url_for("static", filename="vendor/jquery-1.10.2.min.js") }}"></script>
    <script src="{{ url_for("static", filename="vendor/Chart-0.2.0.min.js") }}"></script>
    <script src="{{ url_for("static", filename="language_chart.js") }}"></script>
    <script src="{{ url_for("static", filename="vendor/jquery.dataTables.min.js") }}"></script>
    <script src="{{ url_for("static", filename="vendor/datatables-bootstrap3/assets/js/datatables.js") }}"></script>
    <script src="{{ url_for("static", filename="table.js") }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            {# Need list filter because reverse returns an iterator. #}
            var byte_stats = {{ language_bytes|dictsort(by="value")|reverse|list|tojson }};
            var developer_stats = {{ developer_counts|dictsort(by="value")|reverse|list|tojson }};

            if (byte_stats.length == 0) {
                $("#languages_chart").remove();
                $("#by_code_btn").remove();
                $("#by_dev_btn").remove();
                $("#chart_container").append(
                        "<br><h1 class='text-center'>" +
                                "No code found for this location." +
                                "</h1><br>");
                return;
            }

            // Only show the 10 most popular languages
            createBarChart("languages_chart", developer_stats.slice(0, 10));

            // Sort by developer count by default
            createDataTable("language_table", 2, "desc");

            // TODO clean up duplication
            $("#by_code_btn").click(function (event) {
                $("#by_code_btn").removeClass("btn-default");
                $("#by_dev_btn").removeClass("btn-success");
                $("#by_code_btn").addClass("btn-success");
                $("#by_dev_btn").addClass("btn-default");

                createBarChart("languages_chart", byte_stats.slice(0, 10));
            });

            $("#by_dev_btn").click(function (event) {
                $("#by_code_btn").removeClass("btn-success");
                $("#by_dev_btn").removeClass("btn-default");
                $("#by_code_btn").addClass("btn-default");
                $("#by_dev_btn").addClass("btn-success");

                createBarChart("languages_chart", developer_stats.slice(0, 10));
            });
        });
    </script>
{% endblock %}

{% block custom_nav_items %}
    <a href="{{ url_for("users_by_location", location=location) }}"
       class="btn btn-default navbar-btn">Back to User List</a>
{% endblock %}

{% block body %}

    <h1 class="text-center">Language usage in <b>{{ location }}</b></h1>

    <div class="text-center">
        <div class="btn-group">
            <button type="button" class="btn btn-success" id="by_dev_btn">By Number of Developers</button>
            <button type="button" class="btn btn-default" id="by_code_btn">By Code Size (Bytes)</button>
        </div>
    </div>

    <br>

    <div class="container-canvas" id="chart_container">
        <canvas id="languages_chart" width="800" height="400"></canvas>
    </div>

    <br><br>
    <h1 class="text-center">Click on a language below to find developers.</h1>
        <br>

        <div class="container">
            <div class="col-lg-offset-2 col-lg-8">
                <table class="table table-striped table-bordered" id="language_table">
                    <thead>
                    <tr>
                        <th>Programming Language</th>
{'fraction_non_alphanumeric': 0.17811810154525387, 'fraction_numerical': 0.009657836644591612, 'mean_word_length': 2.3390142791340396, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2551326', 'n_tokens_mistral': 2130, 'n_tokens_neox': 2038, 'n_words': 386}