more jQuery and before actions

i just changed a few more things with the current jQuery and added some
before actions in the controllers to clean up the code.