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

    第一步:打开链接http://www.eclipsecolorthemes.org/选中一款:下载其中的epf格式. 如图: 在eclipse中打开:file > import > Gen ...

  2. UVA 10474

    题意:给你一组数,再给几个数问是否在一组数中. 题很简单:STL入门. 没用到STL. #include<iostream> #include<cstdio> #include ...

  3. [课程设计]Scrum 1.3 多鱼点餐系统开发进度

    [课程设计]Scrum 1.3 多鱼点餐系统开发进度   Scrum 1.3 多鱼点餐系统开发进度 1.团队名称:重案组 2.团队目标:长期经营,积累客户充分准备,伺机而行 3.团队口号:矢志不渝,追 ...

  4. webbrowser 禁用 alert

    void web_Navigated(object sender, WebBrowserNavigatedEventArgs e) { var web = sender as System.Windo ...

  5. SSR三网免流一键包以及使用教程

    这篇文章只是传统的SSR免流教程 首先拿到一台vps,可以是centos,可以是debian,也可以是ubuntu 使用xshell连接vps 执行一键安装包 wget http://104.224. ...

  6. Fully Convolutional Networks for semantic Segmentation(深度学习经典论文翻译)

    摘要 卷积网络在特征分层领域是非常强大的视觉模型.我们证明了经过端到端.像素到像素训练的卷积网络超过语义分割中最先进的技术.我们的核心观点是建立"全卷积"网络,输入任意尺寸,经过有 ...

  7. Hadoop学习笔记

    今天开始要学习Hadoop!开始向"大数据"领域靠拢! 从头开始对于连何为Hadoop都不清楚的人,有好多东西要学,加油! 1.下载hadoop,官网地址:http://mirro ...

  8. PHP eof的使用

    PHP eof的使用 也就是heredoc技术,来部分实现界面与代码的分离 <?php $name = '张三'; print <<<EOT <html> < ...

  9. 自动化运维:网站svn代码上线更新(flask+saltstack)

    阶段性总结:      跌跌撞撞的用了一周左右的时间做完了网站自动升级功能,中间遇到了很多的问题,也学到了很多,在此做一个总结.   1.整体架构: 后台:nginx+uwsgi  #nginx提供w ...

  10. Code Page 编码

    Identifier .NET Name Additional information 037 IBM037 IBM EBCDIC US-Canada 437 IBM437 OEM United St ...