[tor-commits] [webwml/staging] Move scripts to their own js file

hiro at torproject.org hiro at torproject.org
Fri Jun 16 09:16:58 UTC 2017


commit 17643b01962fabf590b6b76959b9fb3efb511c85
Author: hiromipaw <hiro at torproject.org>
Date:   Fri Jun 16 11:16:38 2017 +0200

    Move scripts to their own js file
---
 docs/torbutton/en/index.wml | 82 ++++-----------------------------------------
 en/index.wml                |  5 +--
 include/thankyou-head.wmi   | 27 +++++++--------
 js/animate.js               |  8 +++++
 js/functions.js             | 65 +++++++++++++++++++++++++++++++++++
 rule-41/banner.html         | 19 +++--------
 6 files changed, 98 insertions(+), 108 deletions(-)

diff --git a/docs/torbutton/en/index.wml b/docs/torbutton/en/index.wml
index 1070239..f947b96 100644
--- a/docs/torbutton/en/index.wml
+++ b/docs/torbutton/en/index.wml
@@ -8,81 +8,14 @@
     <a href="<page index>">Home » </a>
     <a href="<page docs/torbutton/index>">Torbutton</a>
   </div>
-	<div id="maincol"> 
+	<div id="maincol">
     <!-- PUT CONTENT AFTER THIS TAG -->
-    
+
     <link rel="search" type="application/opensearchdescription+xml" title="Google Canada" href="search/google-ca.xml"/>
     <link rel="search" type="application/opensearchdescription+xml" title="Google UK" href="search/google-uk.xml"/>
     <link rel="search" type="application/opensearchdescription+xml" title="Google USA" href="search/google-us.xml"/>
-    <script type="text/javascript">
-    
-    function addSearchProvider(prov) {
-    
-    try {
-    window.external.AddSearchProvider(prov);
-    }
-    
-    catch (e) {
-    alert("Search plugins require Firefox 2");
-    return;
-    }
-    }
-    
-    function addEngine(name,ext,cat,pid)
-    {
-      if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
-        window.sidebar.addSearchEngine(
-          "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + ".src",
-          "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + "."+ ext, name, cat );
-      } else {
-        alert("You will need a browser which supports Sherlock to install this plugin.");
-      }
-    }
-    
-    function addOpenSearch(name,ext,cat,pid,meth)
-    {
-      if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
-        if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
-          alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
-        } else {
-          window.external.AddSearchProvider(
-            "http://mycroft.mozdev.org/installos.php/" + pid + "/" + name + ".xml");
-        }
-      } else {
-        alert("You will need a browser which supports OpenSearch to install this plugin.");
-      }
-    }
-    
-    function addOpenSearch2(name,ext,cat,pid,meth)
-    {
-      if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
-        if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
-          alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
-        } else {
-          window.external.AddSearchProvider(
-            "http://torbutton.torproject.org/dev/search/" + name + ".xml");
-        }
-      } else {
-        alert("You will need a browser which supports OpenSearch to install this plugin.");
-      }
-    }
-    
-    function install (aEvent)
-    {
-      var params = {
-        "Torbutton": { URL: aEvent.target.href,
-                 Hash: aEvent.target.getAttribute("hash"),
-                 toString: function () { return this.URL; }
-        }
-      };
-      InstallTrigger.install(params);
-    
-      return false;
-    }
-    
-    
-    </script>
-    
+    <script type="text/javascript" src="$(DOCROOT)/js/functions.js" charset="utf-8"></script>
+
     <h2>Torbutton</h2>
     <hr>
 
@@ -110,12 +43,12 @@
     repository</a> or simply unzip the xpi.
     <br/>
     <strong>Bug Reports:</strong> <a href="https://trac.torproject.org/projects/tor/report/14">Torproject Bug Tracker</a><br/>
