Fix #3214: Add autocomplete for saved searches.

* Autocomplete the `search:<label>` metatag.

* Make label autocompletion do a prefix match instead of a substring
  match. Example: `search:ar` matches `artists`, not `characters`. This
  is how tags and most other things are autocompleted.
This commit is contained in:
evazion
2017-07-11 19:17:22 -05:00
parent dc079d7932
commit 51d0feb2c6
3 changed files with 37 additions and 18 deletions

View File

@@ -1,5 +1,16 @@
$(document).ready(function() {
Danbooru.SavedSearch = {};
Danbooru.SavedSearch.initialize_all = function() {
if ($("#c-saved-searches".length)) {
Danbooru.sorttable($("#c-saved-searches table"));
}
});
}
Danbooru.SavedSearch.labels = function(term) {
return $.getJSON("/saved_searches/labels", {
"search[label]": term + "*",
"limit": 10
});
}
$(Danbooru.SavedSearch.initialize_all);