base.js

var GLOBAL={};
GLOBAL.namespace=function(str){
  var arr=str.split("."),o=GLOBAL;
  for (i=(arr[0]=="GLOBAL"?1:0);i<arr.length;i++){
o[arr[i]]=o[arr[i]] || {};
o=o[arr[i]];
  }
}


//DOM相关
GLOBAL.namespace("Dom");
GLOBAL.Dom.getNextNode=function(node){
  node=typeof node=="string"?document.getElementById(node):node;
  var nextNode=node.nextSibling;
  if(!nextNode) return null;
  if(!document.all){
    while(true){
 if(nextNode.nodeType==1) break;
 else{
   if(nextNode.nextSibling) nextNode=nextNode.nextSibling;
else break;
 }
}
  }
  return nextNode;
};


GLOBAL.Dom.setOpacity=function(node,level){
  node=typeof node=="string"?document.getElementById(node):node;
  if(document.all)  node.type.filter="alpha(opacity="+level+")";
  else node.type.opacity=level/100;
}


GLOBAL.Dom.get=function(node){
  node=typeof node=="string"?document.getElementById(node):node;
  return node;
}


GLOBAL.Dom.getElementsByClassName=function(str,root,tag){
  if(root) 
 root=typeof root=="string"?document.getElementById(root):root;
  else
 root=document.body;
  tag=tag||"*";
  var els=root.getElementsByTagName(tag);
  var arr=[];
  for(i=0;i<els.length;i++){
    for(j=0,k=els[i].className.split(" "),l=k.length;j<l;j++){
 if(str==k[j])
 arr.push(els[j]);
 break;
}
  }
  return arr;
}


//Event相关
GLOBAL.namespace("Event");
GLOBAL.Event.getEventTarget=function(e){
  e=window.event||e;
  return e.srcEvent||e.target;
}


GLOBAL.Event.stopPropagation=function(e){
  e=window.event||e;
  if(document.all)
 e.cancelBubble=true;
  else
 e.stopPropagation();
}


GLOBAL.event.on=function(node,eventType,handler){
  node=typeof node=="string"?document.getElementById(node):node;
  if(document.all)
    node.attachEvent("on"+eventType,handler);
  else
 node.addEventListener(eventType,handler,false);
}


//Lang相关
GLOBAL.namespace("Lang");
GLOBAL.Lang.trim=function(str){
  return str.replace(/^\s+|\s+$/g,"");
}


GLOBAL.Lang.isNumber=function(s){
  return !isNaN(s);
}


GLOBAL.Lang.extend=function(subClass,superClass){
  var F=function(){};
  F.prototype=superClass.prototype;
  subClass.prototype=new F();
  subClass.prototype.constructor=subClass;
  subClass.superclass=superClass.prototype;
  if(superClass.prototype.constructor==Object.prototype.constructor){
    superClass.prototype.constructor=superClass;
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值