<commit_before>'use strict'

import Vue from 'vue';
import io from 'socket.io-client';

//const chatServerURL = 'http://localhost:4000';
const chatServerURL = 'https://louisbourque-chat.herokuapp.com/'

Vue.component('chat-message', {
  template: `<div v-if="message.type=='msg'" class="chatmessage" :class="{'message-so-far':!message.complete}">
              <strong>{{message.from}}:</strong> {{message.msg}}
            </div>
            <div v-else class="chatmessage">
              <em>{{message.name+ " " +message.action}}</em>
            </div>`,
  props: ['message'],

});

Vue.component('chat-window-inner', {
  template: `<div v-if="!connected" class="chatWindowInner">
              <div class="chatHeader">
                <div class="title">Join Chat</div>
                <button class="closeButton" v-on:click="handleHideChat">X</button>
              </div>
              <div class="joinChat">
                <input type="text" id="name" ref="joinName" autofocus v-on:keyup="handleJoinName" placeholder="Type your name" />
                <button class="joinButton" ref="joinButton" v-on:click="handleJoinButton" disabled>Join</button>
              </div>
            </div>
            <div v-else class="chatWindowInner">
              <div class="chatHeader">
                <div class="title">Chat</div>
                <button class="closeButton" v-on:click=handleHideChat>X</button>
              </div>
              <div class="messages" v-scrollDown>
                <template v-for="message in messages">
                  <chat-message v-bind:message="message"></chat-message>
                </template>
                <template v-for="message in messagessofar">
                  <chat-message v-bind:message="message"></chat-message>
                </template>
              </div>
              <div class="chatFooter">
                <textarea id="chatMsg" ref="textArea" autofocus v-on:keyup="handleUserMessage" placeholder="Type your message. Press shift + Enter to send" />
              </div>
            </div>`,
  props: ['connected','messages','messagessofar'],
  methods: {
    handleUserMessage: function(event) {
      // When shift and enter key is pressed
      if (event.shiftKey && event.keyCode === 13) {
        // call the sendmessages of ChatContainer throught the props
        sendMessageEnd();

        // Prevent default and clear the textarea
        event.preventDefault();
        this.$refs.textArea.value = null;
      }else{
        var msg = this.$refs.textArea.value.trim();
        if (msg !== '') {
          // call the sendmessages of ChatContainer throught the props
          sendMessage(msg);
        }
      }

    },
    handleJoinName: function(event) {
      var name = this.$refs.joinName.value.trim();
      if(name.length > 0){
        this.$refs.joinButton.disabled = false;
        if (event.keyCode === 13) {
          this.handleJoinButton();
        }
      }else{
        this.$refs.joinButton.disabled = true;
      }
    },
    handleJoinButton: function() {
      var name = this.$refs.joinName.value.trim();
      if (name !== '') {
        joinChat(name);<commit_msg>Fix empty Message In Progress bug<commit_after>'use strict'

import Vue from 'vue';
import io from 'socket.io-client';

//const chatServerURL = 'http://localhost:4000';
const chatServerURL = 'https://louisbourque-chat.herokuapp.com/'

Vue.component('chat-message', {
  template: `<div v-if="message.type=='msg'" class="chatmessage" :class="{'message-so-far':!message.complete}">
              <strong>{{message.from}}:</strong> {{message.msg}}
            </div>
            <div v-else class="chatmessage">
              <em>{{message.name+ " " +message.action}}</em>
            </div>`,
  props: ['message'],

});

Vue.component('chat-window-inner', {
  template: `<div v-if="!connected" class="chatWindowInner">
              <div class="chatHeader">
                <div class="title">Join Chat</div>
                <button class="closeButton" v-on:click="handleHideChat">X</button>
              </div>
              <div class="joinChat">
                <input type="text" id="name" ref="joinName" autofocus v-on:keyup="handleJoinName" placeholder="Type your name" />
                <button class="joinButton" ref="joinButton" v-on:click="handleJoinButton" disabled>Join</button>
              </div>
            </div>
            <div v-else class="chatWindowInner">
              <div class="chatHeader">
                <div class="title">Chat</div>
                <button class="closeButton" v-on:click=handleHideChat>X</button>
              </div>
              <div class="messages" v-scrollDown>
                <template v-for="message in messages">
                  <chat-message v-bind:message="message"></chat-message>
                </template>
                <template v-for="message in messagessofar">
                  <chat-message v-if="message.msg" v-bind:message="message"></chat-message>
                </template>
              </div>
              <div class="chatFooter">
                <textarea id="chatMsg" ref="textArea" autofocus v-on:keyup="handleUserMessage" placeholder="Type your message. Press shift + Enter to send" />
              </div>
            </div>`,
  props: ['connected','messages','messagessofar'],
  methods: {
    handleUserMessage: function(event) {
      // When shift and enter key is pressed
      if (event.shiftKey && event.keyCode === 13) {
        if (msg !== '') {
          sendMessageEnd();
        }
        // Prevent default and clear the textarea
        event.preventDefault();
        this.$refs.textArea.value = null;
      }else{
        var msg = this.$refs.textArea.value.trim();
        sendMessage(msg);

      }

    },
    handleJoinName: function(event) {
      var name = this.$refs.joinName.value.trim();
      if(name.length > 0){
        this.$refs.joinButton.disabled = false;
        if (event.keyCode === 13) {
          this.handleJoinButton();
        }
      }else{
        this.$refs.joinButton.disabled = true;
      }
    },
    handleJoinButton: function() {
      var name = this.$refs.joinName.value.trim();
      if (name !== '') {
        joinChat(name);
{'fraction_non_alphanumeric': 0.15454983148772267, 'fraction_numerical': 0.002888781896966779, 'mean_word_length': 2.1363865123301458, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 89, 'https://': 2, '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': '4574098', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1743, 'n_words': 357}