在网上找了许多大牛做的农历日历,但是不是不符合项目中的要求,就是本身就有问题有Bug ,把大牛门的做日历看了n遍 自己又改造了一遍得到了这个:随后日历又要做个自适应的长宽,又在js中改造代码。。。。。。 也感谢大牛门的代码 不说了 上代码:

前台:

<table cellpadding="" cellspacing="" id="CalendarTab">
<tr>
<td>
<div id="cal">
<div id="top">
公元<select></select> 年 <select></select>月 农历 <span></span>年 [ <span></span>年 ]
<input type="button" value="回到今天" title="点击后跳转回 今天" style="padding:0px">
</div>
<ul id="wk">
<li>一</li>
<li>二</li>
<li>三</li>
<li>四</li>
<li>五</li>
<li><b>六</b></li>
<li><b>日</b></li>
</ul>
<div id="cm"></div>
</div>
</td>
</tr>
</table>
<script src="~/Scripts/Fullcalendar/LunarClaend.js"></script>

css

/*日历*/
#CalendarTab{width:%}
#cal {width: %; border: ;font-size: 12px;text-align:center;}
#cal #top { height: 28px; line-height: 31px;background: #e7eef8; color: #;}
#cal #top select { font-size: 14px;}
#cal #top input { padding: ;}
#cal ul#wk {margin: ;padding: ;height: 25px;width:%}
#cal ul#wk li {float: left; width: %;line-height: 35px;list-style: none;}
#cal ul#wk li b {font-weight: normal; color: #c60b02;}
#cal #cm { clear: left; border-top: 1px solid #ddd; position: relative;}
#cal #cm .cell {position: absolute;line-height:12px;width:%}
#cal #cm .cell .so {font: bold 18px arial;}

-----------------------

LunarClaend.js

