github.com/wynshop-open-source/gomplate@v3.5.0+incompatible/docs/layouts/partials/footer_js.html (about) 1 <script> 2 {{ with .Scratch.Get "repo_id" }} 3 var base_url = '{{ (printf "%s" $.Site.BaseURL) | safeJS }}'; 4 var repo_id = '{{ . | safeJS }}'; 5 {{ else }} 6 var base_url = ''; 7 var repo_id = ''; 8 {{ end }} 9 </script> 10 11 <script src="{{ "js/application.js" | absURL }}"></script> 12 {{ range .Site.Params.custom_js }} 13 <script src="{{ . | absURL }}"></script> 14 {{ end }} 15 16 <script> 17 {{ "/* Add headers to scrollspy */" | safeJS }} 18 var headers = document.getElementsByTagName("h2"); 19 var scrollspy = document.getElementById('scrollspy'); 20 21 if(scrollspy) { 22 if(headers.length > 0) { 23 for(var i = 0; i < headers.length; i++) { 24 var li = document.createElement("li"); 25 li.setAttribute("class", "anchor"); 26 27 var a = document.createElement("a"); 28 a.setAttribute("href", "#" + headers[i].id); 29 a.setAttribute("title", headers[i].innerHTML); 30 a.innerHTML = headers[i].innerHTML; 31 32 li.appendChild(a) 33 scrollspy.appendChild(li); 34 } 35 } else { 36 scrollspy.parentElement.removeChild(scrollspy) 37 } 38 39 40 {{ "/* Add permanent link next to the headers */" | safeJS }} 41 var headers = document.querySelectorAll("h1, h2, h3, h4, h5, h6"); 42 43 for(var i = 0; i < headers.length; i++) { 44 var a = document.createElement("a"); 45 a.setAttribute("class", "headerlink"); 46 a.setAttribute("href", "#" + headers[i].id); 47 a.setAttribute("title", "Permanent link") 48 a.innerHTML = {{ or .Site.Params.permalink "ΒΆ" }}; 49 headers[i].appendChild(a); 50 } 51 } 52 </script> 53 54 {{ with .Site.GoogleAnalytics }} 55 <script> 56 (function(i,s,o,g,r,a,m){ 57 i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q|| 58 []).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 59 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g; 60 m.parentNode.insertBefore(a,m) 61 })(window, document, 62 'script', '//www.google-analytics.com/analytics.js', 'ga'); 63 /* General initialization */ 64 ga('create', '{{ . }}', 'auto'); 65 ga('set', 'anonymizeIp', true); 66 ga('send', 'pageview'); 67 /* Track outbound links */ 68 var buttons = document.querySelectorAll('a'); 69 Array.prototype.map.call(buttons, function(item) { 70 if (item.host != document.location.host) { 71 item.addEventListener('click', function() { 72 var action = item.getAttribute('data-action') || 'follow'; 73 ga('send', 'event', 'outbound', action, item.href); 74 }); 75 } 76 }); 77 /* Register handler to log search on blur */ 78 var query = document.querySelector('.query'); 79 query.addEventListener('blur', function() { 80 if (this.value) { 81 var path = document.location.pathname; 82 ga('send', 'pageview', path + '?q=' + this.value); 83 } 84 }); 85 </script> 86 {{ end }} 87 88 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script> 89 <script>hljs.initHighlightingOnLoad();</script> 90 </body> 91 </html>