summaryrefslogtreecommitdiff
path: root/templates/public
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-09-24 20:15:54 -0500
committerDan McGee <dan@archlinux.org>2012-09-24 20:25:45 -0500
commitd69e30cbf2cd76bdf87de138db030209ca43b2e1 (patch)
tree88c71333f2880eadaf78e5ce349e1b04db2bbfdc /templates/public
parentddaab159ad5e8735fae7f8d29301181009478d1b (diff)
Add typeahead dropdown to front page packages search
This uses the existing OpenSearch query endpoint to perform the search and displays the results accordingly. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'templates/public')
-rw-r--r--templates/public/index.html18
1 files changed, 18 insertions, 0 deletions
diff --git a/templates/public/index.html b/templates/public/index.html
index 60ae442d..4af5995e 100644
--- a/templates/public/index.html
+++ b/templates/public/index.html
@@ -215,4 +215,22 @@
</div>
{% endcache %}
+
+{% load cdn %}{% jquery %}
+<script type="text/javascript" src="{% static "bootstrap-typeahead.js" %}"></script>
+<script type="text/javascript">
+$(document).ready(function() {
+ $('#pkgsearch-field').typeahead({
+ source: function(query, callback) {
+ $.getJSON('/opensearch/packages/suggest', {q: query}, function(data) {
+ callback(data[1]);
+ });
+ },
+ matcher: function(item) { return true; },
+ sorter: function(items) { return items; },
+ menu: '<ul class="pkgsearch-typeahead"></ul>',
+ items: 10
+ }).attr('autocomplete', 'off');
+});
+</script>
{% endblock %}