Move most of js logic from view to controller. Remove unneeded conditional on home page