| 10 | new Chartist.Line(".ct-chart", data, options); |
| 11 | |
| 12 | function CalendarControl() { |
| 13 | const calendar = new Date(); |
| 14 | const calendarControl = { |
| 15 | localDate: new Date(), |
| 16 | prevMonthLastDate: null, |
| 17 | calWeekDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], |
| 18 | calMonthName: [ |
| 19 | "Jan", |
| 20 | "Feb", |
| 21 | "Mar", |
| 22 | "Apr", |
| 23 | "May", |
| 24 | "Jun", |
| 25 | "Jul", |
| 26 | "Aug", |
| 27 | "Sep", |
| 28 | "Oct", |
| 29 | "Nov", |
| 30 | "Dec", |
| 31 | ], |
| 32 | daysInMonth: function (month, year) { |
| 33 | return new Date(year, month, 0).getDate(); |
| 34 | }, |
| 35 | firstDay: function () { |
| 36 | return new Date(calendar.getFullYear(), calendar.getMonth(), 1); |
| 37 | }, |
| 38 | lastDay: function () { |
| 39 | return new Date(calendar.getFullYear(), calendar.getMonth() + 1, 0); |
| 40 | }, |
| 41 | firstDayNumber: function () { |
| 42 | return calendarControl.firstDay().getDay() + 1; |
| 43 | }, |
| 44 | lastDayNumber: function () { |
| 45 | return calendarControl.lastDay().getDay() + 1; |
| 46 | }, |
| 47 | getPreviousMonthLastDate: function () { |
| 48 | let lastDate = new Date( |
| 49 | calendar.getFullYear(), |
| 50 | calendar.getMonth(), |
| 51 | 0 |
| 52 | ).getDate(); |
| 53 | return lastDate; |
| 54 | }, |
| 55 | navigateToPreviousMonth: function () { |
| 56 | calendar.setMonth(calendar.getMonth() - 1); |
| 57 | calendarControl.attachEventsOnNextPrev(); |
| 58 | }, |
| 59 | navigateToNextMonth: function () { |
| 60 | calendar.setMonth(calendar.getMonth() + 1); |
| 61 | calendarControl.attachEventsOnNextPrev(); |
| 62 | }, |
| 63 | navigateToCurrentMonth: function () { |
| 64 | let currentMonth = calendarControl.localDate.getMonth(); |
| 65 | let currentYear = calendarControl.localDate.getFullYear(); |
| 66 | calendar.setMonth(currentMonth); |
| 67 | calendar.setYear(currentYear); |
| 68 | calendarControl.attachEventsOnNextPrev(); |
| 69 | }, |