My own CMS is currently using J-QueryjQuery, but as one of the goals is to have the whole project to be very small, so I've decided to write my own basic library, I. I only really need to select elements and modify them using results from my server. (via AJaxAjax).
###The Javascript-library v0.01: (Attempt 1) (function(){ a=this.Function; a.prototype.extend=(function(a,b){this[a]=b;return this}); a.prototype.implement=(function(a,b){this.prototype[a]=b;return this}); $=(function(a,b,c){return (b?$(b)[c?c:0]:document).querySelectorAll(a)}) .extend("post",(function(a,b){ c=[]; for(x in a) c[c.length]=[x,a[x]].join("="); d=XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP"); d.open("POST","./",true); d.setRequestHeader("Content-type","application/x-www-form-urlencoded"); d.onreadystatechange=b; d.send(c.join("&")); return this; })) .extend("each",(function(a,b,c){ for(x in a) if(a.hasOwnProperty(x)) b.call(c, a[x], x, a); return this; })); })();The JavaScript-library v0.01: (Attempt 1)
Okay I know that querySelectorAll can't be relied on, but it is just good for the start of this.
(function(){
a=this.Function;
a.prototype.extend=(function(a,b){this[a]=b;return this});
a.prototype.implement=(function(a,b){this.prototype[a]=b;return this});
$=(function(a,b,c){return (b?$(b)[c?c:0]:document).querySelectorAll(a)})
.extend("post",(function(a,b){
c=[];
for(x in a)
c[c.length]=[x,a[x]].join("=");
d=XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
d.open("POST","./",true);
d.setRequestHeader("Content-type","application/x-www-form-urlencoded");
d.onreadystatechange=b;
d.send(c.join("&"));
return this;
}))
.extend("each",(function(a,b,c){
for(x in a)
if(a.hasOwnProperty(x))
b.call(c, a[x], x, a);
return this;
}));
})();
###So what is the point on why I posted this?
Simpleknow that querySelectorAll can't be relied on, thisbut it is code-review and I need feedback, Thanks to anyone withjust good for the commentsstart of this.
###The Javascript-library v0.02: (Attempt 2) OkayThe JavaScript-library v0.02: (Attempt 2)
I believe this is heapsmuch improved (I think) it. It has reasonable variable names, works better, and most of all is quite buggy. :( Any ideas?