Author: justi9
Date: 2007-11-08 15:13:16 -0500 (Thu, 08 Nov 2007)
New Revision: 1272
Modified:
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/resources/wooly.js
Log:
More javascript code improvements. doc.elem is retasked for getting
the first elem of a certain name, and its old meaning is found under
doc.elembyid.
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-11-08 19:25:17 UTC (rev 1271)
+++ mgmt/cumin/python/cumin/queue.strings 2007-11-08 20:13:16 UTC (rev 1272)
@@ -90,10 +90,10 @@
[QueueStatus.javascript]
function updateQueueStatus(xml, elem) {
- var ecount = xml.elems("error-count").next().text().get();
+ var ecount = xml.elem("error-count").text().get();
var errors = ecount + " " + (ecount == "1" &&
"error" || "errors");
- var wcount = xml.elems("warning-count").next().text().get();
+ var wcount = xml.elem("warning-count").text().get();
var warnings = wcount + " " + (wcount == "1" &&
"warning" || "warnings");
if (ecount != "0") {
@@ -104,8 +104,7 @@
elem.node.className = "mstatus green";
}
- var divs = elem.elems("div");
- divs.next().set(errors + ", " + warnings);
+ elem.elem("div").set(errors + ", " + warnings);
var ms = xml.elems("measurements").next();
Modified: mgmt/cumin/resources/wooly.js
===================================================================
--- mgmt/cumin/resources/wooly.js 2007-11-08 19:25:17 UTC (rev 1271)
+++ mgmt/cumin/resources/wooly.js 2007-11-08 20:13:16 UTC (rev 1272)
@@ -50,7 +50,7 @@
if (req.readyState == 4 && req.status == 200) {
//dir(req);
- var elem = wooly.doc().elem(id);
+ var elem = wooly.doc().elembyid(id);
callback(wooly.doc(req.responseXML), elem);
}
@@ -80,7 +80,7 @@
this.node = node;
- this.elem = function(id) {
+ this.elembyid = function(id) {
var node = this.node.getElementById(id);
if (node) {
@@ -88,12 +88,24 @@
}
}
- this.elems = function(tag) {
- var nodes = this.node.getElementsByTagName(tag);
-
- return new WoolyIterator(this, WoolyElement,
- nodes, 1, tag);
+ this.elems = function(name, start) {
+ if (start == null) {
+ start = 0;
+ }
+
+ var nodes = this.node.getElementsByTagName(name);
+ var iter = new WoolyIterator(this, WoolyElement, nodes, 1, name);
+
+ for (var i = 0; i < start; i++) {
+ iter.next();
+ }
+
+ return iter;
}
+
+ this.elem = function(name, n) {
+ return this.elems(name, n).next();
+ }
}
function WoolyIterator(doc, nodeClass, nodes, nodeType, nodeName) {
@@ -191,18 +203,7 @@
}
this.elem = function(name, n) {
- if (n == null) {
- n = 0;
- }
-
- var elems = this.elems(name);
- var elem = null;
-
- for (var i = -1; i < n; i++) {
- elem = elems.next();
- }
-
- return elem;
+ return this.elems(name, n).next();
}
this.text = function() {
Show replies by date