-
Notifications
You must be signed in to change notification settings - Fork 4
/
vanilla-ck.js
1 lines (1 loc) · 1.35 KB
/
vanilla-ck.js
1
var nilla=function(){var a={};a.attrs=function(a,b){for(var c in b)c==="html"?a.innerHTML=b[c]:a.setAttribute(c,b[c]);return a};a.bind=function(b,c,d){typeof b=="string"&&(b=a.find(b));a.each(b,function(a){a.addEventListener?a.addEventListener(c,d,!1):a.attachEvent("on"+c,d)});return b};a.create=function(b,c){c||(c={});var d=document.createElement(b);a.attrs(d,c);return d};a.each=function(b,c){typeof b=="string"&&(b=a.find(b));for(var d=0;d<b.length;d++)c(b[d]);return b};a.empty=function(a){while(a.firstChild)a.removeChild(a.firstChild);return a};a.find=function(a){var b=[];a.substring(0,1)==="#"?b=[document.getElementById(a.replace("#",""))]:b=document.querySelectorAll(a);return b};a.lastOfType=function(b,c){var d=[];a.each(b,function(a){var b=a.querySelectorAll(c);if(b.length>0){var e=b.length-1;d.push(b[e])}});return d};a.load=function(a){var b=document.createElement("script");b.src=a;document.body.appendChild(b)};a.text=function(a,b){if(!b)return a.textContent||a.innerText;a.textContent?a.textContent=b:a.innerText=b};a.docReady=function(a){document.addEventListener?document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",a,!1);a()},!1):document.attachEvent&&document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",a);a()}})};return a}();