[tor-commits] [metrics-web/master] Update JavaScript from CollecTor/Onionoo.

karsten at torproject.org karsten at torproject.org
Tue Feb 28 12:37:07 UTC 2017


commit d0d8758d12d799aac5b5083223f9149616348035
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Feb 28 13:33:35 2017 +0100

    Update JavaScript from CollecTor/Onionoo.
---
 website/web/WEB-INF/glossary.jsp | 54 +++++++++++++++++++---------------------
 website/web/WEB-INF/top.jsp      |  2 +-
 website/web/js/script.js         | 29 ++++++++++++++++++---
 3 files changed, 52 insertions(+), 33 deletions(-)

diff --git a/website/web/WEB-INF/glossary.jsp b/website/web/WEB-INF/glossary.jsp
index 1c8b3ce..edde87d 100644
--- a/website/web/WEB-INF/glossary.jsp
+++ b/website/web/WEB-INF/glossary.jsp
@@ -17,50 +17,50 @@
 
       <h1>Glossary <a href="#glossary" name="glossary" class="anchor">#</a></h1>
 
-      <a name="advertised-bandwidth"></a>
-      <p><b><a href="#advertised-bandwidth">advertised bandwidth:</a></b> the
+      <p id="advertised-bandwidth"><b><a href="#advertised-bandwidth">advertised
+      bandwidth:</a></b> the
       volume of traffic, both incoming and outgoing, that a
       <a href="#relay">relay</a> is willing to sustain, as configured by the
       operator and claimed to be observed from recent data transfers.</p>
       
-      <a name="bandwidth-history"></a>
-      <p><b><a href="#bandwidth-history">bandwidth history:</a></b> the volume
+      <p id="bandwidth-history"><b><a href="#bandwidth-history">bandwidth
+      history:</a></b> the volume
       of incoming and/or outgoing traffic that a <a href="#relay">relay</a>
       claims to have handled on behalf of <a href="#client">clients</a>.</p>
       
-      <a name="bridge"></a>
-      <p><b><a href="#bridge">bridge:</a></b> a <a href="#relay">relay</a> whose
+      <p id="bridge"><b><a href="#bridge">bridge:</a></b> a
+      <a href="#relay">relay</a> whose
       existence is non-public and which can therefore provide access for blocked
       <a href="#client">clients</a>, often in combination with
       <a href="#pluggable-transport">pluggable transports</a>, which registers
       itself with the <a href="#bridge-authority">bridge authority</a>.</p>
       
-      <a name="bridge-authority"></a>
-      <p><b><a href="#bridge-authority">bridge authority:</a></b> a
+      <p id="bridge-authority"><b><a href="#bridge-authority">bridge
+      authority:</a></b> a
       special-purpose <a href="#relay">relay</a> that maintains a list of
       bridges as input for external bridge distribution mechanisms (for example,
       <a href="https://bridges.torproject.org/">BridgeDB</a>).</p>
       
-      <a name="circuit"></a>
-      <p><b><a href="#circuit">circuit:</a></b> a path through the Tor network
+      <p id="circuit"><b><a href="#circuit">circuit:</a></b> a path through the
+      Tor network
       built by <a href="#client">clients</a> consisting of at most one
       <a href="#bridge">bridge</a> and at least one
       <a href="#relay">relay</a>.</p>
       
-      <a name="client"></a>
-      <p><b><a href="#client">client:</a></b> a node in the Tor network,
+      <p id="client"><b><a href="#client">client:</a></b> a node in the Tor
+      network,
       typically running on behalf of one user, that routes application
       connections over a series of <a href="#relay">relays</a>.</p>
       
-      <a name="consensus"></a>
-      <p><b><a href="#consensus">consensus:</a></b> a single document compiled
+      <p id="consensus"><b><a href="#consensus">consensus:</a></b> a single
+      document compiled
       and voted on by the <a href="#directory-authority">directory
       authorities</a> once per hour, ensuring that all
       <a href="#client">clients</a> have the same information about the
       <a href="#relay">relays</a> that make up the Tor network.</p>
       
-      <a name="consensus-weight"></a>
-      <p><b><a href="#consensus-weight">consensus weight:</a></b> a value
+      <p id="consensus-weight"><b><a href="#consensus-weight">consensus
+      weight:</a></b> a value
       assigned to a <a href="#relay">relay</a> that is based on bandwidth
       observed by the relay and bandwidth measured by the
       <a href="#directory-authority">directory authorities</a>, included in the
@@ -68,38 +68,36 @@
       <a href="#client">clients</a> to select relays for their
       <a href="#circuit">circuits</a>.</p>
       
