Last modified: 2010-11-12 20:22:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 6806 - JavaScript tidbits - things to make custom JS easier
JavaScript tidbits - things to make custom JS easier
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2006-07-24 18:49 UTC by Daniel Kinzler
Modified: 2010-11-12 20:22 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

partial patch (4.49 KB, patch)
2006-07-24 23:53 UTC, Lupin

Description Daniel Kinzler 2006-07-24 18:49:29 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)

Perhaps a convenience function for encoding would be nice - like javascript's
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
and all):

* 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
Comment 1 Lupin 2006-07-24 23:53:00 UTC
Created attachment 2146 [details]
partial patch

This patch resolves bug 6030 and the page-specific stuff from this bug.
Comment 2 Daniel Kinzler 2006-07-28 19:08:19 UTC
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.
Comment 3 Daniel Kinzler 2006-07-30 12:00:32 UTC
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.
Comment 4 Joshua C. Lerner 2007-10-05 19:51:36 UTC
Patch to add variables describing the page with the redirect can found at
Comment 5 DieBuche 2010-11-12 20:22:28 UTC
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)

Note You need to log in before you can comment on or make changes to this bug.