Mediawiki: Not sure what they want me to do with this Javascript for Monobook

I am trying to get Auto Complete to work in MediaWiki 1.15.1.

From this page it says:


    * Monobook
          o As the code is here, it only works in the Monobook skin. This can be easily changed in the JavaScript.

newdiv.id = "searchsuggest";
var searchdiv = document.getElementById("searchBody");
searchdiv.appendChild(newdiv);

change searchBody of var searchdiv = document.getElementById("searchBody"); to the name of the div you want the results to appear in.


Looking at the files in my Monobook directory I see no Javascript files.

There are a bunch of Javascript files in the Common directory but no clue which, if any, of those I should edit.

Also:

Absolutely no clue what that last bit means: change searchBody of var searchdiv = document.getElementById(“searchBody”); to the name of the div you want the results to appear in.

What is the “div” name I want?

I have been Googling like mad and found little that clears this up so figured I’d go to the place with all the answers.

Thanks in advance!

First you need to add a folder called SearchSuggest and then put SearchSuggest.php in that folder. Then you need to make a file called SearchSuggest.js and put it in the SearchSuggest folder. And also put in SearchSuggest.css (all of the code for these 3 files is on the page you linked to).

The SearchSuggest.js file contains the code they are referring to. The code will be looking for an element on your page with the ID “searchBody” and using that as the target element under which to put the suggestions.

By using the ID “searchBody”, the code is assuming you are using the Monobook skin because that is apparently the ID of an element in the Monobook skin.

If you weren’t using the Monobook skin, you might not have an element with the ID “searchBody” on your site. So, you would want to change the word “searchBody” in that Javascript code to the ID of your search box.

Since you are presumably using the Monobook skin, your search box’s ID is “searchBody” and you don’t need to change anything.

View the source of a page on your site that has a search box. Find the HTML for the search box. It should have an ID. The ID should be “searchBody” but if it’s not, you need to change SearchSuggest.js to use the actual ID of your search box.

Thanks!

Got it working!