After he said that, I thought to myself "You lack confidence in your
scripts." And I set out to work on it.
On 6/20/05, Dionysis Zindros <dionyziz(a)gmail.com> wrote:
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();";
I was using the DOM method (setAttribute('onSomeEvent',
"codetoexecute();")), amongst other things.
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();";
Why not just get wpPassword directly? It has an ID.
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' ) ?>");
In that particular case, you can just use {{INT:badretype}} (works on
1.4), so that the line looks like this:
alert("{{INT:badretype}}");
Just make sure there's no double quotes (") in the message.
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).
Most of them can be detected by the presense of certain IDs. Try these:
var datacreate = document.getElementById('wpRetype') ? true : false;
var datauserealname = document.getElementById('wpRealName') ? true : false;
var datauseemail = document.getElementById('wpEmail') ? true : false;
I also found out the headings work in that page, as well. So you can
do things like:
/*
=== Some section of code ===
*/
And it works just like usual.
To see what I have so far (albeit not working), see
[[Wikipedia:En:User:Astronouth7303/My monobook script]]
-- Jamie
-------------------------------------------------------------------
http://endeavour.zapto.org/astro73/
Thank you to JosephM for inviting me to Gmail!
Have lots of invites. Gmail now has 2GB.