JKey to Gadget and ResourceLoader
Notes on porting the jKey to a gadget and using mediawiki ResourceLoader:
See http://www.mediawiki.org/wiki/Gadgets
Gadgets are defined on a special mediawiki page like: http://commons.wikimedia.org/wiki/MediaWiki:Gadgets-definition
Gadgets can be system gadgets that are invisible to users. By defining rights = hidden (where there is no such group "hidden" defined) a gadget can be made non-selectable by users, e.g. libCommons [ResourceLoader|rights=hidden|hidden]|libCommons.js
It is possible to have gadgets that run only under certain conditions, like a html class name present on the current page. This requires a jquery code checking for the presence of such a class, and then loading the gadget.
http://www.mediawiki.org/wiki/ResourceLoader/Developing_with_ResourceLoader#Client-side_.28dynamically.29
recommends: "If you only need a module in a certain scenario of the user interface, you could instead create a small init module (that is loaded server side), and from there use JavaScript to kick-off the load of the rest of the module when necessary. Use the mw.loader object for this. mw.loader.using( 'example.fooBar', function () { /* This callback is invoked as soon as the example.fooBar is ready */ } );
Tip: If you just want to load the module, and don't need the callback, you can use mw.loader.load( 'example.fooBar' );
instead."
The relation between gadget and resource loader at present is yet poorly documented. The Gadget definition must have a special attribute ResourceLoader to mark it as compatible with resource loader.
Centralization example
http://en.wikipedia.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=edit contains:
mw.loader.load( '//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' );
that is it externally loads the centralized http://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock.js
Inserting the code directly into a same named test-wiki gadget http://biowikifarm.net/test/MediaWiki:Gadget-UTCLiveClock.js and adding to http://biowikifarm.net/test/MediaWiki:Gadgets-definition and enabling for a given user worked ok.