| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 776 人关注过本帖
标题:请教js的三个问题
只看楼主 加入收藏
sanyeshu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-9-7
收藏
 问题点数:0 回复次数:2 
请教js的三个问题

谁能帮我看看下面这三段脚本是什么意思?
<一>

ycn=window.ycnui||{};
ycn.Common=new function(){
this.lTrim=function(i){
return i.replace(/^\s*/,"");};
this.rTrim=function(i){return i.replace(/\s*$/,"");};
this.trim=function(i){return this.rTrim(this.lTrim(i));};
this.getEl=function(i){if(!document.getElementById)return false;if(typeof i==="string"){return document.getElementById(i);}else{return i;}};this.getElByClassName=function(t,n,s,el){var el=(el)?el:document;var itm=el.getElementsByTagName(t);var num=1;for(i=0;i<itm.length;i++){if(itm[i].className===n&&s===num){return itm[i];}else if(itm[i].className===n){num++;}}
return false;};
this.isIE6=function(){return navigator.userAgent.search('MSIE')>0&&navigator.userAgent.search('6')>0;}
this.isIE=function(){return navigator.userAgent.search('MSIE')>0;}
this.isOpera=function(){return navigator.userAgent.indexOf('Opera')>-1;}
this.isMoz=function(){return navigator.userAgent.indexOf('Mozilla/5.')>-1;}
this.setCookie=function(cn,cv,d,dm){var now=new Date();var expire=new Date();if(d==null||d==0)d=1;expire.setTime(now.getTime()+3600000*24*d);document.cookie=cn+"="+escape(cv)
+";expires="+expire.toGMTString()
+";domain="+dm;}
this.deleteCookie=function(cn,dm){if(getCookie(name))
{document.cookie=cn+"="+
((domain)?"; domain="+dm:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}
this.getCookie=function(cn)
{var dc=document.cookie;var prefix=cn+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1)
{begin=dc.indexOf(prefix);if(begin!=0)return null;}
else
{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1)
{end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end));}};


<二>


ycn=window.ycn||{};ycn.Event={addEvent:function(obj,evType,fn){if(obj.addEventListener)
{obj.addEventListener(evType,fn,false);return true;}
else if(obj.attachEvent)
{var r=obj.attachEvent("on"+evType,fn);ycn.EventCache.add(obj,evType,fn);return r;}
else
{return false;}},removeEvent:function(obj,evType,fn){if(obj.removeEventListener){obj.removeEventListener(evType,fn,false);return true;}else if(obj.detachEvent){var r=obj.detachEvent("on"+evType,fn);return r;}else{return false;}},getEvent:function(e)
{e=window.event||e;e.leftButton=false;if(e.srcElement==null&&e.target!=null)
{e.srcElement=e.target;e.leftButton=(e.button==1);}
else if(e.target==null&&e.srcElement!=null)
{e.target=e.srcElement;e.leftButton=(e.button==0);}
else if(e.srcElement!=null&&e.target!=null)
{}
else{return null}
if(document.body&&document.documentElement)
{e.mouseX=e.pageX||(e.clientX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));e.mouseY=e.pageY||(e.clientY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));}
else
{e.mouseX=-1;e.mouseY=-1;}
return e;},stopEvent:function(e)
{if(e&&e.cancelBubble!=null)
{e.cancelBubble=true;e.returnValue=false;}
if(e&&e.stopPropagation&&e.preventDefault)
{e.stopPropagation();e.preventDefault();}
return false;}};ycn.EventCache=function()
{var listEvents=[];return{listEvents:listEvents,add:function(node,sEventName,fHandler,bCapture){listEvents[listEvents.length]=arguments;},flush:function(){var i,item;for(i=listEvents.length-1;i>=0;i=i-1)
{item=listEvents[i];if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);};if(item[1].substring(0,2)!="on"){item[1]="on"+item[1];};if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);};item[0][item[1]]=null;};}};}();ycn.Event.addEvent(window,"unload",ycn.EventCache.flush);function error_handler(a,b,c)
{window.status=(c+"\n"+b+"\n\n"+a+"\n\n"+error_handler.caller);return true;}


