Browse code

Move scripts to their own js file

hiromipaw authored on16/06/2017 11:16:38
Showing6 changed files
... ...
@@ -8,81 +8,14 @@
8 8
     <a href="<page index>">Home &raquo; </a>
9 9
     <a href="<page docs/torbutton/index>">Torbutton</a>
10 10
   </div>
11
-	<div id="maincol"> 
11
+	<div id="maincol">
12 12
     <!-- PUT CONTENT AFTER THIS TAG -->
13
-    
13
+
14 14
     <link rel="search" type="application/opensearchdescription+xml" title="Google Canada" href="search/google-ca.xml"/>
15 15
     <link rel="search" type="application/opensearchdescription+xml" title="Google UK" href="search/google-uk.xml"/>
16 16
     <link rel="search" type="application/opensearchdescription+xml" title="Google USA" href="search/google-us.xml"/>
17
-    <script type="text/javascript">
18
-    
19
-    function addSearchProvider(prov) {
20
-    
21
-    try {
22
-    window.external.AddSearchProvider(prov);
23
-    }
24
-    
25
-    catch (e) {
26
-    alert("Search plugins require Firefox 2");
27
-    return;
28
-    }
29
-    }
30
-    
31
-    function addEngine(name,ext,cat,pid)
32
-    {
33
-      if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
34
-        window.sidebar.addSearchEngine(
35
-          "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + ".src",
36
-          "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + "."+ ext, name, cat );
37
-      } else {
38
-        alert("You will need a browser which supports Sherlock to install this plugin.");
39
-      }
40
-    }
41
-    
42
-    function addOpenSearch(name,ext,cat,pid,meth)
43
-    {
44
-      if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
45
-        if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
46
-          alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
47
-        } else {
48
-          window.external.AddSearchProvider(
49
-            "http://mycroft.mozdev.org/installos.php/" + pid + "/" + name + ".xml");
50
-        }
51
-      } else {
52
-        alert("You will need a browser which supports OpenSearch to install this plugin.");
53
-      }
54
-    }
55
-    
56
-    function addOpenSearch2(name,ext,cat,pid,meth)
57
-    {
58
-      if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
59
-        if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
60
-          alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
61
-        } else {
62
-          window.external.AddSearchProvider(
63
-            "http://torbutton.torproject.org/dev/search/" + name + ".xml");
64
-        }
65
-      } else {
66
-        alert("You will need a browser which supports OpenSearch to install this plugin.");
67
-      }
68
-    }
69
-    
70
-    function install (aEvent)
71
-    {
72
-      var params = {
73
-        "Torbutton": { URL: aEvent.target.href,
74
-                 Hash: aEvent.target.getAttribute("hash"),
75
-                 toString: function () { return this.URL; }
76
-        }
77
-      };
78
-      InstallTrigger.install(params);
79
-    
80
-      return false;
81
-    }
82
-    
83
-    
84
-    </script>
85
-    
17
+    <script type="text/javascript" src="$(DOCROOT)/js/functions.js" charset="utf-8"></script>
18
+
86 19
     <h2>Torbutton</h2>
87 20
     <hr>
88 21
 
... ...
@@ -110,12 +43,12 @@
110 43
     repository</a> or simply unzip the xpi.
111 44
     <br/>
112 45
     <strong>Bug Reports:</strong> <a href="https://trac.torproject.org/projects/tor/report/14">Torproject Bug Tracker</a><br/>
