kis-js/kis-lite-min.js

10 lines
4.1 KiB
JavaScript
Executable File

(function(){if("undefined"!==typeof document.querySelector){var f,e,d,b;f=function(a){b="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?e(a):a;f.prototype.el=b;var a=d(f),c;for(c in a)"object"===typeof a[c]&&(a[c].el=b);a.el=b;return a};e=function(a,c){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
return 1===b.length?b[0]:b};d=function(a){var c;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);c=typeof a;if(!("object"!==c&&"function"!==c))return c=function(){},c.prototype=a,new c}};f.ext=function(a,c){c.el=b;f[a]=c};f.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{var c=b.length;if(0!==c)for(var g,d=0;d<c;d++)g=b.item(d)?b.item(d):b[d],a.call(g,g)}else a.call(b,
b)});f.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=e}})();"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});
"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true});"undefined"===typeof Array.isArray&&(Array.isArray=function(f){return Object.prototype.toString.apply(f)==="[object Array]"});
(function(){if(typeof window.XMLHttpRequest!=="undefined"){var f={_do:function(e,d,b,a){var c=new XMLHttpRequest;typeof b==="undefined"&&(b=function(){});a=a?"POST":"GET";e=e+(a==="GET"?"?"+this._serialize(d):"");c.open(a,e);c.onreadystatechange=function(){c.readyState===4&&b(c.responseText)};if(a==="POST"){c.setRequestHeader("Content-Type","application/x-www-form-urlencoded");c.send(this._serialize(d))}else c.send(null)},_serialize:function(e){var d,b,a=[];for(d in e)if(e.hasOwnProperty(d)&&typeof e[d]!==
"function"){b=e[d].toString();d=encodeURIComponent(d);b=encodeURIComponent(b);a.push(d+"="+b)}return a.join("&")}};$_.ext("get",function(e,d,b){f._do(e,d,b,false)});$_.ext("post",function(e,d,b){f._do(e,d,b,true)});$_.ext("sse",function(e,d){var b;if(typeof EventSource!=="undefined"){b=new EventSource(e);b.onmessage=function(a){d.call(a.data,a.data)}}})}})();
(function(){var f,e,d,b;if(typeof document.addEventListener!=="undefined"){f=function(a,c,b){typeof a.addEventListener!=="undefined"&&a.addEventListener(c,b,false)};e=function(a,c,b){typeof a.removeEventListener!=="undefined"&&a.removeEventListener(c,b,false)}}else if(typeof document.attachEvent!=="undefined"){f=function(a,c,b){function d(a){b.apply(a)}if(typeof a.attachEvent!=="undefined"){e(c,b);a.attachEvent("on"+c,d);a=a.KIS_0_6_0=a.KIS_0_6_0||{};a.listeners=a.listeners||{};a.listeners[c]=a.listeners[c]||
[];a.listeners[c].push({callback:b,_listener:d})}else console.log("Failed to _attach event:"+c+" on "+a)};e=function(a,c,b){if(typeof a.detachEvent!=="undefined"){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[c])for(var e=d.listeners[c],f=e.length,h=0;h<f;h++)if(e[h].callback===b){a.detachEvent("on"+c,e[h]._listener);e.splice(h,1);e.length===0&&delete d.listeners[c];break}}}}d=function(a,c,b,j){var i,k;if(typeof a==="undefined"){console.log(arguments);console.log(c);return false}if(c.match(/^([\w\-]+)$/))j===
true?f(a,c,b):e(a,c,b);else{c=c.split(" ");k=c.length;for(i=0;i<k;i++)d(a,c[i],b,j)}};b=function(a,c,b,e){d(a,b,function(b){var d,f,g,b=b||window.event;f=$_.$(c,a);for(d in f){g=b.target||b.srcElement;if(g==f[d]){e.call(f[d],b);b.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(e){d(e,a,b,true)})},remove:function(a,b){$_.each(function(e){d(e,a,b,false)})},live:function(a,c,d){b(document.documentElement,a,c,d)},delegate:function(a,c,d){$_.each(function(e){b(e,a,c,d)})}})})();