-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar.js
1295 lines (1251 loc) · 60.9 KB
/
calendar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function () {
var gregorianFestivalGlobal = {
// 5.8-14 6.15-21 節
"3-23": "js国历",
"2-14": "情人节~",
"4-1": "愚人节~",
"4-6": "米粉节&荣耀~",
"6-14": "618家电~",
"8-18": "苏宁818~",
"9-12": "魅友节~",
"9-15": "造物节~",
"11-1": "万圣节~",
"11-11": "双11~",
"12-12": "双12~",
"12-24": "平果安夜~",
"12-25": "圣诞节~",
"1-1": "元旦节",//TODO
"3-8": "妇女节~",
"3-12": "植树节~",
"5-1": "劳动节",
"5-4": "青年节~",
"6-1": "儿童节~",
"7-1": "建党节~",
"8-1": "建军节~",
"9-10": "教师节~",
"10-1": "国庆节"
};
var lunarFestivalGlobal = {
"2-20": "js农历",
"1-1": "春节",
"1-7": "七样~",
"1-15": "元宵节~",
"5-5": "端午节",
"7-7": "七夕~",
"8-15": "中秋节",
"9-9": "重阳节~",
"12-8": "腊八~",
"12-24": "小年~" // 有的是23小年 有的算24小年
};
var calendar = {
gregorianFestival: gregorianFestivalGlobal,
lunarFestival: lunarFestivalGlobal,
/**
* 农历1900-2100的闰大小信息表
* 例如:0x04bd8 相当于 0000 0100 1011 1101 1000 19位 ---> 0位
* 第0-3位代表 是否是闰月,如果全为0代表不闰月,否则代表闰月的月份。
* 第15-4位代表从1月到12月是大月还是小月,大月30天,小月29天。
* 后4位代表的是闰月是大月还是小月 0为小1为大。
* 2033年的数据网上流传的是0x04bd7 其实应该是0x04afb
*/
lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, //1900-1909
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, //1910-1919
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, //1920-1929
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, //1930-1939
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, //1940-1949
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, //1950-1959
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, //1960-1969
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, //1970-1979
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, //1980-1989
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, //1990-1999
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, //2000-2009
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, //2010-2019
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, //2020-2029
0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, //2030-2039
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, //2040-2049
0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, //2050-2059
0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, //2060-2069
0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, //2070-2079
0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, //2080-2089
0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, //2090-2099
0x0d520 //2100
],
/**
* 公历每个月份的天数普通表
*/
solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
//solarMonth:-1, 2, -3, 4, -5, 6, -7, -8, 9,-10, 11,-12],
/**
* 天干地支之天干速查表
*/
Gan: ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"],//6*10
//甲子(鼠年) 1984 wu\ geng- ren/ gui\/
/**
* 生肖
*/
Animals: ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"],
//天干地支之地支速查表
Zhi: ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"],//5*12
//月 11 12 1yin/ 2mao\/ 3 4si\ 5 6 7 8you\/ 9xu- 10hai\
//时辰 昨天23- 1- 3- 5- 7- 9- 11- 13- 15- 17- 19- 21:00-23:00
// 水 土 木 木 土 火 火 土 土 金 金 水
//相克:金克木 木克土 土克水 水克火 火克金 金 木 土 水 火 金木土水火
//相生:水生木 木生火 火生土 土生金 金生水 水木火土金|水木火土金|水木火土金
//金木水火土
//西东北南中
//太极生两仪,两仪生四象,四象生八卦
//
/*
* 计算天干地支季月使用
* "甲": [2, 2] 表示 甲年的第一个月(立春)是丙寅月
*/
monthTD: {
"甲": [2, 2],//木 阳 东方木90 丙寅 -.- -.- ---雷震[zhèn] 青龙 春
"乙": [4, 2],//木 阴 东南方135 戊寅 --- --- -.-风巽[xùn]
"丙": [6, 2],//火 阳 正南方180 庚寅 --- -.-少阳 ---火离[lí] 朱雀 夏
"丁": [8, 2],//火 阴 西南方 壬寅
"戊": [0, 2],//土 阳 正南方 甲寅
"己": [2, 2],//土 阴 西南方225 丙寅 -.- -.-太阴 -.-地坤[kūn]
"庚": [4, 2],//金 阳 正西方270 戊寅 -.- --- ---泽兑[duì] 白虎 秋
"辛": [6, 2],//金 阴 西北方315 庚寅 --- ---太阳 ---天乾[qián]
"壬": [8, 2],//水 阳 正北方0 壬寅 -.- ---少阴 -.-水坎[kǎn] 玄武 冬
"癸": [0, 2] //水 阴 东北方45 甲寅 --- -.- -.-山艮[gèn] 土 后天 外->里
},
/**
* 24节气速查表
*/
solarTerm: ["小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满",
"芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪",
"大雪", "冬至"
],
/**
* 24节气速查表,每种节气的计算数据
*/
sTermInfo: [0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693,
263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758
],
/**
* 日期转农历称呼速查表
*/
lunarDayStrFirst: ['初', '十', '廿', '卅'],
lunarDayStrLast: ["十", "一", "二", "三", "四", "五", "六", "七", "八", "九"],
/**
* 星期称呼速查表
*/
Week: ["一", "二", "三", "四", "五", "六", "日"],
/**
* 月份转农历称呼速查表
*/
lunarMonthStr: ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"], /*
* 返回农历Y年的天数、闰月信息和每个月的信息
*/
getLunarYearDays: function (Y) {
var sum = 348;
var lunarMonth = new Array();
var leapMonth = [0, 0];
var flag = 0;
var temp = 0x8000
for (i = 0; i < 12; i += 1) {
flag = (calendar.lunarInfo[Y - 1900] & temp) ? 1 : 0;
lunarMonth[i] = flag;
sum += flag;
temp >>= 1
}
leapMonth = calendar.getLunarMonth(Y);
sum += leapMonth[1];
return {
sum: sum,
leapMonth: leapMonth,
lunarMonth: lunarMonth
};
},
/*
* 判断今年是否有闰月 闰月是大月还是小月
*/
getLunarMonth: function (Y) {
if (calendar.lunarInfo[Y - 1900] & 0xf) {
return [calendar.lunarInfo[Y - 1900] & 0xf, (calendar.lunarInfo[Y - 1900] & 0x10000) ? 30 : 29];
}
return [0, 0];
},
/*
* 获取1900(1900-01-31)年春节到的Y-M-D的阳历日期
*/
gregorianCalendar: function (Y, M, D) {
var sum = 0;
for (var i = 1900; i < Y; i += 1) {
if (i % 400 == 0 || (i % 100 != 0 && i % 4 == 0)) sum += 366;
else sum += 365;
}
for (var i = 0; i < M - 1; i += 1) sum += calendar.solarMonth[i];
if ((M > 2) && (Y % 400 == 0 || (Y % 100 != 0 && Y % 4 == 0))) sum += 1;
sum += D - 1;
return sum - 30;
},
/*
* 获取1900年春节到的Y的阴历日期
*/
lunarCalendar: function (Y, M, D) {
var sum = 0;
var temp = null;
for (var i = 1900; i < Y; i += 1) {
temp = calendar.getLunarYearDays(i);
sum += temp.sum;
}
temp = calendar.getLunarYearDays(Y);
for (var i = 0; i < M - 1; i++) sum += temp.lunarMonth[i] == 0 ? 29 : 30;
if (temp.leapMonth[0] < M) sum += temp.leapMonth[1];
sum += D - 1;
return sum;
},
/*
* 将阳历转换为阴历
*/
calendarConvert: function (Y, M, D) {
var num = calendar.lunarCalendar(Y, M, D) - calendar.gregorianCalendar(Y, M, D);
var demo = calendar.getLunarYearDays(Y);
var result = 0;
if (D > num) return [0, Y, M, (D - num)];
M -= 1;
if (M == 0) {
M = 12;
Y -= 1;
demo = calendar.getLunarYearDays(Y);
}
if (M == demo.leapMonth[0]) result = 1;
if (D == num) return [result, Y, M, demo.lunarMonth[M - 1] == 0 ? 29 : 30];
if (num > D) num -= D;
while (true) {
var temp = 0;
if (demo.leapMonth[0] == M && result == 1) {
temp = demo.leapMonth[1];
} else {
temp = demo.lunarMonth[M - 1] == 0 ? 29 : 30;
}
if (temp > num) {
num = temp - num;
break;
}
num -= temp;
if (num == 0) {
if (demo.leapMonth[0] == M && result == 1) {
num = demo.lunarMonth[M - 1] == 0 ? 29 : 30;
result = 0;
} else {
M -= 1;
if (M == 0) {
M = 12;
Y -= 1;
demo = calendar.getLunarYearDays(Y);
}
if (demo.leapMonth[0] == M) {
result = 1;
num = demo.leapMonth[1];
} else {
num = demo.lunarMonth[M - 1] == 0 ? 29 : 30;
}
}
break;
}
if (demo.leapMonth[0] == M && result == 1) result = 0;
else {
M -= 1;
if (M == 0) {
Y -= 1;
M = 12;
demo = calendar.getLunarYearDays(Y);
}
if (demo.leapMonth[0] == M) result = 1;
}
}
return [result, Y, M, num];
}
};
/* 保存今天的日期 */
var ToDay = null;
/* 保存点击的日期 */
var ClickDays = 0;
/* 休假和上班自定义配置信息 */
var configDay = {};
/* 本月信息 */
var configDayM = {};
var isclick = false;
var addAutoFestivalFlag = true;
var foreveryearFlag = false;
var untilYear = 1990;
var untilMonth = 1;
var untilDay = 1;
//默认鼠标坐标
var mousex = 10;
var mousey = 20;
/*************************主程序******************************/
$.fn.calendar = function (options) {
var e = this;
var defaults = {
date: new Date(),
width: 516,//800
height: 400,//400
rate: 1,
week: false,
week_walue: "2016/9/17",
isclick: false,
configDay: {}
};
var object = $.extend(true, {}, defaults, options);
ToDay = object.date;
isclick = object.isclick;
configDay = object.configDay;
createTable(object, e);
};
/*************************主程序******************************/
function createTable(options, e) {
var Y = options.date.getFullYear();
var M = options.date.getMonth() + 1;
/* 拷贝configDay对应本月的设置信息 */
ClickDays = options.date.getDate();
/* 创建时间表格 */
var datetable = new DateTable(Y, M, e);
datetable.create();
/* 设置样式 */
setLayer(options, datetable.count);
/* 设置触发事件 */
btnClick(options, e, datetable.count);
/* 设置单双休 */
if (options.week) {
setconfigDay(options, datetable.count, setWeek(options));
}
setconfigDayM(Y, M);
addFestival(Y, M, datetable.days, options);
setconfigDay(options, datetable.count, configDayM);
$("#SY").val(Y);
$("#SM").val(M);
}
/* 拷贝configDay对应本月的设置信息 */
function setconfigDayM(Y, M) {
if (configDay["Y" + Y] && configDay["Y" + Y]["M" + M]) configDayM = $.extend(true/*深度拷贝*/, {}/*保存到新对象*/, configDay["Y" + Y]["M" + M]);
else configDayM = {};
// alert(JSON.stringify(configDayM));
//{"D1":"休","D7":"班","D5":"抢"}
}
function baregetfest(Y, M) {
var date = new Date(Y + "/" + M + "/" + 1);
$.post(
"fest",
{"date": date},
function (response) {
// if(response.success){
alert(response.message);
// }
},
"json"
)
}
function getfest(Y, M) {
var date = new Date(Y + "/" + M + "/" + 1);
var servergregorianFestival = {};
// alert(date);
$.ajax(//TODO ajax order
{
url: "/fest",
async: false,//time
data: {"date": date},
type: "get",
dataType: "json",
success: function (data) {
// alert(JSON.stringify(data));
// alert(JSON.parse(data));
if(servergregorianFestival != {}){
calendar.gregorianFestival = {};
calendar.gregorianFestival = servergregorianFestival;
}
if (data != null) {
for (var i = 0; i < data.length; i++) {
var date = data[i].cal.toString();
var y = date.substring(0, 4);
var m = ~~date.substr(5, 2);
var d = ~~date.substr(8, 2);
// if (Y.toString() == y.toString()) {//TODO 返回一年,支持多年
// alert(y+"!"+m+"!"+d);
servergregorianFestival[m + "-" + d] = data[i].timing;
// if(m == M || m+1 == M)
// }
}
}
// for(var key in servergregorianFestival){
// console.log("属性:" + key + ",值:"+ jsonData[key]);
// }
// servergregorianFestival.forEach(function (item) {
// console.log(item.toString());
// });
// servergregorianFestival.forEach(function (value, key, map) {
// alert(key+value);
// });
},
error: function () {
console.log("errorfest");
}
});
$.ajax(
{
url: "/foreveryear",
async: false,//time
type: "get",
dataType: "json",
success: function (data) {
var serverlunarFestival = {};
for(var i =0;i<data.length;i++){
var m = data[i].month;
var d = data[i].day;
var y = Y;
if(data[i].solar == true){
if(servergregorianFestival[m+"-"+d] && servergregorianFestival[m+"-"+d].indexOf(data[i].timing) != -1) continue;
if (servergregorianFestival[m + "-" + d]) {
if(servergregorianFestival[m + "-" + d].indexOf("~") != -1) {
addRemindFestival(Y, y, M, m, d, servergregorianFestival[m + "-" + d]);
servergregorianFestival[m + "-" + d] = data[i].timing + servergregorianFestival[m + "-" + d];
}else {
addRemindFestival(Y, y, M, m, d, data[i].timing);
servergregorianFestival[m + "-" + d] += data[i].timing;
}
servergregorianFestival[m + "-" + d] = servergregorianFestival[m + "-" + d].replace("节~","").replace("~","");
} else servergregorianFestival[m + "-" + d] = data[i].timing;
}else if(data[i].solar == false){
if(serverlunarFestival[m+"-"+d] && serverlunarFestival[m+"-"+d].indexOf(data[i].timing) != -1) continue;
serverlunarFestival[m+"-"+d] = data[i].timing;
}
}
if(servergregorianFestival != {}){
addAutoFestivalFlag = false;
foreveryearFlag = true;
calendar.gregorianFestival = {};
calendar.gregorianFestival = servergregorianFestival;
if(serverlunarFestival != {}) {
calendar.lunarFestival = {};
calendar.lunarFestival = serverlunarFestival;
}
console.log(servergregorianFestival);
console.log(serverlunarFestival);
}
},//[{"id":1,"timing":"sql农历生日","month":4,"day":24,"solar":false},{"id":2,"timing":"sql国历生日","month":6,"day":25,"solar":true},{"id":3,"timing":"sql造物节~","month":9,"day":15,"solar":true}]
error: function () {
console.log("errorforeveryear");
}
});
}
/*
[{"id":18,"timing":"rest","cal":"2019-05-01T00:00:00.000+0000"},{"id":19,"timing":"rest","cal":"2019-05-02T00:00:00.000+0000"}]
*/
function addqingming(Y) {
var m = 4;
var coefficient = [5.15, 5.37, 5.59, 4.82, 5.02, 5.26, 5.48, 4.70, 4.92, 5.135, 5.36, 4.60, 4.81, 5.04, 5.26];
var cd = parseInt(Y / 100 - 17);
var mod = parseInt(Y % 100);
var qingming = parseInt(mod * 0.2422 + coefficient[cd] - parseInt(mod / 4));
for (var j = 4; j <= 6; j++) {
if(calendar.gregorianFestival[m + "-" + j])
calendar.gregorianFestival[m + "-" + j] = calendar.gregorianFestival[m + "-" + j].replace("清明节","");
}
if(!calendar.gregorianFestival[m + "-" + qingming])
calendar.gregorianFestival[m + "-" + qingming] = "";
calendar.gregorianFestival[m + "-" + qingming] += "清明节";//TODO
// alert(qingming+""+calendar.gregorianFestival[4+"-"+qingming]);
}
function addFestival(Y, M, days, options) {
addAutoFestivalFlag = true;
foreveryearFlag = false;
calendar.gregorianFestival = gregorianFestivalGlobal;
calendar.lunarFestival = lunarFestivalGlobal;
// console.log(calendar.gregorianFestival);
addqingming(Y);
getfest(Y, M);
var date = new Date(Y + "/" + M + "/" + 1);
date.setDate(date.getDate() - 4);
for (var D = 1; D < (days + 7); D++) {
date.setDate(date.getDate() + 1);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
var w = date.getDay();
var xiu = "temp";
var lunar = calendar.calendarConvert(y, m, d);
if (M == 5 && w == 0 && d >= 8 && d <= 14) {
for (var j = 8; j <= 14; j++) {
if(calendar.gregorianFestival[m + "-" + j])
calendar.gregorianFestival[m + "-" + j] = calendar.gregorianFestival[m + "-" + j].replace("历母亲节~","");
}
if(!calendar.gregorianFestival[m + "-" + d])
calendar.gregorianFestival[m + "-" + d] = "";
calendar.gregorianFestival[m + "-" + d] += "历母亲节~";
}
if (M == 6 && w == 0 && d >= 15 && d <= 21) {
for (var j = 15; j <= 21; j++) {
if(calendar.gregorianFestival[m + "-" + j])
calendar.gregorianFestival[m + "-" + j] = calendar.gregorianFestival[m + "-" + j].replace("历父亲节~","");
}
if(!calendar.gregorianFestival[m + "-" + d])
calendar.gregorianFestival[m + "-" + d] = "";
calendar.gregorianFestival[m + "-" + d] += "历父亲节~";
}
addRestFestival(Y, y, M, m, d, xiu + calendar.gregorianFestival[m + "-" + d], w); //all
// if(lunar[0] == 0)//闰
addRestFestival(Y, y, M, m, d, xiu + (lunar[0] == 1?"闰":"") + calendar.lunarFestival[lunar[2] + "-" + lunar[3]], w); //all
var xiu = "抢";
var nextt = new Date(y + "/" + m + "/" + d);
nextt.setDate(nextt.getDate() + 29);
var rest = "";
rest = xiu + calendar.gregorianFestival[nextt.getMonth() + 1 + "-" + nextt.getDate()];
addRobFestival(Y, y, M, m, d, rest, nextt.getDay());//抢
nextt = new Date(y + "/" + m + "/" + d);
nextt.setDate(nextt.getDate() + 29);
lunar = calendar.calendarConvert(nextt.getFullYear(), nextt.getMonth() + 1, nextt.getDate());
rest = xiu + (lunar[0] == 1?"闰":"") + calendar.lunarFestival[lunar[2] + "-" + lunar[3]];
addRobFestival(Y, y, M, m, d, rest, nextt.getDay());
if (addAutoFestivalFlag == true) {
// console.log("addAutoFestivalFlag" + addAutoFestivalFlag);
//国庆start
var flag = ((m == 9) && (d == 29) && (w == 6)) ||//1
((m == 9) && (d == 30) && (w == 0)) ||
((m == 9) && (d == 29) && (w == 0)) ||//2
((m == 10) && (d == 12) && (w == 6)) ||
((m == 9) && (d == 28) && (w == 0)) ||//3
((m == 10) && (d == 11) && (w == 6)) ||
((m == 9) && (d == 27) && (w == 0)) ||//4?
((m == 10) && (d == 10) && (w == 6)) ||
((m == 9) && (d == 26) && (w == 0)) ||//5?
((m == 10) && (d == 9) && (w == 6)) ||
((m == 10) && (d == 8) && (w == 6)) ||//6
((m == 10) && (d == 9) && (w == 0)) ||
((m == 9) && (d == 30) && (w == 6)) ||//0
((m == 10) && (d == 8) && (w == 0));
if (flag == true) {
addRemindFestival(Y, y, M, m, d, "班国庆节");
}
xiu = "休";
nextt = new Date(y + "/" + m + "/" + d);
for (var j = 0; j < 6; j++) {
nextt.setDate(nextt.getDate() - 1);
rest = xiu + calendar.gregorianFestival[nextt.getMonth() + 1 + "-" + nextt.getDate()];
if (rest.indexOf("国庆") != -1) {
addRemindFestival(Y, y, M, m, d, rest);//,nextt.getDay());
}
}
nextt = new Date(y + "/" + m + "/" + d);
for (var j = 0; j < 6; j++) {
if (j == 0) {
nextt.setDate(nextt.getDate() + 1);
} else {
nextt.setDate(nextt.getDate() - 1);
}
lunar = calendar.calendarConvert(nextt.getFullYear(), nextt.getMonth() + 1, nextt.getDate());
rest = xiu + (lunar[0] == 1?"闰":"") + calendar.lunarFestival[lunar[2] + "-" + lunar[3]];
if (rest.indexOf("春节") != -1) {
addRemindFestival(Y, y, M, m, d, rest);//,nextt.getDay());
}
if (j == 0) {
nextt.setDate(nextt.getDate() - 1);
}
}
xiu = "抢";
nextt = new Date(y + "/" + m + "/" + d);
nextt.setDate(nextt.getDate() + 29);
for (var j = 0; j < 6; j++) {
nextt.setDate(nextt.getDate() - 1);
rest = xiu + calendar.gregorianFestival[nextt.getMonth() + 1 + "-" + nextt.getDate()];
if (rest.indexOf("国庆") != -1) {
addRemindFestival(Y, y, M, m, d, rest);//,nextt.getDay());
}
}
nextt = new Date(y + "/" + m + "/" + d);
nextt.setDate(nextt.getDate() + 29 + 8); //比除夕放假前29天提前6天开抢
for (var k = 0; k < 15; k++) {
//23(0) 24(1) 25(2) 26(3) 27(4) 28(5) ---初一(6)--- 6(29+1 -> 11+1) 7 8
//24(0) 25(1) 26(2) 27(3) 28(4) 29(5) ---初一(7)--- 6(12) 7 8
nextt.setDate(nextt.getDate() - 1);
if (k > 5 && k < 12) continue;
lunar = calendar.calendarConvert(nextt.getFullYear(), nextt.getMonth() + 1, nextt.getDate());
rest = xiu + (lunar[0] == 1?"闰":"") + calendar.lunarFestival[lunar[2] + "-" + lunar[3]];
if (rest.indexOf("春节") != -1) {
addRemindFestival(Y, y, M, m, d, rest);//,nextt.getDay());
}
}
}
}
}
function addRemindFestival(Y, y, M, m, d, v) {
console.log("Y" + Y + "y" + y + "M" + M + "m" + m + "D" + d + "v" + v);
v = v.replace("temp", "");//.replace("undefined", "");
if (Y.toString() == y.toString() && M.toString() == m.toString()) {
// if (v.indexOf("节") != -1 || v.indexOf("历") != -1 || v.indexOf("~") != -1 || v.indexOf("抢") != -1) {//for undefine
if (v.indexOf("undefined") == -1 && v != ""){
if(configDayM["D" + d] && (configDayM["D" + d].indexOf(v) != -1 || v.indexOf(configDayM["D" + d]) != -1)){}else{
if(v.indexOf("闰") == -1)
configDayM["D" + d] = configDayM["D" + d]?configDayM["D" + d]+v:v;
else if(v.indexOf("农历") != -1){
configDayM["D" + d] = configDayM["D" + d]?configDayM["D" + d]+v:v;
alert("闰月生日"+"Y"+Y+"y"+y+"M"+M+"m"+m+"D"+d+"v"+v);//2052 2071
}
}
if(configDayM["D"+d]) {
if ((configDayM["D" + d].split(/节[休班]/)).length > 2) {
// if (configDayM["D" + d].replace(/休节/g, "节休").split("节休").length > 2) {//map(_.trim([string=''], [chars=whitespace]))
if(addAutoFestivalFlag == true)
console.log("两个节假日重叠,请人工核实自动计算的结果" + configDayM["D"+d]);//TODO
}
}
}
// alert("Y"+Y+"y"+y+"M"+M+"m"+m+"D"+d+"v"+v);
}
}
function addRestFestival(Y, y, M, m, d, rest, w) {
if (rest.indexOf("节") != -1 && rest.indexOf("~") == -1 && rest.indexOf("班") == -1 && rest.indexOf("节休") == -1)
rest = rest.replace("节", "节休");
// rest = rest.replace("temp", "");
addRemindFestival(Y, y, M, m, d, rest);
if (rest.indexOf("休") != -1) addAutoFestival(Y, y, M, m, d, rest, w);
}
function addRobFestival(Y, y, M, m, d, rest, w) {
rest = rest.replace("休", "");
if (rest.indexOf("节") != -1 && rest.indexOf("~") == -1 && rest.indexOf("班") == -1) {
addRemindFestival(Y, y, M, m, d, rest);
if (rest.indexOf("抢") != -1) addAutoFestival(Y, y, M, m, d, rest, w);
}
}
function addAutoFestival(Y, y, M, m, d, rest, w) {
if (addAutoFestivalFlag == false) return;
if (rest.indexOf("春节") != -1 || rest.indexOf("国庆节") != -1) return;
var date = new Date(y + "/" + m + "/" + d);
var pre = new Date(y + "/" + m + "/" + d);
pre.setDate(pre.getDate() - 1);
var prep = new Date(y + "/" + m + "/" + d);
prep.setDate(prep.getDate() - 2);
var prepp = new Date(y + "/" + m + "/" + d);
prepp.setDate(prepp.getDate() - 3);
var next = new Date(y + "/" + m + "/" + d);
next.setDate(next.getDate() + 1);
var nextp = new Date(y + "/" + m + "/" + d);
nextp.setDate(nextp.getDate() + 2);
var nextpp = new Date(y + "/" + m + "/" + d);
nextpp.setDate(nextpp.getDate() + 3);
if (w == 0) {
addRemindFestival(Y, pre.getFullYear(), M, pre.getMonth() + 1, pre.getDate(), "pre" + rest);
addRemindFestival(Y, next.getFullYear(), M, next.getMonth() + 1, next.getDate(), "next" + rest);
} else if (w == 1) {
addRemindFestival(Y, prep.getFullYear(), M, prep.getMonth() + 1, prep.getDate(), "prep" + rest);
addRemindFestival(Y, pre.getFullYear(), M, pre.getMonth() + 1, pre.getDate(), "pre" + rest);
} else if (w == 2) {
if (rest.indexOf("抢") == -1)
addRemindFestival(Y, prepp.getFullYear(), M, prepp.getMonth() + 1, prepp.getDate(), "prepp" + rest.replace("休", "班"));
addRemindFestival(Y, prep.getFullYear(), M, prep.getMonth() + 1, prep.getDate(), "prep" + rest);
addRemindFestival(Y, pre.getFullYear(), M, pre.getMonth() + 1, pre.getDate(), "pre" + rest);
} else if (w == 4) {
addRemindFestival(Y, next.getFullYear(), M, next.getMonth() + 1, next.getDate(), "next" + rest);
addRemindFestival(Y, nextp.getFullYear(), M, nextp.getMonth() + 1, nextp.getDate(), "nextp" + rest);
if (rest.indexOf("抢") == -1)
addRemindFestival(Y, nextpp.getFullYear(), M, nextpp.getMonth() + 1, nextpp.getDate(), "nextpp" + rest.replace("休", "班"));
} else if (w == 5 || w == 6) {
addRemindFestival(Y, next.getFullYear(), M, next.getMonth() + 1, next.getDate(), "next" + rest);
addRemindFestival(Y, nextp.getFullYear(), M, nextp.getMonth() + 1, nextp.getDate(), "nextp" + rest);
} else if (w == 3) {//new
addRemindFestival(Y, next.getFullYear(), M, next.getMonth() + 1, next.getDate(), "next" + rest);
addRemindFestival(Y, nextp.getFullYear(), M, nextp.getMonth() + 1, nextp.getDate(), "nextp" + rest);
addRemindFestival(Y, nextpp.getFullYear(), M, nextpp.getMonth() + 1, nextpp.getDate(), "nextpp" + rest);
if (rest.indexOf("抢") == -1) {
addRemindFestival(Y, prepp.getFullYear(), M, prepp.getMonth() + 1, prepp.getDate(), "prepp" + rest.replace("休", "班"));
prepp.setDate(prepp.getDate() + 7);
addRemindFestival(Y, prepp.getFullYear(), M, prepp.getMonth() + 1, prepp.getDate(), "nextppp" + rest.replace("休", "班"));
}
}
}
/* 设置单双休 */
function setWeek(options) {
var Y = options.date.getFullYear();
var M = options.date.getMonth() + 1;
var temp = new Date(Y + "/" + M + "/1").getDay();
var D = 7 - (temp == 0 ? 7 : temp)
if (D == 0) D = 7;
var _configDayM = "{"
var alldays = calendar.solarMonth[M - 1];
if ((M == 2) && (Y % 400 == 0 || (Y % 100 != 0 && Y % 4 == 0))) alldays += 1;
var week = 0;
while (alldays >= D) {
week = parseInt((new Date(Y + "/" + M + "/" + D) - new Date(options.week_walue)) / (3600 * 24 * 1000 * 7));
if (week != 0 && week % 2 != 0) _configDayM += "\"D" + D + "\":\"单周\",";
D += 7;
}
_configDayM = _configDayM.substring(0, _configDayM.length - 1) + "}";
// alert(JSON.stringify(_configDayM));
return JSON.parse(_configDayM);
}
/* 设置加班休假日期 */
function setconfigDay(options, count, _configDayM) {
var width = options.width;
var height = options.height;
var Y = options.date.getFullYear();
var M = options.date.getMonth() + 1;
var D = "0";
if (_configDayM) {
$.each(_configDayM, function (k, v) {
D = k.split("D")[1];
var temp = $("#days" + D).find(".xbgj");
if (temp.length > 0) {
$("#days" + D).find(".xbgj").remove();
}
//TODO
if (options.week) {
if (v.indexOf("单周") != -1) {
$("#days" + D).append("<div class=\"xbgj\" xbgj=\"1\" style=\"position: absolute;\"><div class=\"rest\" style=\"top:" +
-parseInt((height - 16) / (count + 1) - 2) + "px;background-color: #e15e5e\">单</div></div>");
}
}
if (options.rest && v.indexOf("节") != -1) {
if (v.indexOf("休") != -1) {
$("#days" + D).append("<div class=\"xbgj\" xbgj=\"0\" style=\"position: absolute;\"><div class=\"rest\" style=\"top:" +
-parseInt((height - 16) / (count + 1) - 2) + "px;background-color: #53a253\">休</div></div>");
}
if (v.indexOf("班") != -1) {
$("#days" + D).append("<div class=\"xbgj\" xbgj=\"1\" style=\"position: absolute;\"><div class=\"rest\" style=\"top:" +
-parseInt((height - 16) / (count + 1) - 2) + "px;background-color: #e15e5e\">班</div></div>");
}
}
if (options.day) {
if (v.indexOf("历") != -1) {
$("#days" + D).append("<div class=\"xbgj\" xbgj=\"1\" style=\"position: absolute;\"><div class=\"day\" style=\"top:" +
-parseInt((height - 16) / (count + 1) - 2 -28) + "px;background-color: #1E90FF\">生</div></div>");//28
}
}
if (options.fest) {
if (v.indexOf("~") != -1) {
$("#days" + D).append("<div class=\"xbgj\" xbgj=\"1\" style=\"position: absolute;\"><div class=\"fest\" style=\"top:" +
-parseInt((height - 16) / (count + 1) - 2) + "px;left:" + parseInt(37) + "px;background-color: #ADFF2F\">节</div></div>");//55
}
}
if (options.bypass) {
if (v.indexOf("抢") != -1) {
$("#days" + D).append("<div class=\"xbgj\" xbgj=\"1\" style=\"position: absolute;\"><div class=\"bypass\" style=\"top:" +
-parseInt((height - 16) / (count + 1) - 2 -28) + "px;left:" + parseInt(37) + "px;background-color: #0000FF\">抢</div></div>");
}
}
});
}
}
/* 定义创建时间表格函数 */
var DateTable = function (Y, M, e) {
var temp = null;
this.Y = Y;
this.M = M;
this.e = e;
temp = new Date(Y + "/" + M + "/1").getDay();
this.W = (temp == 0 ? 7 : temp);
this.days = this.monthDays();
temp = this.days + this.W - 1;
this.count = temp % 7 == 0 ? parseInt(temp / 7) : parseInt(temp / 7) + 1;
this.html = "";
};
/* 获取对应的阴历日期 */
DateTable.prototype.lunarDay = function () {
// for (var j = 8; j <= 14; j++) {//TODO
// delete calendar.gregorianFestival[5 + "-" + j];
// delete calendar.gregorianFestival["6-" + (j + 7)];
// }
// delete calendar.gregorianFestival["4-4"];
// delete calendar.gregorianFestival["4-5"];
// delete calendar.gregorianFestival["4-6"];
var lunar = calendar.calendarConvert(this.Y, this.M, 1);
var info = calendar.getLunarYearDays(lunar[1]);
var temp = "";
var flag = 0;
var solarTerms = "";
var tm = this.M - 1;
// 本月对应节气的日期
var tmp1 = sTerm(this.Y, tm * 2) - 1;
var tmp2 = sTerm(this.Y, tm * 2 + 1) - 1;
for (var i = 0; i < this.days; i += 1) {
solarTerms = "";
// 对应的农历日期
if (lunar[3] === 1) {
temp = calendar.lunarMonthStr[lunar[2] - 1] + "月";
if (lunar[0] === 1) temp = "闰" + temp;
} else if (lunar[3] == 10) {
temp = "初十";
} else {
temp = calendar.lunarDayStrFirst[parseInt(lunar[3] / 10)] + calendar.lunarDayStrLast[lunar[3] % 10]
}
// 判断今天时候是对应节气的日期
if (tmp1 == i) solarTerms = calendar.solarTerm[tm * 2];
if (tmp2 == i) solarTerms = calendar.solarTerm[tm * 2 + 1];
// 显示 有限级别 节日/节气/农历
var temp2 = "";
var W = new Date(this.Y + "/" + this.M + "/" + (i + 1)).getDay();
// if(this.M == 5 && W == 0 && (i+1) >=8 && (i+1) <=14) temp2 += "母亲节";
// if(this.M == 6 && W == 0 && (i+1) >=15 && (i+1) <=21) temp2 += "父亲节";
if (calendar.gregorianFestival[this.M + "-" + (i + 1)]) temp2 += calendar.gregorianFestival[this.M + "-" + (i + 1)].replace("~", "").replace(/^.*节[休班]/, "").replace("休", "");
if (calendar.lunarFestival[lunar[2] + "-" + lunar[3]]){
var show = calendar.lunarFestival[lunar[2] + "-" + lunar[3]].replace("~", "").replace("班", "").replace("休", "");
if(lunar[0] == 0 && temp2.indexOf(show) == -1)
temp2 += show;
}
// console.log(temp2);
if (solarTerms) temp2 += solarTerms;
if (temp2) temp = temp2;
$("#lunar" + (i + 1)).append(temp);
// 设置不同的显示字体颜色
if (calendar.lunarFestival[lunar[2] + "-" + lunar[3]] || calendar.gregorianFestival[this.M + "-" + (i + 1)]) {
$("#lunar" + (i + 1)).css("color", "red");
} else if (solarTerms !== "") {
$("#lunar" + (i + 1)).css("color", "green");
}
// 计算下个日期的农历
if (info.leapMonth[0] === lunar[2] && lunar[0] == 1) {
flag = info.leapMonth[1];
} else flag = info.lunarMonth[lunar[2] - 1] === 0 ? 29 : 30;
if (lunar[3] + 1 > flag) {
lunar[3] = 1;
if (lunar[2] !== info.leapMonth[0]) {
if (lunar[2] + 1 > 12) {
lunar[1] += 1;
lunar[2] = 1;
info = calendar.getLunarYearDays(lunar[1]);
} else lunar[2] += 1;
} else {
if (lunar[0] === 1) {
if (lunar[2] + 1 > 12) {
lunar[1] += 1;
lunar[2] = 1;
info = calendar.getLunarYearDays(lunar[1]);
} else {
lunar[2] += 1;
lunar[0] = 0;
}
} else {
lunar[0] = 1;
}
}
} else {
lunar[3] += 1;
}
}
};
/* 创建表格 */
DateTable.prototype.create = function () {
this.html = "<div class=\"calendar\">";
this.html += "<div class=\"leftArea\">";
this.leftHead();
this.leftWeek();
this.leftDay();
this.html += "</div>";
// this.html += "<div class=\"rightArea\">";
// this.html += "</div>";
this.html += "</div>";
this.e.append(this.html);
this.lunarDay();
// rightArea(this.Y, this.M);
};
/* 获取本月多少天 */
DateTable.prototype.monthDays = function () {
if ((this.M == 2) && (this.Y % 400 == 0 || (this.Y % 100 != 0 && this.Y % 4 == 0))) return 29;
else return calendar.solarMonth[this.M - 1];
}
/* 获取左边区域的头部 */
DateTable.prototype.leftHead = function () {
this.html += "<div class=\"head\">";
this.html += "<div id=\"YL\" class=\"btn\"><</div>";
this.html += "<select id=\"SY\">"
for (var i = 1900; i < 2101; i++) this.html += "<option value=\"" + i + "\">" + i + "</option>";
this.html += "</select>";
this.html += "<div id=\"YR\" class=\"btn\">></div><div class=\"text\">年</div>";
this.html += "<div id=\"ML\" class=\"btn\"><</div>";
this.html += "<select id=\"SM\">"
for (var i = 1; i < 13; i++) this.html += "<option value=\"" + i + "\">" + i + "</option>";
this.html += "</select>"
this.html += "<div id=\"MR\" class=\"btn\">></div><div class=\"text\">月</div>";
this.html += "<input type=\"button\" id=\"ReturnBtn\" value=\"返回今天\" class=\"btnreturn\"/>";
this.html += "<div class=\"text\" style=\"margin-left:20px;\">" + this.Y + "年" + this.M + "月</div>";
this.html += "</div>";
};
/* 获取左边区域的星期名称 */
DateTable.prototype.leftWeek = function () {
for (i = 0; i < 7; i++) this.html += "<div class=\"week\">" + calendar.Week[i] + "</div>";
};
/* 获取本月天数 */
DateTable.prototype.leftDay = function () {
var day = 0;
var W = this.W;
var color = "";
for (i = 0; i < this.count * 7; i += 1) {
if (i < this.W - 1 || i >= this.days + this.W - 1) this.html += "<div class=\"days1\"></div>";
else {
day = i + 2 - this.W;
if (W == 6 || W == 7) color = "red";
else color = "#006db7";
this.html += "<div class=\"days\" id=\"days" + day + "\"><div id=\"num" + day +
"\" class=\"num\" style=\"color:" + color + ";\">" +
(day > 9 ? day : ("0" + day)) + "</div><div class=\"lunar\" id=\"lunar" +
day + "\"></div></div>";
W += 1;
if (W == 8) W = 1;
}
}
};
function sTerm(y, n) {
var offDate = new Date((31556925974.7 * (y - 1900) + calendar.sTermInfo[n] * 60000) + Date.UTC(1900, 0, 6, 2, 5));
return (offDate.getUTCDate());
}
// 生成右边区域代码
// function rightArea(Y, M) {
// var html = "";
// var W = new Date(Y + "/" + M + "/" + ClickDays).getDay();
// W = W == 0 ? 7 : W;
// html += "<div class=\"ui\">" + Y + "年" + (M > 9 ? M : "0" + M) + "月" + (ClickDays > 9 ? ClickDays : "0" + ClickDays) + "日 星期"
// + calendar.Week[W - 1] + "</div>";
// html += "<div class=\"ud\">" + (ClickDays > 9 ? ClickDays : "0" + ClickDays) + "</div>";
// var lunar = calendar.calendarConvert(Y, M, ClickDays);
// var temp = "";
// temp += calendar.lunarMonthStr[lunar[2] - 1] + " 月 ";
// if (lunar[0] == 1) temp = "闰 " + temp;
// if (lunar[3] == 10) {
// temp += "初 十";
// } else {
// temp += calendar.lunarDayStrFirst[parseInt(lunar[3] / 10)] + " " + calendar.lunarDayStrLast[lunar[3] % 10]
// }
// html += "<div class=\"uld\">" + temp + "</div>";
// html += "<div class=\"ultd\">" + getLunarYMD(lunar, Y, M) + "</div>";
// html += getJR(lunar, Y, M);
// if (isclick) {
// html += "<input type=\"button\" style=\"width:100%;\" value=\"保 存\" class=\"saveChange\" />";
// html += "<input type=\"button\" style=\"width:100%;\" value=\"重 置\" class=\"resetData\" />";
// }
// $(".rightArea").empty();
// $(".rightArea").append(html);
// if (lunar[2] == 1 && lunar[3] == 1) {
// $(".calendar").css("border", "2px solid #f44f23");
// $(".rightArea").css("background-color", "#f44f23");
// } else {
// $(".calendar").css("border", "2px solid #8ec59b");
// $(".rightArea").css("background-color", "#e0f3e8");
// }
// if (isclick) getPushClick(Y, M);
// };
// 保存和重置按钮
function getPushClick(Y, M) {
$(".resetData").click(function () {
$(".xbgj").remove();
configDayM = {};
});
$(".saveChange").click(function () {
var html = "";
if (saveConfig(Y, M, configDayM)) {
if (configDay["Y" + Y]) {
configDay["Y" + Y]["M" + M] = $.extend(true, {}, configDayM);
} else {
configDay["Y" + Y] = {};
configDay["Y" + Y]["M" + M] = $.extend(true, {}, configDayM);
}
}
});
}
// 获取今天的节日信息
function getJR(lunar, Y, M) {
var temp = 0;
var html = "<div class=\"djr\"><span class=\"title\">节日</span><span class=\"content\">";
if (calendar.lunarFestival[lunar[2] + "-" + lunar[3]]) {
html += calendar.lunarFestival[lunar[2] + "-" + lunar[3]] + " ";
temp = 1;
}
if (calendar.gregorianFestival[M + "-" + ClickDays]) {
html += calendar.gregorianFestival[M + "-" + ClickDays] + " ";
temp = 1;
}
// var W = new Date(Y + "/" + M + "/" + ClickDays).getDay();
// if(M == 5 && W == 0 && ClickDays >=8 && ClickDays <=14){
// html += "母亲节" + " ";
// temp = 1;