Refactoring BDatepicker JS