UNPKG

kero

Version:
1 lines 3.4 kB
function isDomElement(t){return window.HTMLElement?t instanceof HTMLElement:t&&t.tagName&&1===t.nodeType}window.u=window.u||{};var u=window.u;if(u.polyfill=!0,u._addClass=function(t,e){var r,n,o,a,c,i=/[\t\r\n\f]/g,l="string"==typeof e&&e,s=/\S+/g;if(l&&(r=(e||"").match(s)||[],n=1===t.nodeType&&(t.className?(" "+t.className+" ").replace(i," "):" "))){for(a=0;o=r[a++];)n.indexOf(" "+o+" ")<0&&(n+=o+" ");c=(n+"").trim(),t.className!==c&&(t.className=c)}return this},u._removeClass=function(t,e){var r,n,o,a,c,i=/\S+/g,l=/[\t\r\n\f]/g,s=0===arguments.length||"string"==typeof e&&e;if(s&&(r=(e||"").match(i)||[],n=1===t.nodeType&&(t.className?(" "+t.className+" ").replace(l," "):""))){for(a=0;o=r[a++];)for(;n.indexOf(" "+o+" ")>=0;)n=n.replace(" "+o+" "," ");c=e?(n+"").trim():"",t.className!==c&&(t.className=c)}return this},u._hasClass=function(t,e){var r=/[\t\r\n\f]/g;return 1===t.nodeType&&(" "+t.className+" ").replace(r," ").indexOf(e)>=0},u._toggleClass=function(t,e){u._hasClass(t,e)?u._removeClass(t,e):u._addClass(t,e)},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s*(\b.*\b|)\s*$/,"$1")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){for(var e=0;e<this.length;e++)if(this[e]==t)return e;return-1}),Array.prototype.remove||(Array.prototype.remove=function(t){return 0>t||t>this.length?void alert("index out of bound"):void this.splice(t,1)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){for(var e=0,r=this.length;r>e;e++)t(this[e],e,this)}),NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),!window.HTMLElement){var _querySelectorAll=Element.prototype.querySelectorAll;Element.prototype.querySelectorAll=function(t){var e=_querySelectorAll.call(this,t);if(!isDomElement(this))return e;for(var r=[],n=0;n<e.length;n++)r.push(e[n]);return r};var _docquerySelectorAll=document.querySelectorAll;document.querySelectorAll=function(t){try{var e=_docquerySelectorAll.call(this,t),r=[];if(e.length>0){for(var n=0;n<e.length;n++)r.push(e[n]);return r}return e}catch(o){}}}Element.prototype.addEventListener||(Element.prototype.addEventListener=function(t,e){var r=this;this.attachEvent("on"+t,function(){e.apply(r,arguments)})}),"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(t){for(var e=this,r=[],n=1,o=arguments.length;o>n;n++)r.push(arguments[n]);return function(){return e.apply(t,r.concat(Array.prototype.slice.call(arguments)))}}),window.getCurrentJsPath=function(){var t=document,e={},r=+new Date,n=/((?:http|https|file):\/\/.*?\/[^:]+)(?::\d+)?:\d+/,o=-1===(""+t.querySelector).indexOf("[native code]");if(t.currentScript)return t.currentScript.src;var a;try{e.b()}catch(c){a=c.fileName||c.sourceURL||c.stack||c.stacktrace}if(a){var i=n.exec(a)[1];if(i)return i}for(var l,s=t.scripts,u=s.length-1;l=s[u--];)if(l.className!==r&&"interactive"===l.readyState)return l.className=r,o?l.getAttribute("src",4):l.src},window.encodeBase64=function(t){for(var e,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=t.length,i="";c>a;){if(e=255&t[a++],a==c){i+=o.charAt(e>>2),i+=o.charAt((3&e)<<4),i+="==";break}if(r=t[a++],a==c){i+=o.charAt(e>>2),i+=o.charAt((3&e)<<4|(240&r)>>4),i+=o.charAt((15&r)<<2),i+="=";break}n=t[a++],i+=o.charAt(e>>2),i+=o.charAt((3&e)<<4|(240&r)>>4),i+=o.charAt((15&r)<<2|(192&n)>>6),i+=o.charAt(63&n)}return i};