113
-    <strong>Documents:</strong> 
114
-    <b>[</b> 
46
+    <strong>Documents:</strong>
47
+    <b>[</b>
115 48
     <a href="https://gitweb.torproject.org/torbutton.git/tree/src/CHANGELOG">changelog</a> <b>|</b>
116 49
     <a href="https://gitweb.torproject.org/torbutton.git/tree/src/LICENSE">license</a> <b>|</b>
117 50
     <a href="https://gitweb.torproject.org/torbutton.git/tree/src/CREDITS">credits</a> <b>]</b>
118
-    
51
+
119 52
   </div>
120 53
   <!-- END MAINCOL -->
121 54
   <div id = "sidecol">
... ...
@@ -126,4 +59,3 @@
126 59
 </div>
127 60
 <!-- END CONTENT -->
128 61
 #include <foot.wmi>
129
-
... ...
@@ -65,10 +65,7 @@
65 65
                 browse the Internet.</p>
66 66
                 </div>
67 67
               </td>
68
-              <td>
69
-                <div class="project">
70
-                <a href="https://guardianproject.info/apps/orbot/"><img
71
-                src="$(IMGROOT)/icon-Orbot.jpg" alt="Orbot Icon"></a>
68
+              <td><meta name="description" content="The Tor Project's free software protects your privacy online. Site blocked? Email [mailto:gettor@torproject.org] for help downloading Tor Browser.">
72 69
                 <h3><a href="https://guardianproject.info/apps/orbot/">Orbot</a></h3>
73 70
                 <p>Tor for Google Android devices.</p>
74 71
                 </div>
... ...
@@ -14,7 +14,7 @@
14 14
   <ifneq "$(REDIRECT)" "" "<meta http-equiv="refresh" content="0;url=$(DOCROOT)/$(REDIRECT)">">
15 15
   <ifneq "$(REDIRECT_GLOBAL)" "" "<meta http-equiv="refresh" content="0;url=$(REDIRECT_GLOBAL)">">
16 16
 
17
-  # begin WML to generate css/js paths 
17
+  # begin WML to generate css/js paths
18 18
   <ifneq "$(STYLESHEET)" "" "<link rel="stylesheet" type="text/css" href="$(DOCROOT)/$(STYLESHEET)">">
19 19
   <ifeq "$(STYLESHEET)" "" "<link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/master.css">">
20 20
 
... ...
@@ -29,17 +29,14 @@
29 29
   <link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/ie6.css">
30 30
   <![endif]-->
31 31
 #  <script language="javascript" type="text/javascript" src="$(DOCROOT)/global.js"></script>
32
-  # end WML to generate css/js paths 
32
+  # end WML to generate css/js paths
33 33
 
34 34
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
35 35
   <meta name="author" content="The Tor Project, Inc.">
36 36
   <meta name="keywords" content="anonymity online, tor, tor project, censorship circumvention, traffic analysis, anonymous communications research">
37 37
 <script type="text/javascript" src="$(DOCROOT)/js/jquery.min.js" charset="utf-8"></script>
38 38
 <script type="text/javascript" src="$(DOCROOT)/js/jquery.infieldlabel.min.js" charset="utf-8"></script>
39
-<script type="text/javascript" charset="utf-8">
40
-/* email placeholder function */
41
-	$(function(){ $("label").replaceWith('<label class="active" for="email">Enter your email address</label>'); $("label").inFieldLabels(); });
42
-</script>
39
+<script type="text/javascript" src="$(DOCROOT)/js/functions.js" charset="utf-8"></script>
43 40
 </head>
44 41
 <body>
45 42
 <div id="wrap">
... ...
@@ -63,9 +60,9 @@
63 60
             my $lang = "$(LANG)";
64 61
 
65 62
             for my $key (@keys) {
66
-              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
63
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
67 64
 
68
-              # in directory of active link, set class active 
65
+              # in directory of active link, set class active
69 66
               my $class;
70 67
               if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
71 68
                 $class = 'class="active"';
... ...
@@ -74,12 +71,12 @@
74 71
               }
75 72
 
76 73
 	            $dir = '.' unless defined $dir;
77
-                
74
+
78 75
               # translated version
79 76
               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
80 77
                   printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
81 78
                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$navigation{$key};
82
-              } 
79
+              }
83 80
               # english version
84 81
               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
85 82
               	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),
108 105
               my $val = shift @calltoaction;
109 106
               push @keys, $key;
110 107
               $calltoaction{$key} = $val;
111
-            } 
108
+            }
112 109
 
113 110
             my $page = $WML_SRC_BASENAME;
114 111
             my $lang = "$(LANG)";
115 112
             for my $key (@keys) {
116
-              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
113
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
117 114
 
118
-              # in directory, set active 
115
+              # in directory, set active
119 116
               my $class;
120 117
               if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
121 118
               #if ($WML_SRC_BASENAME eq $base) {
... ...
@@ -129,7 +126,7 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
129 126
               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
130 127
                   printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
131 128
                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$calltoaction{$key};
132
-              } 
129
+              }
133 130
               # default to english version
134 131
               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
