Externalised the js code so that it can be managed more easily within a JS editor. It can also be linter etc. (and has been!)