<三>
var pa_m={wait_timer:null,pa_cur_con:null,pa_cur_pre:null,pa_con_height:80,is_in_anim:false};

function init_pa_tabs(is_login){
var pa=ycn.Common.getEl('pabd');
var patabs1=ycn.Common.getEl('patabs1');
var patabs2=ycn.Common.getEl('patabs2');
var patabs3=ycn.Common.getEl('patabs3');
var patabs4=ycn.Common.getEl('patabs4');

if(!pa||!patabs1||!patabs2||!patabs3||!patabs4)return;
var prediv=new Array;
prediv[0]=ycn.Common.getElByClassName('div','publ2',1,pa);
prediv[1]=ycn.Common.getElByClassName('div','publ2',2,pa);
prediv[2]=ycn.Common.getElByClassName('div','publ2',3,pa);
prediv[3]=ycn.Common.getElByClassName('div','publ2',4,pa);

if(!prediv[0]||!prediv[1]||!prediv[2]||!prediv[3]){return;}
var tabs1=patabs1.getElementsByTagName('a');
var tabs2=patabs2.getElementsByTagName('a');
var tabs3=patabs3.getElementsByTagName('a');
var tabs4=patabs4.getElementsByTagName('a');

for(var i=0;i<tabs1.length;i++)
{
ycn.Event.addEvent(tabs1[i],'mouseover',do_wait_open);
}
for(var i=0;i<tabs2.length;i++)
{
ycn.Event.addEvent(tabs2[i],'mouseover',do_wait_open);
}
for(var i=0;i<tabs3.length;i++)
{
ycn.Event.addEvent(tabs3[i],'mouseover',do_wait_open);
}
for(var i=0;i<tabs4.length;i++)
{
ycn.Event.addEvent(tabs4[i],'mouseover',do_wait_open);
}


ycn.Event.addEvent(pa,'mouseout',close_pa_preview);
ycn.Event.addEvent(pa,'mouseover',keep_pa_preview);
// ycn.Event.addEvent(prediv[0],'mouseover',keep_pre_con);
// ycn.Event.addEvent(prediv[1],'mouseover',keep_pre_con);
// if(ycn.Common.getEl('patop'))
// {
// ycn.Event.addEvent(ycn.Common.getEl('patop'),'mouseover',function(){if(pa_m.wait_timer){clearTimeout(pa_m.wait_timer);}});
// }
}

function do_wait_open(e)
{
if(ycn.Common.isIE()){var el=window.event.srcElement;}else{var el=this;}

while(el.tagName.toLowerCase()!='a'&&el.tagName.toLowerCase()!='body')
{
el=el.parentNode;
}

if(el.tagName.toLowerCase()!='a'){return;}
// el=el.getElementsByTagName('a')[0];
if(pa_m.wait_timer){window.clearTimeout(pa_m.wait_timer);}
pa_m.wait_timer=window.setTimeout(function(){disp_pa_preview(el);},800);
}


