js日历代码片段解析? 我想理解,但大部分看不懂,不明所以,希望大家能有人告诉我为什么这样子,原理 30
js日历代码片段解析?我想理解,但大部分看不懂,不明所以,希望大家能有人告诉我为什么这样子,原理什么的。calendar._dn3和mn3都是一个数组对象,分别存储星期和...
js日历代码片段解析?
我想理解,但大部分看不懂,不明所以,希望大家能有人告诉我为什么这样子,原理什么的。calendar._dn3和mn3都是一个数组对象,分别存储星期和月份,都在calendar-zh的这个js里,同时也存有相关数组变量。下面dn3表示什么,为什么遍历,然后substr(0,3),为什么dn3等
// one-time initializations
if (!Calendar._DN3) {
// table of short day names
var ar = new Array();
for (var i = 8; i > 0;) {
ar[--i] = Calendar._DN[i].substr(0, 3);
}
Calendar._DN3 = ar;
// table of short month names
ar = new Array();
for (var i = 12; i > 0;) {
ar[--i] = Calendar._MN[i].substr(0, 3);
}
Calendar._MN3 = ar;
}
};
// ** constants
/// "static", needed for event handlers.
Calendar._C = null;
/// detect a special case of "web browser"
Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
!/opera/i.test(navigator.userAgent) );
// short day names array (initialized at first constructor call)
Calendar._DN3 = null;
// short month names array (initialized at first constructor call)
Calendar._MN3 = null;
// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate
// library, at some point.
Calendar.getAbsolutePos = function(el) {
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
var tmp = Calendar.getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
}; 展开
我想理解,但大部分看不懂,不明所以,希望大家能有人告诉我为什么这样子,原理什么的。calendar._dn3和mn3都是一个数组对象,分别存储星期和月份,都在calendar-zh的这个js里,同时也存有相关数组变量。下面dn3表示什么,为什么遍历,然后substr(0,3),为什么dn3等
// one-time initializations
if (!Calendar._DN3) {
// table of short day names
var ar = new Array();
for (var i = 8; i > 0;) {
ar[--i] = Calendar._DN[i].substr(0, 3);
}
Calendar._DN3 = ar;
// table of short month names
ar = new Array();
for (var i = 12; i > 0;) {
ar[--i] = Calendar._MN[i].substr(0, 3);
}
Calendar._MN3 = ar;
}
};
// ** constants
/// "static", needed for event handlers.
Calendar._C = null;
/// detect a special case of "web browser"
Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
!/opera/i.test(navigator.userAgent) );
// short day names array (initialized at first constructor call)
Calendar._DN3 = null;
// short month names array (initialized at first constructor call)
Calendar._MN3 = null;
// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate
// library, at some point.
Calendar.getAbsolutePos = function(el) {
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
var tmp = Calendar.getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
}; 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏30(财富值+成长值)
1个回答
2014-08-24
展开全部
你要问哪一行呢?
更多追问追答
追问
比如为什么要if(!dn3)为什么这里要是3
然后最后一个函数不知道原理和作用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询