Refactor js

Rewriting our js to be more readable and less hacky.


While writing [arim/selfreg](https://github.com/OSU-Net/arim), we determined that HTTP 422 is probably the best status code to use.