I also wanted to make add search autocomplete.
I found out that autocomplete option is already built in the code, and is used when someone is asking (not searching) a question on the ask page.
I added a search box to my theme's hearder (you may alrady have your search box somewhere)
<input type="text" placeholder="Find your answer..." name="q" onkeyup="qa_title_change_search(this.value);" autocomplete="off" required>
Then I added the a span which will display the suggested questions just below the search box:
<span id="similar_search"></span>
Now I went to qa-ask.js and based on this function "qa_title_change"(which is used for the autocomplete while asking a question) I careated the function: "qa_title_change_search"
function qa_title_change_search(value) {
qa_ajax_post('asktitle', { title: value }, function (lines) {
if (lines[0] == '1') {
if (lines[1].length) {
qa_tags_examples = lines[1];
qa_tag_hints(true);
}
if (lines.length > 2) {
var simelem = document.getElementById('similar_search');
if (simelem)
simelem.innerHTML = lines.slice(2).join('\n');
}
} else if (lines[0] == '0')
alert(lines[1]);
else
qa_ajax_error();
});
qa_show_waiting_after(document.getElementById('similar_search'), true);
}
If you want to change the line displayed before the suggested questions, you can look for "ask_same_q" in qa-lan-question.php (be default it is: "Before proceeding, please check your question was not asked already:")