On Mon, Dec 5, 2011 at 8:29 AM, Petr Bena benapetr@gmail.com wrote:
Hi,
I have already noted that I work on extension which allows displaying of user online status, see https://bugzilla.wikimedia.org/show_bug.cgi?id=32128, Krinkle come with idea that it could use ajax on user pages for status bar in order to avoid cache issues while keep performance of interface (if cache would need to be suppressed it would have probably negative effect on performance althought it would happen rarely). I like that idea, however I have no experience with ajax. If anyone who understand ajax wanted to help it would be most appreciated!
You'll want to do a little work in three distinct places:
1) Add an API module to return the online state information, or extend ApiQueryUsers to return that info (action=query&list=users&ususers=Username&usprop=online ?)
To write or extend an API module, see docs: https://www.mediawiki.org/wiki/API%3AExtensions
2) Output scaffolding HTML from your existing hook.
Don't do the full lookup and output, but you'll at least need an identifiable spot on the page where you can stick your data once you've loaded it. Make sure that it degrades gracefully if JavaScript is unavailable or disabled! (Don't be afraid to use <noscript>.)
3) Add JavaScript to do the lookup and update the visible state.
For current versions of MediaWiki, the best way to organize client-side JS and CSS scripts is through ResourceLoader modules. See docs:
https://www.mediawiki.org/wiki/ResourceLoader
The actual API hit can be done using jQuery's $.ajax() function, which is much easier than manually dealing with an XMLHTTPRequest object:
http://api.jquery.com/jQuery.ajax/
Feel free to look at other extensions for how they do things (but beware, not all extensions have been modernized to use jQuery and ResourceLoader fully!)
And don't be shy about asking questions in the #mediawiki channel on irc.freenode.net -- we try not to bite!
-- brion vibber (brion @ wikimedia.org / brion @ pobox.com)
Thanks
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l