Hello,
I've been working on a small visual improvement on the login/registration form of MediaWiki (MediaWiki 1.5 CVS). I wrote a small JS script, which disables/enables the "Login" and "Create new account" buttons accordingly; for example, you are not allowed to click on "Create new account" if you haven't filled in the "retype password" field. What's more, the code checks if the two passwords match before the form is sent to the server, and displays a message if they don't (and also cancels the navigation process and clears the password fields). If javascript is disabled, the pages will work normally, as they would without my code. The only file I modified is /include/templates/Userlogin.php. Since I don't have CVS write access, I am submitting the modified file here. If it is possible, I would appreciate it if one of you developers with read/write CVS access can take a few minutes to check my code and CVS commit the file. I am attaching the file in this e-mail. Please let me know if there's something you don't like, or something you'd like me to add, and please let me know if and when you include my changes to the CVS (or if you don't, the reasons why you won't)
Thank you in advance :-) Dionysis Zindros.
On 6/18/05, Dionysis Zindros dionyziz@gmail.com wrote:
The only file I modified is /include/templates/Userlogin.php. Since I don't have CVS write access, I am submitting the modified file here. If it is possible, I would appreciate it if one of you developers with read/write CVS access can take a few minutes to check my code and CVS commit the file. I am attaching the file in this e-mail. Please let me know if there's something you don't like, or something you'd like me to add, and please let me know if and when you include my changes to the CVS (or if you don't, the reasons why you won't)
1. No attachements on this list. 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.)
-- Jamie ------------------------------------------------------------------- http://endeavour.zapto.org/astro73/ Thank you to JosephM for inviting me to Gmail! Have lots of invites. Gmail now has 2GB.
Jamie,
I've moved the code to bugzilla. Please see http://bugzilla.wikimedia.org/show_bug.cgi?id=2449
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).
Dionysis.
On 6/20/05, Jamie Bliss astronouth7303@gmail.com wrote:
On 6/18/05, Dionysis Zindros dionyziz@gmail.com wrote:
The only file I modified is /include/templates/Userlogin.php. Since I don't have CVS write access, I am submitting the modified file here. If it is possible, I would appreciate it if one of you developers with read/write CVS access can take a few minutes to check my code and CVS commit the file. I am attaching the file in this e-mail. Please let me know if there's something you don't like, or something you'd like me to add, and please let me know if and when you include my changes to the CVS (or if you don't, the reasons why you won't)
- No attachements on this list.
- 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.)
-- Jamie
http://endeavour.zapto.org/astro73/ Thank you to JosephM for inviting me to Gmail! Have lots of invites. Gmail now has 2GB.
Dionysis Zindros wrote in gmane.org.wikimedia.mediawiki:
On 6/20/05, Jamie Bliss astronouth7303@gmail.com wrote:
- 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().
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.
On 6/20/05, Kate keturner@livejournal.com wrote:
Dionysis Zindros wrote in gmane.org.wikimedia.mediawiki:
On 6/20/05, Jamie Bliss astronouth7303@gmail.com wrote:
- 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@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
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@gmail.com wrote:
On 6/20/05, Kate keturner@livejournal.com wrote:
Dionysis Zindros wrote in gmane.org.wikimedia.mediawiki:
On 6/20/05, Jamie Bliss astronouth7303@gmail.com wrote:
- 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.
A small update. As it turns out, the 1.4 version of the template doesn't have the id attributes, so it could be harder to find the elements. (I know I'm having problems doing it.)
-- Jamie ------------------------------------------------------------------- http://endeavour.zapto.org/astro73/ Thank you to JosephM for inviting me to Gmail! Have lots of invites. Gmail now has 2GB.
Hi, I have just tried your modified login page (great idea). When you are on the page an undefined index notice is displayed for line 52.
Notice: Undefined index: usedomain in C:\Program Files\Apache Group\Apache2\http\includes\templates\Userlogin.php on line 52
Do you or does anyone know why this is happening
Thanks Arthur
-----Original Message----- From: mediawiki-l-bounces@Wikimedia.org [mailto:mediawiki-l-bounces@Wikimedia.org] On Behalf Of Dionysis Zindros Sent: 19 June 2005 23:50 To: MediaWiki-l Mailing List; Jamie Bliss Subject: Re: [Mediawiki-l] Login form small visual improvement
Jamie,
I've moved the code to bugzilla. Please see http://bugzilla.wikimedia.org/show_bug.cgi?id=2449
'a star solutions' disclaimer The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. We believe that this communication is free from viruses and other potentially dangerous programmes, but the recipient opens this communication at their own risk. We assume no responsibility for any loss or damage arising from the receipt or use of this communication
Hi Arthur,
This is unrelated to my fix, since the reference to the undefined index, $this->data['usedomain'], is called either if my fix is applied or if it is not. However, I am using the latest CVS code in the fix, so you might have to download the whole latest CVS code: the index is defined in some other (updated in the CVS) file, most probably, so getting the latest sources will solve the problem. Keep in mind, however, that notices, unlike warnings, in general do not cause any problems, although there shouldn't be any.
Thanks for giving it a try :-) Dionysis.
On 6/21/05, Arthur Guy arthur@astarsolutions.co.uk wrote:
Hi, I have just tried your modified login page (great idea). When you are on the page an undefined index notice is displayed for line 52.
Notice: Undefined index: usedomain in C:\Program Files\Apache Group\Apache2\http\includes\templates\Userlogin.php on line 52
Do you or does anyone know why this is happening
Thanks Arthur
-----Original Message----- From: mediawiki-l-bounces@Wikimedia.org [mailto:mediawiki-l-bounces@Wikimedia.org] On Behalf Of Dionysis Zindros Sent: 19 June 2005 23:50 To: MediaWiki-l Mailing List; Jamie Bliss Subject: Re: [Mediawiki-l] Login form small visual improvement
Jamie,
I've moved the code to bugzilla. Please see http://bugzilla.wikimedia.org/show_bug.cgi?id=2449
'a star solutions' disclaimer The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you are not the intended recipient of this message you are hereby notified that any use, review, retransmission, dissemination, distribution, reproduction or any action taken in reliance upon this message is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Any views expressed in this message are those of the individual sender and may not necessarily reflect the views of the company. We believe that this communication is free from viruses and other potentially dangerous programmes, but the recipient opens this communication at their own risk. We assume no responsibility for any loss or damage arising from the receipt or use of this communication
mediawiki-l@lists.wikimedia.org