Refactor main.js

Quick summary:

  - Load `CodeMirror` as a module, because `window.CodeMirror` is deprecated
  - Fix JSLint warnings.

If you want, I could squash all JSLint related commits…