/* global cloak */

var form = document.querySelector('#input-form');
var input = document.querySelector('#input');
var messages = document.querySelector('#messages');
var counter = document.querySelector('#counter');

cloak.configure({
  messages: {
    chat: function(msg) {
      var message = document.createElement('div');
      message.innerText = msg;
      message.className = 'msg';
      messages.appendChild(message);
      messages.scrollTop = messages.scrollHeight;
    },
    userCount: function(count) {
      counter.innerText = count;
    }
  },
});

cloak.run('http://localhost:8090');

form.addEventListener('submit', function(e) {
  e.preventDefault();
  var msg = input.value;
  if (msg.length < 1) {
    return;
  }
  cloak.message('chat', msg);
  input.value = '';
});

/* global cloak */

var form = document.querySelector('#input-form');
var input = document.querySelector('#input');
var messages = document.querySelector('#messages');
var counter = document.querySelector('#counter');

cloak.configure({
  messages: {
    chat: function(msg) {
      var message = document.createElement('div');
      message.textContent = msg;
      message.className = 'msg';
      messages.appendChild(message);
      messages.scrollTop = messages.scrollHeight;
    },
    userCount: function(count) {
      counter.textContent = count;
    }
  },
});

cloak.run('http://localhost:8090');

form.addEventListener('submit', function(e) {
  e.preventDefault();
  var msg = input.value;
  if (msg.length < 1) {
    return;
  }
  cloak.message('chat', msg);
  input.value = '';
});

Switch .innerText DOM output to .textContent
Switch .innerText DOM output to .textContent

.innerText started as an IE-ism, but .textContent is the WC3 standard. Eventually, IE9+ supported textContent, but Firefox stood firm (or "stubborn") on NOT supporting innerText. As stands, innerText will break this example for modern Firefox browsers, and I don't believe that punishing IE8 users is necessarily a bad thing. ;)

Mind, there's ways to normalize use of this property for maximum browser compat, but I believe the spirit of this example is to keep the code as lean as possible.