[rhmessaging-commits] rhmessaging commits: r3294 - mgmt/trunk/wooly/resources.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Wed Apr 15 16:09:57 EDT 2009
Author: eallen
Date: 2009-04-15 16:09:57 -0400 (Wed, 15 Apr 2009)
New Revision: 3294
Modified:
mgmt/trunk/wooly/resources/wooly.js
Log:
Support for updating only part of a widget's html.
Don't preempt pending ajax requests each timer interval (Allows background updates to take longer than the update interval)
Modified: mgmt/trunk/wooly/resources/wooly.js
===================================================================
--- mgmt/trunk/wooly/resources/wooly.js 2009-04-15 19:26:33 UTC (rev 3293)
+++ mgmt/trunk/wooly/resources/wooly.js 2009-04-15 20:09:57 UTC (rev 3294)
@@ -210,6 +210,21 @@
}
}
+ function xmlGetElementById(parent, id) {
+ var children = parent.childNodes;
+ if (children) {
+ for (var i=0; i<children.length; i++) {
+ var child = children.item(i);
+ if (child.nodeType == 1) {
+ if (id == child.getAttribute("id")) {
+ return child;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
function copyNode(node) {
switch (node.nodeType) {
case 1:
@@ -306,6 +321,12 @@
newElem = newElem.nextSibling;
}
+ var updateId = newElem.getAttribute("update");
+ // only update a sub-block of html
+ if (updateId) {
+ oldElem = document.getElementById(updateId);
+ newElem = xmlGetElementById(newElem, updateId);
+ }
replaceNode(newElem, oldElem);
} else {
wooly.log("Element '" + id + "' not found");
@@ -354,9 +375,12 @@
var req = this.getNewRequest();
function fetch() {
- req.open("get", url, true);
- req.onreadystatechange = update;
- req.send(null);
+ // don't preempt a pending request
+ if (req.readyState == 0 || req.readyState == 4) {
+ req.open("get", url, true);
+ req.onreadystatechange = update;
+ req.send(null);
+ }
}
fetch();
@@ -661,6 +685,15 @@
return wooly.session.branch(h);
}
+ this.setHash = function (hash) {
+ var href = window.location.href;
+ var hashIndex = href.indexOf("#");
+ if (hashIndex > 0) {
+ href = href.substring(0, hashIndex);
+ }
+ window.location.replace(href + "#" + hash.marshal());
+ }
+
/* convert string query into cumin session object */
function Branch (s) {
More information about the rhmessaging-commits
mailing list