Move google analytics and scrolling code into main.js
authorMagnus Hagander <magnus@hagander.net>
Thu, 20 Dec 2018 14:47:24 +0000 (15:47 +0100)
committerMagnus Hagander <magnus@hagander.net>
Fri, 21 Dec 2018 13:14:03 +0000 (14:14 +0100)
This moves the remaining inline javascript out of the base templates

media/js/main.js
templates/base/base.html
templates/docs/docspage.html

index ac9eb87df823b86b811a4e4c94398fc938e3aa77..5a360bd8b8c9b28895b5511341b517cc2d235d83 100644 (file)
@@ -4,6 +4,25 @@ $(document).ready(function() {
   });
 });
 
+/*
+ * Initialize google analytics
+ */
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-1345454-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+
+/*
+ * Fix scrolling of anchor links
+ */
+var shiftWindow = function() { scrollBy(0, -80) };
+if (location.hash) shiftWindow();
+window.addEventListener("hashchange", shiftWindow);
+
 
 /*
  * Debian/Ubuntu download dropdowns
index 3ae7f7d305b1321e5724bd668865d9e1114937e8..3d4214e470e0729cd6c485e4c2f8f6663bc2bd98 100644 (file)
     <script src="/media/js/bootstrap.min.js?{{gitrev}}"></script>
     <script src="/media/js/main.js?{{gitrev}}"></script>
 {%block extrascript%}{%endblock%}
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-1345454-1']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
-    <script type="text/javascript">
-      var shiftWindow = function() { scrollBy(0, -80) };
-      if (location.hash) shiftWindow();
-      window.addEventListener("hashchange", shiftWindow);
-    </script>
   </body>
 </html>
index e162bd9ec5bf01ac7d5f188ce1347b0f1208e657..a5ec65e3aabc86edb22285340472d2f1f5b2f085 100644 (file)
     <script src="/media/js/popper.min.js?{{gitrev}}"></script>
     <script src="/media/js/bootstrap.min.js?{{gitrev}}"></script>
     <script src="/media/js/main.js?{{gitrev}}"></script>
-    <script type="text/javascript">
-      var _gaq = _gaq || [];
-      _gaq.push(['_setAccount', 'UA-1345454-1']);
-      _gaq.push(['_trackPageview']);
-      (function() {
-        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-      })();
-    </script>
-    <script type="text/javascript">
-      var shiftWindow = function() { scrollBy(0, -80) };
-      if (location.hash) shiftWindow();
-      window.addEventListener("hashchange", shiftWindow);
-    </script>
   </body>
 </html>