(function () {
var S = navigator.userAgent.indexOf("MSIE") != - && !window.opera;
function M(C) {
return document.getElementById(C)
} function R(C) {
return document.createElement(C)
} var P = [, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ];
var K = "甲乙丙丁戊己庚辛壬癸";
var J = "子丑寅卯辰巳午未申酉戌亥";
var O = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
var L = ["小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"];
var D = [, , , , , , , , , , , , , , , , , , , , , , , ];
var B = "日一二三四五六七八九十";
var H = ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"];
var E = "初十廿卅";
//"---"被和谐了 。。。。。。
var V = {
"": "*1元旦节", "": "情人节", "": "学雷锋纪念日", "": "妇女节", "": "植树节", "": "消费者权益日", "": "愚人节", "": "*1劳动节", "": "青年节", "": "国际儿童节", "": "---", "": "建军节", "": "中国教师节", "": "*3国庆节", "": "平安夜", "": "圣诞节"
};
var T = {
"": "*2春节", "": "元宵节", "": "*1端午节", "": "*1中秋节", "": "重阳节", "": "腊八节", "": "除夕"
};
function U(Y) {
function c(j, i) {
var h = new Date((31556925974.7 * (j - ) + D[i] * ) + Date.UTC(, , , , ));
return (h.getUTCDate())
} function d(k) {
var h, j = ;
for (h = ; h > ; h >>= ) {
j += (P[k - ] & h) ? :
} return (j + b(k))
} function a(h) {
return (K.charAt(h % ) + J.charAt(h % ))
} function b(h) {
if (g(h)) {
return ((P[h - ] & ) ? : )
} else {
return ()
}
} function g(h) {
return (P[h - ] & )
} function e(i, h) {
return ((P[i - ] & ( >> h)) ? : )
} function C(m) {
var k, j = , h = ;
var l = new Date(, , );
var n = (m - l) / ;
this.dayCyl = n + ;
this.monCyl = ;
for (k = ; k < && n > ; k++) {
h = d(k);
n -= h;
this.monCyl +=
} if (n < ) {
n += h;
k--;
this.monCyl -=
} this.year = k;
this.yearCyl = k - ;
j = g(k);
this.isLeap = false;
for (k = ; k < && n > ; k++) {
if (j > && k == (j + ) && this.isLeap == false) {
--k;
this.isLeap = true;
h = b(this.year)
} else {
h = e(this.year, k)
} if (this.isLeap == true && k == (j + )) {
this.isLeap = false
} n -= h;
if (this.isLeap == false) {
this.monCyl++
}
} if (n == && j > && k == j + ) {
if (this.isLeap) {
this.isLeap = false
} else {
this.isLeap = true;
--k;
--this.monCyl
}
} if (n < ) {
n += h;
--k;
--this.monCyl
} this.month = k;
this.day = n +
} function G(h) {
return h < ? "" + h : h
} function f(i, j) {
var h = i;
return j.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g, function (k) {
switch (k) {
case "yyyy": var l = "" + h.getFullYear();
return l.substring(l.length - );
case "dd": return G(h.getDate());
case "d": return h.getDate().toString();
case "MM": return G((h.getMonth() + ));
case "M": return h.getMonth() +
}
})
} function Z(i, h) {
var j;
switch (i, h) {
case : j = "初十";
break;
case : j = "二十";
break;
case : j = "三十";
break;
default: j = E.charAt(Math.floor(h / ));
j += B.charAt(h % )
} return (j)
} this.date = Y;
this.isToday = false;
this.isRestDay = false;
this.solarYear = f(Y, "yyyy");
this.solarMonth = f(Y, "M");
this.solarDate = f(Y, "d");
this.solarWeekDay = Y.getDay();
this.solarWeekDayInChinese = "星期" + B.charAt(this.solarWeekDay);
var X = new C(Y);
this.lunarYear = X.year;
this.shengxiao = O.charAt((this.lunarYear - ) % );
this.lunarMonth = X.month;
this.lunarIsLeapMonth = X.isLeap;
this.lunarMonthInChinese = this.lunarIsLeapMonth ? "闰" + H[X.month - ] : H[X.month - ];
this.lunarDate = X.day;
this.showInLunar = this.lunarDateInChinese = Z(this.lunarMonth, this.lunarDate);
if (this.lunarDate == ) {
this.showInLunar = this.lunarMonthInChinese + "月"
} this.ganzhiYear = a(X.yearCyl);
this.ganzhiMonth = a(X.monCyl);
this.ganzhiDate = a(X.dayCyl++);
this.jieqi = "";
this.restDays = ;
if (c(this.solarYear, (this.solarMonth - ) * ) == f(Y, "d")) {
this.showInLunar = this.jieqi = L[(this.solarMonth - ) * ]
} if (c(this.solarYear, (this.solarMonth - ) * + ) == f(Y, "d")) {
this.showInLunar = this.jieqi = L[(this.solarMonth - ) * + ]
} if (this.showInLunar == "清明") {
this.showInLunar = "清明节";
this.restDays =
} this.solarFestival = V[f(Y, "MM") + f(Y, "dd")];
if (typeof this.solarFestival == "undefined") {
this.solarFestival = ""
} else {
if (/\*(\d)/.test(this.solarFestival)) {
this.restDays = parseInt(RegExp.$);
this.solarFestival = this.solarFestival.replace(/\*\d/, "")
}
} this.showInLunar = (this.solarFestival == "") ? this.showInLunar : this.solarFestival;
this.lunarFestival = T[this.lunarIsLeapMonth ? "" : G(this.lunarMonth) + G(this.lunarDate)];
if (typeof this.lunarFestival == "undefined") {
this.lunarFestival = ""
} else {
if (/\*(\d)/.test(this.lunarFestival)) {
this.restDays = (this.restDays > parseInt(RegExp.$)) ? this.restDays : parseInt(RegExp.$);
this.lunarFestival = this.lunarFestival.replace(/\*\d/, "")
}
} if (this.lunarMonth == && this.lunarDate == e(this.lunarYear, )) {
this.lunarFestival = T[""];
this.restDays =
} this.showInLunar = (this.lunarFestival == "") ? this.showInLunar : this.lunarFestival;
// this.showInLunar = (this.showInLunar.length > 4) ? this.showInLunar.substr(0,3) + "..." : this.showInLunar
} var Q = (function () {
var X = {
};
X.lines = ;
X.dateArray = new Array();
function Y(a) {
return (((a % === ) && (a % !== )) || (a % === ))
} function G(a, b) {
return [, (Y(a) ? : ), , , , , , , , , , ][b]
} function C(a, b) {
a.setDate(a.getDate() + b);
return a
} function Z(a) {
var f = ;
var c = new U(new Date(a.solarYear, a.solarMonth - , ));
var d = (c.solarWeekDay - == -) ? : c.solarWeekDay - ;
X.lines = Math.ceil((d + G(a.solarYear, a.solarMonth - )) / );
for (var e = ; e < X.dateArray.length; e++) {
if (c.restDays != ) {
f = c.restDays
} if (f > ) {
c.isRest = true
} if (d-- > || c.solarMonth != a.solarMonth) {
X.dateArray[e] = null;
continue
} var b = new U(new Date());
if (c.solarYear == b.solarYear && c.solarMonth == b.solarMonth && c.solarDate == b.solarDate) {
c.isToday = true
} X.dateArray[e] = c;
c = new U(C(c.date, ));
f--
}
} return {
init: function (a) {
Z(a)
}, getJson: function () {
return X
}
}
})();
var W = (function () {
var C = M("top").getElementsByTagName("SELECT")[];
var X = M("top").getElementsByTagName("SELECT")[];
var G = M("top").getElementsByTagName("SPAN")[];
var c = M("top").getElementsByTagName("SPAN")[];
var Y = M("top").getElementsByTagName("INPUT")[];
function a(g) {
G.innerHTML = g.ganzhiYear;
c.innerHTML = g.shengxiao
} function b(g) {
C[g.solarYear - ].selected = true;
X[g.solarMonth - ].selected = true
} function f() {
var j = C.value;
var g = X.value;
var i = new U(new Date(j, g - , ));
Q.init(i);
N.draw();
if (this == C) {
i = new U(new Date(j, , ));
G.innerHTML = i.ganzhiYear;
c.innerHTML = i.shengxiao
} var h = new U(new Date());
Y.style.visibility = (j == h.solarYear && g == h.solarMonth) ? "hidden" : "visible"
} function Z() {
var g = new U(new Date());
a(g);
b(g);
Q.init(g);
N.draw();
Y.style.visibility = "hidden"
} function d(k, g) {
for (var j = ; j < ; j++) {
var h = R("OPTION");
h.value = j;
h.innerHTML = j;
if (j == k) {
h.selected = "selected"
} C.appendChild(h)
} for (var j = ; j < ; j++) {
var h = R("OPTION");
h.value = j;
h.innerHTML = j;
if (j == g) {
h.selected = "selected"
} X.appendChild(h)
} C.onchange = f;
X.onchange = f
} function e(g) {
d(g.solarYear, g.solarMonth);
G.innerHTML = g.ganzhiYear;
c.innerHTML = g.shengxiao;
Y.onclick = Z;
Y.style.visibility = "hidden"
} return {
init: function (g) {
e(g)
}, reset: function (g) {
b(g)
}
}
})();
var N = (function () {
function C() {
var Z = Q.getJson();
var c = Z.dateArray;
var Wid = $("#CalendarTab").width(); M("cm").style.height = Z.lines * + + "px";
M("cm").innerHTML = "";
for (var a = ; a < c.length; a++) {
if (c[a] == null) {
continue
} var X = R("DIV");
if (c[a].isToday) {
X.style.border = "1px solid #a5b9da";
X.style.background = "#c1d9ff"
} X.className = "cell";
X.style.left = (a % ) * (Wid/7.4) + "px";
X.style.top = Math.floor(a / ) * + + "px"; var b = R("DIV");
b.className = "so";
b.style.color = ((a % ) > || c[a].isRest) ? "#c60b02" : "#313131";
b.innerHTML = c[a].solarDate;
X.appendChild(b);
var Y = R("DIV");
Y.style.color = "#666";
var NInLunar = c[a].showInLunar
var newshowInLunar = "";
if (NInLunar.length>) {
newshowInLunar = NInLunar.substr(, ) + "..."
}
else{newshowInLunar=c[a].showInLunar}
Y.innerHTML = newshowInLunar;
Y.title = c[a].showInLunar;
X.appendChild(Y);
X.onmouseover = (function (d) {
return function (f) {
F.show({
dateIndex: d, cell: this
})
}
})(a);
X.onmouseout = function () {
F.hide()
};
M("cm").appendChild(X)
} var G = R("DIV");
M("cm").appendChild(G);
F.init(G)
} return {
draw: function (G) {
C(G)
}
}
})();
var F = (function () {
var C;
function Y(e, c) {
if (arguments.length > ) {
var b = /([.*+?^=!:${}()|[\]\/\\])/g, Z = "{".replace(b, "\\$1"), d = "}".replace(b, "\\$1");
var a = new RegExp("#" + Z + "([^" + Z + d + "]+)" + d, "g");
if (typeof (c) == "object") {
return e.replace(a, function (f, h) {
var g = c[h];
return typeof (g) == "undefined" ? "" : g
})
}
} return e
} function G(b) {
var a = Q.getJson().dateArray[b.dateIndex];
var Z = b.cell;
if (a.solarFestival != "" || a.lunarFestival != "" || a.jieqi != "") { }
C.style.top = Z.offsetTop + Z.offsetHeight - + "px";
C.style.left = Z.offsetLeft + Z.offsetWidth - + "px";
C.style.display = "block"
} function X() {
C.style.display = "none"
} return {
show: function (Z) {
G(Z)
}, hide: function () {
X()
}, init: function (Z) {
C = Z
}
}
})();
var A = new U(new Date());
if (S) {
window.attachEvent("onload", function () {
W.reset(A)
})
} W.init(A);
Q.init(A);
N.draw();
})();

