MediaWiki talk:Gadget-EoMagicalConversion.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search


Interaction with other gadgets[edit]

This gadget may interfere fatally with other gadgets. It modifies the edit token, but sometimes it does not reset that token correctly before the form is submitted. As far as I can see, this edit token modification is just used to store a boolean flag; it might be better if that were stored explicitly in a dedicated variable. Also, it adds click handlers to several buttons, but forms may also be submitted through form.submit(), which completely bypasses any click handlers, or by setting the focus on the button and hitting return, which may or may not end up as a click event. Forms with a single-line input field may also be submitted by hitting return in that input field (e.g., wpSummary on the edit page), which also does not generate a click event. Finally, simply converting any "ux" to "ŭ" is, of course, not always appropriate (consider a text containing the word "Linux"...).

I'm not sure what the best way would be to fix this gadget. The edit token problem could be avoided, I think, by using an explicit boolean variable instead of fiddling with the edit token. Ensuring that the conversion is run before form submission should probably done by using addHandler (form, 'submit' convert); or some such instead of click handlers. Instead of working only on some specific text input fields, it probably should automatically handle all text input fields, similar to the way MediaWiki:Edittools.js attaches to all text input fields. And finally, the input mechanism should probably changed from "ux" to some slightly less common pattern, like "u\x" or some such (or vice versa: encode any "ux" already in the text to "u\x" to avoid the conversion upon submission replaces it by "ŭ", and convert before submission any "u\x" back to "ux"). Though I don't know what people who actually use this gadget would prefer. Or maybe the gadget should not do any conversions at all but simply set the default section of the Edittools to "Esperanto", which does have these characters.

For a report on interfering with another Gadget (HotCat), see here (the "Eagle Harbor Lighthouse" comment). For unexpected "ux" conversion, see here.

Lupo 10:29, 6 May 2010 (UTC)[reply]

I think the modification of the edit token should be considered a feature — if the convertEsperanto handler doesn't run for some reason, it's better for the submission to fail than for the X-encoded text to get submitted without proper decoding. However, I do see a number of problems with this script:
  • As you said, it should attach the event handler to the form's submit event, not to click events for individual controls.
  • It probably shouldn't run at all if MediaWiki:QuickMod.js is active, or at least should play more nicely with it. (Then again, QuickMod itself should really be considered deprecated in favor of using the API.)
  • The way it's doing the replacement looks really twisted. Alas, JavaScript AFAIK does not have anything exactly like the PHP multi-replacement function used in the original code. I'd be inclined to use String.split() with a RegExp instead, but I've had reports of IE having bugs with that. String.search() might be a more reliable substitute.
  • It needs better documentation, and the code is unreadable. I had to look at the MediaWiki code it's meant to emulate just to figure out what it was supposed to be doing.
I think fixing the handler issue ought to be fairly simple. The rest looks like it really needs a full rewrite from the ground up. —Ilmari Karonen (talk) 15:05, 6 May 2010 (UTC)[reply]
BTW, w:Esperanto orthography#X-system is probably useful for understanding what this script is supposed to do. —Ilmari Karonen (talk) 15:10, 6 May 2010 (UTC)[reply]
Ok, they encode "x" in the input as "xx" (and "X" as "Xx"), and decode that again to single "x" or "X". That also works.
There should also be a way of dynamically attaching this handler or running the converter for dynamically created inputs, such as those on the extended upload form or the editor in ImageAnnotator. Lupo 15:36, 6 May 2010 (UTC)[reply]
I rewrote it for better readability, now attaching it to user inputs looks possible. I still doubt how much this is really needed here--DieBuche (talk) 18:08, 24 October 2010 (UTC)[reply]
Did you test it? I don't think your version works the way it's supposed to. You might be able to fix it with some lookahead assertions, but I think that would still leave some corner cases involving things like "uxxx" broken. Anyway, it does seem likely that nobody's actually using this here. —Ilmari Karonen (talk) 19:51, 24 October 2010 (UTC)[reply]

Problem[edit]

This happened when I saved the page adding a new section. And that is a problem. Jon Harald Søby (talk) 10:55, 28 February 2011 (UTC)[reply]

Yes, as I noted in the previous section, the current code has some issues. I didn't consider it a very high priority to fix before, since nobody seemed to be actually using this gadget. Since it now seems that at least one person (you) does use it, I'll try to do something about it soon. —Ilmari Karonen (talk) 11:56, 28 February 2011 (UTC)[reply]
I've rewritten the script to (hopefully) fix the round-trip issues and to match the MediaWiki PHP implementation. It seems to more or less work, but I'd be thankful for more testing, particularly in different browsers (I've only tested it in Firefox so far) and with different gadgets and user scripts (particular anything that plays with the editing interface).
One known issue is that the script currently doesn't seem to work on the upload form. I have an idea on what might be causing it and how to fix it, but that will have to wait a bit. --Ilmari Karonen (talk) 16:46, 28 February 2011 (UTC)[reply]
Don't spend too much time on it – it is very rare that I write in Esperanto, and with the new toolbar it is not that much inconvenience not to have the keys readily available (for me as a Linux user the only difficult character is ŭ, the rest are available via dead keys). But good job on the rewrite, I will test it out. :-) Jon Harald Søby (talk) 22:20, 28 February 2011 (UTC)[reply]
By the way, I once ran across a page that lists statistics regarding different settings, including gadget usage. However I forgot where it was; I don't even remember if it was a special page or something on the toolserver. If I find it I will let you know. Jon Harald Søby (talk) 22:22, 28 February 2011 (UTC)[reply]
Found it, Special:Prefstats, but it does not track gadgets anymore (if that was the page I used the first time at all, I think so but am not sure). :/ Jon Harald Søby (talk) 22:27, 28 February 2011 (UTC)[reply]

I should say, although that here’s probably not the best place, that this “magical” thingy is one of the reasons I barely edit at eo:wp, although my esperanto-level is near native (much better than this here engrish I type). Obviously I do have esperanto letters built in in my keyboard (MKLC, extended from my own national keyboard) as does anyone who types the language above occasional level; indeed this tool is good for ppl who type in esperanto only in Wikipedia, and that’s a huge mistake, as it enables beginners and diletants into something that should be done by expert speakers. Pisses me off very much to type correct esperanto only to see it mangled to an outdated surogate when I edit the pages again, and to have to resort to stone age tricks like typing "uxx" for "ux", while advanced stuff like LTR scripts, complex rendering, and other Unicode pyrotechnics is allowed to work as it should. Frankly, this tool, and its integrated use in eo:wp, is a great disservice to the esperanto-speaking community. -- Tuválkin 15:03, 8 April 2013 (UTC)[reply]