Last modified: 2010-11-12 20:22:28 UTC
Here are a few things that would make it much easier to hook in custom JS code,
integrate external tools, etc. Most of it should be quite trivial to add.
Page specific stuff (should be set in a <script> tag in the html header):
* page name, encoded (with namespace, not encoded, with blanks, as in
the visible page title)
* page title (the same, without namespace)
* page namespace (canonical name)
* numeric page id (for external tools that have access to the database - like
things on the toolserver)
encode, but with space-to-underscore.
In case of a redirect, the above should reflect the page that is actually shown.
Maybe the page that contains the redirect should be available too, not sure.
User specific stuff (could be set in a <script> tag in the html header, or
referenced there like the user js page; probably the latter, what with caching
* user name (with whitespace - should be null or false for anons)
* user lang (should also work for anons)
* user skin (maybe - since js code is skin-specific already, this is not
really needed. But it may be nice to have anyway)
* a onHtmlLoad (or similar) hook, analogous to onLoad, triggered near the end of
html output. There should be an addHtmlOnloadHook analogous to addOnloadHook as
defined in wikibits.js (there's also something in upload.js - not sure why)
Conveniance functions for injecting things would also be nice. Especially:
* addTab for injecting a tab
* addTool for injecting into the toolbox
* maybe addPersonalTool for injecting into the personal toolbar (that has my
talk, preferences, etc)
Generally, it may be a good idea to introduce an MediaWiki:common.js page,
analogous to common.css
Created attachment 2146 [details]
This patch resolves bug 6030 and the page-specific stuff from this bug.
page and user variables added as of r15871, utility functions are pending.
I did not use the patch provided, because it added the variables after the
user and site JS had already been executed. It's more useful to have those
values from the very beginning.
As of r15883, onload hooks are called at the end if the html body, in all skins.
Utility functions for adding tabs, etc are pending. Note sure how to do this
consistently for all skins.
Patch to add variables describing the page with the redirect can found at http://bugzilla.wikimedia.org/show_bug.cgi?id=11040.
All of these are done imo.
we got wgUserName etc.
And there's addPortletLink()
As well as a common.js (even a user one with r63300)