js assignment

Final refining done
shift this code to view, controller should not touch html or css.