135 132
               	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),
137 134
               } else {
138 135
                 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.";
139 136
               }
140
-            }    
137
+            }
141 138
           }:>
142 139
         </ul>
143 140
       </div>
144 141
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+document.addEventListener("DOMContentLoaded", function(event) {
2
+ var animate = document.getElementById("animate");
3
+ animate.classList.add("not-loaded");
4
+  window.setTimeout(function () {
5
+    animate.classList.remove("not-loaded");
6
+    animate.classList.add("loaded");
7
+  }, 0);
8
+});
0 9
new file mode 100644
... ...
@@ -0,0 +1,65 @@
1
+$(function(){ $("label").replaceWith('<label class="active" for="email">Enter your email address</label>'); $("label").inFieldLabels(); });
2
+
3
+function addSearchProvider(prov) {
4
+
5
+try {
6
+window.external.AddSearchProvider(prov);
7
+}
8
+
9
+catch (e) {
10
+alert("Search plugins require Firefox 2");
11
+return;
12
+}
13
+}
14
+
15
+function addEngine(name,ext,cat,pid)
16
+{
17
+  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
18
+    window.sidebar.addSearchEngine(
19
+      "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + ".src",
20
+      "http://mycroft.mozdev.org/install.php/" + pid + "/" + name + "."+ ext, name, cat );
21
+  } else {
22
+    alert("You will need a browser which supports Sherlock to install this plugin.");
23
+  }
24
+}
25
+
26
+function addOpenSearch(name,ext,cat,pid,meth)
27
+{
28
+  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
29
+    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
30
+      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
31
+    } else {
32
+      window.external.AddSearchProvider(
33
+        "http://mycroft.mozdev.org/installos.php/" + pid + "/" + name + ".xml");
34
+    }
35
+  } else {
36
+    alert("You will need a browser which supports OpenSearch to install this plugin.");
37
+  }
38
+}
39
+
40
+function addOpenSearch2(name,ext,cat,pid,meth)
41
+{
42
+  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
43
+    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
44
+      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
45
+    } else {
46
+      window.external.AddSearchProvider(
47
+        "http://torbutton.torproject.org/dev/search/" + name + ".xml");
48
+    }
49
+  } else {
50
+    alert("You will need a browser which supports OpenSearch to install this plugin.");
51
+  }
52
+}
53
+
54
+function install (aEvent)
55
+{
56
+  var params = {
57
+    "Torbutton": { URL: aEvent.target.href,
58
+             Hash: aEvent.target.getAttribute("hash"),
59
+             toString: function () { return this.URL; }
60
+    }
61
+  };
62
+  InstallTrigger.install(params);
63
+
64
+  return false;
65
+}
... ...
@@ -12,18 +12,9 @@
12 12
     <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
13 13
     <script type="text/javascript" src="js/easyXDM.min.js"></script>
14 14
     <script type='text/javascript' src="js/modernizr.min.js"></script>
15
-    <script type='text/javascript' src="js/css3-mediaqueries.js"></script>   
16
-     <script type="text/javascript">
15
+    <script type='text/javascript' src="js/css3-mediaqueries.js"></script>
16
+    <script type="text/javascript" src="js/animate.js"></script>
17 17
 
18
-      document.addEventListener("DOMContentLoaded", function(event) {
19
-       var animate = document.getElementById("animate");
20
-       animate.classList.add("not-loaded");
21
-        window.setTimeout(function () {
22
-          animate.classList.remove("not-loaded");
23
-          animate.classList.add("loaded");
24
-        }, 0);
25
-      });
26
-    </script>
27 18
     <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
28 19
     <!--[if lt IE 9]>
29 20
       <script type='text/javascript' src="js/html5.js"></script>
... ...
@@ -71,8 +62,8 @@
71 62
    <div class="mobile-banner visible-xs abs-centered">
72 63
       <a href="https://NoGlobalWarrants.org" target="_blank"><img src="imgs/mobile_txt.png" class="img-responsive abs-centered" /></a>
73 64
    </div>
74
-    
75 65
 
76
-    <script type='text/javascript' src="js/main.js"></script>  
66
+
67
+    <script type='text/javascript' src="js/main.js"></script>
77 68
   </body>
78
-</html>
79 69
\ No newline at end of file
70
+</html>