kis-js/kis-min.js

18 lines
8.3 KiB
JavaScript
Executable File

(function(){if("undefined"!==typeof document.querySelector){var d,j,m,e;d=function(g){e="undefined"===typeof g?"undefined"!==typeof d.el?d.el:document.documentElement:j(g);d.prototype.el=e;var g=m(d),i;for(i in g)"object"===typeof g[i]&&(g[i].el=e);g.el=e;return g};j=function(g,d){var e;if("string"!=typeof g||"undefined"===typeof g)return g;e=null!=d&&1===d.nodeType?d:document;if(g.match(/^#([\w\-]+$)/))return document.getElementById(g.split("#")[1]);e=e.querySelectorAll(g);return 1===e.length?e[0]:
e};m=function(d){var e;if("undefined"!==typeof d){if("undefined"!==typeof Object.create)return Object.create(d);e=typeof d;if(!("object"!==e&&"function"!==e))return e=function(){},e.prototype=d,new e}};d.ext=function(g,i){i.el=e;d[g]=i};d.ext("each",function(d){if("undefined"!==typeof e.length&&e!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(e,d);else{var i=e.length;if(0!==i)for(var j,l=0;l<i;l++)j=e.item(l)?e.item(l):e[l],d.call(j,j)}else d.call(e,e)});d.type=function(d){return function(){return d&&
d!==this}.call(d)?(typeof d).toLowerCase():{}.toString.call(d).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};d=window.$_=window.$_||d;d.$=j}})();"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Array.isArray&&(Array.isArray=function(d){return"[object Array]"===Object.prototype.toString.apply(d)});
(function(d){function j(a,b,c){var f,d;"undefined"!==typeof a.hasAttribute?(a.hasAttribute(b)&&(f=a.getAttribute(b)),d=!0):"undefined"!==typeof a[b]?(f=a[b],d=!1):"class"===b&&"undefined"!==typeof a.className&&(b="className",f=a.className,d=!1);if("undefined"===typeof f&&("undefined"===typeof c||null===c))return null;if("undefined"===typeof c)return f;"undefined"!==typeof c&&null!==c?!0===d?a.setAttribute(b,c):a[b]=c:null===c&&(!0===d?a.removeAttribute(b):delete a[b]);return"undefined"!==typeof c?
c:f}function m(a,b,c){var f,b=b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")});f={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof c&&"undefined"!==a.style[b])return a.style[b];if("undefined"===typeof c&&"undefined"!==a.style[f[b]])return a.style[f[b]];if("undefined"!==typeof a.style[b])return a.style[b]=c,null;if(a.style[f[b]])return a.style[f[b]]=c,null}if("undefined"!==typeof document&&!("classList"in document.createElement("a"))){var e=
(self.HTMLElement||self.Element).prototype,g=Object,i=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},y=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},l=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},s=function(a,b){if(""===b)throw new l("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(b))throw new l("INVALID_CHARACTER_ERR","String contains an invalid character");
return y.call(a,b)},u=function(a){for(var b=i.call(a.className),b=b?b.split(/\s+/):[],c=0,f=b.length;c<f;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},k=u.prototype=[],v=function(){return new u(this)};l.prototype=Error.prototype;k.item=function(a){return this[a]||null};k.contains=function(a){return-1!==s(this,a+"")};k.add=function(a){a+="";-1===s(this,a)&&(this.push(a),this._updateClassName())};k.remove=function(a){a=s(this,a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};
k.toggle=function(a){a+="";-1===s(this,a)?this.add(a):this.remove(a)};k.toString=function(){return this.join(" ")};if(g.defineProperty){k={get:v,enumerable:!0,configurable:!0};try{g.defineProperty(e,"classList",k)}catch(z){-2146823252===z.number&&(k.enumerable=!1,g.defineProperty(e,"classList",k))}}else g.prototype.__defineGetter__&&e.__defineGetter__("classList",v)}d.ext("dom",{addClass:function(a){d.each(function(b){b.classList.add(a)})},removeClass:function(a){d.each(function(b){b.classList.remove(a)})},
hide:function(){this.css("display","none")},show:function(a){"undefined"===typeof a&&(a="block");this.css("display",a)},attr:function(a,b){var c=this.el;if(1<c.length&&"undefined"===typeof b)return null;if(1<c.length&&"undefined"!==typeof b)d.each(function(c){return j(c,a,b)});else return j(c,a,b)},text:function(a){var b,c;c=this.el;b=c.textContent;return"undefined"!==typeof a?c.textContent=a:b},css:function(a,b){if("undefined"===typeof b)return m(this.el,a);d.each(function(c){m(c,a,b)})},append:function(a){"undefined"!==
typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML+=a},prepend:function(a){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){"undefined"!==typeof a&&(this.el.innerHTML=a);return this.el.innerHTML}});if("undefined"!==typeof window.XMLHttpRequest){var w={_do:function(a,b,c,f,d){var h=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});d=d?"POST":"GET";
"GET"===d&&(a+=!a.match("?")?"?"+this._serialize(b):this._serialize(b));h.open(d,a);h.onreadystatechange=function(){4===h.readyState&&(200===h.status?c.call(h.responseText,h.responseText):"undefined"!==typeof f&&f.call(h.status,h.status))};"POST"===d?(h.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),h.send(this._serialize(b))):h.send(null)},_serialize:function(a){var b,c,f=[];for(b in a)a.hasOwnProperty(b)&&"function"!==typeof a[b]&&(c=a[b].toString(),b=encodeURIComponent(b),
c=encodeURIComponent(c),f.push(b+"="+c));return f.join("&")}};d.ext("get",function(a,b,c,f){w._do(a,b,c,f,!1)});d.ext("post",function(a,b,c,f){w._do(a,b,c,f,!0)});d.ext("sse",function(a,b){var c;"undefined"!==typeof EventSource&&(c=new EventSource(a),c.onmessage=function(a){b.call(a.data,a.data)})});var n,t;if("undefined"===typeof document.addEventListener)return!1;n=function(a,b,c,d){var r,h;if("undefined"===typeof a)return null;if(b.match(/^([\w\-]+)$/))!0===d?a.addEventListener(b,c,!1):a.removeEventListener(b,
c,!1);else{b=b.split(" ");h=b.length;for(r=0;r<h;r++)n(a,b[r],c,d)}};t=function(a,b,c,f){n(a,c,function(c){var h,e;e=d.$(b,a);for(h in e)c.target==e[h]&&(f.call(e[h],c),c.stopPropagation())},!0)};d.ext("event",{add:function(a,b){d.each(function(c){n(c,a,b,!0)})},remove:function(a,b){d.each(function(c){n(c,a,b,!1)})},live:function(a,b,c){t(document.documentElement,a,b,c)},delegate:function(a,b,c){d.each(function(d){t(d,a,b,c)})}});if("undefined"===typeof localStorage||"undefined"===typeof JSON)return null;
var p=localStorage,q=sessionStorage;d.ext("store",{get:function(a,b){var c=b?q.getItem(a):p.getItem(a);return JSON.parse(c)},set:function(a,b,c){b=JSON.stringify(b);c?q.setItem(a,b):p.setItem(a,b)},remove:function(a,b){b?q.removeItem(a):p.removeItem(a)},getAll:function(a){var b,c={},d,e;e=a?p:q;b=e.length;for(a=0;a<b;a++)d=e.key(a),c[d]=e.getItem(d);return c},clear:function(a){a?q.clear():p.clear()}});var x={object_keys:function(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b},object_values:function(a){var b=
[],c;for(c in a)b.push(a[c]);return b},array_combine:function(a,b){var c={},f,e=0;"array"!==d.type(a)&&(a=this.object_values(a));"array"!==d.type(b)&&(b=this.object_values(b));f=a.length;if(f!==b.length)return!1;for(e=0;e<f;e++)c[a[e]]=b[e];return c},object_merge:function(){var a=Array.prototype.slice.call(arguments),b=a.length,c={},f,e=0,h,g,i;f=!0;for(h=0;h<b;h++)if("array"!==d.type(a[h])){f=!1;break}if(f){c=[];for(h=0;h<b;h++)c=c.contact(a[h]);return c}for(i=h=0;h<b;h++)if(f=a[h],"array"==d.type(f)){g=
0;for(e=f.length;g<e;g++)c[i++]=f[g]}else for(g in f)f.hasOwnProperty(g)&&(parseInt(g,10)+""===g?c[i++]=f[g]:c[g]=f[g]);return c},str_trans:function(a,b,c){var d=[],e=[],h=!1,g=0,i=0,j="",k="",l="",m="",n;if("object"===typeof b){c=[];h=0;g={};c=x.object_keys(b);c.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});h=c.length;for(i=0;i<h;i++)g[c[i]]=b[c[i]];b=g;for(n in b)b.hasOwnProperty(n)&&(d.push(n),e.push(b[n]));
b=d;c=e}i=a.length;g=b.length;j="string"===typeof c;k="string"===typeof b;for(d=0;d<i;d++){h=!1;if(k){a.charAt(d-1);l=a.charAt(d);a.charAt(d+1);for(e=0;e<g;e++)if(l==b.charAt(e)){h=!0;break}}else for(e=0;e<g;e++)if(a.substr(d,b[e].length)==b[e]){h=!0;d=d+b[e].length-1;break}m=h?m+(j?c.charAt(e):c[e]):m+a.charAt(d)}return m}};d.ext("util",x)}})($_);