W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2010

link-checker commit: Add "progress bar" for estimating progress on checking links in one document.

From: Mercurial notifier <nobody@w3.org>
Date: Thu, 05 Aug 2010 14:47:23 +0000
To: link-checker updates <www-validator-cvs@w3.org>
Message-Id: <E1Oh1j9-0006J0-5W@blinky.w3.org>
changeset:   323:d574b99cc78a
user:        ville
date:        Thu Oct 01 16:06:00 2009 +0000
files:       bin/checklink docs/linkchecker.css
description:
Add "progress bar" for estimating progress on checking links in one document.


diff -r 3cb4c9024ad5 -r d574b99cc78a bin/checklink
--- a/bin/checklink	Thu Oct 01 16:01:29 2009 +0000
+++ b/bin/checklink	Thu Oct 01 16:06:00 2009 +0000
@@ -5,7 +5,7 @@
 # (c) 1999-2009 World Wide Web Consortium
 # based on Renaud Bruyeron's checklink.pl
 #
-# $Id: checklink,v 4.165 2009-10-01 16:01:29 ville Exp $
+# $Id: checklink,v 4.166 2009-10-01 16:06:00 ville Exp $
 #
 # This program is licensed under the W3C(r) Software License:
 #       http://www.w3.org/Consortium/Legal/copyright-software
@@ -275,7 +275,7 @@
   $PROGRAM     = 'W3C-checklink';
   $VERSION     = '4.5';
   $REVISION    = sprintf('version %s (c) 1999-2009 W3C', $VERSION);
-  my ($cvsver) = q$Revision: 4.165 $ =~ /(\d+[\d\.]*\.\d+)/;
+  my ($cvsver) = q$Revision: 4.166 $ =~ /(\d+[\d\.]*\.\d+)/;
   $AGENT       = sprintf('%s/%s [%s] %s',
                          $PROGRAM, $VERSION, $cvsver,
                          (W3C::UserAgent::USE_ROBOT_UA
@@ -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)
+function show_progress(progress_id, progress_text, progress_percentage)
 {
-  var progressPre = document.getElementById(progress_pre_id);
-  progressPre.scrollTop = progressPre.scrollHeight;
-}
-function show_progress(progress_text, progress_head_id, progress_pre_id)
-{
-  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};
diff -r 3cb4c9024ad5 -r d574b99cc78a docs/linkchecker.css
--- a/docs/linkchecker.css	Thu Oct 01 16:01:29 2009 +0000
+++ b/docs/linkchecker.css	Thu Oct 01 16:06:00 2009 +0000
@@ -4,7 +4,7 @@
    Copyright 2000-2009 W3C (MIT, INRIA, Keio). All Rights Reserved.
    See http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright
 
-   $Id: linkchecker.css,v 1.29 2009-02-10 18:10:29 ville Exp $
+   $Id: linkchecker.css,v 1.30 2009-10-01 16:06:00 ville Exp $
 */
 
 html, body {
@@ -56,7 +56,7 @@
   white-space: pre;
 }
 
-pre.progress {
+div.progress pre {
   height: 12em;
   font-size: small;
   overflow: auto;
@@ -65,7 +65,7 @@
 	margin-top: 0;
 }
 
-h3.status_progress {
+div.progress h3 {
   margin-bottom: 0;
   background: white;
 	border: 1px solid #DCDDE0;
@@ -73,6 +73,17 @@
 	padding: .4em .8em;
 	text-indent: 0;
 	overflow: hidden;
+}
+
+div.progressbar {
+    border: 1px solid #DCDDE0;
+    border-bottom: 0;
+}
+
+div.progressbar div {
+    height: .15em;
+    width: 0;
+    background-color: #55B05A;
 }
 
 fieldset {
Received on Thursday, 5 August 2010 14:47:46 UTC

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