<commit_before>"use strict";

var arc,
    τ = 2 * Math.PI;
  
var data,
    default_choice = "choice-privacy";

var color = new Object();
    color["choice-privacy"] = "#e24063";
    color["choice-opportunity"] = "#682567";
    color["choice-access"] = "#092c74",
    color["choice-freedom"] = "#81bc2e",
    color["choice-learning"] = "#f18903",
    color["choice-control"] = "#c43a31";
    
var icon = new Object();
	icon["choice-privacy"] = 'fa-eye';
    icon["choice-opportunity"] = 'fa-heart';
    icon["choice-access"] = 'fa-user';
    icon["choice-freedom"] = 'fa-check-circle-o';
    icon["choice-learning"] = 'fa-book';
    icon["choice-control"] = 'fa-cogs';

$(document).ready(function () {
    $("#country").select2();
    
    assignStatsEventListeners();
    drawCharts();
  
    $(".key-stats-panel ul .choice-privacy a")
        .toggleClass("selected")
});

function assignStatsEventListeners() {
    $(".key-stats-panel a").on("click", function () {
        var choice = $(this)[0].parentNode.className;
        
        //update chart 1
        updateDonut(data.GLOBAL[choice], choice);
        $(".donut-icon i")
            .removeClass("fa-eye fa-heart fa-user fa-check-circle-o fa-book fa-cogs")
            .addClass(icon[choice]);
        
        $(".key-stats-panel a").removeClass("selected");
        $(this).toggleClass("selected");
    
        return false;
    });
}

function drawCharts() {
    $(".stats-panel-contents svg").empty();
  
    d3.json("/static/data/dummy-stats.json", function(json_data) {
        data = json_data;
        
	    //add donut prose, all of them, to the html page
	    $.each(json_data.GLOBAL, function(i, d) {
	        $("." + i + "-prose .percentage").html(Math.round(d*100) + "%");
	    })
	    
        drawDonut(json_data.GLOBAL[default_choice]);
    });
}

function updateDonut(data, current_choice) {
    $(".donut-prose p").html($("." + current_choice + "-prose").html());

    d3.select(".donut-foreground").transition()
        .duration(950)
        .style("fill", color[current_choice])
        .style("stroke", color[current_choice])
        .call(arcTween, data * τ);
      
    function arcTween(transition, newAngle) {
        transition.attrTween("d", function(d) {
            var interpolate = d3.interpolate(d.endAngle, newAngle);
            return function(t) {
                d.endAngle = interpolate(t);
                return arc(d);
            };
        });
     }
}

function drawDonut(data) {
    $(".donut-prose p").html($("." + default_choice + "-prose").html());<commit_msg>% literal is in template wrapper now<commit_after>"use strict";

var arc,
    τ = 2 * Math.PI;
  
var data,
    default_choice = "choice-privacy";

var color = new Object();
    color["choice-privacy"] = "#e24063";
    color["choice-opportunity"] = "#682567";
    color["choice-access"] = "#092c74",
    color["choice-freedom"] = "#81bc2e",
    color["choice-learning"] = "#f18903",
    color["choice-control"] = "#c43a31";
    
var icon = new Object();
	icon["choice-privacy"] = 'fa-eye';
    icon["choice-opportunity"] = 'fa-heart';
    icon["choice-access"] = 'fa-user';
    icon["choice-freedom"] = 'fa-check-circle-o';
    icon["choice-learning"] = 'fa-book';
    icon["choice-control"] = 'fa-cogs';

$(document).ready(function () {
    $("#country").select2();
    
    assignStatsEventListeners();
    drawCharts();
  
    $(".key-stats-panel ul .choice-privacy a")
        .toggleClass("selected")
});

function assignStatsEventListeners() {
    $(".key-stats-panel a").on("click", function () {
        var choice = $(this)[0].parentNode.className;
        
        //update chart 1
        updateDonut(data.GLOBAL[choice], choice);
        $(".donut-icon i")
            .removeClass("fa-eye fa-heart fa-user fa-check-circle-o fa-book fa-cogs")
            .addClass(icon[choice]);
        
        $(".key-stats-panel a").removeClass("selected");
        $(this).toggleClass("selected");
    
        return false;
    });
}

function drawCharts() {
    $(".stats-panel-contents svg").empty();
  
    d3.json("/static/data/dummy-stats.json", function(json_data) {
        data = json_data;
        
	    //add donut prose, all of them, to the html page
	    $.each(json_data.GLOBAL, function(i, d) {
	        $("." + i + "-prose .percentage").html(Math.round(d*100));
	    })
	    
        drawDonut(json_data.GLOBAL[default_choice]);
    });
}

function updateDonut(data, current_choice) {
    $(".donut-prose p").html($("." + current_choice + "-prose").html());

    d3.select(".donut-foreground").transition()
        .duration(950)
        .style("fill", color[current_choice])
        .style("stroke", color[current_choice])
        .call(arcTween, data * τ);
      
    function arcTween(transition, newAngle) {
        transition.attrTween("d", function(d) {
            var interpolate = d3.interpolate(d.endAngle, newAngle);
            return function(t) {
                d.endAngle = interpolate(t);
                return arc(d);
            };
        });
     }
}

function drawDonut(data) {
    $(".donut-prose p").html($("." + default_choice + "-prose").html());
{'fraction_non_alphanumeric': 0.1884563238427271, 'fraction_numerical': 0.01588223900832849, 'mean_word_length': 2.573702422145329, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4204848', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1673, 'n_words': 287}