일반 JS 코드 수집

1342 단어 functionurl
// JavaScript Document
Utility = {
	getReqId: function(url){
		var str = "req_id=";
		var idx = url.indexOf(str);
		var reqid = url.slice(idx + str.length);
		var re = /[a-zA-Z0-9]+/;
		return reqid.match(re);
	},
	toDateString: function(C) {  
		if (!this._dateFormater) {   
			this._dateFormater = new Date();  
		}
		this._dateFormater.setTime(C * 1000);
		var _ = this._dateFormater.getMonth() + 1,  D = this._dateFormater.getDate(),  A = this._dateFormater.getHours(),  B = this._dateFormater.getMinutes();
		return this._dateFormater.getFullYear() + "-" + (String(_).length < 2 ? "0" + _: _) + "-" + (String(D).length < 2 ? "0" + D: D) + " " + (String(A).length < 2 ? "0" + A: A) + ":" + (String(B).length < 2 ? "0" + B: B);
	}, 
	dateDiff: function(B, A) {
		var _ = 24 * 60 * 60 * 1000,  C = B + _ * 10 - parseInt(A);
		return Math.max((C / _).toFixed(0), 0);
	},
	encodeHTML: function(_) {
		return String(_).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
	}
}

좋은 웹페이지 즐겨찾기