⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sunrise_library.js

📁 java的搜索引擎的创建与索引工具
💻 JS
📖 第 1 页 / 共 2 页
字号:
                return true;
            };
            
            return SunRise.Dom.batch(el, f, SunRise.Dom, true);
        },
        removeClass: function(el, className) {
            var re = getClassRegEx(className);
            
            var f = function(el) {
                if (!className || !this.hasClass(el, className)) {
                    return false; // not present
                }   
                var c = el.className;
                el.className = c.replace(re, ' ');
                if ( this.hasClass(el, className) ) { // in case of multiple adjacent
                    this.removeClass(el, className);
                }

                el.className = SunRise.lang.trim(el.className); // remove any trailing spaces
                return true;
            };
            
            return SunRise.Dom.batch(el, f, SunRise.Dom, true);
        }, 
        replaceClass: function(el, oldClassName, newClassName) {
            if (!newClassName || oldClassName === newClassName) { // avoid infinite loop
                return false;
            }
            
            var re = getClassRegEx(oldClassName);
			
            var f = function(el) {
            
                if ( !this.hasClass(el, oldClassName) ) {
                    this.addClass(el, newClassName); // just add it if nothing to replace
                    return true; // NOTE: return
                }
            
                el.className = el.className.replace(re, ' ' + newClassName + ' ');

                if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
                    this.replaceClass(el, oldClassName, newClassName);
                }

                el.className = SunRise.lang.trim(el.className); // remove any trailing spaces
                return true;
            };
            
            return SunRise.Dom.batch(el, f, SunRise.Dom, true);
        },        
       
        batch: function(el, method, o, override) {
            el = (el && (el.tagName || el.item)) ? el : SunRise.Dom.get(el); // skip get() when possible

            if (!el || !method) {
                return false;
            } 
            var scope = (override) ? o : window;
            
            if (el.tagName || el.length === undefined) { // element or not array-like 
                return method.call(scope, el, o);
            } 

            var collection = [];
            
            for (var i = 0, len = el.length; i < len; ++i) {
                collection[collection.length] = method.call(scope, el[i], o);
            }
            
            return collection;
        },
        getDocumentHeight: function() {
            var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;

            var h = Math.max(scrollHeight, SunRise.Dom.getViewportHeight());
            return h;
        },   
        getDocumentWidth: function() {
            var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
            var w = Math.max(scrollWidth, SunRise.Dom.getViewportWidth());
            return w;
        },        
        getViewportHeight: function() {
            var height = self.innerHeight; // Safari, Opera
            var mode = document.compatMode;        
            if ( (mode || isIE) && !isOpera ) { // IE, Gecko
                height = (mode == 'CSS1Compat') ?
                        document.documentElement.clientHeight : // Standards
                        document.body.clientHeight; // Quirks
            }
        
            return height;
        },   
        getViewportWidth: function() {
            var width = self.innerWidth;  // Safari
            var mode = document.compatMode;
            
            if (mode || isIE) { // IE, Gecko, Opera
                width = (mode == 'CSS1Compat') ?
                        document.documentElement.clientWidth : // Standards
                        document.body.clientWidth; // Quirks
            }
            return width;
        }
    };
    
    var getXY = function() {
        if (document.documentElement.getBoundingClientRect) { // IE
            return function(el) {
                var box = el.getBoundingClientRect();

                var rootNode = el.ownerDocument;
                return [box.left + SunRise.Dom.getDocumentScrollLeft(rootNode), box.top +
                        SunRise.Dom.getDocumentScrollTop(rootNode)];
            };
        } else {
            return function(el) { // manually calculate by crawling up offsetParents
                var pos = [el.offsetLeft, el.offsetTop];
                var parentNode = el.offsetParent;

                // safari: subtract body offsets if el is abs (or any offsetParent), unless body is offsetParent
                var accountForBody = (isSafari &&
                        SunRise.Dom.getStyle(el, 'position') == 'absolute' &&
                        el.offsetParent == el.ownerDocument.body);

                if (parentNode != el) {
                    while (parentNode) {
                        pos[0] += parentNode.offsetLeft;
                        pos[1] += parentNode.offsetTop;
                        if (!accountForBody && isSafari && 
                                SunRise.Dom.getStyle(parentNode,'position') == 'absolute' ) { 
                            accountForBody = true;
                        }
                        parentNode = parentNode.offsetParent;
                    }
                }

                if (accountForBody) { //safari doubles in this case
                    pos[0] -= el.ownerDocument.body.offsetLeft;
                    pos[1] -= el.ownerDocument.body.offsetTop;
                } 
                parentNode = el.parentNode;

                // account for any scrolled ancestors
                while ( parentNode.tagName && !patterns.ROOT_TAG.test(parentNode.tagName) ) 
                {
                    if (parentNode.scrollTop || parentNode.scrollLeft) {
                        // work around opera inline/table scrollLeft/Top bug (false reports offset as scroll)
                        if (!patterns.OP_SCROLL.test(SunRise.Dom.getStyle(parentNode, 'display'))) { 
                            if (!isOpera || SunRise.Dom.getStyle(parentNode, 'overflow') !== 'visible') { // opera inline-block misreports when visible
                                pos[0] -= parentNode.scrollLeft;
                                pos[1] -= parentNode.scrollTop;
                            }
                        }
                    }
                    
                    parentNode = parentNode.parentNode; 
                }

                return pos;
            };
		
		}
	}	
})();
/*=========================================20081218 添加:SunRise_AJAX.js====================================*/
(function(){
	
	SunRise.Ajax = function(config){
		this.URL = config.URL;
		this.method = config.method || "GET" ;
		this.header = config.header || "GET" ;
		this.beforeRequest = config.beforeRequest || null ; 
		this.isAsynchronism = config.isAsynchronism || true;
	}
	
	
	SunRise.Ajax.prototype = {	
		
		send : function(callback){
			var xmlhttp = createAjaxRequestObject();
			var data = (callback && callback.postData)?callback.postData:null;
			var url = this.URL;
			xmlhttp.onreadystatechange = function(){callback.success(xmlhttp)};
			xmlhttp.open(this.method,url,this.isAsynchronism);
			xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"); 
			//xmlhttp.send(encodeURIComponent(data));
			xmlhttp.send(data);
		}
	}
	
	 function createAjaxRequestObject(){
		var o;
		if(SunRise.ua.ie == 0){
			o = new XMLHttpRequest();
		}else{
			o = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return o;
	}
	
})();
/*=========================================20081218 添加:SunRise_Validate.js====================================*/
(function(){
	SunRise.Validate = function(){
		
	}
	
	SunRise.Validate.prototype = {
		//判断是否是数字
		isNumber : function(n){
			var r = /[^0-9]/;
			return !r.test(n);
		},
		//判断是否是移动手机号码
		isMobile : function(m){
			var pattern = /^1(34|35|36|37|38|39|50|51|57|58|59|88)[0-9]{8}$/;
			var result = pattern.exec(m);
			if(result==null){
				return false;
			}
			return true;
		},
		//判断是否是联通手机号码
		isChinaUnicom : function(m){
			var pattern = /^1(30|31|32|33)[0-9]{8}$/;
			var result = pattern.exec(m);
			if(result != null){
				return true;
			}else{
				return false;
			}
		},
		//判断是字母或者文字
		isLetterAndNumber : function(n){
			var r = /[^a-zA-Z0-9]/;
			return !r.test(n);
		},
		//判断是否已字母开始
		isStartLetter : function(n){
			var r = /^[a-zA-Z]/;
			return r.test(n);
		},
		//验证邮箱地址
		isEmail : function(n){
			var r = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
			return r.test(n);
		},
        //验证电话号码
        isPhone:function(n){
		    var r = /^(\(\d+\))*(\d)+(-(\d)+)*$/;
		    return r.test(n);
        },
        //验证资金数目
		  isFund:function(n){
			  var r=new RegExp(/^[\-\+]?([0-9]\d*|0|[1-9]\d{0,2}(,\d{3})*)(\.\d+)?$/); 
			  return r.test(n); 
		 },
		  //验证身份证号
 		  isIdentityCard:function(n){
			 var r=new RegExp(/^([\d]{15}|[\d]{18}|[\d]{17}[x|X])$/); 
			 return r.test(n); 
		  }, 
		  //验证邮编
		 isPostcode:function(n){
				var r=new RegExp(/^(\d){6}$/); 
				return r.test(n); 
		 },
		 //字符长度判断	
	     isLength:function(s,n){
	        var len = s.length;
	        return len!=n;
	     },
	     //弱密码判断
	     isWeak:function(s){
	        var rpassward = "000000&111111&222222&333333&444444&555555&666666&777777&888888&999999"
		        +"&012345&123456&234567&345678&456789&567890&543210&654321&765432&876543&987654&098765"
		        +"&00000000&11111111&22222222&33333333&44444444&55555555&66666666&77777777&88888888&99999999"
		        +"&01234567&12345678&23456789&34567890&76543210&87654321&98765432&09876543"; 
	        return rpassward.indexOf(s)!=-1;
	     }
	     


	}
}
)();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -