On Wed, May 6, 2015 at 9:06 PM, Brad Jorsch (Anomie) <bjorsch(a)wikimedia.org>
wrote:
On Wed, May 6, 2015 at 1:31 PM, Jack Phoenix
<jack(a)countervandalism.net>
wrote:
I'm trying to build an autocompletion thingy
that suggests categories
based
on user input using the opensearch API [1].
Sounds like
https://en.wikipedia.org/wiki/Wikipedia:HotCat
Something like that, although not quite complicated. HotCat's current
version is ~3k lines of code, my JS is ~40 lines.
How can I totally strip out the "Category:"
part and pretend it doesn't exist and never
did?
Hit api.php?action=query&meta=siteinfo&siprop=namespaces to get the
localized name of the Category namespace. Or you should be safe just
removing everything up to the first colon.
Yeah, probably better to avoid the extra HTTP request.
In any case, I managed to solve my issue for the time being, or so I
think. Defining a "response" callback and fiddling with the API-supplied
data there seems to do the trick:
https://www.mediawiki.org/w/index.php?title=User%3AJack_Phoenix%2FAutocompl…
It does still feel a tad bit hacky to me, so if some JavaScript guru knows
of the proper way to do this, feel free to let me know! But at least now I
can safely throw out some old and icky code in favor of this new code. :)
Thanks and regards,
--
Jack Phoenix
MediaWiki developer