+
+qwebirc.ui.RequestTransformHTML = function(options) {
+ var HREF_ELEMENTS = {
+ "IMG": 1
+ };
+
+ var update = options.update;
+ var onSuccess = options.onSuccess;
+
+ var fixUp = function(node) {
+ if(node.nodeType != 1)
+ return;
+
+ var tagName = node.nodeName.toUpperCase();
+ if(HREF_ELEMENTS[tagName]) {
+ var attr = node.getAttribute("transform_attr");
+ var value = node.getAttribute("transform_value");
+ if($defined(attr) && $defined(value)) {
+ node.removeAttribute("transform_attr");
+ node.removeAttribute("transform_value");
+ node.setAttribute(attr, qwebirc.global.staticBaseURL + value);
+ }
+ }
+
+ for(var i=0;i<node.childNodes.length;i++)
+ fixUp(node.childNodes[i]);
+ };
+
+ delete options["update"];
+ options.onSuccess = function(tree, elements, html, js) {
+ var container = new Element("div");
+ container.set("html", html);
+ fixUp(container);
+ update.empty();
+
+ while(container.childNodes.length > 0) {
+ var x = container.firstChild;
+ container.removeChild(x);
+ update.appendChild(x);
+ }
+ onSuccess();
+ };
+
+ return new Request.HTML(options);
+};
+