在网上找了许多大牛做的农历日历,但是不是不符合项目中的要求,就是本身就有问题有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. h5移动端-1

    iphone3 : 设备分辨率 : 320*480 屏幕分辨率 : 320*480 iphone4 : 设备分辨率 : 320*480 屏幕分辨率 : 640*960 iphone5 : 设备分辨率 ...

  2. nagios监控系统安装及配置

    Nagios通常由一个主程序(Nagios).一个插件程序(Nagios-plugins)和四个可选的ADDON(NRPE.NSCA.NSClient++和NDOUtils)组成.Ngios的监控工作 ...

  3. PHP 与pdf文档 与条码

    必要的步骤 1.导入require_once "tcpdf/tcpdf.php"; 工具源码在demo中 2.$pdf = new TCPDF("P", &qu ...

  4. {part1}DFN+LOW(tarjan)割点

    什么是jarjan? 1)求割点 定义:在无向连通图中,如果去掉一个点/边,剩下的点之间不连通,那么这个点/边就被称为割点/边(或割顶/桥). 意义:由于割点和割边涉及到图的连通性,所以快速地求出割点 ...

  5. js中遍历对象的属性和值

    今天想看一下js的数组遍历的内容,搜索到了一个关于对象遍历写好的函数,保留一下.以后好用. function allPrpos ( obj ) {   // 用来保存所有的属性名称和值   var p ...

  6. C++ exception

    从没用过C++STL中的exception(异常类),在使用rapidxml,操作XML文件时,发现在一个抛出异常的错误.关注了下,就模范着做. 我也专门写了个函数来分配内存,如果发现分配不成功,就抛 ...

  7. Web性能测试的简介

    一.术语 1.并发用户:并发一般分两种.1)严格意义上的并发,即所有的用户在同一时刻做同一件事情或操作,这种操作一般指做同一类型的业务:2)广义范围的并发,与前者主要区别,尽管多个用户对系统发出了请求 ...

  8. unsigned char 类型

    在蓝牙4.0的开发中,很多数据类型都用到了 unsigned char ,我觉得用这个类型的一个原因是相比较于整型,它占的空间更少. 比如: unsigned char a = 1;  // 占1个字 ...

  9. VS调试技巧,提高调试效率(转):

    如果你还没有使用过这些技巧,希望这篇博文能帮你发现它们. 它们学起来很容易,能帮你节省很多时间. 运行到光标(Ctrl+ F10) 我经常看见人们是这样来调试应用程序的: 他们在应用程序需要调试的代码 ...

  10. IIS性能相关的配置、命令

    IIS性能相关的配置.命令 应用程序池回收 不要使用缺省的“固定时间间隔(分钟)”:1740(即29小时),建议改为0 可以根据实际情况设置特定时间回收,比如凌晨4点 最大工作进程数 可以根据实际情况 ...