http://www.51xuediannao.com/js/texiao/rili.html

jquery 农历日历 可自适应的更多相关文章

  1. 一款简洁大气的jquery日期日历插件

    本jquery插件名为manhuaDate,暂时只支持jquery 1.9.0以下版本,比如jquery-1.8.3.min.js 查看效果网址:http://keleyi.com/a/bjad/em ...

  2. 基于jQuery编写的横向自适应幻灯片切换特效

    基于jQuery编写的横向自适应幻灯片切换特效 全屏自适应jquery焦点图切换特效,在IE6这个蛋疼的浏览器兼容性问题上得到了和谐,兼容IE6. 适用浏览器:IE6.IE7.IE8.360.Fire ...

  3. jquery插件——日历控件

    今天在网上有看到一个jquery插件——日历控件,不过之前也在柯乐义的网站上看到了(http://keleyi.com/ 推荐下) 这个插件看着比较大气,所以干脆也分享下,以后自己也好用一点儿 1.页 ...

  4. jQuery实现iframe的自适应高度

    假设我们在当前页面要嵌套一个iframe 1 <iframe id="myframe" src="test.html" height="240& ...

  5. Atitit.基于时间戳的农历日历历法日期计算

    Atitit.基于时间戳的农历日历历法日期计算 1. 农历xx年的大小月份根据万年历查询1 2. 农历xx年1月1日的时间戳获取1 3. 计算当年的时间戳与农历日期的对应表,时间戳为key,日期为va ...

  6. jquery库实现iframe自适应内容高度和宽度

    javascript原生和jquery库实现iframe自适应内容高度和宽度---推荐使用jQuery的代码! ‍<iframe src="index.php" id=&qu ...

  7. 带农历日历的DatePicker控件!Xamarin控件开发小记

    原文:带农历日历的DatePicker控件!Xamarin控件开发小记 闲来无事开发了个日期选择控件,感兴趣的同学前往: https://github.com/MatoApps/Mato.DatePi ...

  8. jquery网页日历显示控件calendar3.1使用详解

    关于日历插件,我做了好多次尝试,一直致力于开发一款简单易用的日历控件.我的想法是争取在引用这个控件后,用一行js代码就能做出一个日历,若在加点参数,就能自定义外观和功能丰富多彩的日历.Calendar ...

  9. jQuery解决iframe高度自适应代码

    网上查了好多用着都不行,自己搞定了:在包含iframe的页面中加入以下脚本,基本思想是在iframe加载内容后重新设置高度,下面代码尽在IE6中用过,没在其他浏览器中测试. 代码如下: <scr ...

随机推荐

  1. HTML5 3D爱心动画 晚来的七夕礼物

    在线演示源码下载 这么好看的HTML5爱心动画,我们当然要把源代码分享给大家,下面是小编整理的源代码,主要是HTML代码和CSS代码. HTML代码: <div class=’heart3d’& ...

  2. uva 12169

    /* 巨大的斐波那契数列_________________________________________________________________________________ #inclu ...

  3. Shiro中的subject.login()

    当调用ShiroHandler中的subject.login()的时候,会自动调用Realm中的doGetAuthenticationInfo方法.

  4. Android学习十一:高德地图使用

    写这篇文章主要有三个目的: 1.使用高德地图api定位 2.获取天气数据 3.编程练手 文件结构 清单文件信息说明: <?xml version="1.0" encoding ...

  5. 10天学会phpWeChat——第六天:实现新闻的后台管理

    通过前面五讲的系列教程,我们完成了一个简单模块的前端发布.列表展示.详情展示.实际生产环境中,所有前台的数据都会有对应的后台操作进行统筹管理.我们称之为后台管理系统. 今天,我们开始<10天学会 ...

  6. 自动运维:Ansible -ansible tower

    文档主页:http://docs.ansible.com/参考文档:http://docs.ansible.com/ansible/参考文档:http://docs.ansible.com/ansib ...

  7. 第一章 数据库概述、MySQL的安装和配置

      第一章 数据库概述.MySQL的安装和配置   1.为什么要使用数据库 最早是纸质文件来存储数据 缺点:不易保存,占用空间大 计算机出现以后,采用软件来进行保存(excel) 缺点:容易损坏 文件 ...

  8. [综]隐马尔可夫模型Hidden Markov Model (HMM)

    http://www.zhihu.com/question/20962240 Yang Eninala杜克大学 生物化学博士 线性代数 收录于 编辑推荐 •2216 人赞同 ×××××11月22日已更 ...

  9. correlation filters in object tracking

    http://www.cnblogs.com/hanhuili/p/4266990.html Correlation Filter in Visual Tracking系列一:Visual Objec ...

  10. Building GCC 4.1.2 in CentOS 7 for Maya API development

    Following the official guid: http://help.autodesk.com/cloudhelp/2015/ENU/Maya-SDK/files/Setting_up_y ...