js 로 컬 추가 방법
                                            
 5528 단어  js
                    
/**
 * @author wsf
 */
/**
 *        val  
 */
if (!Object.prototype.val) {
	Object.prototype.val = function() {
		return this.valueOf();
	}
}
/**
 *           
 */
if (!Object.prototype.isNumber) {
	String.prototype.isNumber = function() {
		return !this || isNuN(this.val()) ? false : ( typeof this.val() === "number");
	}
}
/**
 *      remove  
 */
if (!Array.prototype.remove) {
	Array.prototype.remove = function(s) {
		for (var i = this.length; i >= 0; i--) {
			if (s === this[i])
				this.splice(i, 1);
		}
	}
}
/**
 *          apply       json  
 */
if (!Object.prototype.applyAll) {
	Object.prototype.applyAll = function(callback) {
		if (!this)
			return;
		var idx = 0;
		if (this.remove && this[0]) {
			//  
			for (var o = this[0]; idx < this.length && callback.call(o, idx, o) != false; o = this[++idx]) {
			}
		} else {
			//  
			for (var i in this) {
				if (callback.call(this[i], i, this[i]) === false)
					break;
			}
		}
	}
}
/**
 *      indexOf  
 */
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(o) {
		for (var i = this.length; i >= 0; i--) {
			if (this[i] === o)
				return i;
		}
		return -1;
	}
}
/**
 *      contain  
 */
if (!Array.prototype.contain) {
	Array.prototype.contain = function(o) {
		var validx = this.indexOf(o)//    
		return validx > 0;
	}
}
/**
 *      put  (          )
 */
if (!Array.prototype.put) {
	Array.prototype.put = function(o, idx) {
		return this.splice(idx, 0, o);
	}
}
/**
 *        intVal  
 */
if (!String.prototype.intVal) {
	String.prototype.intVal = function() {
		return parseInt(this);
	}
}
/**
 *        doubleVal  
 */
if(!String.prototype.doubleVal){
	String.prototype.doubleVal = function (){
		return parseDouble(this);
	}
}
/**
 * id        
 */
function selc(s) {
	if (s.indexOf("#") > 0)
		return document.getElementById(s.replace("#", ""));
	else if (s.indexOf(".") > 0) {
		var result = [];
		var a = selector.split(".");
		var prefix = a[0] || "*";
		//  
		var suffix = a[1];
		//  
		var docs = document.getElementsByTagName(prefix);
		docs.applyAll(function() {
			if (this.nodeType === 1 && this.id) {
				var classNames = this.className.split(/\s+/g);
				//    
				var finded = this;
				classNames.applyAll(function() {
					if (this === suffix)
						result.push(finded);
				});
			}
		});
		return result;
		//      
	}
}
/**
 * ajax  
 * @param {} options
 */
function ajax(options) {
	var httpRequest = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	httpRequest.onreadystatechange = function() {
		var dataType = options.dataType.toLowerCase();
		httpRequest.readyState === 4 && httpRequest.status === 200 && options.callback(dataType === "json" ? eval("(" + httpRequest.responseText + ")") : dataType === "xml" ? httpRequest.responseXML : httpRequest.responseText, options.context);
	};
	httpRequest.open(options.mode, options.url, options.sync);
	if (options.mode.toLowerCase() === "post") {
		httpRequest.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded;charset=utf-8");
	}
	options.mode.toLowerCase() === "get" ? httpRequest.send(null) : httpRequest.send(options.params);
}
/**
 * Map  
 */
var Map = function() {
	this.flag = false;
	this.store = new Array();
	if (!this.flag) {
		Map.prototype.entry = function(key, val) {
			this.key = key;
			this.val = val;
		}
		Map.prototype.put = function(key, val) {
			this.store[this.store.length] = new this.entry(key, val);
		}
		Map.prototype.get = function(key) {
			for (var i = this.store.length - 1; i >= 0; i--) {
				if (this.store[i].key === key)
					return this.store[i].val;
			}
			return null;
		}
		Map.prototype.remove = function(key) {
			for (var i = this.store.length - 1; i >= 0; i--) {
				this.store[i].key === key && this.store.splice(i, 1);
			}
		}
		Map.prototype.keySet = function() {
			var keys = new Array();
			for (var i = 0; i <= this.store.length - 1; i++) {
				keys.push(this.store[i].key);
			}
			return keys;
		}
		Map.prototype.valSet = function() {
			var vals = new Array();
			for (var i = 0; i <= this.store.length - 1; i++) {
				vals.push(this.store[i].val);
			}
			return vals;
		}
		Map.prototype.clear = function() {
			this.store.length = 0;
		}
		Map.prototype.size = function() {
			return this.store.length;
		}
		this.flag = true;
	}
}이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[2022.04.19] 자바스크립트 this - 생성자 함수와 이벤트리스너에서의 this18일에 this에 대해 공부하면서 적었던 일반적인 함수나 객체에서의 this가 아닌 오늘은 이벤트리스너와 생성자 함수 안에서의 this를 살펴보기로 했다. new 키워드를 붙여 함수를 생성자로 사용할 때 this는...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.