<commit_before>//handles message function
var SubmitView = Backbone.View.extend({

  events: {
    'submit' : 'handleSubmit'
  },

  initialize: function(){
    this.prevRoom = 'lobby';
  },

  handleSubmit: function(){
    var message = {
      text: $('#chatInput').val(),
      lang: $('#lang').val(),
      username: $('#username').val(),
      room: $('#room').val()
    };
    this.checkRoom(message);
    console.log('message is ->', message);
    socket.emit('chat message', message);
    $('#chatInput').val('');
    return false;
  },

  checkRoom : function(msg){
    if(msg.room !== this.prevRoom){
      this.changeRoom(msg);
    }
  },

  changeRoom : function(msg){
    socket.emit('leave room', this.prevRoom);
    this.prevRoom = msg.room;
    socket.emit('join room', msg.room);
  }
});<commit_msg>changed client to send obj with room to leave/join and client language when changing rooms<commit_after>//handles message function
var SubmitView = Backbone.View.extend({

  events: {
    'submit' : 'handleSubmit'
  },

  initialize: function(){
    this.prevRoom = 'lobby';
  },

  handleSubmit: function(){
    var message = {
      text: $('#chatInput').val(),
      lang: $('#lang').val(),
      username: $('#username').val(),
      room: $('#room').val()
    };
    this.checkRoom(message);
    console.log('message is ->', message);
    socket.emit('chat message', message);
    $('#chatInput').val('');
    return false;
  },

  checkRoom : function(msg){
    if(msg.room !== this.prevRoom){
      this.changeRoom(msg);
    }
  },

  changeRoom : function(msg){
    socket.emit('leave room', {leave: this.prevRoom, lang: msg.lang);
    this.prevRoom = msg.room;
    socket.emit('join room', {join: msg.room, lang: msg.lang});
  }
});
{'fraction_non_alphanumeric': 0.19237336368810473, 'fraction_numerical': 0.0, 'mean_word_length': 3.107476635514019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5195958', 'n_tokens_mistral': 555, 'n_tokens_neox': 548, 'n_words': 120}