//
Copyright (c) 2006 XF Std.
// Refrence.
//
// more information please visit
// http://xfol.spaces.msn.com/blog/cns!C01EF4C3D44D96C3!342.entry
// 世界历资料
// 农历资料
var lunarInfo = new Array(
0x04bd8 , 0x04ae0 , 0x0a570 , 0x054d5 , 0x0d260 , 0x0d950 , 0x16554 , 0x056a0 , 0x09ad0 , 0x055d2 ,
0x04ae0 , 0x0a5b6 , 0x0a4d0 , 0x0d250 , 0x1d255 , 0x0b540 , 0x0d6a0 , 0x0ada2 , 0x095b0 , 0x14977 ,
0x04970 , 0x0a4b0 , 0x0b4b5 , 0x06a50 , 0x06d40 , 0x1ab54 , 0x02b60 , 0x09570 , 0x052f2 , 0x04970 ,
0x06566 , 0x0d4a0 , 0x0ea50 , 0x06e95 , 0x05ad0 , 0x02b60 , 0x186e3 , 0x092e0 , 0x1c8d7 , 0x0c950 ,
0x0d4a0 , 0x1d8a6 , 0x0b550 , 0x056a0 , 0x1a5b4 , 0x025d0 , 0x092d0 , 0x0d2b2 , 0x0a950 , 0x0b557 ,
0x06ca0 , 0x0b550 , 0x15355 , 0x04da0 , 0x0a5b0 , 0x14573 , 0x052b0 , 0x0a9a8 , 0x0e950 , 0x06aa0 ,
0x0aea6 , 0x0ab50 , 0x04b60 , 0x0aae4 , 0x0a570 , 0x05260 , 0x0f263 , 0x0d950 , 0x05b57 , 0x056a0 ,
0x096d0 , 0x04dd5 , 0x04ad0 , 0x0a4d0 , 0x0d4d4 , 0x0d250 , 0x0d558 , 0x0b540 , 0x0b6a0 , 0x195a6 ,
0x095b0 , 0x049b0 , 0x0a974 , 0x0a4b0 , 0x0b27a , 0x06a50 , 0x06d40 , 0x0af46 , 0x0ab60 , 0x09570 ,
0x04af5 , 0x04970 , 0x064b0 , 0x074a3 , 0x0ea50 , 0x06b58 , 0x055c0 , 0x0ab60 , 0x096d5 , 0x092e0 ,
0x0c960 , 0x0d954 , 0x0d4a0 , 0x0da50 , 0x07552 , 0x056a0 , 0x0abb7 , 0x025d0 , 0x092d0 , 0x0cab5 ,
0x0a950 , 0x0b4a0 , 0x0baa4 , 0x0ad50 , 0x055d9 , 0x04ba0 , 0x0a5b0 , 0x15176 , 0x052b0 , 0x0a930 ,
0x07954 , 0x06aa0 , 0x0ad50 , 0x05b52 , 0x04b60 , 0x0a6e6 , 0x0a4e0 , 0x0d260 , 0x0ea65 , 0x0d530 ,
0x05aa0 , 0x076a3 , 0x096d0 , 0x04bd7 , 0x04ad0 , 0x0a4d0 , 0x1d0b6 , 0x0d250 , 0x0d520 , 0x0dd45 ,
0x0b5a0 , 0x056d0 , 0x055b2 , 0x049b0 , 0x0a577 , 0x0a4b0 , 0x0aa50 , 0x1b255 , 0x06d20 , 0x0ada0 ,
0x14b63 );
var solarMonth = new Array( 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 );
var tFive = new Array( " 木 " , " 火 " , " 土 " , " 铁 " , " 水 " );
var Gan = new Array( " 甲 " , " 乙 " , " 丙 " , " 丁 " , " 戊 " , " 己 " , " 庚 " , " 辛 " , " 壬 " , " 癸 " );
var Zhi = new Array( " 子 " , " 丑 " , " 寅 " , " 卯 " , " 辰 " , " 巳 " , " 午 " , " 未 " , " 申 " , " 酉 " , " 戌 " , " 亥 " );
var lunarAnimals = new Array( " 鼠 " , " 牛 " , " 虎 " , " 兔 " , " 龙 " , " 蛇 " , " 马 " , " 羊 " , " 猴 " , " 鸡 " , " 狗 " , " 猪 " );
var sTermInfo = new Array( 0 , 21208 , 42467 , 63836 , 85337 , 107014 , 128867 , 150921 , 173149 , 195551 , 218072 , 240693 , 263343 , 285989 , 308563 , 331033 , 353350 , 375494 , 397447 , 419210 , 440795 , 462224 , 483532 , 504758 );
var nStr1 = new Array( ' 日 ' , ' 一 ' , ' 二 ' , ' 三 ' , ' 四 ' , ' 五 ' , ' 六 ' , ' 七 ' , ' 八 ' , ' 九 ' , ' 十 ' );
var nStr2 = new Array( ' 初 ' , ' 十 ' , ' 廿 ' , ' 卅 ' , ' □ ' );
var monthName = new Array( " JAN " , " FEB " , " MAR " , " APR " , " MAY " , " JUN " , " JUL " , " AUG " , " SEP " , " OCT " , " NOV " , " DEC " );
var lunarTerm = new Array( " 小寒 0 " , " 大寒 0 " , " 立春 0 " , " 雨水 0 " , " 惊蛰 0 " , " 春分 0 " , " 清明 0 " , " 谷雨 0 " , " 立夏 0 " , " 小满 0 " , " 芒种 0 " , " 夏至 0 " , " 小暑 0 " , " 大暑 0 " , " 立秋 0 " , " 处暑 0 " , " 白露 0 " , " 秋分 0 " , " 寒露 0 " , " 霜降 0 " , " 立冬 0 " , " 小雪 0 " , " 大雪 0 " , " 冬至 " );
var sFtv = new Array(
" 01 01 元旦节 0 1949 " ,
" 02 02 世界湿地日 0 1996 " ,
" 02 10 国际气象节 0 1991 " ,
" 02 14 情人节 0 0 " ,
" 03 01 国际海豹日 0 1983 " ,
" 03 03 全国爱耳日 1 2000 " ,
" 03 05 学雷锋纪念日 1 1963 " ,
" 03 08 妇女节 0 1857 " ,
" 03 12 植树节 1 1979 " ,
" 03 12 孙中山逝世 5 1979 " ,
" 03 14 国际警察日 0 2004 " ,
" 03 15 消费者权益日 0 1962 " ,
" 03 17 中医节 1 1930 " ,
" 03 17 国际航海日 0 0 " ,
" 03 21 世界森林日 0 1971 " ,
" 03 21 消除种族歧视国际日 0 1966 " ,
" 03 21 世界儿歌日 0 1976 " ,
" 03 22 世界水日 0 1993 " ,
" 03 23 世界气象日 0 1960 " ,
" 03 24 世界防治结核病日 0 1982 " ,
" 03 25 全国中小学生安全教育日 1 1996 " ,
" 03 30 巴勒斯坦国土日 1 1976 " ,
" 04 01 愚人节 0 1564 " ,
" 04 01 (四月)全国爱国卫生运动月 1 1989 " ,
" 04 01 (四月)税收宣传月 1 1995 " ,
" 04 07 世界卫生日 0 1950 " ,
" 04 22 世界地球日 0 1970 " ,
" 04 23 世界图书和版权日 0 1995 " ,
" 04 24 亚非新闻工作者日 1 1963 " ,
" 05 01 劳动节 0 1889 " ,
" 05 02 劳动节假日 1 0 " ,
" 05 03 劳动节假日 1 0 " ,
" 05 04 青年节 1 1949 " ,
" 05 05 碘缺乏病防治日 1 1993 " ,
" 05 08 世界红十字日 0 1948 " ,
" 05 12 国际护士节 0 1912 " ,
" 05 15 国际家庭日 0 1993 " ,
" 05 17 国际电信日 0 1968 " ,
" 05 18 国际博物馆日 0 1977 " ,
" 05 20 全国学生营养日 1 1990 " ,
" 05 23 国际牛奶日 0 1961 " ,
" 05 31 世界无烟日 0 1988 " ,
" 06 01 国际儿童节 0 1949 " ,
" 06 05 世界环境保护日 0 1972 " ,
" 06 06 全国爱眼日 1 1996 " ,
" 06 17 防治荒漠化和干旱日 0 1994 " ,
" 06 23 国际奥林匹克日 0 1894 " ,
" 06 25 全国土地日 1 1991 " ,
" 06 26 国际禁毒日 0 1987 " ,
" 07 01 建党 5 1921 " ,
" 07 01 香港回归 5 1997 " ,
" 07 01 世界建筑日 0 1985 " ,
" 07 02 国际体育记者日 0 1995 " ,
" 07 07 抗日战争纪念日 1 1937 " ,
" 07 11 世界人口日 0 1988 " ,
" 07 30 非洲妇女日 1 1962 " ,
" 08 01 建军 5 1927 " ,
" 08 08 中国父亲节 1 1988 " ,
" 09 03 抗日战争胜利 1 1945 " ,
" 09 08 国际扫盲日 0 1966 " ,
" 09 08 国际新闻工作者日 0 1958 " ,
" 09 09 毛泽东逝世 0 1976 " ,
" 09 10 中国教师节 1 1985 " ,
" 09 14 世界清洁地球日 0 1970 " ,
" 09 16 国际臭氧层保护日 0 1987 " ,
" 09 18 九·一八事变 1 1931 " ,
" 09 20 国际爱牙日 0 1989 " ,
" 09 27 世界旅游日 0 1979 " ,
" 09 28 孔子诞辰 0 -551 " ,
" 10 01 国庆 5 1949 " ,
" 10 01 世界音乐日 0 1980 " ,
" 10 01 国际老人节 0 1990 " ,
" 10 02 国庆节假日 1 0 " ,
" 10 02 国际和平与民主自由斗争日 0 1949 " ,
" 10 03 国庆节假日 1 0 " ,
" 10 04 世界动物日 0 1949 " ,
" 10 06 老人节 0 0 " ,
" 10 08 全国高血压日 1 1998 " ,
" 10 08 世界视觉日 0 1998 " ,
" 10 09 世界邮政(万国邮联)日 0 1969 " ,
" 10 10 辛亥革命 5 1911 " ,
" 10 10 世界精神卫生日 0 1992 " ,
" 10 13 世界保健日 1 0 " ,
" 10 13 国际教师节 0 0 " ,
" 10 14 世界标准日 0 1969 " ,
" 10 15 国际盲人(白手杖)节 0 1984 " ,
" 10 16 世界粮食日 0 1979 " ,
" 10 17 世界消除贫困日 0 0 " ,
" 10 22 世界传统医药日 0 1992 " ,
" 10 24 联合国日 0 1945 " ,
" 10 31 世界勤俭日 0 0 " ,
" 11 07 十月革命 5 1911 " ,
" 11 08 中国记者日 0 2000 " ,
" 11 09 全国消防安全宣传教育日 0 1992 " ,
" 11 10 世界青年节 0 1946 " ,
" 11 11 (本日所属的一周)国际科学与和平周 0 0 " ,
" 11 12 孙中山诞辰 5 1866 " ,
" 11 14 世界糖尿病日 0 1991 " ,
" 11 17 国际大学生(世界学生)节 0 1946 " ,
" 11 20 彝族年 2 0 " ,
" 11 21 彝族年 2 0 " ,
" 11 21 世界问候日 0 1973 " ,
" 11 21 世界电视日 0 1996 " ,
" 11 22 彝族年 2 0 " ,
" 11 29 声援巴勒斯坦人民国际日 0 1977 " ,
" 12 01 世界艾滋病日 0 1988 " ,
" 12 03 世界残疾人日 0 1992 " ,
" 12 05 国际经济和社会发展志愿人员日 0 1985 " ,
" 12 08 国际儿童电视日 0 0 " ,
" 12 09 世界足球日 0 1995 " ,
" 12 10 世界人权日 0 1950 " ,
" 12 12 西安事变 5 1936 " ,
" 12 13 南京大屠杀 5 1937 " ,
" 12 20 澳门回归 5 1999 " ,
" 12 21 国际篮球日 0 1891 " ,
" 12 24 平安夜 0 0 " ,
" 12 25 圣诞节 0 0 " ,
" 12 26 毛泽东诞辰 5 1894 " )
// 农历节日
var lFtv = new Array(
" 01 01 春节 2 0 " ,
" 01 02 大年初二 2 0 " ,
" 01 03 大年初三 2 0 " ,
" 01 15 元宵节 2 0 " ,
" 05 05 端午节 2 0 " ,
" 07 07 七夕 2 0 " ,
" 07 15 中元节 2 0 " ,
" 08 15 中秋节 2 0 " ,
" 09 09 重阳节 2 0 " ,
" 10 06 晓风 0 0 " ,
" 12 08 腊八节 2 0 " ,
" 12 23 小年 2 0 " ,
" 01 00 除夕 2 0 " )
// 某月的第几个星期几
var wFtv = new Array(
" 01 5 0 世界麻风日 0 1954 " , // 一月的最后一个星期日(月倒数第一个星期日)
" 05 2 0 国际母亲节 0 1914 " ,
" 05 3 0 全国助残日 0 1990 " ,
" 06 3 0 父亲节 0 0 " ,
" 07 3 0 被奴役国家周 0 0 " ,
" 09 3 2 国际和平日 0 1981 " ,
" 09 4 0 国际聋人节 0 1958 " ,
" 09 4 0 世界儿童日 0 1986 " ,
" 09 5 0 世界海事日 0 1978 " ,
" 10 1 1 国际住房日 0 1982 " ,
" 10 1 3 国际减轻自然灾害(减灾)日 0 1990 " ,
" 11 4 4 感恩节 0 1620 " )
// ====================================== 返回农历 y年的总天数
function lYearDays(y) {
var i, sum = 348;
for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0;
return(sum+leapDays(y));
}
// ====================================== 返回农历 y年闰月的天数
function leapDays(y) {
if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29);
else return(0);
}
// ====================================== 返回农历 y年闰哪个月 1-12 , 没闰返回 0
function leapMonth(y) {
return(lunarInfo[y-1900] & 0xf);
}
// ====================================== 返回农历 y年m月的总天数
function monthDays(y,m) {
return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 );
}
// ====================================== 算出农历, 传入日期控件, 返回农历日期控件
// 该控件属性有 .year .month .day .isLeap
function Lunar(objDate) {
var i, leap=0, temp=0;
var offset = (Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate()) - Date.UTC(1900,0,31))/86400000;
for(i=1900; i<2050 && offset>0; i++) { temp=lYearDays(i); offset-=temp; }
if(offset<0) { offset+=temp; i--; }
this.year = i;
leap = leapMonth(i); //闰哪个月
this.isLeap = false;
for(i=1; i<13 && offset>0; i++) {
//闰月
if(leap>0 && i==(leap+1) && this.isLeap==false)
{ --i; this.isLeap = true; temp = leapDays(this.year); }
else
{ temp = monthDays(this.year, i); }
//解除闰月
if(this.isLeap==true && i==(leap+1)) this.isLeap = false;
offset -= temp;
}
if(offset==0 && leap>0 && i==leap+1)
if(this.isLeap)
{ this.isLeap = false; }
else
{ this.isLeap = true; --i; }
if(offset<0){ offset += temp; --i; }
this.month = i;
this.day = offset + 1;
}
// ==============================返回公历 y年某m+1月的天数
function solarDays(y,m) {
if(m==1)
return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28);
else
return(solarMonth[m]);
}
// ============================== 传入 offset 返回干支, 0=甲子
function cyclical(num) {
return(Gan[num%10]+Zhi[num%12]);
}
// ============================== 阴历属性
function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {
this.isToday = false;
//瓣句
this.sYear = sYear; //公元年4位数字
this.sMonth = sMonth; //公元月数字
this.sDay = sDay; //公元日数字
this.week = week; //星期, 1个中文
//农历
this.lYear = lYear; //公元年4位数字
this.lMonth = lMonth; //农历月数字
this.lDay = lDay; //农历日数字
this.isLeap = isLeap; //是否为农历闰月?
//八字
this.cYear = cYear; //年柱, 2个中文
this.cMonth = cMonth; //月柱, 2个中文
this.cDay = cDay; //日柱, 2个中文
this.color = '';
this.lunarFestival = ''; //农历节日
this.solarFestival = ''; //公历节日
this.lunarTerms = ''; //节气
}
// ===== 某年的第n个节气为几日(从0小寒起算)
function sTerm(y,n) {
var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) );
return(offDate.getUTCDate());
}
function calendar(y,m) {
var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2, tmp3;
var cY, cM, cD; //年柱,月柱,日柱
var lDPOS = new Array(3);
var n = 0;
var firstLM = 0;
sDObj = new Date(y,m,1,0,0,0,0); //当月一日日期
this.length = solarDays(y,m); //公历当月天数
this.firstWeek = sDObj.getDay(); //公历当月1日星期几
////年柱 1900年立春后为庚子年(60进制36)
if(m<2) cY=cyclical(y-1900+36-1);
else cY=cyclical(y-1900+36);
var term2=sTerm(y,2); //立春日期
////月柱 1900年1月小寒以前为 丙子月(60进制12)
var firstNode = sTerm(y,m*2) //返回当月「节」为几日开始
cM = cyclical((y-1900)*12+m+12);
//当月一日与 1900/1/1 相差天数
//1900/1/1与 1970/1/1 相差25567日, 1900/1/1 日柱为甲戌日(60进制10)
var dayCyclical = Date.UTC(y,m,1,0,0,0,0)/86400000+25567+10;
for(var i=0;i<this.length;i++) {
if(lD>lX) {
sDObj = new Date(y,m,i+1); //当月一日日期
lDObj = new Lunar(sDObj); //农历
lY = lDObj.year; //农历年
lM = lDObj.month; //农历月
lD = lDObj.day; //农历日
lL = lDObj.isLeap; //农历是否闰月
lX = lL? leapDays(lY): monthDays(lY,lM); //农历当月最后一天
if(n==0) firstLM = lM;
lDPOS[n++] = i-lD+1;
}
//依节气调整二月分的年柱, 以立春为界
if(m==1 && (i+1)==term2) cY=cyclical(y-1900+36);
//依节气月柱, 以「节」为界
if((i+1)==firstNode) cM = cyclical((y-1900)*12+m+13);
//日柱
cD = cyclical(dayCyclical+i);
//sYear,sMonth,sDay,week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],lY, lM, lD++, lL,cY ,cM, cD );
}
//节气
tmp1=sTerm(y,m*2 )-1;
tmp2=sTerm(y,m*2+1)-1;
this[tmp1].lunarTerms = lunarTerm[m*2];
this[tmp2].lunarTerms = lunarTerm[m*2+1];
//公历节日
for(i in sFtv){
//if(sFtv[i].match(/^(d{2}) (d{2}) ([s*])(.+)$/))
var tmpA=sFtv[i].split(" ");
if(Number(tmpA[0])==(m+1)) {
if (tmpA[4]=='0')
this[Number(tmpA[1])-1].solarFestival += tmpA[2]+' ';
else {
var yOffset=eval(this[Number(tmpA[1])-1].sYear-Number(tmpA[4]));
if (yOffset>0)
//if (tmpA[2].substring(tmpA[2].length-1,1)=='-')
if (tmpA[3]=='5')
this[Number(tmpA[1])-1].solarFestival +=tmpA[2]+yOffset+'周年 ';
else if (yOffset<0)
this[Number(tmpA[1])-1].solarFestival ='';
else this[Number(tmpA[1])-1].solarFestival += tmpA[2]+' ';
}
}
}
//月周节日
for(i in wFtv){
//if(wFtv[i].match(/^(d{2}) (d)(d) ([s*])(.+)$/))
tmpA =wFtv[i].split(" ");
if(Number(tmpA[0])==(m+1)) {
tmp1=Number(tmpA[1]);
tmp2=Number(tmpA[2]);
if(tmp1<5)
this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += tmpA[3]+' ';
else {
tmp1 -= 5;
tmp3 = (this.firstWeek+this.length-1)%7; //当月最后一天星期?
this[this.length - tmp3 - 7*tmp1 + tmp2 - (tmp2>tmp3?7:0) - 1 ].solarFestival += tmpA[3]+' ';
}
}
}
//农历节日
for(i in lFtv){
//if(lFtv[i].match(/^(d{2}) (.{2}) ([s*])(.+)$/)) {
tmpA =lFtv[i].split(" ");
tmp1=Number(tmpA[0])-firstLM;
if(tmp1==-11) tmp1=1;
if(tmp1 >=0 && tmp1<n) {
tmp2 = lDPOS[tmp1] + Number(tmpA[1]) -1;
if( tmp2 >= 0 && tmp2<this.length && this[tmp2].isLeap!=true) {
this[tmp2].lunarFestival += tmpA[2]+' ';
if ((this[tmp2].lMonth==10) && (this[tmp2].lDay==6)){
var xf_age=eval(this[tmp2].lYear-1985)
this[tmp2].lunarFestival = tmpA[2];
if (xf_age< 0) this[tmp2].lunarFestival+='还没生下来呢~~ ';
else if (xf_age==0) this[tmp2].lunarFestival+='横空出世~ ';
else if (xf_age==1) this[tmp2].lunarFestival+='会走路啦 ';
else if (xf_age==4) this[tmp2].lunarFestival+='上学了 ';
else if (xf_age==16) this[tmp2].lunarFestival+='弱冠之纪跑东北去了 ';
else if (xf_age> 100) this[tmp2].lunarFestival+='... ';
else this[tmp2].lunarFestival+=xf_age+'岁生日 ';
}
}
}
//}
}
//复活节只出现在3或4月
if(m==2 || m==3) {
var estDay = new easter(y);
if(m == estDay.m)
this[estDay.d-1].solarFestival = this[estDay.d-1].solarFestival+' 复活节 Easter Sunday';
}
if(m==2) this[20].solarFestival = this[20].solarFestival+unescape('%20%u6D35%u8CE2%u751F%u65E5');
//黑色星期五
if((this.firstWeek+12)%7==5)
this[12].solarFestival += '黑色星期五';
//今日
if(y==tY && m==tM) this[tD-1].isToday = true;
}
// ======================================= 返回该年的复活节(春分后第一次满月周后的第一主日)
function easter(y) {
var term2=sTerm(y,5); //取得春分日期
var dayTerm2 = new Date(Date.UTC(y,2,term2,0,0,0,0)); //取得春分的公历日期控件(春分一定出现在3月)
var lDayTerm2 = new Lunar(dayTerm2); //取得取得春分农历
if(lDayTerm2.day<15) //取得下个月圆的相差天数
var lMlen= 15-lDayTerm2.day;
else
var lMlen= (lDayTerm2.isLeap? leapDays(y): monthDays(y,lDayTerm2.month)) - lDayTerm2.day + 15;
//一天等于 1000*60*60*24 = 86400000 毫秒
var l15 = new Date(dayTerm2.getTime() + 86400000*lMlen ); //求出第一次月圆为公历几日
var dayEaster = new Date(l15.getTime() + 86400000*( 7-l15.getUTCDay() ) ); //求出下个周日
this.m = dayEaster.getUTCMonth();
this.d = dayEaster.getUTCDate();
}
function OnDetailsView(item) {
var html_for_details_view = "<html><head><script language="javascript">function click() {if (event.button==2||event.button==3) {alert('right click unabled');history.go(0);}}document.οnmοusedοwn=click</script></head><body>"
html_for_details_view = html_for_details_view+"<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066" style="filter:Alpha(opacity=80)"><TR><TD>"
html_for_details_view = html_for_details_view+"<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#ffffff" STYLE="font-size:9pt;">"
html_for_details_view = html_for_details_view+"cld[d].sYear+' 年 '+cld[d].sMonth+' 月 '+cld[d].sDay+' 日星期'+cld[d].week+'"
html_for_details_view = html_for_details_view+"<font color="violet">农历'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日</font>"
html_for_details_view = html_for_details_view+"<font color="yellow">'+cld[d].cYear+'年 '+cld[d].cMonth+'月 '+cld[d].cDay + '日</font>"
html_for_details_view = html_for_details_view+"</FONT></TD></TR></TABLE>"
html_for_details_view = html_for_details_view+"<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>"
html_for_details_view = html_for_details_view+"<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].lunarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD></TR></TABLE>"
html_for_details_view = html_for_details_view+"</TD></TR></TABLE></body></html>";
var control = new OpenItem();
var tm = new Date();
control.SetContent("Details Infomation 0", tm.getVarDate(), html_for_details_view,
true, item.layout);
control.html_content = true;
var details = new Object();
details.details_control = control;
return details;
}
var Today = new Date();
var tY = Today.getFullYear();
var tM = Today.getMonth();
var tDay = Today.getDay();
var tD = Today.getDate();
// var strHeading=tY+' '+tM+' '+tD+' ';
//
var width = " 130 " ;
var offsetx = 2 ;
var offsety = 8 ;
var x = 0 ;
var y = 0 ;
var snow = 0 ;
var sw = 0 ;
var cnt = 0 ;
var dStyle;
var cld;
// 初始值设定options
options.defaultValue( " u_solar " ) = true ;
options.defaultValue( " d_s_festival " ) = true ;
options.defaultValue( " d_week " ) = true ;
options.defaultValue( " d_g_festival " ) = true ;
options.defaultValue( " u_lunar " ) = true ;
options.defaultValue( " d_l_festival " ) = true ;
options.defaultValue( " d_l_terms " ) = true ;
options.defaultValue( " d_l_gz " ) = true ;
options.defaultValue( " u_world " ) = false ;
options.defaultValue( " u_tibetan " ) = false ;
options.defaultValue( " d_t_festival " ) = true ;
options.defaultValue( " u_hui " ) = false ;
options.defaultValue( " d_h_festival " ) = true ;
options.defaultValue( " u_festivals " ) = true ;
options.defaultValue( " d_f_global " ) = true ;
options.defaultValue( " d_f_region " ) = true ;
options.defaultValue( " d_f_trad " ) = true ;
options.defaultValue( " d_f_religion " ) = true ;
options.defaultValue( " d_f_remember " ) = true ;
options.defaultValue( " d_f_custom " ) = true ;
options.defaultValue( " display_language " ) = " en " ;
// Setup the icons, about dialog stuff and flags.
view.caption = strTitle;
contentArea.contentFlags = gddContentFlagManualLayout; // 手动设置item位置
contentArea.maxContentItems = 42 ; // 设置item最大数
// plugin.onShowOptionsDlg = ShowOptionsDlg; // handler for options dialog
plugin.onAddCustomMenuItems = AddCustomMenuItems; // handler to add menu items
goto_btn.onclick = Goto_Click;
today_btn.onclick = Today_Click;
/*
if (options("display_language")=='en') {
var imgToday = graphics.loadImage("en_today.gif");
var imgGoto = graphics.loadImage("en_goto.gif");
goto_btn.image=imgGoto;
today_btn.image=imgToday;
switch (tM+1){
case 1:sm_edit.value=__MSG_january__;
case 2:sm_edit.value=__MSG_february__;
case 3:sm_edit.value=__MSG_march__;
case 4:sm_edit.value=__MSG_april__;
case 5:sm_edit.value=__MSG_may__;
case 6:sm_edit.value=__MSG_june__;
case 7:sm_edit.value=__MSG_july__;
case 8:sm_edit.value=__MSG_august__;
case 9:sm_edit.value=__MSG_september__;
case 10:sm_edit.value=__MSG_october__;
case 11:sm_edit.value=__MSG_november__;
case 12:sm_edit.value=__MSG_december__;
}
sun_lab.innerText=__MSG_sunday__;
mon_lab.innerText=__MSG_monday__;
tues_lab.innerText=__MSG_tuesday__;
wed_lab.innerText=__MSG_wednesday__;
thurs_lab.innerText=__MSG_thursday__;
fri_lab.innerText=__MSG_friday__;
sat_lab.innerText=__MSG_saturday__;
}
*/
RefreshDisplay();
// Create true content item
// var item = new ContentItem();
// item.heading = "1号."; // this string is shown in the item
// item.onDetailsView = onDetailsView;
// contentArea.addContentItem(item, gddItemDisplayInSidebar); // add the item to the display
function RefreshDisplay() {
sy_edit.value=tY;
sm_edit.value=tM+1;
d_lab.innerText=tD;
drawCld(tY,tM);
}
function drawCld(SY,SM) {
var i,sD,s;
cld = new calendar(SY,SM);
var itemLayout = options("item_layout");
// remove existing and add new items.
contentArea.removeAllContentItems();
//if(SY>1874 && SY<1909) yDisplay = '光绪' + (((SY-1874)==true)?'元':SY-1874);
//if(SY>1908 && SY<1912) yDisplay = '宣统' + (((SY-1908)==true)?'元':SY-1908);
//if(SY>1911) yDisplay = '建国' + (((SY-1949)==true)?'元':SY-1949);
//GZ.innerHTML = yDisplay +'年 农历 ' + cyclical(SY-1900+36) + '年 【'+lunarAnimals[(SY-4)%12]+'年】';
//YMBG.innerHTML = " " + SY + " " + monthName[SM];
for(i=0;i<42;i++) {
var strDTooltip,strFestival;
var item=new ContentItem();
//SetRect(x, y, width, height)
//item.SetRect((i%7)*14%*view.width,42+(Math.floor(i/7))*20,14%*view.width,20);
item.SetRect(5+(i%7)*25,5+(Math.floor(i/7))*20,25,20);
sD = i - cld.firstWeek;
if(sD>-1 && sD<cld.length) { //日期内
item.heading=sD+1;
strDTooltip='';
strFestival='';
//if (options("u_festivals")){
//if (options("d_l_terms"))
strFestival+=cld[sD].lunarTerms;
//if (options("d_l_festivals"))
strFestival+=cld[sD].lunarFestival;
//if (options("d_s_festivals"))
strFestival+=cld[sD].solarFestival;
//}
strDTooltip=strDTooltip +'公元'+ cld[sD].sYear +'年' + cld[sD].sMonth + '月' + cld[sD].sDay + '日 ';
strDTooltip=strDTooltip + '星期' + cld[sD].week + ' ';
//}
//if (options("details_calendars_lunar")=='true'){
if ((cld[sD].sYear > 1899) && (cld[sD].sYear < 2051)){
if (cld[sD].isLeap) {strDTooltip=strDTooltip + '农历 闰' + cld[sD].lMonth + '月' + cld[sD].lDay + '日 ';}
else {strDTooltip=strDTooltip + '农历'+ cld[sD].lMonth + '月' + cld[sD].lDay + '日 ';}
//if(options("details_calendars_lunar_ganzhi")=='true'){
strDTooltip=strDTooltip + cld[sD].cYear +'年' + cld[sD].cMonth + '月' + cld[sD].cDay + '日 ';
}
//}
//}
//other calendars
if(cld[sD].isToday) {
item.heading='☆';
item.tooltip="TODAY "+strFestival+strDTooltip;
//item.Image=imgToday;
//item.onDrawItem = DrawItem;
//item.onGetHeight = GetItemHeight;
} //当天
else {
item.tooltip=strFestival+strDTooltip;
}
//item.onGetIsTooltipRequired=onGetIsTooltipRequired;
//if(cld[sD].lunarTerms=='清明') s = '清明节'.fontcolor('red');
//if(cld[sD].lunarTerms=='芒种') s = '芒种节'.fontcolor('red');
//if(cld[sD].lunarTerms=='夏至') s = '夏至节'.fontcolor('red');
//if(cld[sD].lunarTerms=='冬至') s = '冬至节'.fontcolor('red');
var vbarrItems = contentArea.contentItems;
var items = vbarrItems.toArray();
var curItem = null;
if (i == items.length) {
curItem = new ContentItem(); // not found so add it fresh
//curItem.source = source; //设置到网络查询的变量
curItem.layout = gddContentItemLayoutNews;
curItem.onDetailsView = OnDetailsView;
contentArea.addContentItem(curItem, gddItemDisplayInSidebar);
} else {
curItem = items[i]; // update the existing item
}
//curItem.heading=cld[sD].sMonth+cld[sD].sDay;
//curItem.snippet = cld[sD].sYear+cld[sD].sMonth+cld[sD].sDay; // to show in details view
//curItem.open_command = "http://192.168.2.1";
item.layout = itemLayout;
contentArea.addContentItem(item, gddItemDisplayInSidebar);
}
else { //非日期
item.heading='';
//SD.innerText = '';
//LD.innerText = '';
}
}
}
function Today_Click() {
RefreshDisplay();
}
function Goto_Click() {
d_lab.innerText='';
drawCld(sy_edit.value,eval(sm_edit.value-1));
}
function AddCustomMenuItems(menu) {
// Add the various item layouts as menu items and check the currently selected one
var itemLayout = options("item_layout");
for (var i = 0; i < menuItems.length; ++i) {
if (i == itemLayout) {
menu.AddItem(menuItems[i], gddMenuItemFlagChecked, MenuItemClicked);
} else {
menu.AddItem(menuItems[i], 0, MenuItemClicked);
}
}
}
function MenuItemClicked(item) {
// find which one was clicked and switch items to the chosen layout.
var itemLayout = gddContentItemLayoutNowrapItems;
for (var i = 0; i < menuItems.length; ++i) {
if (item == menuItems[i]) {
itemLayout = i;
}
}
// save the option selected by the user in our options store
options("item_layout") = itemLayout;
RefreshDisplay();
}
// Called to find out the height of each content item
function GetItemHeight(item, target, graphics, width) {
return itemImageHeight + 2 +
graphics.GetTextHeight(strItemText, width, 0, gddFontNormal);
}
// Called to draw each content item
function DrawItem(item, target, graphics, x, y, width, height) {
graphics.DrawImage(x, y, width, itemImageHeight, itemImage, 100);
y += itemImageHeight + 2;
height -= itemImageHeight + 2;
graphics.DrawText(x, y, width, height, item.heading, gddColorNormalText,
gddTextFlagCenter, gddFontNormal);
}
/*
目前存在的待解决的问题~~
选项(options)
详细信息查看(onDetailView)事件的响应
双击获取历史上的今天(onOpenItem)事件的响应
*/
// Refrence.
//
// more information please visit
// http://xfol.spaces.msn.com/blog/cns!C01EF4C3D44D96C3!342.entry
// 世界历资料
// 农历资料
var lunarInfo = new Array(
0x04bd8 , 0x04ae0 , 0x0a570 , 0x054d5 , 0x0d260 , 0x0d950 , 0x16554 , 0x056a0 , 0x09ad0 , 0x055d2 ,
0x04ae0 , 0x0a5b6 , 0x0a4d0 , 0x0d250 , 0x1d255 , 0x0b540 , 0x0d6a0 , 0x0ada2 , 0x095b0 , 0x14977 ,
0x04970 , 0x0a4b0 , 0x0b4b5 , 0x06a50 , 0x06d40 , 0x1ab54 , 0x02b60 , 0x09570 , 0x052f2 , 0x04970 ,
0x06566 , 0x0d4a0 , 0x0ea50 , 0x06e95 , 0x05ad0 , 0x02b60 , 0x186e3 , 0x092e0 , 0x1c8d7 , 0x0c950 ,
0x0d4a0 , 0x1d8a6 , 0x0b550 , 0x056a0 , 0x1a5b4 , 0x025d0 , 0x092d0 , 0x0d2b2 , 0x0a950 , 0x0b557 ,
0x06ca0 , 0x0b550 , 0x15355 , 0x04da0 , 0x0a5b0 , 0x14573 , 0x052b0 , 0x0a9a8 , 0x0e950 , 0x06aa0 ,
0x0aea6 , 0x0ab50 , 0x04b60 , 0x0aae4 , 0x0a570 , 0x05260 , 0x0f263 , 0x0d950 , 0x05b57 , 0x056a0 ,
0x096d0 , 0x04dd5 , 0x04ad0 , 0x0a4d0 , 0x0d4d4 , 0x0d250 , 0x0d558 , 0x0b540 , 0x0b6a0 , 0x195a6 ,
0x095b0 , 0x049b0 , 0x0a974 , 0x0a4b0 , 0x0b27a , 0x06a50 , 0x06d40 , 0x0af46 , 0x0ab60 , 0x09570 ,
0x04af5 , 0x04970 , 0x064b0 , 0x074a3 , 0x0ea50 , 0x06b58 , 0x055c0 , 0x0ab60 , 0x096d5 , 0x092e0 ,
0x0c960 , 0x0d954 , 0x0d4a0 , 0x0da50 , 0x07552 , 0x056a0 , 0x0abb7 , 0x025d0 , 0x092d0 , 0x0cab5 ,
0x0a950 , 0x0b4a0 , 0x0baa4 , 0x0ad50 , 0x055d9 , 0x04ba0 , 0x0a5b0 , 0x15176 , 0x052b0 , 0x0a930 ,
0x07954 , 0x06aa0 , 0x0ad50 , 0x05b52 , 0x04b60 , 0x0a6e6 , 0x0a4e0 , 0x0d260 , 0x0ea65 , 0x0d530 ,
0x05aa0 , 0x076a3 , 0x096d0 , 0x04bd7 , 0x04ad0 , 0x0a4d0 , 0x1d0b6 , 0x0d250 , 0x0d520 , 0x0dd45 ,
0x0b5a0 , 0x056d0 , 0x055b2 , 0x049b0 , 0x0a577 , 0x0a4b0 , 0x0aa50 , 0x1b255 , 0x06d20 , 0x0ada0 ,
0x14b63 );
var solarMonth = new Array( 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 );
var tFive = new Array( " 木 " , " 火 " , " 土 " , " 铁 " , " 水 " );
var Gan = new Array( " 甲 " , " 乙 " , " 丙 " , " 丁 " , " 戊 " , " 己 " , " 庚 " , " 辛 " , " 壬 " , " 癸 " );
var Zhi = new Array( " 子 " , " 丑 " , " 寅 " , " 卯 " , " 辰 " , " 巳 " , " 午 " , " 未 " , " 申 " , " 酉 " , " 戌 " , " 亥 " );
var lunarAnimals = new Array( " 鼠 " , " 牛 " , " 虎 " , " 兔 " , " 龙 " , " 蛇 " , " 马 " , " 羊 " , " 猴 " , " 鸡 " , " 狗 " , " 猪 " );
var sTermInfo = new Array( 0 , 21208 , 42467 , 63836 , 85337 , 107014 , 128867 , 150921 , 173149 , 195551 , 218072 , 240693 , 263343 , 285989 , 308563 , 331033 , 353350 , 375494 , 397447 , 419210 , 440795 , 462224 , 483532 , 504758 );
var nStr1 = new Array( ' 日 ' , ' 一 ' , ' 二 ' , ' 三 ' , ' 四 ' , ' 五 ' , ' 六 ' , ' 七 ' , ' 八 ' , ' 九 ' , ' 十 ' );
var nStr2 = new Array( ' 初 ' , ' 十 ' , ' 廿 ' , ' 卅 ' , ' □ ' );
var monthName = new Array( " JAN " , " FEB " , " MAR " , " APR " , " MAY " , " JUN " , " JUL " , " AUG " , " SEP " , " OCT " , " NOV " , " DEC " );
var lunarTerm = new Array( " 小寒 0 " , " 大寒 0 " , " 立春 0 " , " 雨水 0 " , " 惊蛰 0 " , " 春分 0 " , " 清明 0 " , " 谷雨 0 " , " 立夏 0 " , " 小满 0 " , " 芒种 0 " , " 夏至 0 " , " 小暑 0 " , " 大暑 0 " , " 立秋 0 " , " 处暑 0 " , " 白露 0 " , " 秋分 0 " , " 寒露 0 " , " 霜降 0 " , " 立冬 0 " , " 小雪 0 " , " 大雪 0 " , " 冬至 " );
var sFtv = new Array(
" 01 01 元旦节 0 1949 " ,
" 02 02 世界湿地日 0 1996 " ,
" 02 10 国际气象节 0 1991 " ,
" 02 14 情人节 0 0 " ,
" 03 01 国际海豹日 0 1983 " ,
" 03 03 全国爱耳日 1 2000 " ,
" 03 05 学雷锋纪念日 1 1963 " ,
" 03 08 妇女节 0 1857 " ,
" 03 12 植树节 1 1979 " ,
" 03 12 孙中山逝世 5 1979 " ,
" 03 14 国际警察日 0 2004 " ,
" 03 15 消费者权益日 0 1962 " ,
" 03 17 中医节 1 1930 " ,
" 03 17 国际航海日 0 0 " ,
" 03 21 世界森林日 0 1971 " ,
" 03 21 消除种族歧视国际日 0 1966 " ,
" 03 21 世界儿歌日 0 1976 " ,
" 03 22 世界水日 0 1993 " ,
" 03 23 世界气象日 0 1960 " ,
" 03 24 世界防治结核病日 0 1982 " ,
" 03 25 全国中小学生安全教育日 1 1996 " ,
" 03 30 巴勒斯坦国土日 1 1976 " ,
" 04 01 愚人节 0 1564 " ,
" 04 01 (四月)全国爱国卫生运动月 1 1989 " ,
" 04 01 (四月)税收宣传月 1 1995 " ,
" 04 07 世界卫生日 0 1950 " ,
" 04 22 世界地球日 0 1970 " ,
" 04 23 世界图书和版权日 0 1995 " ,
" 04 24 亚非新闻工作者日 1 1963 " ,
" 05 01 劳动节 0 1889 " ,
" 05 02 劳动节假日 1 0 " ,
" 05 03 劳动节假日 1 0 " ,
" 05 04 青年节 1 1949 " ,
" 05 05 碘缺乏病防治日 1 1993 " ,
" 05 08 世界红十字日 0 1948 " ,
" 05 12 国际护士节 0 1912 " ,
" 05 15 国际家庭日 0 1993 " ,
" 05 17 国际电信日 0 1968 " ,
" 05 18 国际博物馆日 0 1977 " ,
" 05 20 全国学生营养日 1 1990 " ,
" 05 23 国际牛奶日 0 1961 " ,
" 05 31 世界无烟日 0 1988 " ,
" 06 01 国际儿童节 0 1949 " ,
" 06 05 世界环境保护日 0 1972 " ,
" 06 06 全国爱眼日 1 1996 " ,
" 06 17 防治荒漠化和干旱日 0 1994 " ,
" 06 23 国际奥林匹克日 0 1894 " ,
" 06 25 全国土地日 1 1991 " ,
" 06 26 国际禁毒日 0 1987 " ,
" 07 01 建党 5 1921 " ,
" 07 01 香港回归 5 1997 " ,
" 07 01 世界建筑日 0 1985 " ,
" 07 02 国际体育记者日 0 1995 " ,
" 07 07 抗日战争纪念日 1 1937 " ,
" 07 11 世界人口日 0 1988 " ,
" 07 30 非洲妇女日 1 1962 " ,
" 08 01 建军 5 1927 " ,
" 08 08 中国父亲节 1 1988 " ,
" 09 03 抗日战争胜利 1 1945 " ,
" 09 08 国际扫盲日 0 1966 " ,
" 09 08 国际新闻工作者日 0 1958 " ,
" 09 09 毛泽东逝世 0 1976 " ,
" 09 10 中国教师节 1 1985 " ,
" 09 14 世界清洁地球日 0 1970 " ,
" 09 16 国际臭氧层保护日 0 1987 " ,
" 09 18 九·一八事变 1 1931 " ,
" 09 20 国际爱牙日 0 1989 " ,
" 09 27 世界旅游日 0 1979 " ,
" 09 28 孔子诞辰 0 -551 " ,
" 10 01 国庆 5 1949 " ,
" 10 01 世界音乐日 0 1980 " ,
" 10 01 国际老人节 0 1990 " ,
" 10 02 国庆节假日 1 0 " ,
" 10 02 国际和平与民主自由斗争日 0 1949 " ,
" 10 03 国庆节假日 1 0 " ,
" 10 04 世界动物日 0 1949 " ,
" 10 06 老人节 0 0 " ,
" 10 08 全国高血压日 1 1998 " ,
" 10 08 世界视觉日 0 1998 " ,
" 10 09 世界邮政(万国邮联)日 0 1969 " ,
" 10 10 辛亥革命 5 1911 " ,
" 10 10 世界精神卫生日 0 1992 " ,
" 10 13 世界保健日 1 0 " ,
" 10 13 国际教师节 0 0 " ,
" 10 14 世界标准日 0 1969 " ,
" 10 15 国际盲人(白手杖)节 0 1984 " ,
" 10 16 世界粮食日 0 1979 " ,
" 10 17 世界消除贫困日 0 0 " ,
" 10 22 世界传统医药日 0 1992 " ,
" 10 24 联合国日 0 1945 " ,
" 10 31 世界勤俭日 0 0 " ,
" 11 07 十月革命 5 1911 " ,
" 11 08 中国记者日 0 2000 " ,
" 11 09 全国消防安全宣传教育日 0 1992 " ,
" 11 10 世界青年节 0 1946 " ,
" 11 11 (本日所属的一周)国际科学与和平周 0 0 " ,
" 11 12 孙中山诞辰 5 1866 " ,
" 11 14 世界糖尿病日 0 1991 " ,
" 11 17 国际大学生(世界学生)节 0 1946 " ,
" 11 20 彝族年 2 0 " ,
" 11 21 彝族年 2 0 " ,
" 11 21 世界问候日 0 1973 " ,
" 11 21 世界电视日 0 1996 " ,
" 11 22 彝族年 2 0 " ,
" 11 29 声援巴勒斯坦人民国际日 0 1977 " ,
" 12 01 世界艾滋病日 0 1988 " ,
" 12 03 世界残疾人日 0 1992 " ,
" 12 05 国际经济和社会发展志愿人员日 0 1985 " ,
" 12 08 国际儿童电视日 0 0 " ,
" 12 09 世界足球日 0 1995 " ,
" 12 10 世界人权日 0 1950 " ,
" 12 12 西安事变 5 1936 " ,
" 12 13 南京大屠杀 5 1937 " ,
" 12 20 澳门回归 5 1999 " ,
" 12 21 国际篮球日 0 1891 " ,
" 12 24 平安夜 0 0 " ,
" 12 25 圣诞节 0 0 " ,
" 12 26 毛泽东诞辰 5 1894 " )
// 农历节日
var lFtv = new Array(
" 01 01 春节 2 0 " ,
" 01 02 大年初二 2 0 " ,
" 01 03 大年初三 2 0 " ,
" 01 15 元宵节 2 0 " ,
" 05 05 端午节 2 0 " ,
" 07 07 七夕 2 0 " ,
" 07 15 中元节 2 0 " ,
" 08 15 中秋节 2 0 " ,
" 09 09 重阳节 2 0 " ,
" 10 06 晓风 0 0 " ,
" 12 08 腊八节 2 0 " ,
" 12 23 小年 2 0 " ,
" 01 00 除夕 2 0 " )
// 某月的第几个星期几
var wFtv = new Array(
" 01 5 0 世界麻风日 0 1954 " , // 一月的最后一个星期日(月倒数第一个星期日)
" 05 2 0 国际母亲节 0 1914 " ,
" 05 3 0 全国助残日 0 1990 " ,
" 06 3 0 父亲节 0 0 " ,
" 07 3 0 被奴役国家周 0 0 " ,
" 09 3 2 国际和平日 0 1981 " ,
" 09 4 0 国际聋人节 0 1958 " ,
" 09 4 0 世界儿童日 0 1986 " ,
" 09 5 0 世界海事日 0 1978 " ,
" 10 1 1 国际住房日 0 1982 " ,
" 10 1 3 国际减轻自然灾害(减灾)日 0 1990 " ,
" 11 4 4 感恩节 0 1620 " )
// ====================================== 返回农历 y年的总天数
function lYearDays(y) {
var i, sum = 348;
for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0;
return(sum+leapDays(y));
}
// ====================================== 返回农历 y年闰月的天数
function leapDays(y) {
if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29);
else return(0);
}
// ====================================== 返回农历 y年闰哪个月 1-12 , 没闰返回 0
function leapMonth(y) {
return(lunarInfo[y-1900] & 0xf);
}
// ====================================== 返回农历 y年m月的总天数
function monthDays(y,m) {
return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 );
}
// ====================================== 算出农历, 传入日期控件, 返回农历日期控件
// 该控件属性有 .year .month .day .isLeap
function Lunar(objDate) {
var i, leap=0, temp=0;
var offset = (Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate()) - Date.UTC(1900,0,31))/86400000;
for(i=1900; i<2050 && offset>0; i++) { temp=lYearDays(i); offset-=temp; }
if(offset<0) { offset+=temp; i--; }
this.year = i;
leap = leapMonth(i); //闰哪个月
this.isLeap = false;
for(i=1; i<13 && offset>0; i++) {
//闰月
if(leap>0 && i==(leap+1) && this.isLeap==false)
{ --i; this.isLeap = true; temp = leapDays(this.year); }
else
{ temp = monthDays(this.year, i); }
//解除闰月
if(this.isLeap==true && i==(leap+1)) this.isLeap = false;
offset -= temp;
}
if(offset==0 && leap>0 && i==leap+1)
if(this.isLeap)
{ this.isLeap = false; }
else
{ this.isLeap = true; --i; }
if(offset<0){ offset += temp; --i; }
this.month = i;
this.day = offset + 1;
}
// ==============================返回公历 y年某m+1月的天数
function solarDays(y,m) {
if(m==1)
return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28);
else
return(solarMonth[m]);
}
// ============================== 传入 offset 返回干支, 0=甲子
function cyclical(num) {
return(Gan[num%10]+Zhi[num%12]);
}
// ============================== 阴历属性
function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {
this.isToday = false;
//瓣句
this.sYear = sYear; //公元年4位数字
this.sMonth = sMonth; //公元月数字
this.sDay = sDay; //公元日数字
this.week = week; //星期, 1个中文
//农历
this.lYear = lYear; //公元年4位数字
this.lMonth = lMonth; //农历月数字
this.lDay = lDay; //农历日数字
this.isLeap = isLeap; //是否为农历闰月?
//八字
this.cYear = cYear; //年柱, 2个中文
this.cMonth = cMonth; //月柱, 2个中文
this.cDay = cDay; //日柱, 2个中文
this.color = '';
this.lunarFestival = ''; //农历节日
this.solarFestival = ''; //公历节日
this.lunarTerms = ''; //节气
}
// ===== 某年的第n个节气为几日(从0小寒起算)
function sTerm(y,n) {
var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) );
return(offDate.getUTCDate());
}
function calendar(y,m) {
var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2, tmp3;
var cY, cM, cD; //年柱,月柱,日柱
var lDPOS = new Array(3);
var n = 0;
var firstLM = 0;
sDObj = new Date(y,m,1,0,0,0,0); //当月一日日期
this.length = solarDays(y,m); //公历当月天数
this.firstWeek = sDObj.getDay(); //公历当月1日星期几
////年柱 1900年立春后为庚子年(60进制36)
if(m<2) cY=cyclical(y-1900+36-1);
else cY=cyclical(y-1900+36);
var term2=sTerm(y,2); //立春日期
////月柱 1900年1月小寒以前为 丙子月(60进制12)
var firstNode = sTerm(y,m*2) //返回当月「节」为几日开始
cM = cyclical((y-1900)*12+m+12);
//当月一日与 1900/1/1 相差天数
//1900/1/1与 1970/1/1 相差25567日, 1900/1/1 日柱为甲戌日(60进制10)
var dayCyclical = Date.UTC(y,m,1,0,0,0,0)/86400000+25567+10;
for(var i=0;i<this.length;i++) {
if(lD>lX) {
sDObj = new Date(y,m,i+1); //当月一日日期
lDObj = new Lunar(sDObj); //农历
lY = lDObj.year; //农历年
lM = lDObj.month; //农历月
lD = lDObj.day; //农历日
lL = lDObj.isLeap; //农历是否闰月
lX = lL? leapDays(lY): monthDays(lY,lM); //农历当月最后一天
if(n==0) firstLM = lM;
lDPOS[n++] = i-lD+1;
}
//依节气调整二月分的年柱, 以立春为界
if(m==1 && (i+1)==term2) cY=cyclical(y-1900+36);
//依节气月柱, 以「节」为界
if((i+1)==firstNode) cM = cyclical((y-1900)*12+m+13);
//日柱
cD = cyclical(dayCyclical+i);
//sYear,sMonth,sDay,week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],lY, lM, lD++, lL,cY ,cM, cD );
}
//节气
tmp1=sTerm(y,m*2 )-1;
tmp2=sTerm(y,m*2+1)-1;
this[tmp1].lunarTerms = lunarTerm[m*2];
this[tmp2].lunarTerms = lunarTerm[m*2+1];
//公历节日
for(i in sFtv){
//if(sFtv[i].match(/^(d{2}) (d{2}) ([s*])(.+)$/))
var tmpA=sFtv[i].split(" ");
if(Number(tmpA[0])==(m+1)) {
if (tmpA[4]=='0')
this[Number(tmpA[1])-1].solarFestival += tmpA[2]+' ';
else {
var yOffset=eval(this[Number(tmpA[1])-1].sYear-Number(tmpA[4]));
if (yOffset>0)
//if (tmpA[2].substring(tmpA[2].length-1,1)=='-')
if (tmpA[3]=='5')
this[Number(tmpA[1])-1].solarFestival +=tmpA[2]+yOffset+'周年 ';
else if (yOffset<0)
this[Number(tmpA[1])-1].solarFestival ='';
else this[Number(tmpA[1])-1].solarFestival += tmpA[2]+' ';
}
}
}
//月周节日
for(i in wFtv){
//if(wFtv[i].match(/^(d{2}) (d)(d) ([s*])(.+)$/))
tmpA =wFtv[i].split(" ");
if(Number(tmpA[0])==(m+1)) {
tmp1=Number(tmpA[1]);
tmp2=Number(tmpA[2]);
if(tmp1<5)
this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += tmpA[3]+' ';
else {
tmp1 -= 5;
tmp3 = (this.firstWeek+this.length-1)%7; //当月最后一天星期?
this[this.length - tmp3 - 7*tmp1 + tmp2 - (tmp2>tmp3?7:0) - 1 ].solarFestival += tmpA[3]+' ';
}
}
}
//农历节日
for(i in lFtv){
//if(lFtv[i].match(/^(d{2}) (.{2}) ([s*])(.+)$/)) {
tmpA =lFtv[i].split(" ");
tmp1=Number(tmpA[0])-firstLM;
if(tmp1==-11) tmp1=1;
if(tmp1 >=0 && tmp1<n) {
tmp2 = lDPOS[tmp1] + Number(tmpA[1]) -1;
if( tmp2 >= 0 && tmp2<this.length && this[tmp2].isLeap!=true) {
this[tmp2].lunarFestival += tmpA[2]+' ';
if ((this[tmp2].lMonth==10) && (this[tmp2].lDay==6)){
var xf_age=eval(this[tmp2].lYear-1985)
this[tmp2].lunarFestival = tmpA[2];
if (xf_age< 0) this[tmp2].lunarFestival+='还没生下来呢~~ ';
else if (xf_age==0) this[tmp2].lunarFestival+='横空出世~ ';
else if (xf_age==1) this[tmp2].lunarFestival+='会走路啦 ';
else if (xf_age==4) this[tmp2].lunarFestival+='上学了 ';
else if (xf_age==16) this[tmp2].lunarFestival+='弱冠之纪跑东北去了 ';
else if (xf_age> 100) this[tmp2].lunarFestival+='... ';
else this[tmp2].lunarFestival+=xf_age+'岁生日 ';
}
}
}
//}
}
//复活节只出现在3或4月
if(m==2 || m==3) {
var estDay = new easter(y);
if(m == estDay.m)
this[estDay.d-1].solarFestival = this[estDay.d-1].solarFestival+' 复活节 Easter Sunday';
}
if(m==2) this[20].solarFestival = this[20].solarFestival+unescape('%20%u6D35%u8CE2%u751F%u65E5');
//黑色星期五
if((this.firstWeek+12)%7==5)
this[12].solarFestival += '黑色星期五';
//今日
if(y==tY && m==tM) this[tD-1].isToday = true;
}
// ======================================= 返回该年的复活节(春分后第一次满月周后的第一主日)
function easter(y) {
var term2=sTerm(y,5); //取得春分日期
var dayTerm2 = new Date(Date.UTC(y,2,term2,0,0,0,0)); //取得春分的公历日期控件(春分一定出现在3月)
var lDayTerm2 = new Lunar(dayTerm2); //取得取得春分农历
if(lDayTerm2.day<15) //取得下个月圆的相差天数
var lMlen= 15-lDayTerm2.day;
else
var lMlen= (lDayTerm2.isLeap? leapDays(y): monthDays(y,lDayTerm2.month)) - lDayTerm2.day + 15;
//一天等于 1000*60*60*24 = 86400000 毫秒
var l15 = new Date(dayTerm2.getTime() + 86400000*lMlen ); //求出第一次月圆为公历几日
var dayEaster = new Date(l15.getTime() + 86400000*( 7-l15.getUTCDay() ) ); //求出下个周日
this.m = dayEaster.getUTCMonth();
this.d = dayEaster.getUTCDate();
}
function OnDetailsView(item) {
var html_for_details_view = "<html><head><script language="javascript">function click() {if (event.button==2||event.button==3) {alert('right click unabled');history.go(0);}}document.οnmοusedοwn=click</script></head><body>"
html_for_details_view = html_for_details_view+"<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066" style="filter:Alpha(opacity=80)"><TR><TD>"
html_for_details_view = html_for_details_view+"<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#ffffff" STYLE="font-size:9pt;">"
html_for_details_view = html_for_details_view+"cld[d].sYear+' 年 '+cld[d].sMonth+' 月 '+cld[d].sDay+' 日星期'+cld[d].week+'"
html_for_details_view = html_for_details_view+"<font color="violet">农历'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日</font>"
html_for_details_view = html_for_details_view+"<font color="yellow">'+cld[d].cYear+'年 '+cld[d].cMonth+'月 '+cld[d].cDay + '日</font>"
html_for_details_view = html_for_details_view+"</FONT></TD></TR></TABLE>"
html_for_details_view = html_for_details_view+"<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>"
html_for_details_view = html_for_details_view+"<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].lunarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD></TR></TABLE>"
html_for_details_view = html_for_details_view+"</TD></TR></TABLE></body></html>";
var control = new OpenItem();
var tm = new Date();
control.SetContent("Details Infomation 0", tm.getVarDate(), html_for_details_view,
true, item.layout);
control.html_content = true;
var details = new Object();
details.details_control = control;
return details;
}
var Today = new Date();
var tY = Today.getFullYear();
var tM = Today.getMonth();
var tDay = Today.getDay();
var tD = Today.getDate();
// var strHeading=tY+' '+tM+' '+tD+' ';
//
var width = " 130 " ;
var offsetx = 2 ;
var offsety = 8 ;
var x = 0 ;
var y = 0 ;
var snow = 0 ;
var sw = 0 ;
var cnt = 0 ;
var dStyle;
var cld;
// 初始值设定options
options.defaultValue( " u_solar " ) = true ;
options.defaultValue( " d_s_festival " ) = true ;
options.defaultValue( " d_week " ) = true ;
options.defaultValue( " d_g_festival " ) = true ;
options.defaultValue( " u_lunar " ) = true ;
options.defaultValue( " d_l_festival " ) = true ;
options.defaultValue( " d_l_terms " ) = true ;
options.defaultValue( " d_l_gz " ) = true ;
options.defaultValue( " u_world " ) = false ;
options.defaultValue( " u_tibetan " ) = false ;
options.defaultValue( " d_t_festival " ) = true ;
options.defaultValue( " u_hui " ) = false ;
options.defaultValue( " d_h_festival " ) = true ;
options.defaultValue( " u_festivals " ) = true ;
options.defaultValue( " d_f_global " ) = true ;
options.defaultValue( " d_f_region " ) = true ;
options.defaultValue( " d_f_trad " ) = true ;
options.defaultValue( " d_f_religion " ) = true ;
options.defaultValue( " d_f_remember " ) = true ;
options.defaultValue( " d_f_custom " ) = true ;
options.defaultValue( " display_language " ) = " en " ;
// Setup the icons, about dialog stuff and flags.
view.caption = strTitle;
contentArea.contentFlags = gddContentFlagManualLayout; // 手动设置item位置
contentArea.maxContentItems = 42 ; // 设置item最大数
// plugin.onShowOptionsDlg = ShowOptionsDlg; // handler for options dialog
plugin.onAddCustomMenuItems = AddCustomMenuItems; // handler to add menu items
goto_btn.onclick = Goto_Click;
today_btn.onclick = Today_Click;
/*
if (options("display_language")=='en') {
var imgToday = graphics.loadImage("en_today.gif");
var imgGoto = graphics.loadImage("en_goto.gif");
goto_btn.image=imgGoto;
today_btn.image=imgToday;
switch (tM+1){
case 1:sm_edit.value=__MSG_january__;
case 2:sm_edit.value=__MSG_february__;
case 3:sm_edit.value=__MSG_march__;
case 4:sm_edit.value=__MSG_april__;
case 5:sm_edit.value=__MSG_may__;
case 6:sm_edit.value=__MSG_june__;
case 7:sm_edit.value=__MSG_july__;
case 8:sm_edit.value=__MSG_august__;
case 9:sm_edit.value=__MSG_september__;
case 10:sm_edit.value=__MSG_october__;
case 11:sm_edit.value=__MSG_november__;
case 12:sm_edit.value=__MSG_december__;
}
sun_lab.innerText=__MSG_sunday__;
mon_lab.innerText=__MSG_monday__;
tues_lab.innerText=__MSG_tuesday__;
wed_lab.innerText=__MSG_wednesday__;
thurs_lab.innerText=__MSG_thursday__;
fri_lab.innerText=__MSG_friday__;
sat_lab.innerText=__MSG_saturday__;
}
*/
RefreshDisplay();
// Create true content item
// var item = new ContentItem();
// item.heading = "1号."; // this string is shown in the item
// item.onDetailsView = onDetailsView;
// contentArea.addContentItem(item, gddItemDisplayInSidebar); // add the item to the display
function RefreshDisplay() {
sy_edit.value=tY;
sm_edit.value=tM+1;
d_lab.innerText=tD;
drawCld(tY,tM);
}
function drawCld(SY,SM) {
var i,sD,s;
cld = new calendar(SY,SM);
var itemLayout = options("item_layout");
// remove existing and add new items.
contentArea.removeAllContentItems();
//if(SY>1874 && SY<1909) yDisplay = '光绪' + (((SY-1874)==true)?'元':SY-1874);
//if(SY>1908 && SY<1912) yDisplay = '宣统' + (((SY-1908)==true)?'元':SY-1908);
//if(SY>1911) yDisplay = '建国' + (((SY-1949)==true)?'元':SY-1949);
//GZ.innerHTML = yDisplay +'年 农历 ' + cyclical(SY-1900+36) + '年 【'+lunarAnimals[(SY-4)%12]+'年】';
//YMBG.innerHTML = " " + SY + " " + monthName[SM];
for(i=0;i<42;i++) {
var strDTooltip,strFestival;
var item=new ContentItem();
//SetRect(x, y, width, height)
//item.SetRect((i%7)*14%*view.width,42+(Math.floor(i/7))*20,14%*view.width,20);
item.SetRect(5+(i%7)*25,5+(Math.floor(i/7))*20,25,20);
sD = i - cld.firstWeek;
if(sD>-1 && sD<cld.length) { //日期内
item.heading=sD+1;
strDTooltip='';
strFestival='';
//if (options("u_festivals")){
//if (options("d_l_terms"))
strFestival+=cld[sD].lunarTerms;
//if (options("d_l_festivals"))
strFestival+=cld[sD].lunarFestival;
//if (options("d_s_festivals"))
strFestival+=cld[sD].solarFestival;
//}
strDTooltip=strDTooltip +'公元'+ cld[sD].sYear +'年' + cld[sD].sMonth + '月' + cld[sD].sDay + '日 ';
strDTooltip=strDTooltip + '星期' + cld[sD].week + ' ';
//}
//if (options("details_calendars_lunar")=='true'){
if ((cld[sD].sYear > 1899) && (cld[sD].sYear < 2051)){
if (cld[sD].isLeap) {strDTooltip=strDTooltip + '农历 闰' + cld[sD].lMonth + '月' + cld[sD].lDay + '日 ';}
else {strDTooltip=strDTooltip + '农历'+ cld[sD].lMonth + '月' + cld[sD].lDay + '日 ';}
//if(options("details_calendars_lunar_ganzhi")=='true'){
strDTooltip=strDTooltip + cld[sD].cYear +'年' + cld[sD].cMonth + '月' + cld[sD].cDay + '日 ';
}
//}
//}
//other calendars
if(cld[sD].isToday) {
item.heading='☆';
item.tooltip="TODAY "+strFestival+strDTooltip;
//item.Image=imgToday;
//item.onDrawItem = DrawItem;
//item.onGetHeight = GetItemHeight;
} //当天
else {
item.tooltip=strFestival+strDTooltip;
}
//item.onGetIsTooltipRequired=onGetIsTooltipRequired;
//if(cld[sD].lunarTerms=='清明') s = '清明节'.fontcolor('red');
//if(cld[sD].lunarTerms=='芒种') s = '芒种节'.fontcolor('red');
//if(cld[sD].lunarTerms=='夏至') s = '夏至节'.fontcolor('red');
//if(cld[sD].lunarTerms=='冬至') s = '冬至节'.fontcolor('red');
var vbarrItems = contentArea.contentItems;
var items = vbarrItems.toArray();
var curItem = null;
if (i == items.length) {
curItem = new ContentItem(); // not found so add it fresh
//curItem.source = source; //设置到网络查询的变量
curItem.layout = gddContentItemLayoutNews;
curItem.onDetailsView = OnDetailsView;
contentArea.addContentItem(curItem, gddItemDisplayInSidebar);
} else {
curItem = items[i]; // update the existing item
}
//curItem.heading=cld[sD].sMonth+cld[sD].sDay;
//curItem.snippet = cld[sD].sYear+cld[sD].sMonth+cld[sD].sDay; // to show in details view
//curItem.open_command = "http://192.168.2.1";
item.layout = itemLayout;
contentArea.addContentItem(item, gddItemDisplayInSidebar);
}
else { //非日期
item.heading='';
//SD.innerText = '';
//LD.innerText = '';
}
}
}
function Today_Click() {
RefreshDisplay();
}
function Goto_Click() {
d_lab.innerText='';
drawCld(sy_edit.value,eval(sm_edit.value-1));
}
function AddCustomMenuItems(menu) {
// Add the various item layouts as menu items and check the currently selected one
var itemLayout = options("item_layout");
for (var i = 0; i < menuItems.length; ++i) {
if (i == itemLayout) {
menu.AddItem(menuItems[i], gddMenuItemFlagChecked, MenuItemClicked);
} else {
menu.AddItem(menuItems[i], 0, MenuItemClicked);
}
}
}
function MenuItemClicked(item) {
// find which one was clicked and switch items to the chosen layout.
var itemLayout = gddContentItemLayoutNowrapItems;
for (var i = 0; i < menuItems.length; ++i) {
if (item == menuItems[i]) {
itemLayout = i;
}
}
// save the option selected by the user in our options store
options("item_layout") = itemLayout;
RefreshDisplay();
}
// Called to find out the height of each content item
function GetItemHeight(item, target, graphics, width) {
return itemImageHeight + 2 +
graphics.GetTextHeight(strItemText, width, 0, gddFontNormal);
}
// Called to draw each content item
function DrawItem(item, target, graphics, x, y, width, height) {
graphics.DrawImage(x, y, width, itemImageHeight, itemImage, 100);
y += itemImageHeight + 2;
height -= itemImageHeight + 2;
graphics.DrawText(x, y, width, height, item.heading, gddColorNormalText,
gddTextFlagCenter, gddFontNormal);
}
/*
目前存在的待解决的问题~~
选项(options)
详细信息查看(onDetailView)事件的响应
双击获取历史上的今天(onOpenItem)事件的响应
*/