<commit_before>﻿/*global define, document, window, setTimeout*/
define([
    'jquery',
    'logger',
    'kernel',
    'jabbr/events',
    // Libraries
    'jquery.cookie',
    'jquery.signalr',
    'noext!signalr/hubs'
], function ($, Logger, kernel, events) {
    var logger = new Logger('jabbr/client'),
        object = null;

    logger.trace('loaded');

    var initialize = function () {
        var $window = $(window),
            $this = $(this),
            connection = $.connection,
            chat = connection.chat,
            options = {},
            initial = true,
            mentionStrings = null,
            customMentionRegex = null,
            privateRooms = null,
            logging = $.cookie('jabbr.logging') === '1',
            transport = $.cookie('jabbr.transport');

        if (transport) {
            options.transport = transport;
        }

        connection.hub.logging = logging;
        connection.hub.qs = "version=" + window.jabbrVersion;

        function generateCustomMentionRegex(strings) {
            if (strings === null || strings.length < 0) {
                return null;
            }

            var pattern = "(\\W|^)(?:" + strings.join("|") + ")(\\W|$)";

            return new RegExp(pattern, "i");
        }

        function updateMentions(mentions) {
            mentionStrings = mentions;
            customMentionRegex = generateCustomMentionRegex(mentions);
        }

        //
        // Chat Event Handlers
        //

        chat.client.logOn = function (rooms, myRooms, userPreferences, mentions, notifications) {
            logger.trace('logOn');

            updateMentions(mentions);
            privateRooms = myRooms;

            $this.trigger(events.client.loggedOn, [rooms, myRooms, userPreferences, mentions, notifications]);<commit_msg>The users name is now included in mention strings if it doesn't already exist<commit_after>﻿/*global define, document, window, setTimeout*/
define([
    'jquery',
    'logger',
    'kernel',
    'jabbr/events',
    // Libraries
    'jquery.cookie',
    'jquery.signalr',
    'noext!signalr/hubs'
], function ($, Logger, kernel, events) {
    var logger = new Logger('jabbr/client'),
        object = null;

    logger.trace('loaded');

    var initialize = function () {
        var $window = $(window),
            $this = $(this),
            connection = $.connection,
            chat = connection.chat,
            options = {},
            initial = true,
            mentionStrings = null,
            customMentionRegex = null,
            privateRooms = null,
            logging = $.cookie('jabbr.logging') === '1',
            transport = $.cookie('jabbr.transport');

        if (transport) {
            options.transport = transport;
        }

        connection.hub.logging = logging;
        connection.hub.qs = "version=" + window.jabbrVersion;

        function generateCustomMentionRegex(strings) {
            if (strings === null || strings.length < 0) {
                return null;
            }

            var pattern = "(\\W|^)(?:" + strings.join("|") + ")(\\W|$)";

            return new RegExp(pattern, "i");
        }

        function updateMentions(mentions) {
            var name = chat.state.name.toLowerCase();

            if (mentions.indexOf(name) == -1) {
                mentions.push(name);
            }

            mentionStrings = mentions;
            customMentionRegex = generateCustomMentionRegex(mentions);
        }

        //
        // Chat Event Handlers
        //

        chat.client.logOn = function (rooms, myRooms, userPreferences, mentions, notifications) {
            logger.trace('logOn');

            updateMentions(mentions);
            privateRooms = myRooms;

            $this.trigger(events.client.loggedOn, [rooms, myRooms, userPreferences, mentions, notifications]);
{'fraction_non_alphanumeric': 0.132333936417679, 'fraction_numerical': 0.0012923235978288964, 'mean_word_length': 1.8902165795369679, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5253451', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1017, 'n_words': 227}