function disp_pa_preview(el){
var p=el.parentNode;
while(p.tagName.toLowerCase()!='div'&&p.tagName.toLowerCase()!='body'){p=p.parentNode;}
if(p.tagName.toLowerCase()!='div'){return;}
var con=ycn.Common.getEl(p.id+"previewdiv");if(!con){return;}

if(pa_m.pa_cur_pre!=null){
var o_id = ycn.Common.getEl(pa_m.pa_cur_pre);

var s = o_id.className.replace("0","");
o_id.className = s;
}
pa_m.pa_cur_pre=el.id;

el.className = "hq0"+el.className.substring(2);

if(pa_m.pa_cur_con!=null&&pa_m.pa_cur_con!=con)
{
con.innerHTML='';
var o_con=pa_m.pa_cur_con;
var o_tabs=ycn.Common.getEl(o_con.id.replace("previewdiv",""));
o_tabs.className="publ";

o_con.innerHTML='';

var m=(o_con.offsetHeight)?o_con.offsetHeight:pa_m.pa_con_height;
o_con.style.visibility="hidden";
o_con.style.overflow="hidden";
var close_con=function()
{
m-=30;
if(m<=0)
{
o_con.style.height=0;
o_con.style.display="none";
window.clearInterval(tt_1)
}else
{
o_con.style.height=m+"px";
}
}
var tt_1=window.setInterval(close_con,10);
}

var class_name="publ1";

var n=(con.offsetHeight)?con.offsetHeight:0;
pa_m.is_in_anim=true;
pa_m.pa_cur_con=con;
con.style.visibility="visible";
con.style.display="block";
con.style.overflow="hidden";
con.className="publ2";
if(el.parentNode.className!=class_name)
{
el.parentNode.className=class_name;
}
var open_con=function()
{
n+=30;
if(n>=pa_m.pa_con_height){
// con.style.height=pa_m.pa_con_height+"px";
con.style.height="";
con.style.overflow="visible";
pa_m.is_in_anim=false;
pa_preview_cont(con,el.id);
window.clearInterval(tt_0);
}else{
con.style.height=n+"px";
}
}
var tt_0=window.setInterval(open_con,10);
}

function pa_preview_cont(pa,id)
{
var con = ycn.Common.getEl(id+"_con");
pa.innerHTML = con.innerHTML;

}


function close_pa_preview(e){
pa_m.is_in_pa=false;
if(pa_m.wait_timer){window.clearTimeout(pa_m.wait_timer);}
pa_m.wait_close_timer=window.setTimeout(function(){do_close_pa(e)},4000);
ycn.Event.stopEvent(ycn.Event.getEvent(e));
}

function do_close_pa(e){
if(pa_m.is_in_anim){return;}
pa_m.is_in_anim=true;
var o_con=pa_m.pa_cur_con;
if(!o_con)
{
pa_m.is_in_anim=false;
return;
}
if(ycn.Common.getEl(o_con.id.replace("previewdiv","")))
{
var o_tabs=ycn.Common.getEl(o_con.id.replace("previewdiv",""));
o_tabs.className="publ";
var o_id = ycn.Common.getEl(pa_m.pa_cur_pre);
var s = o_id.className.replace("0","");
o_id.className = s;
}
var m=(o_con.offsetHeight)?o_con.offsetHeight:pa_m.pa_con_height;
o_con.innerHTML='';
o_con.style.visibility="hidden";
o_con.style.overflow="hidden";
var close_con=function()
{
m-=30;
if(m<=0)
{
o_con.style.height=0;
o_con.style.display="none";
pa_m.is_in_anim=false;
pa_m.pa_cur_con=null;
pa_m.pa_cur_pre=null;
window.clearInterval(pa_m.close_timer);
}
else
{
o_con.style.height=m+"px";
}
}
pa_m.close_timer=window.setInterval(close_con,1);
}

function keep_pa_preview(e)
{
pa_m.is_in_pa=true;
if(pa_m.wait_close_timer!=null)
{
window.clearTimeout(pa_m.wait_close_timer);
}
ycn.Event.stopEvent(ycn.Event.getEvent(e));
}

搜索更多相关主题的帖子: function return document ycn 
2007-09-07 16:46
thllilac
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-9-7
收藏
得分:0 
真不会发贴

曾经有一个女孩问我:“你长的帅不帅?”我说:“不帅。”她打了我一巴掌,生气的说:“你骗人!”
2007-09-10 13:35
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
收藏
得分:0 
估计不会等到答案的。。。。
2007-09-10 13:47
快速回复:请教js的三个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059545 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved