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
Provenance
- Commit
bd46a5d- Tree
3ab6518- Author
David Tolnay <dtolnay@gmail.com>- Committer
David Tolnay <dtolnay@gmail.com>- Parent
7f87785
4 files changed+36 added−34 removed
added:docs/public/js/manual-search.js+20 added
1234567891011121314151617181920var 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>'); });});modified:docs/templates/shared/_footer.liquid+4 added
1 unmodified line2 <div class="container">3 {{ footer | markdownify }}4 </div>5 </footer>6+7+<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 lines8 <!--[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 lines16 </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 lines84 </div>85 </div>86 87 {% 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>