-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprot.min.js
1 lines (1 loc) · 16.8 KB
/
prot.min.js
1
function A(t){return(arguments.length>1||!(t instanceof Array))&&(t=Array.prototype.slice.call(arguments,0)),new Arr(t)}function O(t){return new Obj(t)}function S(t){return new Str(t)}function N(t){return new Nod(t)}function E(t){return new Evnt(t)}function D(t){return new Dig(t)}function P(t){return t instanceof Array?A(t):t instanceof Node?N(t):t instanceof Event?E(t):"object"==typeof t?O(t):"string"==typeof t?S(t):"number"==typeof t?D(t):null}function InheritFrom(t,r){"function"==typeof r?(t.prototype=new r,t.prototype.parent=r.prototype):(t.prototype=r,t.prototype.parent=r),t.prototype.constructor=t,t.prototype.store=t.prototype.constructor}function addEvent(t,r,n){return r instanceof Array?void A(r).loop(function(r){addEvent(t,r,n)}):(r=r.replace(/^on/,""),"function"!=typeof n?!1:t.addEventListener?t.addEventListener(r,n,!1):t.attachEvent("on"+r,n))}function addOnload(t){addEvent(window,"onload",t)}function protCopy(t,r){if(t instanceof Array){for(var n=[],e=0,o=t.length;o>e;e++)n[e]=r?arguments.callee(t[e],r):t[e];return n}if("object"==typeof t){var e,n={};for(e in t)n[e]=r?arguments.callee(t[e],r):t[e];return n}return t}function df(t,r,n){var e="undefined"==typeof r?"undefined"!=typeof t:typeof t===r;return"undefined"!=typeof n?e?t:n:e}function getEvent(t){return t=t||window.event,t.target=t.srcElement||t.target,t}Arr=function(t){this.a=t},Arr.prototype=new Array,Arr.prototype._ret=function(t){return this._retWrap&&t instanceof Array?A(t).wrapAll():t},Arr.prototype._retWrap=!1,Arr.prototype.concat=function(){return this._ret(this.a.concat.apply(this.a,arguments))},Arr.prototype.contains=function(t){return this.indexOf(t)>-1},Arr.prototype.copy=function(t){return this._ret(protCopy(this.a,t))},Arr.prototype.every=function(t,r){if(r=r||this.a,"function"==typeof this.a.every)return this.a.every.apply(r,arguments);for(var n=0,e=this.a.length;e>n;n++)if(t.call(r,this.a[n],n,this.a)!==!0)return!1;return!0},Arr.prototype.filter=function(t,r){if(r=r||this.a,"function"==typeof this.a.filter)return this._ret(this.a.filter.apply(r,arguments));for(var n=[],e=0,o=this.a.length;o>e;e++)t.call(r,this.a[e],e,this.a)===!0&&n.push(this.a[e]);return this._ret(n)},Arr.prototype.first=function(){return this._ret(this.a[0])},Arr.prototype.forEach=function(t,r){r=r||this.a,"function"==typeof this.a.forEach?this.a.forEach.apply(r,arguments):this.loop(t,r)},Arr.prototype.getUnique=function(){var t=[];return this.loop(function(r){A(t).contains(r)||t.push(r)}),this._ret(t)},Arr.prototype.has=Arr.prototype.contains,Arr.prototype.indexOf=function(t){if("function"==typeof this.a.indexOf)return this.a.indexOf.apply(this.a,arguments);if(null===this)throw new TypeError;var r,n=0,e=new Object(this.a),o=e.length>>>0;if(0===o)return-1;if(arguments.length>1&&(n=Number(arguments[1]),n!==n?n=0:0!==n&&1/0!==n&&n!==-1/0&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=o)return-1;for(r=n>=0?n:Math.max(o-Math.abs(n),0);o>r;r++)if(e[r]&&e[r]===t)return r;return-1},Arr.prototype.join=function(){return this.a.join.apply(this.a,arguments)},Arr.prototype.last=function(){return this.a[this.a.length-1]},Arr.prototype.lastIndexOf=function(t){if("function"==typeof this.a.lastIndexOf)return this.a.lastIndexOf.apply(this.a,arguments);if(null===this)throw new TypeError;var r,n,e=new Object(this.a),o=e.length>>>0;if(0===o)return-1;for(r=o,arguments.length>1&&(r=Number(arguments[1]),r!==r?r=0:0!==r&&1/0!==r&&r!==-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),n=r>=0?Math.min(r,o-1):o-Math.abs(r);n>=0;n--)if(e[n]&&e[n]===t)return n;return-1},Arr.prototype.loop=function(t,r){for(var n=0,e=this.a.length;e>n;n++){r=r||this.a[n];var o=null;if(o=t.call(r,this.a[n],n,this.a),df(o)){if("__continue"===o)continue;return o}}},Arr.prototype.map=function(t){if(df(this.a.map,"function"))return this.a=this.a.map.apply(this.a,arguments),this._ret(this.a);for(var r=0,n=this.a.length;n>r;r++)this.a[r]=t(this.a[r],r,this.a);return this._ret(this.a)},Arr.prototype.pop=function(){return this.a.pop.apply(this.a,arguments)},Arr.prototype.push=function(){return this.a.push.apply(this.a,arguments)},Arr.prototype.reverse=function(){return this._ret(this.a.reverse.apply(this.a,arguments))},Arr.prototype.shift=function(){return this.a.shift.apply(this.a,arguments)},Arr.prototype.slice=function(){return this._ret(this.a.slice.apply(this.a,arguments))},Arr.prototype.some=function(t){if("function"==typeof this.a.some)return this.a.some.apply(this.a,arguments);for(var r=0,n=this.a.length;n>r;r++)if(t(this.a[r],r,this.a)===!0)return!0;return!1},Arr.prototype.sort=function(t){if(df(t,"function")||!df(t))return this._ret(this.a.sort.apply(this.a,arguments));if(df(t,"object")){var r={col:t.col||0,dir:t.dir||"asc"};return-1===r.dir&&(r.dir="desc"),1===r.dir&&(r.dir="asc"),this.sort(function(t,n){return(t instanceof Array||t instanceof Object)&&(n instanceof Array||n instanceof Object)&&df(t[r.col])&&df(n[r.col])&&(t=t[r.col],n=n[r.col]),"desc"===r.dir?n>t?1:t>n?-1:0:t>n?1:n>t?-1:0})}return!1},Arr.prototype.splice=function(){return this._ret(this.a.splice.apply(this.a,arguments))},Arr.prototype.toSource=function(){return this.a.toSource?this.a.toSource.apply(this.a,arguments):"["+this.a.toString.apply(this.a,arguments)+"]"},Arr.prototype.toString=function(){return this.a.toString.apply(this.a,arguments)},Arr.prototype.unshift=function(){return this.a.unshift.apply(this.a,arguments)||this.a.length},Arr.prototype.vAdjust=function(t,r){if(r=df(r)?r:!1,df(t,"number"))this.map(function(r){return r+t});else if(df(t,"string")){var n=t.match(/^([*/])(\d+(\.\d+)?)$/);if(t.match(/^\\([*/])(\d+(\.\d+)?)$/)&&(t=t.substr(1)),null!==n)"*"===n[1]&&this.map(function(t){return t*n[2]}),"/"===n[1]&&this.map(function(t){return t/n[2]});else{var e=r?t:"",o=r?"":t;this.map(function(t){return e+t+o})}}else df(t,"function")&&this.map(t);return this._ret(this.a)},Arr.prototype.valueOf=function(){return this.a.valueOf()},Arr.prototype.unwrap=function(){return this.a},Arr.prototype.wrapAll=function(t){return this._retWrap=df(t,"boolean",!0),this},Obj=function(t){this.o=t,this.length()},Obj.prototype._ret=function(t){return this._retWrap&&t instanceof Object?O(t).wrapAll():t},Obj.prototype._retWrap=!1,Obj.prototype.copy=function(t){return this._ret(protCopy(this.o,t))},Obj.prototype.hasProp=function(t){return Object.prototype.hasOwnProperty.call(this.o,t)},Obj.prototype.keys=function(){var t=[];return this.loop(function(r,n){t.push(n)}),t},Obj.prototype.length=function(){var t=0;for(var r in this.o)this.hasProp(r)&&t++;return this.len=t,t},Obj.prototype.loop=function(t,r,n){if(n=df(n,"boolean")?n:!1,!df(t,"function"))return!1;for(var e in this.o)if((n||this.hasProp(e))&&"length"!==e){var o=null;if(o=r?t.apply(r,[this.o[e],e,this.o]):t(this.o[e],e,this.o),"undefined"!=typeof o){if("__continue"===o)continue;return o}}},Obj.prototype.map=function(t){return this.loop(function(r,n){this.o[n]=t(r)},this),this._ret(this.o)},Obj.prototype.toArray=function(){var t=[];if(this.loop(function(r){t.push(r)}),0===t.length&&this.length()>0){var r=[];return this.loop(function(t){r.push(t)}),r}var n=A(t);return n._retWrap=this._retWrap,n.filter(function(){return!0})},Obj.prototype.vAdjust=function(t,r){if(r=df(r)?r:!1,df(t,"number"))this.map(function(r){return r+t});else if(df(t,"string")){var n=t.match(/^([*/])(\d+(\.\d+)?)$/);if(t.match(/^\\([*/])(\d+(\.\d+)?)$/)&&(t=t.substr(1)),null!==n)"*"===n[1]&&this.map(function(t){return t*n[2]}),"/"===n[1]&&this.map(function(t){return t/n[2]});else{var e=r?t:"",o=r?"":t;this.map(function(t){return e+t+o})}}else df(t,"function")&&this.map(t);return this._ret(this.o)},Obj.prototype.valueOf=function(){return this.o.valueOf()},Obj.prototype.unwrap=function(){return this.o},Obj.prototype.wrapAll=function(t){return this._retWrap=df(t,"boolean",!0),this},Str=function(t){this.s=t},Str.prototype=new String,Str.prototype._ret=function(t){return this._retWrap&&"string"==typeof t?S(t).wrapAll():t},Str.prototype._retWrap=!1,Str.prototype.contains=function(t,r){return this.s.indexOf(t,r)>-1},Str.prototype.endsWith=function(t,r){return"function"==typeof this.s.endsWith?this.s.endsWith.call(this.s,t,r):(r=r||this.s.length,r-=t.length,this.lastIndexOf(t)===r)},Str.prototype.has=Str.prototype.contains,Str.prototype.is=function(t,r,n){return r="boolean"==typeof r?r:!1,t instanceof RegExp?this.matches(t):r||n?n?this.s===t:this.s==t:this.lower()===S(t).lower()},Str.prototype.isIn=function(t){return t.indexOf(this.s)>-1},Str.prototype.len=function(t,r){return t||r?(t=t?this.s.length>=t:!0,r=r?this.s.length<=r:!0,t&&r):this.s.length},Str.prototype.log=function(){console.log(this.valueOf())},Str.prototype.lower=function(){return this._ret(this.toLowerCase())},Str.prototype.matches=function(t){return t.test(this)},Str.prototype.quote=function(){return this._ret("function"==typeof this.s.quote?this.s.quote.call(this.s):'"'+this.rereplace(/(["\\])/g,"\\$1",/\r?\n/g,"\\n",/\t/g,"\\t")+'"')},Str.prototype.rereplace=function(){var t=this.s;return A(O(arguments).toArray()).loop(function(r,n){n%2===0&&"undefined"!=typeof this[n+1]&&(t=t.replace(r,this[n+1]))},arguments),this._ret(t)},Str.prototype.startsWith=function(t,r){return"function"==typeof this.s.startsWith?this.s.startsWith.call(this.s,t,r):(r=r||0,this.indexOf(t)===r)},Str.prototype.toSource=function(){return this._ret('"'+this.toString()+'"')},Str.prototype.toString=function(){return this._ret(this.s?this.s.toString():"")},Str.prototype.trim=function(t,r,n){return t=df(t,"boolean",!0),r=df(r,"boolean",!0),n=n||"\\s",t="u"===(typeof t)[0]||t===!0?"^["+n+"]*":"",r="u"===(typeof r)[0]||r===!0?"["+n+"]*$":"",this._ret(this.s.replace(new RegExp(t+"(.*?)"+r),"$1"))},Str.prototype.trimLeft=function(t){return this._ret(this.trim(!0,!1,t))},Str.prototype.trimRight=function(t){return this._ret(this.trim(!1,!0,t))},Str.prototype.valueOf=function(){return this.s.valueOf()},Str.prototype.unwrap=function(){return this.s},Str.prototype.wrapAll=function(t){return this._retWrap=df(t,"boolean",!0),this},Nod=function(t){df(t,"string")&&(t=document.querySelector(t)),this.n=t},Nod.prototype.addClass=function(t){var r=S(this.n.getAttribute("class")||"").trim(),n=r.replace(/^\s*(.*)\s*$/,"$1").split(" ");return n=A(n).filter(function(t){return""!==t}),this.hasClass(t)||n.push(t),this.n.setAttribute("class",n.join(" ")),this.hasClass(t)},Nod.prototype.adj=function(t,r,n){t=t?t.toLowerCase():"",r=r?r:!1;for(var e="",o=!1,i=this.n,s="prev"===n?"previousSibling":"nextSibling";!o;){if(i=i[s],null===i){i=!1;break}e=i?N(i).getTagName():"",""!==e&&((""===t||e===t)&&(o=!0),r!==!1&&o===!0&&(o=N(i).hasClass(r)))}return i},Nod.prototype.children=function(){if(df(this.n.children))return this.n.children;var t=this.n.childNodes,r=[];return O(t).loop(function(t){1===t.nodeType&&r.push(t)}),r},Nod.prototype.find=function(t){return this.isElement()&&this.n.querySelector?this.n.querySelector(t||"*"):null},Nod.prototype.findAll=function(t){return this.isElement()&&this.n.querySelectorAll?this.n.querySelectorAll(t||"*"):{}},Nod.prototype.getCompStyle=function(t){return this.n.currentStyle?this.n.currentStyle[t]:getComputedStyle(this.n,null)[t]},Nod.prototype.getPos=function(){for(var t=this.n.offsetLeft,r=this.n.offsetTop,n=this.n;n.offsetParent&&n!==document.getElementsByTagName("body")[0];)t+=n.offsetParent.offsetLeft,r+=n.offsetParent.offsetTop,n=n.offsetParent;return[t,r]},Nod.prototype.getTagName=function(){return this.n.tagName?this.n.tagName.toLowerCase():""},Nod.prototype.hasClass=function(t){return 1===arguments.length?new RegExp("(^|\\s)"+t+"(\\s|$)").test(this.n.getAttribute("class")):O(arguments).toArray().every(function(t){return this.hasClass(t)},this)},Nod.prototype.hasParent=function(t,r){if(t instanceof Nod&&(t=t.n),r=df(r,"boolean")?r:!1,df(t,"string")){var n=t.substr(0,1);"."!==n&&"#"!==n&&(n="tag"),t=t.replace(/^(\.|#)/,"")}else var n="node";for(var e=r?this.n:this.n.parentNode;null!==e;){if("#"===n&&e.id===t)return!0;if("."===n&&N(e).hasClass(t))return!0;if("tag"===n&&N(e).getTagName()===t)return!0;if("node"===n&&e===t)return!0;e=e.parentNode}return!1},Nod.prototype.hide=function(){this.n.style.display="none"},Nod.prototype.html=function(t){return df(t)?this.n.innerHTML=t:this.n.innerHTML},Nod.prototype.index=function(){return A(O(N(this.n.parentNode).children()).toArray()).indexOf(this.n)},Nod.prototype.isElement=function(){return this.n&&df(this.n.nodeType)&&1===this.n.nodeType&&""!==this.n.tagName},Nod.prototype.next=function(t,r){return this.adj(t,r,"next")},Nod.prototype.on=function(t,r){addEvent(this.n,t,r)},Nod.prototype.parent=function(){return this.n.parentNode||!1},Nod.prototype.prev=function(t,r){return this.adj(t,r,"prev")},Nod.prototype.remove=function(){return this.n.parentNode.removeChild(this.n)},Nod.prototype.removeClass=function(t){var r=S(this.n.getAttribute("class")||"").trim(),n=-1,e=r.replace(/^\s*(.*)\s*$/,"$1").split(" ");return e=A(e).filter(function(t){return""!==t}),(n=A(e).contains(t))&&e.splice(n,1),this.n.setAttribute("class",e.join(" ")),!this.hasClass(t)},Nod.prototype.selectContents=function(){if(document.body.createTextRange){var t=document.body.createTextRange();t.moveToElementText(this.n),t.select()}else if(window.getSelection){var r=window.getSelection(),t=document.createRange();t.selectNodeContents(this.n),r.removeAllRanges(),r.addRange(t)}},Nod.prototype.setStyles=function(t){this.n.style&&df(t,"object")&&O(t).length()>0&&O(t).loop(function(t,r){this.style[r]=t},this.n,!0)},Nod.prototype.style=function(t,r){return df(r)?this.n.style[t]=r:this.getCompStyle(t)},Nod.prototype.show=function(){this.n.style.display=""},Nod.prototype.toString=function(){return this.n?this.n.toString():""},Nod.prototype.toggle=function(){this.n.style.display="none"===this.n.style.display?"":"none"},Nod.prototype.value=function(){return this.n.value},Nod.prototype.valueOf=function(){return this.n.valueOf?this.n.valueOf():this.n},Nod.prototype.unwrap=function(){return this.n},Evnt=function(t){this.e=t||window.event,this.getTarget()},Evnt.prototype.target=null,Evnt.prototype.getTarget=function(){this.target=this.e.srcElement||this.e.target},Evnt.prototype.kill=function(t){return t=df(t,"boolean")?t:!0,this.e.preventDefault?this.e.preventDefault():this.e.returnValue=!1,t?this.stopBubble():!0},Evnt.prototype.stopBubble=function(){return this.e.stopPropagation?(this.e.stopPropagation(),!0):(this.e.cancelBubble=!0,!1)},Evnt.prototype.toString=function(){return this.e?this.e.toString():""},Evnt.prototype.valueOf=function(){return this.e.valueOf()},Evnt.prototype.which=function(t){if(df(this.e.which))var r=this.e.which;else if(!df(this.e.button)||df(this.e.keyCode)&&this.e.keyCode>0)var r=this.e.keyCode;else{var r=this.e.button;r=0===r||1===r?1:4===r?2:3}if(df(t)){if(df(t,"string")){var n={esc:27,backspace:8,del:46,enter:13,home:36,end:35,pageup:33,pagedown:34,space:32,f1:112,f2:113,left:37,up:38,right:39,down:40};df(n[S(t).lower()],"number")?t=n[S(t).lower()]:t.match(/^[a-z]$/)?t="abcdefghijklmnopqstuvwxyz".indexOf(t)+65:t.match(/^[0-9]$/)&&(t=parseInt(t)+48)}return r===t}return r},Dig=function(t){this.d=t.valueOf()},Dig.prototype=new Number,Dig.prototype._ret=function(t){return this._retWrap&&"number"==typeof t?D(t).wrapAll():t},Dig.prototype._retWrap=!0,Dig.prototype.precision=8,Dig.prototype.isFinite=function(){return!isNaN(this.d)&&1/0!==this.d&&this.d!==-1/0&&"number"==typeof this.d},Dig.prototype.isInteger=function(){return df(this.d.isInteger,"function")?this.d.isInteger():"number"==typeof this.d&&this.isFinite()&&Math.floor(this.d)===this.d},Dig.prototype.isNaN=function(){return isNaN(this.d)},Dig.prototype.pad=function(t,r,n){for(var e=this.toString(),r=r||"0";e.length<t;)e="r"===n?e+r:r+e;return e},Dig.prototype.parseFloat=Dig.prototype.asFloat=function(){return this._ret(parseFloat(this.d))},Dig.prototype.parseInt=Dig.prototype.asInt=function(t){return this._ret(parseInt(this.d,df(t,"number",10)))},Dig.prototype.round=function(t,r){var n=this.d;return t=df(t,"number",1),r=A([-1,1,"down","up"]).contains(r)?r:0,n=-1===r||"down"===r?t*Math.floor(this.d/t):1===r||"up"===r?t*Math.ceil(this.d/t):t*Math.round(this.d/t),this._ret(n)},Dig.prototype.toInteger=Dig.prototype.toInt=function(){var t=this.isFinite()?this.asInt():null;return this._ret(D(t).isNaN()?0:t)},Dig.prototype.toPrecision=function(t){return t=df(t)?t:this.precision,this._ret(this.d.toPrecision(t))},Dig.prototype.toString=function(){return this.d.toString()},Dig.prototype.valueOf=function(){return this.d.valueOf()},Dig.prototype.wrapAll=function(t){return this._retWrap=df(t,"boolean",!0),this},Function.prototype.inheritFrom=function(t){InheritFrom(this,t)},Function.prototype._ext=function(){A(O(arguments).toArray()).loop(function(t){InheritFrom(t,this)},this)},Function.prototype.throttle=function(t,r){var n,e=!0,o=this,r="b"===(typeof r)[0]?r:!0;return function(){var i=this,s=arguments;e&&(r&&o.apply(i,s),e=!1,n=setTimeout(function(){e=!0,r||o.apply(i,s)},t))}},Function.prototype.debounce=function(t,r){var n,e=this;return function(){var o=this,i=arguments;clearTimeout(n),n=setTimeout(function(){n=null,r||e.apply(o,i)},t),r&&!n&&e.apply(o,i)}};