<commit_before>$(function() {
    var log = {
        i: function(message) {
            this.addLog('info', message);
        },
        s: function(message) {
            this.addLog('success', message);
        },
        e: function(message) {
            this.addLog('danger', message);
        },

        addLog: function(level, message) {
            $('#result').html('<span class="text-' + level + '">' + message + '</span>');
            setTimeout(function() {
                $('#result').html('');
            }, 5000);
        }
    };

    var storage = {
        set: function(key, value) {
            localStorage.setItem(key, value);
        },
        get: function(key) {
            return localStorage.getItem(key);
        },
        remove: function(key) {
            localStorage.removeItem(key);
        },
        clear: function() {
            localStorage.clear();
        },
        bind: function(elm, key) {
            var self = this;

            elm.val(self.get(key));

            elm.change(function() {
                self.set(key, elm.val());
            })
        }
    };

    function refreshBots() {
        var bots = JSON.parse(storage.get('bots')) || [];

        if (bots.length > 0) {
            var list = '';

            for (var i = 0; i < bots.length; i++) {
                list += '<li class="load-bot" data-index="' + i + '"><a href="javascript:void(0);">';

                if (bots[i].image && bots[i].image.length) {
                    if (bots[i].image.slice(0, 1) == ':' && bots[i].image.slice(-1) == ':') {
                        list += '<b>' + bots[i].image + '</b> ';
                    } else {
                        list += '<img src="' + bots[i].image + '" /> ';
                    }
                }

                list += bots[i].name;
                list += '</a></li>';
            }

            $('#bots').html(list);
        }
    }

    storage.bind($('#url'), 'url');
    storage.bind($('#target'), 'target');
    storage.bind($('#name'), 'name');
    storage.bind($('#image'), 'image');
    refreshBots();

    $('#save-bot').click(function() {<commit_msg>The title is now updated with the bot name<commit_after>$(function() {
    var log = {
        i: function(message) {
            this.addLog('info', message);
        },
        s: function(message) {
            this.addLog('success', message);
        },
        e: function(message) {
            this.addLog('danger', message);
        },

        addLog: function(level, message) {
            $('#result').html('<span class="text-' + level + '">' + message + '</span>');
            setTimeout(function() {
                $('#result').html('');
            }, 5000);
        }
    };

    var storage = {
        set: function(key, value) {
            localStorage.setItem(key, value);
        },
        get: function(key) {
            return localStorage.getItem(key);
        },
        remove: function(key) {
            localStorage.removeItem(key);
        },
        clear: function() {
            localStorage.clear();
        },
        bind: function(elm, key) {
            var self = this;

            elm.val(self.get(key));

            elm.change(function() {
                self.set(key, elm.val());
            })
        }
    };

    function refreshBots() {
        var bots = JSON.parse(storage.get('bots')) || [];

        if (bots.length > 0) {
            var list = '';

            for (var i = 0; i < bots.length; i++) {
                list += '<li class="load-bot" data-index="' + i + '"><a href="javascript:void(0);">';

                if (bots[i].image && bots[i].image.length) {
                    if (bots[i].image.slice(0, 1) == ':' && bots[i].image.slice(-1) == ':') {
                        list += '<b>' + bots[i].image + '</b> ';
                    } else {
                        list += '<img src="' + bots[i].image + '" /> ';
                    }
                }

                list += bots[i].name;
                list += '</a></li>';
            }

            $('#bots').html(list);
        }
    }

    function refreshPageTitle() {
        var botName = $('#name').val();
        document.title = 'Slack Bot Manager';

        if (botName.length) {
            document.title = botName + ' - ' + document.title;
        }
    }

    storage.bind($('#url'), 'url');
    storage.bind($('#target'), 'target');
    storage.bind($('#name'), 'name');
    storage.bind($('#image'), 'image');
    refreshBots();
    refreshPageTitle();

    $('#name').change(function() {
        refreshPageTitle();
    });

    $('#save-bot').click(function() {
{'fraction_non_alphanumeric': 0.19305019305019305, 'fraction_numerical': 0.00429000429000429, 'mean_word_length': 1.4464847848898217, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '1940040', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1336, 'n_words': 241}