2006/ack check.js,1.2,1.3 grab.pl,1.2,1.3

Update of /sources/public/2006/ack
In directory hutz:/tmp/cvs-serv1667

Modified Files:
	check.js grab.pl 
Log Message:
Use DOM instead of inner{HTML,Text}.

Index: check.js
===================================================================
RCS file: /sources/public/2006/ack/check.js,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check.js	11 Apr 2006 19:34:27 -0000	1.2
+++ check.js	26 Apr 2006 22:20:14 -0000	1.3
@@ -21,7 +21,10 @@
 
 function setTextContent(el, text)
 {
-  el.textContent = el.innerText = text;
+  while (el.firstChild) {
+    el.removeChild(el.firstChild);
+  }
+  el.appendChild(document.createTextNode(text));
 }
 
 function hostid(url)
@@ -62,7 +65,7 @@
     if (reqs[i] == null) continue;
     if (reqs[i].readyState < 4) {
       reqs[i].abort();
-      document.getElementById("S" + i).innerHTML = "paused";
+      setTextContent(document.getElementById("S" + i), "paused");
     }
   }
 }
@@ -114,16 +117,16 @@
   var req = reqs[key];
   var el = document.getElementById("S" + key);
   if (req.readyState == 0) {
-    el.innerHTML = "uninitialized";
+    setTextContent(el, "uninitialized");
   }
   else if (req.readyState == 1) {
-    el.innerHTML = "initialized";
+    setTextContent(el, "initialized");
   }
   else if (req.readyState == 2) {
-    el.innerHTML = "connected";
+    setTextContent(el, "connected");
   }
   else if (req.readyState == 3) {
-    el.innerHTML = "receiving data";
+    setTextContent(el, "receiving data");
   }
   else if (req.readyState == 4) {
     var st = req.getResponseHeader("X-LinkCheck-Status");
@@ -131,10 +134,22 @@
     var redirect = "";
     try {
       redirect = req.getResponseHeader("X-LinkCheck-Redirect");
-      if (redirect != null && redirect != "")
-        msg += "<br />-&gt;&nbsp;" + redirect.link(redirect);
     } catch (e) { /* duh */ }
-    el.innerHTML = msg;
+    if (redirect == null || redirect == "") {
+      setTextContent(el, msg);
+    }
+    else {
+      while (el.firstChild) {
+        el.removeChild(el.firstChild);
+      }
+      el.appendChild(document.createTextNode(msg));
+      el.appendChild(document.createElement("br"));
+      el.appendChild(document.createTextNode("\u21d2\u00a0")); // "-> "
+      var a = document.createElement("a");
+      a.setAttribute("href", redirect);
+      a.appendChild(document.createTextNode(redirect));
+      el.appendChild(a);
+    }
 
     if (req.status != 200 || st > 399) {
       el.className = "error";

Index: grab.pl
===================================================================
RCS file: /sources/public/2006/ack/grab.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- grab.pl	11 Apr 2006 19:34:27 -0000	1.2
+++ grab.pl	26 Apr 2006 22:20:14 -0000	1.3
@@ -51,7 +51,7 @@
 $redirect = URI->new_abs($redirect, $req->uri()) if $redirect;
 
 print "Content-Type: text/plain\n";
-print "X-LinkCheck-Status: ", CGI::escapeHTML($res->code()), "\n";
-print "X-LinkCheck-Message: ", CGI::escapeHTML($res->status_line()), "\n";
-print "X-LinkCheck-Redirect: ", CGI::escapeHTML($redirect), "\n" if $redirect;
+print "X-LinkCheck-Status: ", $res->code(), "\n";
+print "X-LinkCheck-Message: ", $res->status_line(), "\n";
+print "X-LinkCheck-Redirect: ", $redirect, "\n" if $redirect;
 print "Content-Length: 0\n\n";

Received on Wednesday, 26 April 2006 22:20:23 UTC