PageSourceSearch

https://takeuchi-naika.jp/wp-content/plugins/wevery-calendar/wevery-calendar.js

js takeuchi-naika.jp collected 2026-09-26 07:10:52 UTC 10,527 bytes, 365 lines download raw bytes

1//
2// ページ読み込み時
3//
4jQuery(document).ready(function(){
5
6	jQuery(".isp-calendar-frame").each( function() {
7
8		// 当月カレンダーをdiv内に表示
9		create_wevery_calendar(jQuery(this));
10
11		// リターン
12		return true;
13	});
14
15});
16
17// 指定月のカレンダーを表示
18// 第1引数: isp-calendar-frame の jQueryオブジェクト
19// 第2引数: カレンダーの年(省略時は当年)
20// 第3引数: カレンダーの月(省略時は当月)
21function create_wevery_calendar(jq, y, m) {
22
23	// html埋め込みパラメータ
24	var bas_holiday = new Array();
25	var inc_holiday = new Array();
26	var exc_holiday = new Array();
27	//2016.06.29 add
28	var cst_holiday = new Array();
29	var cst_label = new Array();
30	var jpn_holiday = new Array();
31	var month_future;
32	var month_past;
33	var s_day;
34	//2016.07.20 add
35	var sinryo;
36	
37	// 変数
38	var now = new Date();	// 現在時カレンダー
39	var arr;				// "yyyy-m"形式の文字列
40	var today = false;		// 当月であれば true
41	var mydate;				// 表示年月の先頭日
42	var firstday;			// 表示年月の先頭日の曜日
43	var enddate;			// 表示年月の末日
44	var nxt_y;				// 翌月の年
45	var nxt_m;				// 翌月の月
46	var prv_y;				// 先月の年
47	var prv_m;				// 先月の月
48	var max_y_f;			// 月送りの限界年
49	var max_m_f;			// 月送りの限界月
50	var max_y_p;			// 月戻りの限界年
51	var max_m_p;			// 月戻りの限界月
52	var nxt_link;			// 先月へのリンクhtml
53	var prv_link;			// 来月へのリンクhtml
54	var day_array;			// 曜日表示文字の配列
55	
56	// 作業変数
57	var today_class = '';
58	var check_date;
59	var week = -1;
60	var holiday;
61	var html;				// 出力html
62	var values;
63	var val;
64	var i;
65	var diff;
66
67	// 省略時引数のセット
68	if(y == undefined) y = now.getFullYear();
69	if(m == undefined) m = now.getMonth() + 1;
70	while ( jq.attr("class") != "isp-calendar-frame") {
71		jq = jq.parent();
72	}
73
74	// 当月か確認
75	if(y == now.getFullYear() && m == now.getMonth() + 1) {
76		today = true;
77	}
78
79	// HTML埋め込みパラメータの取得
80	values = jq.children(".base-holiday").val();
81	values = values.split('&');
82	for(i=0; i<values.length; i++) {
83		val = values[i].split('=');
84		bas_holiday[i] = val[1].split(',');
85	}
86
87
88	values = jq.children(".inc-holiday").val();
89	if( values.length > 0) {
90		values = values.split('&');
91		for(i=0; i<values.length; i++) {
92			val = values[i].split('=');
93			inc_holiday[val[0]] = val[1].split(',');
94		}
95	}
96
97	values = jq.children(".exc-holiday").val();
98	if( values.length > 0) {
99		values = values.split('&');
100		for(i=0; i<values.length; i++) {
101			val = values[i].split('=');
102			exc_holiday[val[0]] = val[1].split(',');
103		}
104	}
105	
106	//2016.06.29 add
107	values = jq.children(".cst-holiday").val();
108	if( values.length > 0) {
109		values = values.split('&');
110		for(i=0; i<values.length; i++) {
111			val = values[i].split('=');
112			cst_holiday[val[0]] = val[1].split(',');
113		}
114	}
115	values = jq.children(".cst-label").val();
116	if( values.length > 0) {
117		values = values.split('&');
118		for(i=0; i<values.length; i++) {
119			val = values[i].split('=');
120			cst_label[val[0]] = val[1].split(',');
121		}
122	}
123	values = jq.children(".jpn-holiday").val();
124	if( values.length > 0) {
125		values = values.split('&');
126		for(i=0; i<values.length; i++) {
127			val = values[i].split('=');
128			jpn_holiday[val[0]] = val[1].split(',');
129		}
130	}
131	
132	sinryo = jq.children(".sinryo").val();
133
134	month_future = parseInt(jq.children(".month_future").val());
135	
136	month_past = parseInt(jq.children(".month_past").val());
137
138	s_day = parseInt(jq.children(".s_day").val());
139	var label_note = jq.children(".label_note").val();
140
141
142	// 月送りを求める(未来)
143	max_y_f = now.getFullYear();
144	max_m_f = (now.getMonth() + 1) + month_future;
145	if(max_m_f > 12) {
146		max_y_f++;
147		max_m_f -= 12;
148	}
149	check_date = new Date(max_y_f, (max_m_f-1), 1);
150	mydate = new Date(y, (m-1), 1);
151	if((check_date - mydate) < 0) {
152		y = max_y_f;
153		m = max_m_f;
154	}
155
156
157	// 月送りを求める(過去)
158	max_y_p = now.getFullYear();
159	max_m_p = (now.getMonth() + 1) - month_past;
160	if(max_m_p < 0) {
161		max_y_p--;
162		max_m_p += 12;
163	}
164	check_date = new Date(max_y_p, (max_m_p-1), 1);
165	mydate = new Date(y, (m-1), 1);
166	if((mydate - check_date) < 0) {
167		y = max_y_p;
168		m = max_m_p;
169	}
170
171	arr = y + "-" + m;
172
173	// 翌月、先月を取得
174	if(m == 1) {
175		nxt_y = y; nxt_m = m + 1; prv_y = y - 1; prv_m = 12;
176	} else if(m == 12) {
177		nxt_y = y + 1; nxt_m = 1; prv_y = y; prv_m = m - 1;
178	} else {
179		nxt_y = y; nxt_m = m + 1; prv_y = y; prv_m = m - 1;
180	}
181
182	// リンクを取得
183	if(y == max_y_f && m == max_m_f) {
184		nxt_link = '<div class="move_button nxt_off">&nbsp;</div>';
185	} else {
186		nxt_link = '<div class="move_button nxt" onclick="create_wevery_calendar( jQuery(this), ' + nxt_y + ', ' + nxt_m + ')">&nbsp;</div>';
187	}
188
189	if(y == max_y_p && m == max_m_p) {
190		prv_link = '<div class="move_button prv_off">&nbsp;</div>';
191	} else {
192		prv_link = '<div class="move_button prv" onclick="create_wevery_calendar( jQuery(this), ' + prv_y + ', ' + prv_m + ')">&nbsp;</div>';
193	}
194
195	// 末日を取得
196	mydate = new Date(y, m, 0);
197	enddate = mydate.getDate();
198
199	// 指定年指定月1日の曜日
200	mydate = new Date(y, (m-1), 1);
201	firstday = mydate.getDay();
202
203	// 週始めを取得
204	if(s_day == 0) {
205		day_array = new Array("日", "月", "火", "水", "木", "金", "土");
206	} else if(s_day == 1) {
207		day_array = new Array("月", "火", "水", "木", "金", "土", "日");
208	} else if(s_day == 2) {
209		day_array = new Array("火", "水", "木", "金", "土", "日", "月");
210	} else if(s_day == 3) {
211		day_array = new Array("水", "木", "金", "土", "日", "月", "火");
212	} else if(s_day == 4) {
213		day_array = new Array("木", "金", "土", "日", "月", "火", "水");
214	} else if(s_day == 5) {
215		day_array = new Array("金", "土", "日", "月", "火", "水", "木");
216	} else if(s_day == 6) {
217		day_array = new Array("土", "日", "月", "火", "水", "木", "金");
218	}
219
220	// カレンダーの作成
221	html = '<table summary="休診日カレンダー" class="isp-calendar-inner" border="0" cellspacing="0" cellpadding="0"><tbody>'
222				+ '<tr><td>' + prv_link + '</td>'
223				+ '<td class="calendar-date-title">' + y + ' 年 ' + m + ' 月</td>'
224				+ '<td align="right">' + nxt_link + '</td></tr>'
225				+ '<tr><td colspan="3">'
226				+ '<table summary="休診日カレンダー" class="isp-business-calendar" border="0" cellpadding="0" cellspacing="1"><thead><tr>';
227
228	for(var i=0; i<day_array.length; i++) {
229		html += '<th>' + day_array[i] + '</th>';
230	}
231
232	html += '</tr></thead><tbody>';
233
234
235	// 1日になるまで空白のセルを作成
236	if(firstday < s_day) {
237		diff = Math.abs((7+firstday) - s_day);
238	} else {
239		diff = Math.abs(firstday - s_day);
240	}
241
242	if(diff > 0) {
243		html += '<tr valign="middle">';
244		for(var i=0; i<diff; i++) {
245			html += '<td class="space">&nbsp;</td>';
246		}
247	}
248
249	// カレンダー本体の作成
250	for(var i=1; i<=enddate; i++) {
251		myday = mydate.getDay();
252		if(myday == s_day && i != 1) {
253			html += '</tr><tr valign="middle">';
254		}
255
256		if(myday == firstday) week++;
257
258		// 休日の確認
259		holiday = bas_holiday[week][myday];
260		
261		if(jpn_holiday[arr] != undefined) {
262			if(jQuery.inArray(i+"", jpn_holiday[arr]) > -1) holiday = "A";
263		}
264		if(exc_holiday[arr] != undefined) {
265			if(jQuery.inArray(i+"", exc_holiday[arr]) > -1) holiday = sinryo;
266		}
267		if(inc_holiday[arr] != undefined) {
268			if(jQuery.inArray(i+"", inc_holiday[arr]) > -1) holiday = "A";
269		}
270
271		//2016.06.29 add start
272		//カスタム日程を表示する
273		cst_arr = y + "-" + m + "-" + i
274		if (cst_holiday[arr] != undefined) {
275			//ラベルを取得
276			if(cst_label[cst_arr]) {
277				if(jQuery.inArray(i+"", cst_holiday[arr]) > -1) holiday = cst_label[cst_arr];
278			}
279		}
280		//2016.06.29 add end
281		
282		//if(jpn_holiday[arr] != undefined) {
283		//	if(jQuery.inArray(i+"", jpn_holiday[arr]) > -1) holiday = "A";
284		//}
285
286		// 本日の確認
287		if(today) {
288			if(i == now.getDate()) {
289				today_class = ' today';
290			} else {
291				today_class = '';
292			}
293		}
294
295		if(holiday.length > 0) {
296			html += '<td class="' + holiday + today_class + '">' + i + '</td>';
297		} else {
298			html += '<td class="business' + today_class + '">' + i + '</td>';
299		}
300
301		mydate.setDate(mydate.getDate() + 1);
302
303		// 末日以降のデータを埋める
304		if(i == enddate) {
305			while(mydate.getDay() != s_day) {
306				html += '<td class="space">&nbsp;</td>';
307				mydate.setDate(mydate.getDate() + 1);
308			}
309		}
310	}
311	
312	//2018.10.18 change start カレンダー上テキストを可変
313	//var holiday_ex = '<p class="calendar-information"><span class="holiday-color A">&nbsp;</span>休診日</p>';
314	var holiday_txt = '';
315	var holiday_ex = '';
316	if($('.txt_a').val().length) {
317		holiday_txt = $('.txt_a').val();
318	} else {
319		holiday_txt = "休診日";
320	}
321	holiday_ex += '<p class="calendar-information"><span class="holiday-color A">&nbsp;</span>' + holiday_txt + '</p>';
322	//2018.10.18 change end
323	if($('.txt_b').val().length) {
324		holiday_txt = $('.txt_b').val();
325		holiday_ex += '<p class="calendar-information"><span class="holiday-color B">&nbsp;</span>' + holiday_txt + '</p>';
326	}
327	if($('.txt_c').val().length) {
328		holiday_txt = $('.txt_c').val();
329		holiday_ex += '<p class="calendar-information"><span class="holiday-color C">&nbsp;</span>' + holiday_txt + '</p>';
330	}
331	if($('.txt_d').val().length) {
332		holiday_txt = $('.txt_d').val();
333		holiday_ex += '<p class="calendar-information"><span class="holiday-color D">&nbsp;</span>' + holiday_txt + '</p>';
334	}
335	if($('.txt_e').val().length) {
336		holiday_txt = $('.txt_e').val();
337		holiday_ex += '<p class="calendar-information"><span class="holiday-color E">&nbsp;</span>' + holiday_txt + '</p>';
338	}
339	if($('.txt_f').val().length) {
340		holiday_txt = $('.txt_f').val();
341		holiday_ex += '<p class="calendar-information"><span class="holiday-color F">&nbsp;</span>' + holiday_txt + '</p>';
342	}
343
344	html += '</tr></tbody></table>'
345				+ '</td></tr>'
346				+ '<tr><td colspan="3">'
347				+ holiday_ex
348				+ '</td></tr>';
349
350	if (label_note && label_note.length > 0) {
351		html += '<tr><td colspan="3">'
352				+ '<p class="calendar-label-note">' + label_note.replace(/\n|&#13;&#10;/g, '<br/>') + '</p>'
353				+ '</td></tr>';
354	}
355
356	html += '<tr><td colspan="3">'
357				+ '<p class="return_now"><a href="javascript:void(0);" onclick="create_wevery_calendar( jQuery(this), ' + now.getFullYear() + ', ' + (now.getMonth() + 1) + ');">当月に戻る</a></p>'
358				+ '<div style="clear: both;"></div></td></tr>'
359				+ '</tbody></table>';
360
361	jq.children(".isp-calendar-table").html(html);
362	
363	// リターン
364	return true;
365}

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.