[rhmessaging-commits] rhmessaging commits: r1292 - in mgmt/cumin: resources and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Nov 12 17:57:21 EST 2007


Author: justi9
Date: 2007-11-12 17:57:21 -0500 (Mon, 12 Nov 2007)
New Revision: 1292

Modified:
   mgmt/cumin/python/cumin/page.strings
   mgmt/cumin/python/cumin/queue.strings
   mgmt/cumin/resources/wooly.js
Log:
Fixes refreshing chart urls, such that they don't expand forever.

Improves the javascript code a bit; makes it a little more efficient
for common operations.



Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings	2007-11-12 22:37:37 UTC (rev 1291)
+++ mgmt/cumin/python/cumin/page.strings	2007-11-12 22:57:21 UTC (rev 1292)
@@ -574,25 +574,30 @@
     var status = wooly.doc().elembyid(id);
 
     if (ecount != "0") {
-        status.node.className = "mstatus red";
+        status.setattr("class", "mstatus red");
     } else if (wcount != "0") {
-        status.node.className = "mstatus yellow";
+        status.setattr("class", "mstatus yellow");
     } else {
-        status.node.className = "mstatus green";
+        status.setattr("class", "mstatus green");
     }
 
     status.elem("div").set(errors + ", " + warnings);
 }
 
-counter = 0;
-
 function updateImage(id, object) {
     var img = wooly.doc().elembyid(id);
     
-    src = img.getattr("src");
-    sep = src.lastIndexOf(";");
+    var src = img.getattr("src");
+    var sep = src.lastIndexOf(";");
+    var time = new Date().getTime();
 
-    img.setattr("src", src + ";");
+    if (isNaN(parseInt(src.substring(sep + 1)))) {
+        src = src + ";" + time;
+    } else {
+        src = src.substring(0, sep) + ";" + time;
+    }
+
+    img.setattr("src", src);
 }
 
 [CuminPage.html]

Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings	2007-11-12 22:37:37 UTC (rev 1291)
+++ mgmt/cumin/python/cumin/queue.strings	2007-11-12 22:57:21 UTC (rev 1292)
@@ -151,6 +151,8 @@
     for (var id in cumin.queue.listeners) {
         cumin.queue.listeners[id](id, queue);
     }
+
+    //throw new Error();
 }
 
 [QueueView.html]

Modified: mgmt/cumin/resources/wooly.js
===================================================================
--- mgmt/cumin/resources/wooly.js	2007-11-12 22:37:37 UTC (rev 1291)
+++ mgmt/cumin/resources/wooly.js	2007-11-12 22:57:21 UTC (rev 1292)
@@ -140,17 +140,33 @@
         return node;
     }
 
+    function findexpr(found, limit, node, expr) {
+        var result = document.evaluate
+            (expr, node, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
+
+        var node = result.iterateNext();
+
+        for (var i = 0; node != null && i < limit; i++) {
+            found.push(node);
+            node = result.iterateNext();
+        }
+
+        return found;
+    }
+
     function find(found, limit,
-                  nodeParent, nodeType, nodeName,
+                  node, nodeType, nodeName,
                   attr, attrValue) {
+        //log("find", found, limit, node, nodeType, nodeName, attr, attrValue);
+
         /*
         assert(found);
         assert(found instanceof Array);
-        assert(nodeParent);
+        assert(node);
         assert(nodeType);
         */
 
-        var children = nodeParent.childNodes;
+        var children = node.childNodes;
 
         for (var i = 0; i < children.length; i++) {
             var child = children[i];
@@ -176,7 +192,7 @@
                 if (found.length == limit) {
                     return;
                 }
-            } else {
+            } else if (child.nodeType == 1) {
                 find(found, limit, child, nodeType, nodeName, attr, attrValue);
             }
         }
@@ -255,13 +271,13 @@
             }
 
             var nodes = this.node.getElementsByTagName(name);
-            var iter = new WoolyIterator(this, nodes, WoolyElement);
+            var coll = new WoolyCollection(this, nodes, WoolyElement);
 
             for (var i = 0; i < start; i++) {
-                iter.next();
+                coll.next();
             }
 
-            return iter;
+            return coll;
         }
 
         this.elem = function(name, n) {
@@ -269,7 +285,7 @@
         }
     }
 
-    function WoolyIterator(doc, nodes, nodeClass) {
+    function WoolyCollection(doc, nodes, nodeClass) {
         assert(doc);
         assert(nodes);
         assert(nodeClass);
@@ -281,7 +297,7 @@
         this.pos = 0;
 
         this.next = function() {
-            var node = nodes[this.pos++]
+            var node = this.nodes[this.pos++];
 
             if (node) {
                 return new this.nodeClass(this.doc, node);
@@ -289,6 +305,16 @@
                 return null;
             }
         }
+
+        this.get = function(index) {
+            var node = this.nodes[index];
+
+            if (node) {
+                return new this.nodeClass(this.doc, node);
+            } else {
+                return null;
+            }
+        }
     }
 
     function WoolyElement(doc, node) {
@@ -378,17 +404,17 @@
 
             find(nodes, limit, this.node, 1, name, attr, attrValue);
 
-            var iter = new WoolyIterator(this.doc, nodes, WoolyElement);
+            var coll = new WoolyCollection(this.doc, nodes, WoolyElement);
 
             for (var i = 0; i < start; i++) {
-                iter.next();
+                coll.next();
             }
 
-            return iter;
+            return coll;
         }
 
-        this.elem = function(name, attr, attrValue, n) {
-            return this.elems(name, attr, attrValue, n, n + 1).next();
+        this.elem = function(name, attr, attrValue) {
+            return this.elems(name, attr, attrValue, 0, 1).next();
         }
 
         this.texts = function(start, limit) {
@@ -396,13 +422,13 @@
 
             find(nodes, limit, this.node, 3);
 
-            var iter = new WoolyIterator(this.doc, nodes, WoolyText);
+            var coll = new WoolyCollection(this.doc, nodes, WoolyText);
 
             for (var i = 0; i < start; i++) {
-                iter.next();
+                coll.next();
             }
 
-            return iter;
+            return coll;
         }
 
         this.text = function() {




More information about the rhmessaging-commits mailing list