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

📄 util.js

📁 新技术论坛系统 v1.0 前后台管理的初始用户名 : admin 密码 123456
💻 JS
字号:
/*
 * Copyright (C) 2002-2005 
 * 
 * For further information visit:  http://www.ntsky.com
 * 
 * File Name: util.js
 * 	This is the integration file for JavaScript.
 * 
 * 	It defines classes : 
 *  1、HTTP.class
 *  2、ErrorMonitor.class
 * 
 * Version:  1.0
 * Modified: 2005-02-27 19:04:39
 * 
 * File Authors: ntsky (yntsky@gmail.com)
 */


//============= Common's Begin ===============//
var Browser = {
	ie : navigator.appName == "Microsoft Internet Explorer",
	ns : navigator.appName == "Netscape"
};

/*
if((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ) && (navigator.platform == "Win32") && (navigator.userAgent.indexOf(" Opera ") == -1) && (navigator.userAgent.indexOf("Opera/") == -1)){
	if ((navigator.appVersion.indexOf('MSIE 6')) != -1 || (navigator.appVersion.indexOf('MSIE 7')) != -1){
	document.write('<link rel="stylesheet" media="screen" href="//www.ibm.com/common/v14/cn/zh/ie2_screen.css" type="text/css"/>');
	}
	else{
	document.write('<link rel="stylesheet" media="screen" href="//www.ibm.com/common/v14/cn/zh/ie1_screen.css" type="text/css"/>');
	}
}*/


//============= Common's Begin ===============//


//============= HTTP's Begin ===============//
/**
 * HTTP.class
 */
var HTTP = function() {
	this.Cookie = null;  
	this.Request = null;
}

/**
 * Write a cookie value
 * 
 * @name	cookie's name
 * @value	cookie's value
 * @expires	the life of the cookie exist
 * @path	the path of the cookie save
 * @domain	cookie's domain
 * @secure	ture ? false
 */
HTTP.prototype.setCookie = function(name, value, expires, path, domain, secure) {
	var expiresDate = null;
	if (expires) {
		// Netscape -- "GMT" 、IE -- "UTC"
		if (expires.toGMTString) {
			expiresDate = expires;
		}
		else
			if (typeof(expires) == "number") {
				expiresDate = new Date();
				expiresDate.setTime(expiresDate.getTime() + 1000 * parseInt(expires));
			}
	}
	this.Cookie = name + '=' + escape(value) + ((expiresDate) ? '; expires=' + expiresDate.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
	//document.write(document.cookie);
	document.writeln(this.Cookie);
}

/**
 * get a Cookie value by name
 * 
 * @name	cookie's name
 * @return	cookie's value	
 */
HTTP.prototype.getCookie = function(name) {
	var dc = document.cookie;
	// find beginning of cookie value in document.cookie
	// Note: cookie with more specific path comes first!
	var prefix = name + "=";
	var begin = dc.indexOf(prefix);
	if (begin == -1) {
		return null;
	}
	else if (begin > 0) {
		begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			return null;
		}
		else {
			begin += 2;
		}		
	}
	// find end of cookie value
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	// return cookie value
	return unescape(dc.substring(begin + prefix.length, end));
}

// delete cookie 
HTTP.prototype.deleteCookie = function(name, path, domain) {
	var value = this.getCookie(name);
	if (value != null)
		document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
	return value;
}
//============= HTTP's END ===============//


//============= ErrorMonitor's Begin ===============//
/**
 * ErrorMonitor.class
 */
var ErrorMonitor = {
	// static method "output".This method can output the exception message of the javascript.
	output : function(error,method){
		error.getExInfo(method);
	}
};
/*
 * AlertError.class 
 * @msg		the message of alert
 */
var AlertError = function(msg) {
	this.message = msg;
};
/*
 * AlertError.class 
 * @msg		the message of print
 */
var WriterError = function(msg) {
	this.message = msg;
};

AlertError.prototype = new Error();
WriterError.prototype = new Error();
AlertError.prototype.constructor = AlertError;
WriterError.prototype.constructor = WriterError;

Error.prototype.outInfo = function(method,type){
	if(method==null){
		if("outText" == type){
			document.write(this.message);
		}
		else{
			alert(this.message);
		}
	}
	else{
		if("outText" == type){
			document.write(method + " : " + this.message);
		}
		else{
			alert(method + " : " + this.message);
		}
	}	
}

Error.prototype.getExInfo = function(method){
	var errorMsg = this.message;
	/*switch(this.name) {
		case "EvalError" : 
			errorMsg = "eval()的使用与定义不一致"; 
			break;
		case "RangeError" :
			errorMsg = "数值越界"; 
			break;
		case "ReferenceError" :
			errorMsg = "非法或不能识别的引用数值"; 
			break;
		case "SyntaxError" :
			errorMsg = "发生语法解析错误"; 
			break;
		case "TypeError" :
			errorMsg = "操作数类型错误"; 
			break;
		case "URIError" :
			errorMsg = "URI处理函数使用不当"; 
			break;
		default : 
			errorMsg = "未知JavaScript错误"; 
			break;
	}*/
	if(this instanceof AlertError){
		this.outInfo(method);
	}
	if(this instanceof WriterError){		
		this.outInfo(method,"outText");
	}
	else{
		//this.outInfo(method);	
		alert(method + " : " + errorMsg);
	}
};
//============= ErrorMonitor's END ===============//

⌨️ 快捷键说明

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