]> granicus.if.org Git - jq/commitdiff
Move all javascript to end of body
authorDavid Tolnay <dtolnay@gmail.com>
Fri, 14 Aug 2015 06:00:54 +0000 (23:00 -0700)
committerDavid Tolnay <dtolnay@gmail.com>
Fri, 14 Aug 2015 06:00:54 +0000 (23:00 -0700)
docs/public/js/manual-search.js [new file with mode: 0644]
docs/templates/manual.liquid
docs/templates/shared/_footer.liquid
docs/templates/shared/_head.liquid

diff --git a/docs/public/js/manual-search.js b/docs/public/js/manual-search.js
new file mode 100644 (file)
index 0000000..59e7792
--- /dev/null
@@ -0,0 +1,20 @@
+var section_names = $.map(section_map, function(v,k){return k});
+$(function(){
+  $('#searchbox').typeahead({source: section_names})
+  $('#searchbox').change(function() {
+    if ($(this).val() in section_map) {
+      location.hash = '#' + section_map[$(this).val()];
+    }
+  });
+});
+// add "Run" button to execute examples on jqplay.org
+$(function() {
+  $.each($('table.manual-example'), function(index, value) {
+    $value = $(value)
+    var j = $value.find('tr:nth-child(2) td:first').text();
+    var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');
+    var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
+    var $last_tr = $value.find('tr:last');
+    $last_tr.after('<tr><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
+  });
+});
index f4240658d7928ab4ca2d04759b3f9c2180794067..51e4f13bbe2bbaa8189b2dc4d5ff68f84998696f 100644 (file)
             {% endfor %}
           </ul>
           <form class="form-group">
-            <script type="text/javascript">
-              var section_map = {
-                {% for section in sections %}
-                  {% for entry in section.entries %}
-                    {{entry.title | json}} : {{entry.title | sanitize | json}},
-                  {% endfor %}
-                  {{section.title | json}} : {{section.title | sanitize | json}}
-                  {% unless forloop.last %},{% endunless %}
-                {% endfor %}
-              };
-              var section_names = $.map(section_map, function(v,k){return k});
-              $(function(){
-                $('#searchbox').typeahead({source: section_names})
-                $('#searchbox').change(function() {
-                  if ($(this).val() in section_map) {
-                    location.hash = '#' + section_map[$(this).val()];
-                  }
-                });
-              });
-              // add "Run" button to execute examples on jqplay.org
-              $(function() {
-                $.each($('table.manual-example'), function(index, value) {
-                  $value = $(value)
-                  var j = $value.find('tr:nth-child(2) td:first').text();
-                  var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');
-                  var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
-                  var $last_tr = $value.find('tr:last');
-                  $last_tr.after('<tr><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
-                });
-              });
-            </script>
             <input type="text"
                   class="form-control"
                   placeholder="Search"
     </div>
 
     {% include "shared/footer" %}
+    <script>
+      var section_map = {
+        {% for section in sections %}
+          {% for entry in section.entries %}
+            {{entry.title | json}} : {{entry.title | sanitize | json}},
+          {% endfor %}
+          {{section.title | json}} : {{section.title | sanitize | json}}
+          {% unless forloop.last %},{% endunless %}
+        {% endfor %}
+      };
+    </script>
+    <script src="{{root}}/js/manual-search.js"></script>
   </body>
 </html>
index 0e50c133ba6113bf146f6a2316fc64b0e2d7bc30..7623c4b4779c6fd9bf2069e9f0ef9b4ab77807d2 100644 (file)
@@ -3,3 +3,7 @@
     {{ footer | markdownify }}
   </div>
 </footer>
+
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
+<script src="{{root}}/bootstrap/js/bootstrap.min.js"></script>
+<script src="{{root}}/js/bootstrap3-typeahead.js"></script>
index c5ed22e19d3c0ef26493264790d782cdf34e36f8..59e4b19d58a24a6e89ba890885e34a7696f82385 100644 (file)
@@ -9,7 +9,4 @@
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
   <![endif]-->
-  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
-  <script src="{{root}}/bootstrap/js/bootstrap.js"></script>
-  <script src="{{root}}/js/bootstrap3-typeahead.js"></script>
 </head>