CAL-942 Improve JS code on calendar webapp