//Writen/Compiled by Bedirhan Teymur, with the help of StackOverflow ofc (function(glob){ var globVar = 'e'; // Change global variable here if needed! var e = (function (){ 'use strict'; var hc = function(a, b){ try{ if(e.type(a.className) !== 'string') return !1; var c = a.className.split(' '); for(var i = 0; i < c.length; i++) if(c[i] === b) return !0 } catch(k){} return !1 }, rc = function(a) { var b = '', c = this, d = c.className.split(' '); if(!hc(c, a)) return; for(var i = 0; i < d.length; i++) { if(d[i] !== a) { b += d[i] + ' '; } } c.className = b.trim(); }, mk = { html: function(a){ var b = this, d = b.length; if(b.empty) return this; if(e.type(a) !== 'string') return b[0].innerHTML; for(var i = 0; i < d; i++) { b[i].innerHTML = a } return this }, swapClass: function(a, c, j){ var b = j ? [this[j]] : this, d = b.length; if(d === 0) return this; for(var i = 0; i < d; i++){ if(hc(b[i], a)){ rc.call(b[i], a); b[i].className = b[i].className + ' ' + c; } else if(hc(b[i], c)){ rc.call(b[i], c); b[i].className = b[i].className + ' ' + a; } } return this; }, removeClass: function(a){ var b = this, d = b.length; for(var i = 0; i < d; i++) { rc.call(b[i], a); } return this }, hasClass: function(a){ var b = this, d = b.length, c = !1; for(var i = 0; i < d; i++) { if(hc(b[i], a)) c = !0; } return c; }, addClass: function(a){ var b = this, d = b.length; for(var i = 0; i < d; i++) { if(!hc(b[i], a)) b[i].className = b[i].className + ' ' + a; } return this }, listen: function(a, c, k){ var b = this, d = b.length, f = new Function(); if(d === 0) return this; if(e.type(a) === 'array'){ for(var i = 0; i < a.length; i++) { this.listen(a[i], c||f, k||!1); } return this; } for(var i = 0; i < d; i++) { if(e.type(c) === 'object'){ e.foreach(c, function(j, l){ b[i].addEventListener(j, (e.type(l) === 'function') ? l : f, k||!1); }); } else b[i].addEventListener(a, c||f, k||!1); } return this; }, each: function(c){ var b = this, g = e.clone(b); if(g.length < 1) return this; for(var j = 0; j < g.length; j++) c.call(g[j]); return this; }, css: function(c, ki){ var b = this; if(b.length === 0) return this; if(!c) { var k = getComputedStyle(ki ? b[ki]:b[0]), fn = {}; e.foreach(k, function(l, j){ fn[j] = k.getPropertyValue(j); }); return fn; } if(e.type(c) === 'object'){ for(var j = 0; j < b.length; j++) { for(var i in c) if(c.hasOwnProperty(i)){ b[j].style[i] = c[i]; } } } return this; }, onDrag: function(m, f){ var b = this, t, k = function(g){ (m).call(t, g); }, y = function(i){ i.addEventListener('mousedown', function(a){ t = this; a.preventDefault(); document.addEventListener('mousemove', k, !1) }); document.addEventListener('mouseup', function(a){ var u = t; if(t == null) return; t = null; document.removeEventListener('mousemove', k, !1); if(e.type(f) == 'function') f.call(u, a); if(f === !0) k.call(u, a); }); } for(var j = 0; j < b.length; j++) y(b[j]); return this } }, km = function(a, g){ var c = []; if(e.type(a) === 'function'){ return document.addEventListener('DOMContentLoaded' , a); } if(typeof a === 'string'){ if(!e.isEmpty(a)){ var b = a.split(':'), d = ((!!g && !!g['querySelectorAll']) ? g : document).querySelectorAll(b[0]), f = (b.length > 1) ? (b[1] == 'first' ? [d[0]] : b[1] == 'last' ? [d[d.length-1]] : d) : d; for(var i = 0; i < f.length; i++){ c[c.length] = f[i]; } } } else if(a instanceof Array) { for(var i = 0; i < a.length; i++){ var d = document.querySelectorAll(a[i]); for(var j = 0; j < d.length; j++){ c[c.length] = d[j]; } } } else if (a instanceof NodeList || a instanceof HTMLCollection){ for(var i = 0; i < a.length; i++) { c[c.length] = a[i]; } } else c[c.length] = a; return e.extend(c, mk, {empty: c.length < 1, f: c[0]}); } //End return km; })(), p = function(){ var a = ['webkit','moz','ms','o']; if ('hidden' in document) return 'hidden'; for (var i = 0; i < a.length; i++){ if ((a[i] + 'Hidden') in document) return a[i] + 'Hidden'; } return !1; }, qq = { arrayCompare: function(a, b){ if (!b || !a) return !1; if (a.length != b.length) return !1; for(var i = 0, l = a.length; i < l; i++){ if(b[i] instanceof Array && a[i] instanceof Array){ if(!a[i].equals(b[i])) return !1; } else if(a[i] != b[i]){ return !1; } } return !0; }, randomize: function(u, h){ var a = this.clone(u), b = a.length, c, d, f = (this.type(h) === 'number'), g = 'a'; while(0 < b){ d = Math.floor(Math.random() * b); c = a[--b]; a[b] = a[d]; a[d] = c g = (f && g == 'a') ? ((h === d) ? b : ((h === b) ? d : g)) : g; } return (f) ? {pos: (g == 'a') ? null : g, array: a} : a; }, isMobile: function(){ var a = window.navigator.userAgent.toLowerCase(), b = ['iphone', 'ipad', 'android', 'blackberry', 'nokia', 'opera mini', 'windows mobile', 'windows phone', 'iemobile', 'mobile safari', 'bb10; touch']; for (var i in b) if (a.indexOf(b[i]) > 0) return !0; return !1; }, isFirefox: function(){ var a = window.navigator.userAgent.toLowerCase(); if (a.indexOf('firefox') > 0) return !0; return !1; }, isVis: function(){ if(p()){ return !document[p()] || !1; } return !1 }, winScroll: function(){ return (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop; }, screenSize: function(){ var w = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], x = w.innerWidth || e.clientWidth || g.clientWidth, y = w.innerHeight || e.clientHeight || g.clientHeight; return { x : x, y : y } }, foreach: function(a, b){ for(var i in a) { if(a.hasOwnProperty(i)) { if(b(i, a[i]) === !1) break; } } }, replace: function(a, b, g){ var h; if(this.type(a) !== 'string') throw 'First argument must be a string!'; switch(this.type(b)){ case 'string': if(e.type(g) !== 'string') throw 'Last argument invalid!'; h = this.parseJson('{'+b+':"'+g+'"}'); break; case 'object': h = b; } var d = new RegExp(Object.keys(h).join("|"), "gi"); return a.replace(d, function(f){ return h[f]; }); }, isEmpty: function(a){ if(typeof a === 'string') { if (a.trim() !== '') return !1 } else { for (var b in a) return !1 } return !0 }, clone: function(a){ var b, s = this.clone; if(null === a || "object" != typeof a) return a; if(a instanceof Node || a instanceof Element) { return a } if(a instanceof Date) { b = new Date(); b.setTime(a.getTime()); return b } if(a instanceof Array) { b = []; for(var i = 0; i < a.length; i++) { b[i] = s(a[i]); } return b } if(a instanceof Object) { b = {}; for(var c in a) { if(a.hasOwnProperty(c)) b[c] = s(a[c]); } return b } throw new TypeError('Unsupported type') }, extend: function(){ var p, l = arguments.length, f = arguments[0] || {}, h = this.type(f), e = (f instanceof Node) ? f : (h === 'object' || h === 'string'|| h === 'boolean') ? {} : (h === 'array') ? [] : f, i = (h === 'string' || f instanceof Node || h === 'boolean') ? 1 : 0; for(;i < l; i++) { for(p in arguments[i]){ if(Object.prototype.hasOwnProperty.call(arguments[i], p)){ e[p] = arguments[i][p]; } } } return e; }, type: function(a){ var b = typeof a, c = ['object', 'array', 'function', 'number', '[object Window]', '[object Array]', '[object Function]', 'undefined'], d = Object.prototype.toString.call(a); if (c[0] == b) if(a){ if(a instanceof Array) return c[1]; if(a instanceof Object) return b; if(c[4] == d) return c[0]; if(c[5] == d || c[3] == typeof a.length && c[7] != typeof a.splice && c[7] != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable('splice')) return c[1]; if(c[6] == d || c[7] != typeof a.call && c[7] != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable('call')) return c[2]; } else return 'null'; else if(c[2] == b && c[7] == typeof a.call) return c[0]; return b }, post: function(a, b, c){ //a = URL, b = params(object), c = object with functions to call(done/fail/loading), it can also be a function(success only). var xhr = new XMLHttpRequest(), p = '', j = new Function(), l = { done: j, fail: j, loading: j, type: '', data: null, json: !1 }, h = this.type(c), f = (h === 'object') ? this.extend(l, c) : (h === 'function') ? this.extend(l, {done: c}) : l, v = this; xhr.open('POST', a); xhr.responseType = f.type; xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function(){ if(this.readyState == 3){ f.loading(xhr.response); }; if(this.readyState == 4){ switch(this.status == 200){ case !0: if(f.json){ try{ var p = v.parseJson(xhr.response); } catch(h){ return f.fail(h); } f.done(p); } else f.done(xhr.response); break; case !1: f.fail(xhr.response); break } } } if(b && v.type(b) == 'object'){ v.foreach(b, function(k, m){ p += encodeURIComponent(k) + '=' + encodeURIComponent(m) + '&'; }); p = p.substr(0, p.length-1) } xhr.send(p); }, promisePost: function(a, b, c){//Experimental var k = this; return new Promise(function(j, r){ k.post(a, b, { done: function(g){ j(g); }, fail: function(g){ r(g); }, json: c }); }); } } glob[globVar] = qq.extend(e, qq); })(this);