mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Move all javascript to end of body
This commit is contained in:
20
docs/public/js/manual-search.js
Normal file
20
docs/public/js/manual-search.js
Normal file
@@ -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>');
|
||||||
|
});
|
||||||
|
});
|
||||||
43
docs/templates/manual.liquid
vendored
43
docs/templates/manual.liquid
vendored
@@ -17,37 +17,6 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<form class="form-group">
|
<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"
|
<input type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
@@ -116,5 +85,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include "shared/footer" %}
|
{% 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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
4
docs/templates/shared/_footer.liquid
vendored
4
docs/templates/shared/_footer.liquid
vendored
@@ -3,3 +3,7 @@
|
|||||||
{{ footer | markdownify }}
|
{{ footer | markdownify }}
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</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>
|
||||||
|
|||||||
3
docs/templates/shared/_head.liquid
vendored
3
docs/templates/shared/_head.liquid
vendored
@@ -9,7 +9,4 @@
|
|||||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
<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>
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||||
<![endif]-->
|
<![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>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user