Drastic JS refactor

The main purpose of this PR is to make the custom JavaScript files more maintainable.
* Complete reformatting.
* Best practices.
* Dead code removal.
* Simplified event handlers.
* Slightly more modular design, though much work remains to be done here.

Eventually it would be nice to get around to making the dashboard a fully fledged module but this necessitates that the data tables be moved out. That's a huge undertaking I didn't want to do now but it's something I'm hoping to get back to.

I experimented with replacing table data instead of destroying and rebuilding the tables. This seems like a cleaner solution but I ran into some issues with the `ps` table not updating if I had applied a filter. I would prefer it to work this way but I don't know if I'll get back to that.