Author: malrase
Description:
Is it possible to have a "suggested searches" thing for the search box? I.e. typing "Fra-" gives "France" as one of the first ones, or something.
Version: unspecified
Severity: enhancement
• bzimport | |
Jul 27 2009, 5:39 PM |
F5771: testwiki.zip | |
Nov 21 2014, 10:39 PM |
Author: malrase
Description:
Is it possible to have a "suggested searches" thing for the search box? I.e. typing "Fra-" gives "France" as one of the first ones, or something.
Version: unspecified
Severity: enhancement
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | Feature | None | T29411 Search Suggest bugs (tracking) | ||
Resolved | None | T21956 Suggestions in search for Wikipedia Mobile | |||
Resolved | None | T34082 MobileFrontend beta search suggestions don't start suggesting when expected on Firefox |
admin wrote:
The source code for a working example
This is a problem made easy by Wikipedia's existing API. I have a working example (modified after mobile.wikipedia.org) at http://rossbender.com/temp/testwiki/ - try it on your mobile phone! See also my personal site's example (a stripped down version): http://rossbender.com/random/wikipedia/
The changes attached are minimal to the already existing page at mobile.wikipedia.org. I'm using that as comparison instead of en.m.wikipedia.org for simplicity's sake only--the changes would be similar there. If you compare the HTML source from mobile.wikipedia.org with the source attached that you will see I have only added 4 lines in the <head> (meta tag for mobile compatibility, 1 link to an external stylesheet, and 2 links to external Javascript files) and 1 line in the <body> (results div).
(Note that the wikiapi.php file is only necessary on my server because I cannot do cross-domain XML requests in Javascript. So the wikiapi.php file simply returns the results of the Wikipedia API results.)
I personally prefer the results being displayed as part of the page, but adding the same effect to a dropdown box is not difficult using http://jqueryui.com/demos/autocomplete/. For my own personal site I had actually started with that but preferred to opt for the more simplistic version.
I would be happy to help out with this where necessary. Autocomplete for search engines nowadays is basically a must (read more on my thoughts here: http://rossbender.com/2011/09/25/mobile-wikipedia-search/).
Let me know if there's anything more I can do to help. Thanks!
Attached:
preilly wrote:
Ross great work!
How hard do you think it would be to remove the dependency on jQuery?
admin wrote:
I updated the page at http://www.rossbender.com/temp/testwiki/ to be jQuery independent (see the JavaScript file at http://www.rossbender.com/temp/testwiki/main.js compared to the old one: http://www.rossbender.com/temp/testwiki/mainJquery.js ).
I removed a few "nice-ities" such as the window automatically scrolling to the top as well as the colored background on a touch event. They wouldn't be super difficult to add back in but I figured those would be more of a site-wide design rather than through the plugin.
Feature is out in beta: http://blog.wikimedia.org/2011/10/27/wikimedia-mobile-opt-in-beta/