-    <strong>Documents:</strong> 
-    <b>[</b> 
+    <strong>Documents:</strong>
+    <b>[</b>
     <a href="https://gitweb.torproject.org/torbutton.git/tree/src/CHANGELOG">changelog</a> <b>|</b>
     <a href="https://gitweb.torproject.org/torbutton.git/tree/src/LICENSE">license</a> <b>|</b>
     <a href="https://gitweb.torproject.org/torbutton.git/tree/src/CREDITS">credits</a> <b>]</b>
-    
+
   </div>
   <!-- END MAINCOL -->
   <div id = "sidecol">
@@ -126,4 +59,3 @@
 </div>
 <!-- END CONTENT -->
 #include <foot.wmi>
-
diff --git a/en/index.wml b/en/index.wml
index 836d3b0..a228691 100644
--- a/en/index.wml
+++ b/en/index.wml
@@ -65,10 +65,7 @@
                 browse the Internet.</p>
                 </div>
               </td>
-              <td>
-                <div class="project">
-                <a href="https://guardianproject.info/apps/orbot/"><img
-                src="$(IMGROOT)/icon-Orbot.jpg" alt="Orbot Icon"></a>
+              <td><meta name="description" content="The Tor Project's free software protects your privacy online. Site blocked? Email [mailto:gettor at torproject.org] for help downloading Tor Browser.">
                 <h3><a href="https://guardianproject.info/apps/orbot/">Orbot</a></h3>
                 <p>Tor for Google Android devices.</p>
                 </div>
diff --git a/include/thankyou-head.wmi b/include/thankyou-head.wmi
index 388944e..661dde0 100644
--- a/include/thankyou-head.wmi
+++ b/include/thankyou-head.wmi
@@ -14,7 +14,7 @@
   <ifneq "$(REDIRECT)" "" "<meta http-equiv="refresh" content="0;url=$(DOCROOT)/$(REDIRECT)">">
   <ifneq "$(REDIRECT_GLOBAL)" "" "<meta http-equiv="refresh" content="0;url=$(REDIRECT_GLOBAL)">">
 
-  # begin WML to generate css/js paths 
+  # begin WML to generate css/js paths
   <ifneq "$(STYLESHEET)" "" "<link rel="stylesheet" type="text/css" href="$(DOCROOT)/$(STYLESHEET)">">
   <ifeq "$(STYLESHEET)" "" "<link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/master.css">">
 
@@ -29,17 +29,14 @@
   <link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/ie6.css">
   <![endif]-->
 #  <script language="javascript" type="text/javascript" src="$(DOCROOT)/global.js"></script>
-  # end WML to generate css/js paths 
+  # end WML to generate css/js paths
 
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <meta name="author" content="The Tor Project, Inc.">
   <meta name="keywords" content="anonymity online, tor, tor project, censorship circumvention, traffic analysis, anonymous communications research">
 <script type="text/javascript" src="$(DOCROOT)/js/jquery.min.js" charset="utf-8"></script>
 <script type="text/javascript" src="$(DOCROOT)/js/jquery.infieldlabel.min.js" charset="utf-8"></script>
-<script type="text/javascript" charset="utf-8">
-/* email placeholder function */
-	$(function(){ $("label").replaceWith('<label class="active" for="email">Enter your email address</label>'); $("label").inFieldLabels(); });
-</script>
+<script type="text/javascript" src="$(DOCROOT)/js/functions.js" charset="utf-8"></script>
 </head>
 <body>
 <div id="wrap">
@@ -63,9 +60,9 @@
             my $lang = "$(LANG)";
 
             for my $key (@keys) {
-              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
 
-              # in directory of active link, set class active 
+              # in directory of active link, set class active
               my $class;
               if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
                 $class = 'class="active"';
@@ -74,12 +71,12 @@
               }
 
 	            $dir = '.' unless defined $dir;
-                
+
               # translated version
               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
                   printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$navigation{$key};
-              } 
+              }
               # english version
               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
               	printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
@@ -108,14 +105,14 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
               my $val = shift @calltoaction;
               push @keys, $key;
               $calltoaction{$key} = $val;
-            } 
+            }
 
             my $page = $WML_SRC_BASENAME;
             my $lang = "$(LANG)";
             for my $key (@keys) {
-              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
 
-              # in directory, set active 
+              # in directory, set active
               my $class;
               if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
               #if ($WML_SRC_BASENAME eq $base) {
@@ -129,7 +126,7 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
                   printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$calltoaction{$key};
-              } 
+              }
               # default to english version
               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
               	printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
