<commit_before>$(function () {
    var word_list = $('#word-alerts');
    _.each(alert_words.words, function (word) {
        var li = templates.render('alert_word_settings_item', {'word': word});
        word_list.append(li);
    });
    var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true});
    word_list.append(new_word);

    function update_word_alerts() {
        var words = _.map($('.alert-word-item'), function (e) {
            return $(e).data('word');
        });
        words = _.filter(words, function (word) {
            return word !== "";
        });

        $.ajax({
            type: 'POST',
            url: '/json/set_alert_words',
            data: {alert_words: JSON.stringify(words)},
            dataType: 'json'});
    }

    function add_alert_word(word) {
          if (word === '') {
            return;
        }

        var final_li = templates.render('alert_word_settings_item', {'word': word, editing: false});

        var li = $(event.target).parent();
        li.replaceWith(final_li);

        var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true});
        word_list.append(new_word);

        if (word_list.find('input').length > 0) {
            word_list.find('input').focus();
        }

        update_word_alerts();
    }

    $('#word-alerts').on('click', '.add-alert-word', function (event) {
        var word = $(event.target).siblings('input').val();
        add_alert_word(word);
    });

    $('#word-alerts').on('click', '.remove-alert-word', function (event) {
        var li = $(event.currentTarget).parent();
        li.remove();

        update_word_alerts();<commit_msg>alert words: fix accidental use of a global variable.<commit_after>$(function () {
    var word_list = $('#word-alerts');
    _.each(alert_words.words, function (word) {
        var li = templates.render('alert_word_settings_item', {'word': word});
        word_list.append(li);
    });
    var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true});
    word_list.append(new_word);

    function update_word_alerts() {
        var words = _.map($('.alert-word-item'), function (e) {
            return $(e).data('word');
        });
        words = _.filter(words, function (word) {
            return word !== "";
        });

        $.ajax({
            type: 'POST',
            url: '/json/set_alert_words',
            data: {alert_words: JSON.stringify(words)},
            dataType: 'json'});
    }

    function add_alert_word(word, event) {
          if (word === '') {
            return;
        }

        var final_li = templates.render('alert_word_settings_item', {'word': word, editing: false});

        var li = $(event.target).parent();
        li.replaceWith(final_li);

        var new_word = templates.render('alert_word_settings_item', {'word': '', editing: true});
        word_list.append(new_word);

        if (word_list.find('input').length > 0) {
            word_list.find('input').focus();
        }

        update_word_alerts();
    }

    $('#word-alerts').on('click', '.add-alert-word', function (event) {
        var word = $(event.target).siblings('input').val();
        add_alert_word(word, event);
    });

    $('#word-alerts').on('click', '.remove-alert-word', function (event) {
        var li = $(event.currentTarget).parent();
        li.remove();

        update_word_alerts();
{'fraction_non_alphanumeric': 0.17718587145338738, 'fraction_numerical': 0.0005790387955993051, 'mean_word_length': 2.4072978303747536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5188304', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1021, 'n_words': 189}