<commit_before>var Familiarity = function () {
    this.familiarityRenderedFlag = false;
    this.familiaritiesUrl = '<%= Familiarity::Engine.routes.url_helpers.familiarities_path(format: :json) %>';
    this.familiarity_hash_pointer = -1;
    this.familiarity_hash = {};
    this.familiarity_bubbles = [];

    // Show and hide on F1 and ESC key respectively
    var _this = this;
    $(document).keyup(function (e) {
        if (e.keyCode == 27 && _this.familiarityRenderedFlag) { //ESC key pressed
            _this.familiarityView(false);
        }
        if (e.keyCode == 112 && !_this.familiarityRenderedFlag) { //F1 key pressed
            _this.familiarityView(true);
        }
        if (e.keyCode == 37 && _this.familiarityRenderedFlag) { //LEFT arrow key pressed
            _this.showPreviousBubble();
        }
        if (e.keyCode == 39 && _this.familiarityRenderedFlag) { //RIGHT arrow key pressed
            _this.showNextBubble()
        }
    });
}
Familiarity.prototype = {
    familiarity_hash_keys: function () {
        return($.map(this.familiarity_hash, function (v, k) {
            return k;
        }));
    },
    showNextBubble: function () {
        if (this.familiarity_hash_keys().length <= 0) {
            return false;
        }
        this.familiarity_hash_pointer++;
        if ((this.familiarity_hash_pointer + 1) > this.familiarity_hash_keys().length) {
            this.familiarity_hash_pointer = 0;
        }
        this.showOneByOne();
    },
    showPreviousBubble: function () {
        if (this.familiarity_hash_keys().length <= 0) {
            return false;
        }
        this.familiarity_hash_pointer--;
        if (this.familiarity_hash_pointer < 0) {
            this.familiarity_hash_pointer = this.familiarity_hash_keys().length - 1;
        }
        this.showOneByOne();
    },
    showOneByOne: function () {
        console.log(this.familiarity_hash_pointer);
        console.log(this.familiarity_hash);
        console.log(this.familiarity_bubbles);
        this.hideFBubbles();
        return this.showFBubble();
    },
    showFBubble: function () {
        var current_bubble_key = this.familiarity_hash_keys()[this.familiarity_hash_pointer];
        var element = $(current_bubble_key)
        var content = this.familiarity_hash[current_bubble_key];

        if (element.length <= 0) {
            return false;
        }
//        $('html, body').animate({
//            scrollTop: element.offset().top
//        }, 500);

        element.addClass('familiarity-bubble-parent').tooltipster({
            content: $('<span><strong>' + content.replace(/\n/g, "<br/>") + '</strong></span>'),
            maxWidth: 400,
            animation: 'grow', //fade, grow, swing, slide, fall
            autoClose: true, //true, false
            position: 'bottom-right', //right, left, top, top-right, top-left, bottom, bottom-right, bottom-left
            delay: 700,
            speed: 700,
            theme: 'tooltipster-default',
            touchDevices: false,
            trigger: 'custom' //hover, click, custom
        });
        element.tooltipster('show');
        this.familiarity_bubbles.push(element)
        return true;
    },
    hideFBubbles: function () {<commit_msg>Fixing event that were recreating old variables(object) like zombies by shifting even to fire from 'body' instead of 'document' and also added mosedown event in parallel for RIGHT arrow key<commit_after>var Familiarity = function () {
    this.familiarityRenderedFlag = false;
    this.familiaritiesUrl = '<%= Familiarity::Engine.routes.url_helpers.familiarities_path(format: :json) %>';
    this.familiarity_hash_pointer = -1;
    this.familiarity_hash = {};
    this.familiarity_bubbles = [];

    // Show and hide on F1 and ESC key respectively
    var _this = this;
    $('body').keyup(function (e) {
        if (e.keyCode == 27 && _this.familiarityRenderedFlag) { //ESC key pressed
            _this.familiarityView(false);
        }
        if (e.keyCode == 112 && !_this.familiarityRenderedFlag) { //F1 key pressed
            _this.familiarityView(true);
        }
        if (e.keyCode == 37 && _this.familiarityRenderedFlag) { //LEFT arrow key pressed
            _this.showPreviousBubble();
        }
        if (e.keyCode == 39 && _this.familiarityRenderedFlag) { //RIGHT arrow key pressed
            _this.showNextBubble()
        }
    }).mousedown(function (e) {
                if (_this.familiarityRenderedFlag) { //Show next bubble on mouse down('click')
                    _this.showNextBubble()
                }

            });
}
Familiarity.prototype = {
    familiarity_hash_keys: function () {
        return($.map(this.familiarity_hash, function (v, k) {
            return k;
        }));
    },
    showNextBubble: function () {
        if (this.familiarity_hash_keys().length <= 0) {
            return false;
        }
        this.familiarity_hash_pointer++;
        if ((this.familiarity_hash_pointer + 1) > this.familiarity_hash_keys().length) {
            this.familiarity_hash_pointer = 0;
        }
        this.showOneByOne();
    },
    showPreviousBubble: function () {
        if (this.familiarity_hash_keys().length <= 0) {
            return false;
        }
        this.familiarity_hash_pointer--;
        if (this.familiarity_hash_pointer < 0) {
            this.familiarity_hash_pointer = this.familiarity_hash_keys().length - 1;
        }
        this.showOneByOne();
    },
    showOneByOne: function () {
//        console.log(this.familiarity_hash_pointer);
//        console.log(this.familiarity_hash);
//        console.log(this.familiarity_bubbles);
        this.hideFBubbles();
        return this.showFBubble();
    },
    showFBubble: function () {
        var current_bubble_key = this.familiarity_hash_keys()[this.familiarity_hash_pointer];
        var element = $(current_bubble_key)
        var content = this.familiarity_hash[current_bubble_key];

        if (element.length <= 0) {
            return false;
        }

        element.addClass('familiarity-bubble-parent').tooltipster({
            content: $('<span><strong>' + content.replace(/\n/g, "<br/>") + '</strong></span>'),
            maxWidth: 400,
            animation: 'grow', //fade, grow, swing, slide, fall
            autoClose: true, //true, false
            position: 'bottom-right', //right, left, top, top-right, top-left, bottom, bottom-right, bottom-left
            delay: 700,
            speed: 700,
            theme: 'tooltipster-default',
            touchDevices: false,
            trigger: 'custom' //hover, click, custom
        });
        element.tooltipster('show');
        this.familiarity_bubbles.push(element)
        return true;
    },
    hideFBubbles: function () {
{'fraction_non_alphanumeric': 0.12702862201239304, 'fraction_numerical': 0.008704632634995574, 'mean_word_length': 2.248203162434116, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 17, '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': '525905', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2031, 'n_words': 387}