/
qwery.min.js
2 lines (1 loc) · 3.04 KB
/
qwery.min.js
1
2
!function(a){function b(a){return a.all?a.all:a.getElementsByTagName("*")}var c={"=":function(a,b,c){return a.getAttribute(b)==c},"~":function(a,b,c){return a.getAttribute(b).match(new RegExp("\\b"+c+"\\b"))},"|":function(a,b,c){return a.getAttribute(b).match(new RegExp("^"+c+"-?"))},"^":function(a,b,c){return a.getAttribute(b).indexOf(c)===0},$:function(a,b,c){return a.getAttribute(b).lastIndexOf(c)==a.getAttribute(b).length-c.length},"*":function(a,b,c){return a.getAttribute(b).indexOf(c)>-1},"":function(a,b){return a.getAttribute(b)}};a.getElementsBySelector=function(a){if(!document.getElementsByTagName)return[];var d=a.split(" "),e,f,g,h,i,j,k,l,m,n,o,p,q=[document];for(h=0,k=d.length;h<k;h++){token=d[h].replace(/^\s+|\s+$/g,"");if(token.indexOf("#")>-1){e=token.split("#"),f=e[0];var r=document.getElementById(e[1]);if(f&&r.nodeName.toLowerCase()!=f)return[];q=[r];continue}if(token.indexOf(".")>-1){e=token.split("."),f=e[n=0],f=f||"*",m=[];for(g=0,l=q.length;g<l;g++){o=f=="*"?b(q[g]):q[g].getElementsByTagName(f);for(i=0,j=o.length;i<j;i++)m[n++]=o[i]}q=[],p=0;for(j=0,l=m.length;j<l;j++)m[j].className&&m[j].className.match(new RegExp("(?:^|\\s+)"+e[1]+"(?:\\s+|$)"))&&(q[p++]=m[j]);continue}if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)){f=RegExp.$1;var s=RegExp.$2,t=RegExp.$3,u=RegExp.$4;f||(f="*"),m=[],n=0;for(g=0;g<q.length;g++){f=="*"?o=b(q[g]):o=q[g].getElementsByTagName(f);for(i=0;i<o.length;i++)m[n++]=o[i]}q=[],p=0;var v=c[t]||c[""];q=[],p=0;for(j=0;j<m.length;j++)v(m[j],s,u)&&(q[p++]=m[j]);continue}f=token,m=[],n=0;for(g=0;g<q.length;g++){o=q[g].getElementsByTagName(f);for(i=0;i<o.length;i++)m[n++]=o[i]}q=m}return q};var d=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(document.documentElement.childNodes,0)[0].nodeType}catch(e){d=function(a,b){var c=0,d=b||[];if(toString.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}document.querySelectorAll&&!function(){var b=document.createElement("div"),c="__qworry__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0)a.getElementsBySelector=function(a,b,e,f){b=b||document;var g=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(a);if(g&&(b.nodeType===1||b.nodeType===9)){if(g[1])return d(b.getElementsByTagName(a),e);if(g[2]&&Expr.find.CLASS&&b.getElementsByClassName)return d(b.getElementsByClassName(g[2]),e)}if(b.nodeType===9){if(a==="body"&&b.body)return d([b.body],e);if(g&&g[3]){var h=b.getElementById(g[3]);if(!h||!h.parentNode)return d([],e);if(h.id===g[3])return d([h],e)}try{return d(b.querySelectorAll(a),e)}catch(i){}}else if(b.nodeType===1&&b.nodeName.toLowerCase()!=="object"){var j=b,k=b.getAttribute("id"),l=k||c,m=b.parentNode,n=/^\s*[+~]/.test(a);k?l=l.replace(/'/g,"\\$&"):b.setAttribute("id",l),n&&m&&(b=b.parentNode);try{if(!n||m)return d(b.querySelectorAll("[id='"+l+"'] "+a),e)}catch(o){}finally{k||j.removeAttribute("id")}}return[]},b=null}()}(this)