all files / dist/ xAssist-main.js

100% Statements 29/29
65% Branches 13/20
100% Functions 9/9
100% Lines 29/29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                                                            11×                  
/**
* @preserve
* https://github.com/GregBee2/xassist-main#readme Version 1.0.4.
*  Copyright 2018 Gregory Beirens.
*  Created on Mon, 30 Jul 2018 09:59:16 GMT.
*/
(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
	typeof define === 'function' && define.amd ? define(['exports'], factory) :
	(factory((global.xa = global.xa || {})));
}(this, (function (exports) { 'use strict';
 
var idSeed=Math.round(Math.random()*(1000000)),
	DOMContentLoadedEvent,
	readyCallBacks=[],
	isReady=false;
document.addEventListener( "DOMContentLoaded", readyHandler,{once:true});
function readyHandler(){
	//save event information
	DOMContentLoadedEvent=arguments[0];
	readyCallBacks.forEach(function(cb){
		cb[0].call(cb[1],DOMContentLoadedEvent);
	});
	//empty readyCallBacks
	readyCallBacks=[];
	isReady=true;
}
function id(prefix){
	//creates unique ID based on 
	return ((!arguments.length?'':prefix+'_')+idSeed++);
	
}
function ready(callBack,thisArg){
	//thisArg refers to this inside callback
	if(!thisArg){
		thisArg=document;
	}
	//check if document state is complete
	if (isReady){
		callBack.call(thisArg,DOMContentLoadedEvent);
	}
	else{
		//add to executionList;
		readyCallBacks.push([callBack,thisArg]);
	}
	
}
function template(text,obj,notfoundText){
	notfoundText=(notfoundText?notfoundText:"");
	return text.replace(/\${([^}]*)}/g,function(match,p1){
		
		return p1.split(".").reduce(function(obj,prop){
			if(obj.hasOwnProperty(prop)){
				return obj[prop];
			}
			return notfoundText;
		},obj);
	});
}
 
exports.id = id;
exports.ready = ready;
exports.template = template;
 
Object.defineProperty(exports, '__esModule', { value: true });
 
})));