Moved client script to separate file

Also fixed JSHint errors.