right now this is all in static/app.js but it's super messy and should be replaced with something less insane.