<commit_before>﻿@model JabberBCIT.Models.ChatGroup
@using Microsoft.AspNet.Identity

@{
    ViewBag.Title = "Chat";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@Styles.Render("~/Content/Chat.css")

@Html.AntiForgeryToken()

<div id="wrapper">
    @using (Html.BeginForm("Chat", "Chat", FormMethod.Post, new { name = "Start", id = "Start" })) {
        <div class="side_columns">
            <div class="chat_convos">
                <div id="newChat" class="btn btn-default">+ Create New Chat</div>
                <ul id="chatlist" class="nav navbar-nav side-nav">
                    <li>
                        @Html.Raw(ViewBag.Chats)
                    </li>
                </ul>
            </div>
        </div>
        <div id="chat" class="container">
            @Html.HiddenFor(model => model.ChatID, htmlAttributes: new { @id = "chatID" })
            <div id="discussion">
                @Html.Raw(ViewBag.Messages)
            </div>
            <input type="text" id="message" placeholder="Enter message here..." />
            <input type="button" id="sendmessage" class="btn btn-default" value="Send" />
            <input type="hidden" id="displayname" />
        </div>
        <div class="side_columns">
            <div class="chat_members">
                <ul id="memberList" class="nav navbar-nav side-nav">
                    <li>
                        @Html.Raw(ViewBag.Members)
                    </li>
                </ul>
            </div>
        </div>
        <div id="newChatDiv">
            @Html.TextBoxFor(model => model.GroupName, htmlAttributes: new { @id = "addName", @placeholder = "Group Name" })
            <input type="text" name="memberSearch" id="memberSearch" placeholder="UserName" />
            <input type="button" value="Add" id="addMember" class="btn btn-default" />
            <div>
                <ul id="members">
                    <li>
                    @Html.HiddenFor(model => model.Members, htmlAttributes: new { @id = "membersHidden" })
                    </li>
                </ul>
            </div>
            <input type="submit" class="btn btn-default" value="Done" id="createConversation" />
            <input type="button" class="btn btn-default" value="Cancel" id="cancel" />
        </div>
    }
</div>
@section scripts {
    <!--Script references. -->
    <!--The jQuery library is required and is referenced by default in _Layout.cshtml. -->
    <!--Reference the SignalR library. -->
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.12.4.js"></script>
    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script src="~/Scripts/jquery.signalR-2.2.1.js"></script>
    <script type="text/javascript">
        var con = $.hubConnection();
        console.log(con);
        con.connectionSlow(function () {
            console.log('We are currently experiencing difficulties with the connection.')
        });
        var hub = con.createHubProxy('ChatServer');
        function Trim(value) {
            return value.replace(/^\s+|\s+$/gm, '');
        }
        con.start().done(function () {
            $(document).keypress(function (e) {
                if (e.keyCode === 13) {
                    e.preventDefault();
                    sndFunc();
                }
            });
        });
        con.start().done(function () {
            var userId = "@User.Identity.GetUserId()";
            hub.invoke('ConnectToGroups', userId, $('#chatID').val());
        });

        var sndFunc = function () {
            var msg = Trim($("#message").val());
            var username = "@User.Identity.GetUserName()";
            var roomname = $('#chatID').val();
            if (msg != "") {
                $("#message").val(""); //clear the message box after sending message
                hub.invoke('Send', roomname, username, msg, "@User.Identity.GetUserId()");
            }
        };
        hub.on('AddMessage', function (username, message) {
            console.log(username + ": " + message);
            $("#discussion").append("<div id=\"chatmessage>\"><div id=\"right\"><span><strong>" + username + ": </strong>" + message + "</span></div></div>");
            $('#discussion').animate({ scrollTop: $('#discussion').prop("scrollHeight") }, 10);

        });
        $(function () {
            $(document).on('click', '#newChat', function (e) {
                if (!$('#newChatDiv').is(":visible")) {
                    $('#newChatDiv').show();
                    $('#chatID').val('-1');
                    $('#addName').val('');
                    $('#membersHidden').val('');
                }
            });
            $(document).on('click', '.chats', function (e) {
                $('#newChatDiv').hide();
                $('#message').show();
                $('#memberList').show();
                $('#discussion').show();
                $('#chatID').val(this.id);<commit_msg>Added autoscroll to bottom of message div<commit_after>﻿@model JabberBCIT.Models.ChatGroup
@using Microsoft.AspNet.Identity

@{
    ViewBag.Title = "Chat";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@Styles.Render("~/Content/Chat.css")

@Html.AntiForgeryToken()

<div id="wrapper">
    @using (Html.BeginForm("Chat", "Chat", FormMethod.Post, new { name = "Start", id = "Start" })) {
        <div class="side_columns">
            <div class="chat_convos">
                <div id="newChat" class="btn btn-default">+ Create New Chat</div>
                <ul id="chatlist" class="nav navbar-nav side-nav">
                    <li>
                        @Html.Raw(ViewBag.Chats)
                    </li>
                </ul>
            </div>
        </div>
        <div id="chat" class="container">
            @Html.HiddenFor(model => model.ChatID, htmlAttributes: new { @id = "chatID" })
            <div id="discussion">
                @Html.Raw(ViewBag.Messages)
            </div>
            <input type="text" id="message" placeholder="Enter message here..." />
            <input type="button" id="sendmessage" class="btn btn-default" value="Send" />
            <input type="hidden" id="displayname" />
        </div>
        <div class="side_columns">
            <div class="chat_members">
                <ul id="memberList" class="nav navbar-nav side-nav">
                    <li>
                        @Html.Raw(ViewBag.Members)
                    </li>
                </ul>
            </div>
        </div>
        <div id="newChatDiv">
            @Html.TextBoxFor(model => model.GroupName, htmlAttributes: new { @id = "addName", @placeholder = "Group Name" })
            <input type="text" name="memberSearch" id="memberSearch" placeholder="UserName" />
            <input type="button" value="Add" id="addMember" class="btn btn-default" />
            <div>
                <ul id="members">
                    <li>
                    @Html.HiddenFor(model => model.Members, htmlAttributes: new { @id = "membersHidden" })
                    </li>
                </ul>
            </div>
            <input type="submit" class="btn btn-default" value="Done" id="createConversation" />
            <input type="button" class="btn btn-default" value="Cancel" id="cancel" />
        </div>
    }
</div>
@section scripts {
    <!--Script references. -->
    <!--The jQuery library is required and is referenced by default in _Layout.cshtml. -->
    <!--Reference the SignalR library. -->
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.12.4.js"></script>
    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script src="~/Scripts/jquery.signalR-2.2.1.js"></script>
    <script type="text/javascript">
        var con = $.hubConnection();
        console.log(con);
        con.connectionSlow(function () {
            console.log('We are currently experiencing difficulties with the connection.')
        });
        var hub = con.createHubProxy('ChatServer');
        function Trim(value) {
            return value.replace(/^\s+|\s+$/gm, '');
        }
        con.start().done(function () {
            $(document).keypress(function (e) {
                if (e.keyCode === 13) {
                    e.preventDefault();
                    sndFunc();
                }
            });
        });
        con.start().done(function () {
            var userId = "@User.Identity.GetUserId()";
            hub.invoke('ConnectToGroups', userId, $('#chatID').val());
        });

        var sndFunc = function () {
            var msg = Trim($("#message").val());
            var username = "@User.Identity.GetUserName()";
            var roomname = $('#chatID').val();
            if (msg != "") {
                $("#message").val(""); //clear the message box after sending message
                hub.invoke('Send', roomname, username, msg, "@User.Identity.GetUserId()");
            }
        };
        hub.on('AddMessage', function (username, message) {
            console.log(username + ": " + message);
            $("#discussion").append("<div id=\"chatmessage>\"><div id=\"right\"><span><strong>" + username + ": </strong>" + message + "</span></div></div>");
            $('#discussion').animate({ scrollTop: $('#discussion').prop("scrollHeight") }, 10);

        });
        $(function () {
            $(document).ready(function () {
                $('#discussion').animate({ scrollTop: $('#discussion').prop("scrollHeight") }, 500);
            });
            $(document).on('click', '#newChat', function (e) {
                if (!$('#newChatDiv').is(":visible")) {
                    $('#newChatDiv').show();
                    $('#chatID').val('-1');
                    $('#addName').val('');
                    $('#membersHidden').val('');
                }
            });
            $(document).on('click', '.chats', function (e) {
                $('#newChatDiv').hide();
                $('#message').show();
                $('#memberList').show();
                $('#discussion').show();
                $('#chatID').val(this.id);
{'fraction_non_alphanumeric': 0.18503667481662592, 'fraction_numerical': 0.004205378973105135, 'mean_word_length': 1.7978112175102599, 'pattern_counts': {'":': 6, '<': 119, '<?xml version=': 0, '>': 127, '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': '4219355', 'n_tokens_mistral': 2868, 'n_tokens_neox': 2783, 'n_words': 542}