PageSourceSearch

https://syntone.ru/wp-content/themes/syntone/assets/js/calendar.js

js syntone.ru collected 2026-10-02 14:54:14 UTC 7,603 bytes, 265 lines download raw bytes

1var calendar = {
2	
3	init: function() {
4		this.startCalendar();
5	},
6	
7	getMonthName: function(monthNumber, withdate) {
8		var months1 = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
9		var months2 = ['Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря'];
10		if (withdate) {
11			return months2[monthNumber];
12			} else {
13			return months1[monthNumber];
14		}
15	},
16	
17	setMonth: function(monthNumber, yearNumber) {
18		$('.month').text(this.getMonthName(monthNumber, false) + ' ' + yearNumber);
19		$('.month').attr('data-month', monthNumber);
20		$('.month').attr('data-year', yearNumber);
21		this.printDateNumber(monthNumber, yearNumber);
22	},
23	
24	getDaysInMonth: function(month, year) {
25		var date = new Date(year, month, 1);
26		var days = [];
27		while (date.getMonth() === month) {
28			days.push(new Date(date));
29			date.setDate(date.getDate() + 1);
30		}
31		return days;
32	},
33	
34	setCurrentDay: function() {
35		var viewMonth = $('.month').attr('data-month');
36		var viewYear = $('.month').attr('data-year');
37		var d = new Date();
38		if (d.getFullYear() == viewYear && d.getMonth() == viewMonth) {
39			$('tbody.event-calendar td[data-day="' + d.getDate() + '"]').addClass('current-day');
40		}
41	},
42	
43	setEvent: function () {
44		$('.day-event').each(function(i) {
45			var eventMonth = $(this).attr('data-month'),
46			eventDay = $(this).attr('data-day'),
47			eventYear = $(this).attr('data-year'),
48			eventClass = $(this).attr('event-class'),
49			stringToStr = '<a href="./?eventYear=' + eventYear + '&eventMonth=' + eventMonth + '&eventDay=' + eventDay + '">' + eventDay + '</a>';
50			
51			if (eventClass === undefined) {
52				eventClass = 'event';
53				} else {
54				eventClass = 'event ' + eventClass;
55			}
56			$('tbody.event-calendar tr td[data-year="' + eventYear + '"][data-month="' + eventMonth + '"][data-day="' + eventDay + '"]').addClass(eventClass);
57			$('tbody.event-calendar tr td[data-year="' + eventYear + '"][data-month="' + eventMonth + '"][data-day="' + eventDay + '"]').html(stringToStr);
58		});
59	},
60	
61	displayEvent: function() {
62		$('tbody.event-calendar td').on('click', function(e) {
63			var monthEvent = $(this).attr('data-month'),
64			dayEvent = $(this).attr('data-day'),
65			yearEvent = $(this).attr('data-year');
66			if ($(this).hasClass('event')) {
67			}
68		});
69	},
70	
71	printDateNumber: function(monthNumber, yearNumber) {
72		
73		$($('tbody.event-calendar')).empty();
74		
75		$($('thead.event-days tr')).each(function(index) {
76			$(this).empty();
77		});
78		
79		var week_days = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
80		$(week_days).each(function(index, val) {
81			$('thead.event-days tr').append('<td>' + val + '</td>');
82		});
83		
84		var days = this.getDaysInMonth(monthNumber, yearNumber);
85		var i = 0;
86		var row = 0;
87		
88		monthNumber++;
89		
90		$(days).each(function(index, val) {
91			if (i == 0) {
92				$('tbody.event-calendar').append('<tr class="row' + row + '"></tr>');
93			}
94			if (index == 0) {
95				var w_day = val.getDay();
96				if (w_day == 0) {
97					w_day = 7;
98				}
99				while(--w_day) {
100					i++;
101					$('tbody.event-calendar tr.row'  + row).append('<td>&nbsp;</td>');
102				}
103			}
104			$('tbody.event-calendar tr.row'  + row).append('<td data-month="' + monthNumber + '" data-day="' + val.getDate() + '" data-year="' + yearNumber + '">' + val.getDate() + '</td>');
105			
106			i++;
107			
108			if (i >=7) {
109				i = 0;
110				row++;
111			}
112		});
113		
114		this.setCurrentDay();
115		this.setEvent();
116		this.displayEvent();
117	},
118	
119	//обработчики ссылок на календаре
120	sortEvents: function() {
121		var cal = this;
122		$('.event a').click(function(e) {
123			var eventMonth = $(this).parent().attr('data-month'),
124			eventDay = $(this).parent().attr('data-day'),
125			eventYear = $(this).parent().attr('data-year');
126			
127			$('.filter a').removeClass('active');
128			
129			$('.trmonth,.item,.tcat').hide();
130			$('.headmonth').show();
131			$('.headmonth .container .month').text(eventDay + ' ' + cal.getMonthName(eventMonth - 1, true));
132			$('.item[data-month="' + eventMonth + '"][data-day="' + eventDay + '"][data-year="' + eventYear + '"]').show();
133			
134			e.preventDefault();
135		}
136	)},
137	showTraining: function(month, year) {
138		month++;
139		$('.headmonth').show();
140		
141		$('.trmonth,.item,.tcat').hide();
142		$('.item[data-month="' + month + '"][data-year="' + year + '"]').show();
143		$('.filter a').removeClass('active');
144		$('.short-calendar-list .container .filter a').show();
145		
146		if ( !$('.short-calendar-list .item:visible').length ) {
147			$('.no-resuilts').show();
148			} else {
149			$('.no-resuilts').hide();
150		}
151		
152	},
153	startCalendar: function() {
154		var cal = this;
155		var d = new Date();
156		var yearNumber = (new Date).getFullYear();
157		var monthNumber = d.getMonth();
158		
159		this.setMonth(monthNumber, yearNumber);
160		
161		
162		$('.btn-next').on('click', function(e) {
163			var monthNumber = $('.month').attr('data-month');
164			var yearNumber = $('.month').attr('data-year');
165			monthNumber++;
166			if (monthNumber > 11) {
167				monthNumber = 0;
168				yearNumber++;
169			}
170			cal.setMonth(monthNumber, yearNumber);
171			e.preventDefault();
172			cal.sortEvents();
173			cal.showTraining(monthNumber, yearNumber);
174		});
175		
176		$('.btn-prev').on('click', function(e) {
177			var monthNumber = $('.month').attr('data-month');
178			var yearNumber = $('.month').attr('data-year');
179			monthNumber--;
180			if (monthNumber < 0) {
181				monthNumber = 11;
182				yearNumber--;
183			}
184			cal.setMonth(monthNumber, yearNumber);
185			e.preventDefault();
186			cal.sortEvents();
187			cal.showTraining(monthNumber, yearNumber);
188		});
189		
190		$('.sort-by-date, .sort-by-cat').click(function() {
191			$('.no-resuilts').hide();
192		});
193		
194		$('.short-calendar-list .container .filter a, .col-8 .filter a').click(function() {
195			$('.short-calendar-list .container .filter a').hide();
196			$('.sort-by-date').addClass('active');
197		});	
198		
199		
200		$('tbody td').on('click', function(e) {
201			if ($(this).hasClass('event')) {
202				$('tbody.event-calendar td').removeClass('active');
203				$(this).addClass('active');
204				} else {
205				$('tbody.event-calendar td').removeClass('active');
206			}
207		});
208		
209		this.sortEvents();
210	}
211};
212
213$(document).ready(function() {
214	calendar.init('ajax');
215});
216
217function getSorted(selector, attrName) {
218    return $($(selector).toArray().sort(function(a, b){
219		var aVal = parseInt(a.getAttribute(attrName)),
220		bVal = parseInt(b.getAttribute(attrName));
221		return aVal - bVal;
222	}));
223}
224
225$(document).ready(function() {
226	
227	$('.sort-by-date').click(function(e) {
228		$('.tcat,.headmonth').hide();
229		
230		$(this).siblings('a').removeClass('active');
231		$(this).addClass('active');
232		
233		$(".short-calendar-list .sort").sort(sort_li).appendTo('.short-calendar-list');
234		function sort_li(a, b){
235			return ($(b).data('number')) < ($(a).data('number')) ? 1 : -1;  
236		}
237		$('.trmonth').show();
238		$('.item').show();
239		
240		e.preventDefault();
241	});
242	
243	$('.sort-by-cat').click(function(e) {
244		$('.trmonth,.headmonth').hide();
245		$(this).siblings('a').removeClass('active');
246		$(this).addClass('active');
247		$(".short-calendar-list .sort").sort(sort_li).appendTo('.short-calendar-list');
248		function sort_li(a, b){
249			return ($(b).data('cat-index')) < ($(a).data('cat-index')) ? 1 : -1;  
250		}
251		$('.item').show();
252		
253		$('.tcat').each(function(i, v){
254			var cat = $(v).data('cat') + 0.5;
255			var cnt = $('.item[data-cat="' + cat + '"]').length;
256			if (cnt == 0) {
257				$(v).hide();
258				} else {
259				$(v).show();
260			}
261		});
262		e.preventDefault();
263	});
264	
265});

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.