@@ -137,7 +134,7 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
               } else {
                 warn "$WML_SRC_FILENAME has a [page $key] (parses to docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml), but that doesn't exist.";
               }
-            }    
+            }
           }:>
         </ul>
       </div>
diff --git a/js/animate.js b/js/animate.js
new file mode 100644
index 0000000..a789365
--- /dev/null
+++ b/js/animate.js
@@ -0,0 +1,8 @@
+document.addEventListener("DOMContentLoaded", function(event) {
+ var animate = document.getElementById("animate");
+ animate.classList.add("not-loaded");
+  window.setTimeout(function () {
+    animate.classList.remove("not-loaded");
+    animate.classList.add("loaded");
+  }, 0);
+});
diff --git a/js/functions.js b/js/functions.js
new file mode 100644
index 0000000..661ad81
--- /dev/null
+++ b/js/functions.js
@@ -0,0 +1,65 @@
+$(function(){ $("label").replaceWith('<label class="active" for="email">Enter your email address</label>'); $("label").inFieldLabels(); });
+
+function addSearchProvider(prov) {
+
+try {
+window.external.AddSearchProvider(prov);
+}
+
+catch (e) {
+alert("Search plugins require Firefox 2");
+return;
+}
+}
+
+function addEngine(name,ext,cat,pid)
+{
+  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
+    window.sidebar.addSearchEngine(
+      "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + ".src",
+      "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + "."+ ext, name, cat );
+  } else {
+    alert("You will need a browser which supports Sherlock to install this plugin.");
+  }
+}
+
+function addOpenSearch(name,ext,cat,pid,meth)
+{
+  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
+    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
+      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
+    } else {
+      window.external.AddSearchProvider(
+        "http://mycroft.mozdev.org/installos.php/" + pid + "/" + name + ".xml");
+    }
+  } else {
+    alert("You will need a browser which supports OpenSearch to install this plugin.");
+  }
+}
+
+function addOpenSearch2(name,ext,cat,pid,meth)
+{
+  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
+    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
+      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
+    } else {
+      window.external.AddSearchProvider(
+        "http://torbutton.torproject.org/dev/search/" + name + ".xml");
+    }
+  } else {
+    alert("You will need a browser which supports OpenSearch to install this plugin.");
+  }
+}
+
+function install (aEvent)
+{
+  var params = {
+    "Torbutton": { URL: aEvent.target.href,
+             Hash: aEvent.target.getAttribute("hash"),
+             toString: function () { return this.URL; }
+    }
+  };
+  InstallTrigger.install(params);
+
+  return false;
+}
diff --git a/rule-41/banner.html b/rule-41/banner.html
index 1c8372a..e356f3d 100644
--- a/rule-41/banner.html
+++ b/rule-41/banner.html
@@ -12,18 +12,9 @@
     <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
     <script type="text/javascript" src="js/easyXDM.min.js"></script>
     <script type='text/javascript' src="js/modernizr.min.js"></script>
-    <script type='text/javascript' src="js/css3-mediaqueries.js"></script>   
-     <script type="text/javascript">
+    <script type='text/javascript' src="js/css3-mediaqueries.js"></script>
+    <script type="text/javascript" src="js/animate.js"></script>
 
-      document.addEventListener("DOMContentLoaded", function(event) {
-       var animate = document.getElementById("animate");
-       animate.classList.add("not-loaded");
-        window.setTimeout(function () {
-          animate.classList.remove("not-loaded");
-          animate.classList.add("loaded");
-        }, 0);
-      });
-    </script>
     <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
     <!--[if lt IE 9]>
       <script type='text/javascript' src="js/html5.js"></script>
@@ -71,8 +62,8 @@
    <div class="mobile-banner visible-xs abs-centered">
       <a href="https://NoGlobalWarrants.org" target="_blank"><img src="imgs/mobile_txt.png" class="img-responsive abs-centered" /></a>
    </div>
-    
 
-    <script type='text/javascript' src="js/main.js"></script>  
+
+    <script type='text/javascript' src="js/main.js"></script>
   </body>
-</html>
\ No newline at end of file
+</html>



More information about the tor-commits mailing list