net.CommandQueue = function(id,url, freq) {
this.id = id;
net.cmdQueues[id] = this;
this.url = url;
this.queued = new Array();
[COLOR="Blue"][B]this.sent = new Array();[/B][/COLOR]
if(freq) {
this.repeat(freq);
}
}
net.CommandQueue.prototype.addCommand = function(command) {
if(this.isCommand(command)) {
this.queue.append(command,true);
}
}
net.CommandQueue.prototype.fireRequest = function() {
if (this.queued.length == 0) {
return;
}
var data = "data=";
for(var i = 0; i < this.queued.length; i++) {
var cmd = this.queued[i];
if(this.isCommand(cmd)) {
data += cmd.toRequestString();
[COLOR="Blue"][B]this.sent[cmd.id] = cmd;[/B][/COLOR]
}
}
this.queued = new Array();
this.loader = new net.ContentLoader(this.url, net.CommandQueue.onload, net.CommandQueue.onerror, "POST",
data);
}
net.CommandQueue.prototype.isCommand = function(obj) {
return (
obj.implementsProp("id") &&
obj.implementsFunc("toRequestString") &&
obj.implementsFunc("parseResponse")
);
}
net.CommandQueue.onload = function(loader) {
var xmlDoc = net.req.responseXML;
var elDocRoot = xmlDoc.getElementsByTagName("commands")[0];
if(elDocRoot) {
for(i = 0; i < elDocRoot.childNodes.length; i++) {
elChild = elDocRoot.childNodes[i];
if(elChild.nodeName == "command") {
var attrs = elChild.attributes;
var id = attrs.getNamedItem("id").value;
[COLOR="Blue"][B]var command = net.CommandQueue.sent[id];[/B][/COLOR]
if(command) {
command.parseResponse(elChild);
}
}
}
}
}
I highlighted the lines of codes that I dont understand above.
I dont understand the code var command = net.CommandQueue.sent[id];. How come this code need to be coded like that? Is it possible to change it like this: var command = this.sent[id];. Since this refers to net.CommandQueue then the code should work right?
Please explain it to me. Im still a student.
Thanks!