<commit_before>/**
* Sends the focus back to #inbound
* @return {[type]} [description]
*/
inboundFocus = function() {
  if ($('textarea, input:not(#inbound):visible').length) { return false; }
  $('#inbound').focus(); return true;
};

/**
* Sets the placehodler text in #inbound
* @param  {[type]} error [description]
* @param  {[type]} text  [description]
* @return {[type]}       [description]
*/
inbound = function(error, text) {
  if (error || voice_enabled === false) {
    if (error) { sAlert.error(error); }
    $('.navbar-brand .fa').attr('class', 'fa fa-microphone-slash');
    $('#inbound').attr('placeholder', TAPi18n.__('app.inboundWriteOk')).focus();
  } else {
    if(!text) text = TAPi18n.__('app.inboundTalkOk');
    $('.navbar-brand .fa').attr('class', 'fa fa-microphone');
    $('#inbound').attr('placeholder', text).focus();
  }
  $('#inbound').focus();
};

menuModule = function(module) {

  if (module === 'languageSelector') {
    menuOpts = lodash.map(TAPi18n.getLanguages(), function(v, k) {
      return { title: v.name, value:k };
    });
    var menu = menuOptions.insert({
      title: TAPi18n.__('app.languageSetup'),
      action: 'session',
      parameters: ['language'],
      options: menuOpts
    });

    speechSay({
      text: TAPi18n.__('app.languageSetup')
    });

    Session.set('menuOptions', menu);
  }

}

Template.inboundBox.onRendered(function inboundBoxRendered() {
  $( document ).ready(function() {
    recognitionToggle(true);
    inboundFocus();
  });
});

Template.inboundBox.events({
  "submit #inbound-form": function(event, template){
    event.preventDefault();
    recognitionToggle(false);

    var txt = $('#inbound').val() ? $('#inbound').val() : final_transcript;

    if (txt === '') return false;

    var textId = chat.insert({
      direction: 'inbound',
      text: txt
    });

    $('#inbound').val('');<commit_msg>new possible hack<commit_after>/**
* Sends the focus back to #inbound
* @return {[type]} [description]
*/
inboundFocus = function() {
  if ($('textarea, input:not(#inbound):visible').length) { return false; }
  $('#inbound').focus(); return true;
};

/**
* Sets the placehodler text in #inbound
* @param  {[type]} error [description]
* @param  {[type]} text  [description]
* @return {[type]}       [description]
*/
inbound = function(error, text) {
  if (error || voice_enabled === false) {
    if (error) { sAlert.error(error); }
    $('.navbar-brand .fa').attr('class', 'fa fa-microphone-slash');
    $('#inbound').attr('placeholder', TAPi18n.__('app.inboundWriteOk')).focus();
  } else {
    if(!text) text = TAPi18n.__('app.inboundTalkOk');
    $('.navbar-brand .fa').attr('class', 'fa fa-microphone');
    $('#inbound').attr('placeholder', text).focus();
  }
  $('#inbound').focus();
};

menuModule = function(module) {

  if (module === 'languageSelector') {
    menuOpts = lodash.map(TAPi18n.getLanguages(), function(v, k) {
      return { title: v.name, value:k };
    });
    var menu = menuOptions.insert({
      title: TAPi18n.__('app.languageSetup'),
      action: 'session',
      parameters: ['language'],
      options: menuOpts
    });

    speechSay({
      text: TAPi18n.__('app.languageSetup')
    });

    Session.set('menuOptions', menu);
  }

}

Template.inboundBox.onRendered(function inboundBoxRendered() {
  $( document ).ready(function() {
    recognitionToggle(true);
    inboundFocus();
  });
});

Template.inboundBox.events({

  /* HACK to use your OS voice recognition solution focused in #inbound */
  /*
  "input #inbound": function(event, template) {
    var $this = $(this);
    var delay = 500; // 2 seconds delay after last input
    clearTimeout($this.data('timer'));
    $this.data('timer', setTimeout(function(){
      $this.removeData('timer');
      $('#inbound-form').submit();
    }, delay));
  },
  */

  "submit #inbound-form": function(event, template){
    event.preventDefault();
    recognitionToggle(false);

    var txt = $('#inbound').val() ? $('#inbound').val() : final_transcript;

    if (txt === '') return false;

    var textId = chat.insert({
      direction: 'inbound',
      text: txt
    });

    $('#inbound').val('');
{'fraction_non_alphanumeric': 0.20187229956793087, 'fraction_numerical': 0.005760921747479597, 'mean_word_length': 3.6248612652608214, 'pattern_counts': {'":': 3, '<': 3, '<?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': '5909964', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1352, 'n_words': 280}