<commit_before>'use strict';

var GOOD = "#0d0";
var BAD = "#ff0000";
var NEUTRAL = "#bbb";
var HOLDER = '#map-holder';
var STROKE_WIDTH = 1.5;
var RIVER_WIDTH = STROKE_WIDTH * 2;
var WATER_COLOR = "#73c5ef";
var ANIMATION_TIME_MS = 500;

(function(window, $K, undefined){

var times = {};
var time;
function profile(message) {
    if (!times[message]) {
        times[message] = new Date().getTime();
    } else {
        time = new Date().getTime() - times[message];
        console.log(message, time, "ms");
        times[message] = undefined;
    }
}

window.initMap = function(config, callback) {

    var map = $K.map(HOLDER);
    var panZoom;
    var layers;

    var holderInitHeight = $(HOLDER).height();
    var mapAspectRatio;

    $.fn.qtip.defaults.style.classes = 'qtip-dark';

    var scale = chroma.scale([BAD, "#ff4500", "#ffa500", "#ffff00", GOOD]);

    var layerConfig = {};
    layerConfig.bg = {
        'styles' : {
            'fill' : NEUTRAL,
            'stroke-width' : STROKE_WIDTH,
            'transform' : ""
        }
    };

    layerConfig.states = {
        'styles' : {
            'fill' : function(d) {
                var state = config.states && config.states[d.name];
                return (state
                    ? (scale(state.probability).brighten((1 - state.certainty) * 80).hex())
                    : '#fff');
            },
            'stroke-width' : STROKE_WIDTH,
            'transform' : ""
        },
        'click' : function(data, path, event) {
            console.log(data["name"]);
            if (config.click != undefined) {
                config.click(data.name);
            }
        }
    };

    if (config.showTooltips) {
        layerConfig.states.tooltips = function(d) {
            var state = config.states && config.states[d.name];
            var name = ( state
                ? '<span class="label">'
                    + '<i class="flag-' + d.name + '"></i> '
                    + state.name
                    + '</span>'
                : '<br>Zatím neprocvičováno<br><br>');
            var description = (state
                ? '<div>'
                    + '<i class="color-indicator" style="background-color:'
                    + scale(state.probability).hex() + '"></i>'
                    + ' Úspěšnost: ' + Math.round(100 * state.probability) + '%</div>'
                : "");
            return [
                name + description,
                config.states[d.name] ? config.states[d.name].name : ""
            ];
        };
    }

    layerConfig.provinces = jQuery.extend({}, layerConfig.states);
    layerConfig.cities = jQuery.extend(jQuery.extend({}, layerConfig.states), {
        'mouseenter' : function(data, path, event) {
            path.toFront();
            var zoomRatio = 2;
            var aminAttrs = {
                'transform' : "s"+zoomRatio,
                'stroke-width' : zoomRatio * STROKE_WIDTH<commit_msg>'uspesnost' replaced by 'odhad znalosti'<commit_after>'use strict';

var GOOD = "#0d0";
var BAD = "#ff0000";
var NEUTRAL = "#bbb";
var HOLDER = '#map-holder';
var STROKE_WIDTH = 1.5;
var RIVER_WIDTH = STROKE_WIDTH * 2;
var WATER_COLOR = "#73c5ef";
var ANIMATION_TIME_MS = 500;

(function(window, $K, undefined){

var times = {};
var time;
function profile(message) {
    if (!times[message]) {
        times[message] = new Date().getTime();
    } else {
        time = new Date().getTime() - times[message];
        console.log(message, time, "ms");
        times[message] = undefined;
    }
}

window.initMap = function(config, callback) {

    var map = $K.map(HOLDER);
    var panZoom;
    var layers;

    var holderInitHeight = $(HOLDER).height();
    var mapAspectRatio;

    $.fn.qtip.defaults.style.classes = 'qtip-dark';

    var scale = chroma.scale([BAD, "#ff4500", "#ffa500", "#ffff00", GOOD]);

    var layerConfig = {};
    layerConfig.bg = {
        'styles' : {
            'fill' : NEUTRAL,
            'stroke-width' : STROKE_WIDTH,
            'transform' : ""
        }
    };

    layerConfig.states = {
        'styles' : {
            'fill' : function(d) {
                var state = config.states && config.states[d.name];
                return (state
                    ? (scale(state.probability).brighten((1 - state.certainty) * 80).hex())
                    : '#fff');
            },
            'stroke-width' : STROKE_WIDTH,
            'transform' : ""
        },
        'click' : function(data, path, event) {
            console.log(data["name"]);
            if (config.click != undefined) {
                config.click(data.name);
            }
        }
    };

    if (config.showTooltips) {
        layerConfig.states.tooltips = function(d) {
            var state = config.states && config.states[d.name];
            var name = ( state
                ? '<span class="label">'
                    + '<i class="flag-' + d.name + '"></i> '
                    + state.name
                    + '</span>'
                : '<br>Zatím neprocvičováno<br><br>');
            var description = (state
                ? '<div>'
                    + '<i class="color-indicator" style="background-color:'
                    + scale(state.probability).hex() + '"></i>'
                    + ' Odhad znalosti: ' + Math.round(100 * state.probability) + '%</div>'
                : "");
            return [
                name + description,
                config.states[d.name] ? config.states[d.name].name : ""
            ];
        };
    }

    layerConfig.provinces = jQuery.extend({}, layerConfig.states);
    layerConfig.cities = jQuery.extend(jQuery.extend({}, layerConfig.states), {
        'mouseenter' : function(data, path, event) {
            path.toFront();
            var zoomRatio = 2;
            var aminAttrs = {
                'transform' : "s"+zoomRatio,
                'stroke-width' : zoomRatio * STROKE_WIDTH
{'fraction_non_alphanumeric': 0.15675675675675677, 'fraction_numerical': 0.010472972972972974, 'mean_word_length': 1.7135655362053162, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '812135', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1782, 'n_words': 344}