Improve readability of calendar.js
Refactor part of calendar.js