1(function ($) { 2 $.fn.calendar = function (options) { 3 'use strict'; 4 return $(this).each(function () { 5 var defaults = { 6 lang: 'en', 7 width: '100%', 8 backgroundcolor: 'transparent', 9 color: '#000000', 10 canPast: false, 11 initDate: null, 12 todayDate: null, 13 }, 14 activeOptions = $.extend(defaults, options); 15 if (activeOptions.initDate != null) { 16 var inDate = new Date(activeOptions.initDate), 17 CurrentDay = inDate.getDate(), 18 CurrentMonth = inDate.getMonth(), 19 CurrentYear = inDate.getFullYear(), 20 Today = inDate.getDate(); 21 } else { 22 var CurrentDay = new Date().getDate(), 23 CurrentMonth = new Date().getMonth(), 24 CurrentYear = new Date().getFullYear(), 25 Today = new Date().getDate(); 26 } 27 var self = this, 28 element = $(this), 29 element_id = element.attr("id"), 30 element_class = 'bankfax_calendar', 31 DaysHeader = '', 32 LastRow = '', 33 tr_count = 0, 34 lang = '', 35 calendar = '', 36 canPast = false, 37 empty_day = '<td class="empty"> </td>', // 38 initElement = function (show_month = CurrentMonth, show_year = CurrentYear) { 39 if (activeOptions['lang'] === undefined || activeOptions['lang'] === null) { 40 var strings = new Object(); 41 if (navigator.browserLanguage) { 42 lang = navigator.browserLanguage; 43 } else { 44 lang = navigator.language; 45 } 46 lang = lang.substr(0, 2).toLowerCase(); 47 if (lang === undefined || lang === null) lang = 'ru'; 48 } else { 49 lang = activeOptions['lang']; 50 } 51 if (lang == 'en') { 52 var nmonth = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
52November", "December"], 53 nday = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; 54 } else { 55 var nmonth = ["ЯнваÑÑ", "ФевÑалÑ", "ÐаÑÑ", "ÐпÑелÑ", "Ðай", "ÐÑнÑ", "ÐÑлÑ", "ÐвгÑÑÑ", "СенÑÑбÑÑ", "ÐкÑÑбÑÑ", "ÐоÑбÑÑ", "ÐекабÑÑ"], 56 nday = ["Ðн", "ÐÑ", "СÑ", "ЧÑ", "ÐÑ", "Сб", "ÐÑ"]; 57 } 58 var Dlast = new Date(show_year, show_month + 1, 0).getDate(), 59 D = new Date(show_year, show_month, Dlast), 60 DNlast = new Date(D.getFullYear(), D.getMonth(), Dlast).getDay(), 61 DNfirst = new Date(D.getFullYear(), D.getMonth(), 1).getDay(), curr_cls = ''; 62 calendar = '<tr>'; 63 tr_count = 0; 64 LastRow = ''; 65 if (DNfirst != 0) { 66 for (var i = 1; i < DNfirst; i++) calendar += empty_day; 67 } else { 68 for (var i = 0; i < 6; i++) calendar += empty_day; 69 } 70 for (var i = 1; i <= Dlast; i++) { 71 var curFormatted = format_event_date(CurrentYear, CurrentMonth, i); 72 if (i == new Date().getDate() && D.getFullYear() == new Date().getFullYear() && D.getMonth() == new Date().getMonth()) { 73 curr_cls = 'today'; 74 } else { 75 curr_cls = 'normal'; 76 } 77 78 if (isDateInFuture(format_event_date(CurrentYear, CurrentMonth, i))) curr_cls = 'idle'; 79 if (isDateInPastExcludingToday(format_event_date(CurrentYear, CurrentMonth, i))) curr_cls = 'normal'; //'idle'; 80 if (activeOptions.initDate != null && isDatebyDefault(curFormatted, activeOptions.initDate)) curr_cls += ' selected '; 81 82 calendar += '<td class="' + curr_cls + '" ' 83 + 'data-date="' + curFormatted + '" ' 84 + 'data-year="' + CurrentYear + '" ' 85 + 'data-month="' + (CurrentMonth + 1) + '" ' 86 + 'data-day="' + i + '" ' 87 + '>' 88 + i 89 + '</td>'; 90 if (new Date(D.getFullYear(), D.getMonth(), i).getDay() == 0) { 91 calendar += '<tr>'; 92 tr_count++; 93 } 94 } 95 for (var i = DNlast; i < 7; i++) calendar += empty_day; 96 DaysHeader = ''; 97 for (var i = 0; i < 7; i++) DaysHeader += '<td>' + nday[i] + '</td>'; 98 LastRow = ''; 99 if (tr_count < 5) LastRow = '<tr><td colspan="7" class="empty"></td></tr>'; 100 element.html('' 101 + '<table class="' + element_class + '">' // style="background-color:' + activeOptions.backgroundcolor + ';color:' + activeOptions.color + ';width:' + activeOptions.width + '">' 102 + '<thead>' 103 //+ '<tr><td class="y_Prev"></td><td colspan="5" data-month="' + D.getMonth() + 1 + '" data-year="' + D.getFullYear() + '">' + D.getFullYear() + '</td><td class="y_Next"></td></tr>' 104 + '<tr class="month"><td class="prev"><i class="fa fa-chevron-left" aria-hidden="true"></i></td>' 105 + '<td colspan="5" data-month="' + D.getMonth() + 1 + '" data-year="' + D.getFullYear() + '">' + nmonth[D.getMonth()] + ' ' + D.getFullYear() + '</td>' 106 + '<td class="next"><i class="fa fa-chevron-right" aria-hidden="true"></i></td></tr>' 107 + '</thead>' 108 + '<tbody>' 109 + '<tr class="weekday_title">' + DaysHeader + '</tr>' 110 + calendar 111 + LastRow 112 + '</tbody></table>'); 113 }, 114 115 format_event_date = function (iyear, imonth, iday) { 116 var Dlast = new Date(CurrentYear, CurrentMonth + 1, 0).getDate(), 117 D = new Date(CurrentYear, CurrentMonth, Dlast), d_month = D.getMonth() + 1; 118 return D.getFullYear() + '-' + d_month.toString().padStart(2, "0") + '-' + iday.toString().padStart(2, "0"); 119 }, 120 isDateInPastExcludingToday = function (checkDate) { //2023-01-01 121 var currentDate = new Date(); 122 currentDate.setHours(0, 0, 0, 0); 123 checkDate = new Date(checkDate); 124 checkDate.setHours(23, 59, 59, 999); 125 return checkDate < currentDate; 126 }, 127 isDateInFuture = function (checkDate) { 128 //debugger; 129 var todayDate = new Date(activeOptions.todayDate); 130 todayDate.setHours(23, 59, 59, 999); 131 checkDate = new Date(checkDate); 132 checkDate.setHours(0, 0, 0, 0); 133 var t = checkDate > todayDate; 134 return checkDate > todayDate; 135 }, 136 isDatebyDefault = function (D1, D2) { //2023-01-01 137 if (D2 === undefined || D2 === null || D2 == '') return false;
138 var Date1 = new Date(D1); 139 var D1_str = Date1.getFullYear() + '-' + Date1.getMonth() + '-' + Date1.getDate(); 140 var Date2 = new Date(D2); 141 var D2_str = Date2.getFullYear() + '-' + Date2.getMonth() + '-' + Date2.getDate(); 142 return (D1_str == D2_str); 143 }; 144 145 initElement(); 146 element.ready(function () { 147 var evt = $.Event('ready'); 148 element.trigger(evt, new Date(CurrentYear, CurrentMonth, CurrentDay)); 149 }); 150 element.on('click', '.month .prev', function (e) { 151 if (e.which != 1) return false; 152 e.preventDefault(); 153 CurrentMonth--; 154 if (CurrentMonth < 0) { 155 CurrentMonth = 11; 156 CurrentYear--; 157 } 158 initElement(CurrentMonth, CurrentYear); 159 var evt = $.Event('month_prev'); 160 element.trigger(evt, new Date(CurrentYear, CurrentMonth, CurrentDay)); 161 }); 162 element.on('click', '.month .next', function (e) { 163 //debugger; 164 if (e.which != 1) return false; 165 e.preventDefault(); 166 CurrentMonth++; 167 if (CurrentMonth > 12) { 168 CurrentMonth = 1; 169 CurrentYear++; 170 } 171 initElement(CurrentMonth, CurrentYear); 172 var evt = $.Event('month_next'); 173 element.trigger(evt, new Date(CurrentYear, CurrentMonth, CurrentDay)); 174 }); 175 element.on('click', '.y_Prev', function (e) { 176 if (e.which != 1) return false; 177 e.preventDefault(); 178 CurrentYear--; 179 initElement(CurrentMonth, CurrentYear); 180 var evt = $.Event('year_prev'); 181 element.trigger(evt, new Date(CurrentYear, CurrentMonth, CurrentDay)); 182 }); 183 element.on('click', '.y_Next', function (e) { 184 if (e.which != 1) return false; 185 e.preventDefault(); 186 CurrentYear++; 187 initElement(CurrentMonth, CurrentYear); 188 var evt = $.Event('year_next'); 189 element.trigger(evt, new Date(CurrentYear, CurrentMonth, CurrentDay)); 190 }); 191 element.on('click', '.normal, .today', function (e) { 192 //debugger; 193 e.preventDefault(); 194 CurrentDay = $(e.target).attr('data-day'); 195 if ($(e.target).attr('day-active') == 'true') { 196 var evt = $.Event('select'); 197 element.trigger(evt, new Date(CurrentYear, CurrentMonth, CurrentDay)); 198 } 199 }); 200 }); 201 } 202})(jQuery); 203 204/** 205 * 206 * @param date Date 207 * @param selector string 208 * @returns {Promise<void>} 209 */ 210let getMonthInfo = async function (date, selector) { 211 //debugger; 212 213 let url = '/calendar/info/' + date.getFullYear() + '/' + (date.getMonth() + 1); 214 let response = await fetch(url); 215 if (response.ok) { 216 data = await response.json(); 217 data.days.forEach(function (item) { 218 //debugger; 219 var $el = $(selector).find('[data-date="' + item.date + '"]'); 220 $(selector).find('[data-date="' + item.date + '"]') 221 .attr('day-off', (item.is_day_off ? true : false)) 222 .attr('day-active', ((item.news_count > 0) ? true : false)); 223 }); 224 } 225}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.