/**************************************************************************
* HTML요소 어트리뷰트(프로퍼티,이벤트) 등록
**************************************************************************/
class ObjectInspector {
	
	static help(){
		console.log("regist(doctx명, 어트리뷰트정보) : HTML요소에 어트리뷰트(프로퍼티,이벤트) 등록");
	}
	
	static regist(doctx, data){
		let objectInspector = {};
			
		if(data == null){
			objectInspector = JSON.parse(document.querySelector("[data-doctx='"+doctx+"']").querySelector("script.objectInspector").text);
		} else if(data instanceof HTMLScriptElement){
			objectInspector = JSON.parse(data.text);
		} else if(typeof data == "string"){
			let curlyBracketsOpen = String.fromCharCode(123); //중괄호시작
			if(!data.trim().startsWith(curlyBracketsOpen)){
				objectInspector = JSON.parse(document.querySelector("script[id='"+data+"'").text);
			} else {
				objectInspector = JSON.parse(data);
			}
		} else {
			objectInspector = data;
		}
		
		let keys = Object.keys(objectInspector);
		for(let key of keys){
			let elem = document.querySelector("[data-doctx='"+doctx+"'] [name='"+key+"']");
			let attrs = objectInspector[key];
			let attrNames = Object.keys(attrs);
			for(let attrName of attrNames){
				elem.setAttribute(attrName,attrs[attrName]);
			}
		}
	}
}