On 6/20/05, Kate <keturner(a)livejournal.com> wrote:
Dionysis Zindros wrote in
gmane.org.wikimedia.mediawiki:
On 6/20/05, Jamie Bliss
<astronouth7303(a)gmail.com> wrote:
> 2. Can you move the code to
MediaWiki:Monobook.js? (One of my pet
> peeves is modifying files. The first one you change makes upgrading so
> much harder.)
Regarding your suggestion to move the code to
monobook.js, this is not
possible, since there are certain events that should be added to the
file (onSubmit, onKeyUp, etc).
my (limited) understanding of Javascript is that this could be done entirely
from a script file using the "id" attribute and getElementById().
Yes, it's true that it is possible to assign events to elements like this:
document.getElementById("elementid").onSomeEvent =
"codetoexecute();";
which, in our case, would look similar to this, for one of the
elements (just given as an example):
document.getElementById("userlogin").wpPassword.onkeyup =
"updateloginform();";
The problem occurs because the javascript code is *not* static, but
instead dynamically created via php. Consider the following code, for
instance:
alert("<?php echo wfMsg( 'badretype' ) ?>");
This, will output some javascript code that will, when fired, show up
a message box with the text stored in the key "badretype" (that can be
modified). The message text is evaluated via PHP, then outputed to the
HTML document as javascript code. This is a simple example, but the
same applies to the fields checking; for example, the script checks
whether the user has enabled the e-mail features on his or her wiki
via PHP and, only if it's enabled, it outputs the javascript code that
performs the e-mail field check (because if it were a piece of static
code that always checked the e-mail field, it would cause an error in
case the user had disabled all e-mail features).
I hope it is clear now that the code can't be moved to the MediaWiki:
namespace. Even if it could, however, I agree with Kate to the fact
that this is a new feature of MediaWiki and should be included in
every newer MediaWiki build (if we decided to accept it as a feature,
that is) and not just a user-mod that COULD be applied if the user
wants it to. Also, even if we put the certain code in Monobook.js by
default, a user may clear it or replace it with other code, which is
something that we don't want. In either case, this is not an option,
anyway.
Regards,
Dionysis.
however, i can't see any reason why this would be
beneficial. the user is
more likely to have modified MediaWiki:Monobook.js than the PHP files,
which are not intended to be changed by the user.
also, putting it in the MediaWiki: namespace will prevent it being picked up
on upgrades.
Dionysis.
kate.
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)Wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l