<commit_before>function mmg_interaction(mmg) {

    var mi = {},
        tooltips = [],
        exclusive = true,
        hide_on_move = true,
        show_on_hover = true,
        close_timer = null,
        formatter;

    mi.formatter = function(x) {
        if (!arguments.length) return formatter;
        formatter = x;
        return mi;
    };
    mi.formatter(function(feature) {
        var o = '',
            props = feature.properties;

        if (props.title) {
            o += '<strong>' + props.title + '</strong><br />';
        }
        if (props.description) {
            o += props.description;
        }

        if (typeof html_sanitize !== undefined) {
            o = html_sanitize(o,
                function(url) {
                    if (/^(https?:\/\/|data:image)/.test(url)) return url;
                },
                function(x) { return x; });
        }

        return o;
    });

    mi.hide_on_move = function(x) {
        if (!arguments.length) return hide_on_move;
        hide_on_move = x;
        return mi;
    };

    mi.exclusive = function(x) {
        if (!arguments.length) return exclusive;
        exclusive = x;
        return mi;
    };

    mi.show_on_hover = function(x) {
        if (!arguments.length) return show_on_hover;
        show_on_hover = x;
        return mi;
    };

    mi.hide_tooltips = function() {
        while (tooltips.length) mmg.remove(tooltips.pop());
        for (var i = 0; i < markers.length; i++) {
            delete markers[i].clicked;
        }
    };

    mi.bind_marker = function(marker) {
        var delayed_close = function() {
            if (!marker.clicked) close_timer = window.setTimeout(function() {
                mi.hide_tooltips();
            }, 200);
        };

        var show = function(e) {
            var content = formatter(marker.data);
            // Don't show a popup if the formatter returns an
            // empty string. This does not do any magic around DOM elements.
            if (!content) return;

            if (exclusive && tooltips.length > 0) {
                mi.hide_tooltips();
            }<commit_msg>Fix #15 - closing all tooltips due to exclusivity should also clear the timeout for hiding other markers.<commit_after>function mmg_interaction(mmg) {

    var mi = {},
        tooltips = [],
        exclusive = true,
        hide_on_move = true,
        show_on_hover = true,
        close_timer = null,
        formatter;

    mi.formatter = function(x) {
        if (!arguments.length) return formatter;
        formatter = x;
        return mi;
    };
    mi.formatter(function(feature) {
        var o = '',
            props = feature.properties;

        if (props.title) {
            o += '<strong>' + props.title + '</strong><br />';
        }
        if (props.description) {
            o += props.description;
        }

        if (typeof html_sanitize !== undefined) {
            o = html_sanitize(o,
                function(url) {
                    if (/^(https?:\/\/|data:image)/.test(url)) return url;
                },
                function(x) { return x; });
        }

        return o;
    });

    mi.hide_on_move = function(x) {
        if (!arguments.length) return hide_on_move;
        hide_on_move = x;
        return mi;
    };

    mi.exclusive = function(x) {
        if (!arguments.length) return exclusive;
        exclusive = x;
        return mi;
    };

    mi.show_on_hover = function(x) {
        if (!arguments.length) return show_on_hover;
        show_on_hover = x;
        return mi;
    };

    mi.hide_tooltips = function() {
        while (tooltips.length) mmg.remove(tooltips.pop());
        for (var i = 0; i < markers.length; i++) {
            delete markers[i].clicked;
        }
    };

    mi.bind_marker = function(marker) {
        var delayed_close = function() {
            if (!marker.clicked) close_timer = window.setTimeout(function() {
                mi.hide_tooltips();
            }, 200);
        };

        var show = function(e) {
            var content = formatter(marker.data);
            // Don't show a popup if the formatter returns an
            // empty string. This does not do any magic around DOM elements.
            if (!content) return;

            if (exclusive && tooltips.length > 0) {
                mi.hide_tooltips();
                // We've hidden all of the tooltips, so let's not close
                // the one that we're creating as soon as it is created.
                if (close_timer) window.clearTimeout(close_timer);
            }
{'fraction_non_alphanumeric': 0.11954624781849912, 'fraction_numerical': 0.002617801047120419, 'mean_word_length': 1.587471783295711, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4855854', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1293, 'n_words': 328}