<commit_before>'use strict';
var ConversationService;
$(document).ready(function(){
  var $conversationContainer =  $("#conversation-container");

  var conversationId = chrome.extension.getBackgroundPage().focusedConversationId;
  ConversationService = chrome.extension.getBackgroundPage().ConversationService;

  ConversationService.getConversation(conversationId).then(function(conversation){
    var messages = conversation.messages;
    for(var i = 0; i < messages.length; i++) {
      var message = messages[i];
      updateConversation(message.contactName, messages[i].message);
      scrollToBottom();
    }
  });

  chrome.storage.onChanged.addListener(function(changes, namespace) {
    ConversationService.getConversation(conversationId).then(function(conversation){
      var messages = conversation.messages;
      for (var i = 0; i < changes.conversations.oldValue.length; i++) {
            var tempConversation = changes.conversations.oldValue[i];
            if (tempConversation.contact == conversationId) {
              if(tempConversation.messages.length < messages.length) {
                var message = messages[messages.length-1];
                updateConversation(message.contactName, message.message);
                scrollToBottom();
              }
              break;
            }
      } 
    });
  });
  
  $('#send-button').on('click',function(event) {
    event.preventDefault();
    sendMessage(conversationId);
  });

});

function updateConversation(contactName, message) {
  var $conversationContainer =  $("#conversation-container");
  $conversationContainer.append("<p>" + contactName + " : " + message + "</p>");
}

function scrollToBottom() {
  var elem = document.getElementById('conversation-container');
  elem.scrollTop = elem.scrollHeight;
}

function sendMessage(conversationId) {
  var text = $('#reply-text-area').val();
  var payload = '{"contactName":"me",' + '"to":"' + conversationId + '","message":"'+ text +'"}';
  ConversationService.sendMessage(conversationId, payload);<commit_msg>clear reply box on send<commit_after>'use strict';
var ConversationService;
$(document).ready(function(){
  var $conversationContainer =  $("#conversation-container");

  var conversationId = chrome.extension.getBackgroundPage().focusedConversationId;
  ConversationService = chrome.extension.getBackgroundPage().ConversationService;

  ConversationService.getConversation(conversationId).then(function(conversation){
    var messages = conversation.messages;
    for(var i = 0; i < messages.length; i++) {
      var message = messages[i];
      updateConversation(message.contactName, messages[i].message);
      scrollToBottom();
    }
  });

  chrome.storage.onChanged.addListener(function(changes, namespace) {
    ConversationService.getConversation(conversationId).then(function(conversation){
      var messages = conversation.messages;
      for (var i = 0; i < changes.conversations.oldValue.length; i++) {
            var tempConversation = changes.conversations.oldValue[i];
            if (tempConversation.contact == conversationId) {
              if(tempConversation.messages.length < messages.length) {
                var message = messages[messages.length-1];
                updateConversation(message.contactName, message.message);
                scrollToBottom();
              }
              break;
            }
      } 
    });
  });
  
  $('#send-button').on('click',function(event) {
    event.preventDefault();
    sendMessage(conversationId);
  });

});

function updateConversation(contactName, message) {
  var $conversationContainer =  $("#conversation-container");
  $conversationContainer.append("<p>" + contactName + " : " + message + "</p>");
}

function scrollToBottom() {
  var elem = document.getElementById('conversation-container');
  elem.scrollTop = elem.scrollHeight;
}

function sendMessage(conversationId) {
  var text = $('#reply-text-area').val();
  var payload = '{"contactName":"me",' + '"to":"' + conversationId + '","message":"'+ text +'"}';
  ConversationService.sendMessage(conversationId, payload);
  $('#reply-text-area').val('');
{'fraction_non_alphanumeric': 0.14330670539820867, 'fraction_numerical': 0.0014524328249818446, 'mean_word_length': 3.832748538011696, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 7, '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': '2731444', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1107, 'n_words': 186}