mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
FastAPI: use internal typeahead and remove jquery
Awesome! Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
2835dd89ea
commit
3a74f76ff9
6 changed files with 20 additions and 35 deletions
|
@ -93,4 +93,14 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap typeahead for the homepage. -->
|
||||
<script type="text/javascript" src="/static/js/typeahead-home.js"></script>
|
||||
|
||||
<!-- Stub inline javascript with a nonce. Used for testing purposes. -->
|
||||
<script type="text/javascript" nonce={{ request.user.nonce }}>
|
||||
function NONEXISTENT() {}
|
||||
NONEXISTENT();
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -12,5 +12,8 @@
|
|||
<link rel="alternate" type="application/rss+xml"
|
||||
title="Newest Packages RSS" href="/rss/">
|
||||
|
||||
<!-- Include local typeahead -->
|
||||
<script type="text/javascript" src="/static/js/typeahead.js"></script>
|
||||
|
||||
<title>AUR ({{ language }}) - {{ title | tr }}</title>
|
||||
</head>
|
||||
|
|
|
@ -6,6 +6,5 @@
|
|||
<body>
|
||||
{% include 'partials/navbar.html' %}
|
||||
{% extends 'partials/body.html' %}
|
||||
{% include 'partials/typeahead.html' %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/bootstrap-typeahead.min.js"></script>
|
||||
<script type="text/javascript" nonce="{{ request.user.nonce }}">
|
||||
$(document).ready(function() {
|
||||
$('#pkgsearch-field').typeahead({
|
||||
source: function(query, callback) {
|
||||
$.getJSON('/rpc', {type: "suggest", arg: query}, function(data) {
|
||||
callback(data);
|
||||
});
|
||||
},
|
||||
matcher: function(item) { return true; },
|
||||
sorter: function(items) { return items; },
|
||||
menu: '<ul class="pkgsearch-typeahead"></ul>',
|
||||
items: 20,
|
||||
updater: function(item) {
|
||||
document.location = '/packages/' + item;
|
||||
return item;
|
||||
}
|
||||
}).attr('autocomplete', 'off');
|
||||
|
||||
$('#pkgsearch-field').keydown(function(e) {
|
||||
if (e.keyCode == 13) {
|
||||
var selectedItem = $('ul.pkgsearch-typeahead li.active');
|
||||
if (selectedItem.length == 0) {
|
||||
$('#pkgsearch-form').submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue