W3C home > Mailing lists > Public > www-validator-cvs@w3.org > October 2009

perl/modules/W3C/LinkChecker/bin checklink,4.165,4.166

From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 01 Oct 2009 16:06:02 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MtOAM-0002SP-GG@lionel-hutz.w3.org>
Update of /sources/public/perl/modules/W3C/LinkChecker/bin
In directory hutz:/tmp/cvs-serv9405/bin

Modified Files:
	checklink 
Log Message:
Add "progress bar" for estimating progress on checking links in one document.

Index: checklink
===================================================================
RCS file: /sources/public/perl/modules/W3C/LinkChecker/bin/checklink,v
retrieving revision 4.165
retrieving revision 4.166
diff -u -d -r4.165 -r4.166
--- checklink	1 Oct 2009 16:01:29 -0000	4.165
+++ checklink	1 Oct 2009 16:06:00 -0000	4.166
@@ -343,20 +343,22 @@
 <meta name="generator" content="%s" />
 <link rel="stylesheet" type="text/css" href="%s" />
 <script type="text/javascript">
-function scroll_bottom(progress_pre_id)
-{
-  var progressPre = document.getElementById(progress_pre_id);
-  progressPre.scrollTop = progressPre.scrollHeight;
-}
-function show_progress(progress_text, progress_head_id, progress_pre_id)
+function show_progress(progress_id, progress_text, progress_percentage)
 {
-  var progressHead = document.getElementById(progress_head_id);
-  var txt = document.createTextNode(progress_text);
-  var oChild = progressHead.childNodes[1];
-  var oNewChild = document.createElement("span");
-  oNewChild.appendChild(txt);
-  progressHead.replaceChild(oNewChild, oChild);
-  scroll_bottom(progress_pre_id);
+    var div = document.getElementById("progress" + progress_id);
+
+    var head = div.getElementsByTagName("h3")[0];
+    var text = document.createTextNode(progress_text);
+    var span = document.createElement("span");
+    span.appendChild(text);
+    head.replaceChild(span, head.getElementsByTagName("span")[0]);
+
+    var bar = div.getElementsByTagName("div")[0];
+    bar.firstChild.style.width = progress_percentage;
+    bar.title = progress_percentage;
+
+    var pre = div.getElementsByTagName("pre")[0];
+    pre.scrollTop = pre.scrollHeight;
 }
 </script>
 EOF
@@ -994,8 +996,12 @@
              &encode(sprintf($Cfg{CSS_Validator_URI}, $esc_uri)),
              &encode($Opts{_Self_URI}));
 
-      printf ('<h3 class="status_progress" id="status_progress%s">Status: <span></span></h3>', $result_anchor);
-      printf("<pre class=\"progress\" id=\"pre_progress%s\">\n", $result_anchor);
+      printf(<<EOF, $result_anchor);
+<div class="progress" id="progress%s">
+<h3>Status: <span></span></h3>
+<div class="progressbar"><div></div></div>
+<pre>
+EOF
     }
   }
 
@@ -1069,9 +1075,14 @@
   }
 
   # Build the list of broken URI's
-  &hprintf("Checking %d links to build list of broken URI's\n", scalar (keys %links))
+
+  my $nlinks = scalar(keys(%links));
+
+  &hprintf("Checking %d links to build list of broken URI's\n", $nlinks)
     if ($Opts{Verbose});
+
   my %broken;
+  my $link_num = 0;
   while (my ($u, $ulinks) = each(%links)) {
 
     if ($Opts{Summary_Only}) {
@@ -1079,9 +1090,11 @@
       print ' ' if ($Opts{HTML} && !$Opts{Command_Line});
     } else {
       &hprintf("\nChecking link %s\n", $u);
-      printf('<script type="text/javascript">show_progress("Checking link %s", "status_progress%s", "pre_progress%s");</script>' , &encode($u), $result_anchor, $result_anchor)
+      my $progress = ($link_num/$nlinks) * 100;
+      printf('<script type="text/javascript">show_progress("%s", "Checking link %s", "%.1f%%");</script>', $result_anchor, &encode($u), $progress)
         if (!$Opts{Command_Line} && $Opts{HTML} && !$Opts{Summary_Only});
     }
+    $link_num++;
 
     # Check that a link is valid
     &check_validity($uri, $u,
@@ -1122,12 +1135,12 @@
   }
   &hprintf("\nProcessed in %s seconds.\n", &time_diff($start, &get_timestamp()))
    unless $Opts{Summary_Only};
-   printf('<script type="text/javascript">show_progress("Done. Document processed in %s seconds.", "status_progress%s", "pre_progress%s");</script>' , &time_diff($start, &get_timestamp()), $result_anchor, $result_anchor)
+   printf('<script type="text/javascript">show_progress("%s", "Done. Document processed in %s seconds.", "100%");</script>', $result_anchor, &time_diff($start, &get_timestamp()))
    if ($Opts{HTML} && !$Opts{Summary_Only});
 
   # Display results
   if ($Opts{HTML} && !$Opts{Summary_Only}) {
-    print("</pre>\n");
+    print("</pre>\n</div>\n");
     printf("<h2><a name=\"%s\">Results</a></h2>\n", $result_anchor);
   }
   print "\n" unless $Opts{Quiet};
Received on Thursday, 1 October 2009 16:06:03 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:39 UTC