在网上找了许多大牛做的农历日历,但是不是不符合项目中的要求,就是本身就有问题有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. C# DataGridView自定义分页控件

    好些日子不仔细写C#代码了,现在主要是Java项目,C#.Net相关项目不多了,有点手生了,以下代码不足之处望各位提出建议和批评. 近日闲来无事想研究一下自定义控件,虽然之前也看过,那也仅限于皮毛,粗 ...

  2. 一些好的python IDE

    pyscipter 是一个不错的选择,快速灵巧.功能丰富.它的安装包只有五六兆,功能却一个都不少.语法高亮功能也很强,运算符.数字.hex都能按照你的需要改变颜色.还有非常灵敏的code comple ...

  3. 另类vs2015+xamarin 的android界面乱码 解决

    text.Text += "验证key 验证出错! 请在 AndroidManifest.xml 文件中检查 key 设置"; 代码就上面一行,单步走之前text.Text里面是汉 ...

  4. catalog备份数据库及RMAN存储脚本

    环境说明: 提前配置好两个库的监听与tnsnames.oraIP:10.100.25.13 为目标数据库  IP:10.100.25.14 为恢复目录数据库(catalog database) 以下操 ...

  5. js数组键入值push和 arr[]i]区别

    push 和 arr[i] 遍历 var arr = new Array(); $(":check").each(function(i){if(this.checked==true ...

  6. Winform水印

    本文实例展示了WinForm实现为TextBox设置水印文字功能,非常实用的技巧,分享给大家供大家参考. 关键代码如下 using System; using System.Runtime.Inter ...

  7. acm之poj题库1001方法

    题目所言是银行等不能用四舍五入等影响精度的方法来计算的情况,是为提出背景.因此需要特殊的编写.这里使用了好几种方法才找到一个合适的方法.因为C++或者C缺乏类库,又跟底层关联太大,缺乏常用的类库,在写 ...

  8. Base64加密工具-iBlogs

    简易的Base64加密工具开发步骤 1.编写Java测试桩 import java.io.BufferedReader; import java.io.IOException; import java ...

  9. kali 初始化

    关于kali使用前的一些配置,网上有很多版本,但是几乎都很雷同,或者是不全,或者是根本就没有测试过,或者是有的方法是错的(换句话说是版本变化的差异),因此让很多人接触kali时百度无数,效果一般,浪费 ...

  10. putty远程连接ubuntu

      步骤一.在ubuntu系统中安装ssh,可使用如下的命令进行安装: sudo apt-get install openssh-server步骤二.为了保险起见,安装完成后重启一下ssh服务,命令如 ...