Last modified: 2011-03-19 19:49:30 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 4178 - Add MediaWiki:Common.js file, similar to MediaWiki:Common.css
Add MediaWiki:Common.js file, similar to MediaWiki:Common.css
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
unspecified
All All
: Normal enhancement with 13 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 7072 (view as bug list)
Depends on:
Blocks: javascript
  Show dependency treegraph
 
Reported: 2005-12-05 07:29 UTC by Jelte (WebBoy)
Modified: 2011-03-19 19:49 UTC (History)
3 users (show)

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


Attachments

Description Jelte (WebBoy) 2005-12-05 07:29:25 UTC
Is it possible to make a [[MediaWiki:Common.js]] just like [[MediaWiki:Common.css]]?
Comment 1 Rob Church 2005-12-05 07:34:36 UTC
Creating it would be possible. Do you mean, "would it have an effect?" I don't
believe so; not in the current incarnation.
Comment 2 Jelte (WebBoy) 2005-12-05 07:38:25 UTC
Yes, I have made one (on nl.wikipedia.org) but it doesn't work. :-(

It would be nice when it works.
Comment 3 Rob Church 2005-12-05 07:43:32 UTC
Changing to a feature request...
Comment 4 lɛʁi לערי ריינהארט 2005-12-05 19:25:06 UTC
Hallo!

[[en:MediaWiki:Common.css]] does not list inside [[en:Special:Allmessages]].
Should it?

regards reinhardt [[user:gangleri]]
Comment 5 Omegatron 2006-08-18 14:22:58 UTC
This could be fixed simply by adding a few lines to wikibits.js:

document.write('<scr' + 'ipt type="text/javascript"
src="http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr'
             + 'ipt>');
Comment 6 Dan Li 2006-08-18 20:06:32 UTC
You could also easily add this functionality in an extension:
http://en.wikipedia.org/wiki/User:Dto/CommonJSext
Comment 7 Dan Li 2006-08-18 23:20:09 UTC
(In reply to comment #6)
> You could also easily add this functionality in an extension:
> http://en.wikipedia.org/wiki/User:Dto/CommonJSext

Oops. Not quite. As far as I can tell, the BeforePageDisplay hook is only called
by SkinTemplate, and the standard/classic skin doesn't extend that.
Comment 8 Dan Li 2006-08-18 23:30:46 UTC
OK. Rewrote http://en.wikipedia.org/wiki/User:Dto/CommonJSext so that it works
independent of the current skin.
Comment 9 Karl Dickman 2006-08-18 23:51:18 UTC
Dan, I take it that said extension would have to be added to MediaWiki, and
couldn't be done client-side?
Comment 10 Dan Li 2006-08-18 23:55:15 UTC
(In reply to comment #9)
> Dan, I take it that said extension would have to be added to MediaWiki, and
> couldn't be done client-side?

Yeah, and so does everything else, I believe. If something is going to affect
every Wikipedia user, something in MediaWiki has to change, as far as I can tell.
Comment 11 Dan Li 2006-08-20 06:47:58 UTC
*** Bug 7072 has been marked as a duplicate of this bug. ***
Comment 12 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-11-16 06:19:26 UTC
Okay, Brion is apparently concerned with the possibility of adding more
unnecessary server hits.  Ideally I suppose all the JS should be merged via PHP
into a single <script>, so that only one server hit occurs, but in lieu of that,
why not just ditch Monobook.js in favor of Common.js (in a backwards-compatible
way)?  Why does Monobook need a separate script file anyway?  If someone
actually wants to do separate stuff for Monobook, we have handy variables for that.

Anyone object to this?  I'd probably just add lines to both Monobook and
Skin.php to the effect of using Common.js if it exists, otherwise Monobook.js
(as a deprecated fallback).
Comment 13 Karl Dickman 2006-11-16 06:39:02 UTC
(In reply to comment #12)
>why not just ditch Monobook.js in favor of Common.js (in a backwards-compatible
>way)? Why does Monobook need a separate script file anyway? If someone
>actually wants to do separate stuff for Monobook, we have handy variables for that.

If I interpret some of what Simetrical says correctly, then it is possible to
collect scripts from all skins into a single repository; however, some scripts
would only work in certain skins, through the use of "hand variables".

If I interpret his proposal correctly, then I wholeheartedly support it.  I
believe that this will be a useful step in providing better accommodation for
those of us who don't use the monobook skin.

Also, if I interpret Simetrical's proposal correctly, it would supersede the
need for a solution to Bug 6377.
Comment 14 Cesar Eduardo Barros 2006-11-16 13:53:52 UTC
I don't see why it would add more server hits; AFAIK, currently Monobook.js is
output from "/w/index.php?title=-&action=raw&gen=js", together with a couple of
extra variables; you could simply output Common.js together with it. Unless I'm
misunderstanding something, it wouldn't add any new server hits.
Comment 15 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-11-17 02:06:21 UTC
D'oh.  You're right, of course.  No problem, then: added in r17737.
Comment 16 Karl Dickman 2006-11-17 11:02:38 UTC
Regarding comment #12: are the "handy variables" PHP variables or Javascript
variables?  If the latter, then I interpret Simetrical's comment to mean that
there is a way to specify which skin a particular function in
[[MediaWiki:Common.js]] would be executed in.

If this reading is true, then the Common repository would supersede any other
skin-specific repository, and obviate the need for a solution to Bug 6377.

Did I read correctly?  I have to admit that I'm not much of techie.
Comment 17 Aryeh Gregor (not reading bugmail, please e-mail directly) 2006-11-17 12:50:18 UTC
You read correctly.  The variable "skin" is provided in JavaScript on every page
and should be available to any script writers, and yes, I noted in a couple of
places that Monobook.js is deprecated (although not until I get around to
removing all those tooltips from it ;) ).
Comment 18 Brion Vibber 2008-06-03 20:42:42 UTC
Just a note for posterity -- I've removed those deprecation notices; MediaWiki:Monobook.js and fellows are perfectly suitable for genuinely skin-specific JS... and it is indeed served along with MediaWiki:Common.js in the same server request (but only to those actually using that skin).

While general code does belong in Common.js, there's nothing wrong with using the specific ones when it's suitable.

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


Navigation
Links