Skip to content
Myr

Move all javascript to end of body

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 7f87785 · Browse files · 4 files+36 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+36 added−34 removed

  • other:+36 added−34 removed

4 files+36 added−34 removed

added:docs/public/js/manual-search.js+20 added
modified:docs/templates/shared/_footer.liquid+4 added
1 unmodified line
2 <div class="container">3 {{ footer | markdownify }}4 </div>5</footer>67<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>8<script src="{{root}}/bootstrap/js/bootstrap.min.js"></script>9<script src="{{root}}/js/bootstrap3-typeahead.js"></script>
modified:docs/templates/shared/_head.liquid-3 removed
7 unmodified lines
8 <!--[if lt IE 9]>9 <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>10 <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>11 <![endif]-->12 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>13 <script src="{{root}}/bootstrap/js/bootstrap.js"></script>14 <script src="{{root}}/js/bootstrap3-typeahead.js"></script>12</head>
modified:docs/templates/manual.liquid+12 added-31 removed
15 unmodified lines
16 </li>17 {% endfor %}18 </ul>19 <form class="form-group">20 <script type="text/javascript">21 var section_map = {22 {% for section in sections %}23 {% for entry in section.entries %}24 {{entry.title | json}} : {{entry.title | sanitize | json}},25 {% endfor %}26 {{section.title | json}} : {{section.title | sanitize | json}}27 {% unless forloop.last %},{% endunless %}28 {% endfor %}29 };30 var section_names = $.map(section_map, function(v,k){return k});31 $(function(){32 $('#searchbox').typeahead({source: section_names})33 $('#searchbox').change(function() {34 if ($(this).val() in section_map) {35 location.hash = '#' + section_map[$(this).val()];36 }37 });38 });39 // add "Run" button to execute examples on jqplay.org40 $(function() {41 $.each($('table.manual-example'), function(index, value) {42 $value = $(value)43 var j = $value.find('tr:nth-child(2) td:first').text();44 var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');45 var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)46 var $last_tr = $value.find('tr:last');47 $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>');48 });49 });50 </script>20 <input type="text"21 class="form-control"22 placeholder="Search"23 autocomplete="off"
60 unmodified lines
84 </div>85 </div>8687 {% include "shared/footer" %}88 <script>89 var section_map = {90 {% for section in sections %}91 {% for entry in section.entries %}92 {{entry.title | json}} : {{entry.title | sanitize | json}},93 {% endfor %}94 {{section.title | json}} : {{section.title | sanitize | json}}95 {% unless forloop.last %},{% endunless %}96 {% endfor %}97 };98 </script>99 <script src="{{root}}/js/manual-search.js"></script>100 </body>101</html>