-      <a name="directory-authority"></a>
-      <p><b><a href="#directory-authority">directory authority:</a></b> a
+      <p id="directory-authority"><b><a href="#directory-authority">directory
+      authority:</a></b> a
       special-purpose <a href="#relay">relay</a> that maintains a list of
       currently-running relays and periodically publishes a
       <a href="#consensus">consensus</a> together with the other directory
       authorities.</p>
       
-      <a name="directory-mirror"></a>
-      <p><b><a href="#directory-mirror">directory mirror:</a></b> a
+      <p id="directory-mirror"><b><a href="#directory-mirror">directory
+      mirror:</a></b> a
       <a href="#relay">relay</a> that provides a recent copy of directory
       information to clients, in order to reduce the load on
       <a href="#directory-authority">directory authorities</a>.</p>
       
-      <a name="onion-service"></a>
-      <p><b><a href="#onion-service">onion service:</a></b> a
+      <p id="onion-service"><b><a href="#onion-service">onion service:</a></b> a
       service (for example, a website or instant-messaging server) that is only
       accessible via the Tor network.</p>
       
-      <a name="pluggable-transport"></a>
-      <p><b><a href="#pluggable-transport">pluggable transport:</a></b> an
+      <p id="pluggable-transport"><b><a href="#pluggable-transport">pluggable
+      transport:</a></b> an
       alternative transport protocol provided by <a href="#bridge">bridges</a>
       and used by <a href="#client">clients</a> to circumvent transport-level
       blockings (for example, by ISPs or governments).</p>
       
-      <a name="relay"></a>
-      <p><b><a href="#relay">relay:</a></b> a publicly-listed node in the Tor
+      <p id="relay"><b><a href="#relay">relay:</a></b> a publicly-listed node in
+      the Tor
       network that forwards traffic on behalf of <a href="#client">clients</a>,
       and that registers itself with the
       <a href="#directory-authority">directory authorities</a>.</p>
       
-      <a name="relay-flag"></a>
-      <p><b><a href="#relay-flag">relay flag:</a></b> a special
+      <p id="relay-flag"><b><a href="#relay-flag">relay flag:</a></b> a special
       (dis-)qualification of <a href="#relay">relays</a> for circuit positions
       (for example, "Guard", "Exit", "BadExit"), circuit properties (for
       example, "Fast", "Stable"), or roles (for example, "Authority", "HSDir"),
diff --git a/website/web/WEB-INF/top.jsp b/website/web/WEB-INF/top.jsp
index c0428e2..f34031b 100644
--- a/website/web/WEB-INF/top.jsp
+++ b/website/web/WEB-INF/top.jsp
@@ -52,7 +52,7 @@
 <script type="text/javascript">
 document.write('<div class="topButton" style="display:none;"><a href="#top"><i class="fa fa-chevron-up" aria-hidden="true"></i></a></div>');
 </script>
-<a name="top" id="anchor-top"></a>
+<a id="top"></a>
 
 <!-- secondary navigation -->
 <nav class="navbar navbar-default navbar-secondary">
diff --git a/website/web/js/script.js b/website/web/js/script.js
index 5efcf10..6d195bc 100644
--- a/website/web/js/script.js
+++ b/website/web/js/script.js
@@ -1,6 +1,26 @@
 
 /* Please keep this file [✓] UTF-8 encoded */
 
+
+function getCoords(elem) { // crossbrowser version
+    var box = elem.getBoundingClientRect();
+
+    var body = document.body;
+    var docEl = document.documentElement;
+
+    var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
+    var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
+
+    var clientTop = docEl.clientTop || body.clientTop || 0;
+    var clientLeft = docEl.clientLeft || body.clientLeft || 0;
+
+    var top  = box.top +  scrollTop - clientTop;
+    var left = box.left + scrollLeft - clientLeft;
+
+    return { top: Math.round(top), left: Math.round(left) };
+}
+
+
 jQuery(function() {
   // jQuery is .ready() - let's do stuff!
   
@@ -21,11 +41,12 @@ jQuery(function() {
   
   // smooth scolling for all anchor links
   jQuery('a[href^="#"]:not(.anchor)').on('click',function (e) {
-    e.preventDefault();
     var target = this.hash;
-    var $target = $(target.split('#').join('#anchor-'));
-    if ($target.offset() != null) {
-      jQuery('html,body').animate({scrollTop: $target.offset().top},900, function(){
+    var tID = document.getElementById(target.split('#').join(''));
+    if (tID != null) {
+      e.preventDefault();
+      var offset = getCoords(tID);
+      jQuery('html,body').animate({scrollTop: offset.top},900, function(){
         window.location.hash = target;
       });
     }



More information about the tor-commits mailing list