{"size": 3608, "ext": "js", "max_stars_repo_path": "public/js/Dom.js", "max_stars_repo_name": "Albert-Lin/Semantic_Lab", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/Dom.js", "max_issues_repo_name": "Albert-Lin/Semantic_Lab", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/Dom.js", "max_forks_repo_name": "Albert-Lin/Semantic_Lab", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.3333333333, "max_line_length": 87, "alphanum_fraction": 0.5532150776}
/**
 * Created by AlbertLin on 2017/3/16.
 */

(function(){
	// Ψ: `U03A8
	// window.Ψ = function(selector, context){
	// 	let result = undefined;
	// 	let selectorArray = selector.replace(/ /g, '').split('>');
	// 	let singleDom = function(selector, context){
	// 		let result = undefined;
	// 		if(selector.indexOf('#') === 0){
	// 			let id = context.getElementById(selector.replace(/#/g, ''));
	// 			if(id === null || id === undefined){
	// 				console.warn('Ψ Error: There is no id named: '+selector.replace(/#/g, ''));
	// 			}
	// 			else{
	// 				result = id;
	// 			}
	// 		}
	// 		else if(selector.indexOf('.') === 0){
	// 			let classes = context.getElementsByClassName(selector.replace(/\./g, ''));
	// 			if(classes === null || classes === undefined){
	// 				console.warn('Ψ Error: There is no class named: '+selector.replace(/\./g, ''));
	// 			}
	// 			else{
	// 				result = classes;
	// 			}
	// 		}
	// 		else{
	// 			let tags = context.getElementsByTagName(selector);
	// 			if(tags === null || tags === undefined){
	// 				console.warn('Ψ Error: There is no tag named: '+selector);
	// 			}
	// 			else{
	// 				result = tags;
	// 			}
	// 		}
	//
	// 		return result;
	// 	};
	//
	// 	selector = selector.replace(/ /g, '');
	// 	if(typeof context === 'undefined'){
	// 		context = document;
	// 	}
	// 	if(selectorArray.length > 1){
	// 		context = singleDom(selectorArray[0], context);
	// 		if(context !== null || context !== undefined){
	// 			console.log(selector);
	// 			console.log(selectorArray[0]);
	// 			console.log(selector.replace(selectorArray[0]+'>', ''));
	// 			console.log("==============================");
	// 			result = Ψ(selector.replace(selectorArray[0]+'>', ''), context);
	// 		}
	// 	}
	// 	else{
	// 		result = singleDom(selector, context);
	// 	}
	//
	// 	return result;
	// }

	window.Ψ = function(selector, context){
		let result = [];
		let selectorString = selector.replace(/ /g, '');
		let selectorArray = selectorString.split('>');
		let domSelect = function(selector, context){
			let result = [];

			if(selector.indexOf('#') === 0){
				let idEl = context.getElementById(selector.replace(/#/g, ''));
				if(idEl !== null && idEl !== undefined){
					result = idEl;
				}
			}
			else if(selector.indexOf('.') === 0){
				let classEl = context.getElementsByClassName(selector.replace(/\./g, ''));
				if(classEl !== null && classEl !== undefined){
					result = classEl;
				}
			}
			else{
				let tagEl = context.getElementsByTagName(selector);
				if(tagEl !== null && tagEl !== undefined){
					result = tagEl;
				}
			}

			return result;
		};

		if(typeof context === 'undefined'){
			context = document;
		}

		if(selectorArray.length > 1){
			let subContext = domSelect(selectorArray[0], context);
			let subSelector = selectorString.replace(selectorArray[0]+'>', '');
			if(Array.isArray(subContext) === true || subContext.length > 0){
				for(let i = 0; i < subContext.length; i++){
					let subResult = Ψ(subSelector, subContext[i]);
					for(let j = 0; j < subResult.length; j++){
						result.push(subResult[j]);
					}
				}
			}
			else{
				let subResult = Ψ(subSelector, subContext[i]);
				for(let j = 0; j < subResult.length; j++){
					result.push(subResult[j]);
				}
			}
		}
		else{
			if(Array.isArray(context) === true || context.length > 0){
				for(let i = 0; i < context.length; i++){
					let subResult = Ψ(selector, context[i]);
					for(let j = 0; j < subResult.length; j++){
						result.push(subResult[j]);
					}
				}
			}
			else{
				result = domSelect(selector, context);
			}
		}

		return result;
	};

})();