organizing js day view code