Refractored connection javascript
Merge branch 'core-2.x' of github.com:frontlinesms/frontlinesms2 into core-2.x