MediaWiki talk:RefToolbarLegacy.js

Hyphen conversion
There is a chunk that is supposed to convert a hyphen to an ndash:

However, it is obviously inserting unicode characters instead. ---— Gadget850 (Ed)  talk 12:31, 27 November 2011 (UTC)

Not into JS, but the fix looks obvious. To be safe, I tracked the origin of this code to User:Apoc2400/refToolbar.js.

---— Gadget850 (Ed)  talk 16:09, 27 November 2011 (UTC)
 * I think you are right there. Are there any sensible ways to test this before letting the change go out to everyone? Graeme Bartlett (talk) 20:37, 27 November 2011 (UTC)
 * Now testing at http://test.wikipedia.org/wiki/User:Gadget850/RefToolbarLegacy.js ---— Gadget850 (Ed)  talk 20:49, 27 November 2011 (UTC)
 * Worked on test.wiki. Made the change here and purged/bypassed, but still seeing the problem. ---— Gadget850 (Ed)  talk 21:04, 27 November 2011 (UTC)
 * My test here:  works for me! I did control-shift-R to reload  .js files. Graeme Bartlett (talk) 21:09, 27 November 2011 (UTC)
 * Guess it just took some time. While the conversion is a good idea, it is only implemented for Cite book. And the bug has been extant since at least February. ---— Gadget850 (Ed)  talk 22:54, 27 November 2011 (UTC)
 * How about doing the conversion for cite journal as well? Page ranges are very common in that. Graeme Bartlett (talk) 08:31, 28 November 2011 (UTC)
 * Beyond my capabilities. I really don't know JavaScript, but I am really good a logic and patterns. ---— Gadget850 (Ed)  talk 13:05, 28 November 2011 (UTC)

exceptions on ie-9

 * Move in comment left on an administrator's talk page. — billinghurst  sDrewth  03:38, 14 March 2012 (UTC)

so here is the deal: the line that reads

throws exceptions on ie-9 when *not* in compatibility mode. the problem is that the brain-damaged browser returns "null" for, even though severl lines prior this section was just created.

i would recommend to transform this whole ugly piece to something that uses jquery, instead of having a piece of code that behaves differently for different browser in enwiki "Mediawiki:" space. let jquery worry about browser compatability. i.e., replace the mess at the beginning of the file with

it would also make sense to translate the rest of the file to more modern and maintainable code (using jquery), but this is your business (i am not active on enwiki).

however, throwing exception is considered bad form and should be avoided where possible.

peace, קיפודנחש (talk) 18:35, 13 March 2012 (UTC)

I think I found the error - you didn't set the id of the div in the else part of if (navigator.userAgent.indexOf('MSIE') == -1). Please, add citeselect.id = 'citeselect'; somewhere after line 56. Thanks. --V111P (talk) 03:04, 28 July 2013 (UTC)


 * The problem: In IE, when the option "Enable enhanced editing toolbar" is not checked in Preferences, IE reports an error when opening an article for editing: "Unable to get property 'appendChild' of undefined or null reference". Clicking on the icon in the toolbar above the textarea results in the same error message and the citation tool doesn't work.
 * How to recreate the error: To see the error message, first uncheck the option "Enable enhanced editing toolbar" in the Editing section of your preferences. Now press F12 to open Developer Tools and click on the Console tab. Now open an article for editing. The error message should appear in the console and the button above the textarea won't work.
 * The cause: This error is caused by the author of the script not setting the id of a div element in the else part of if (navigator.userAgent.indexOf('MSIE') == -1).
 * Solution: This error can be fixed by adding the line citeselect.id = 'citeselect'; after line 56 of this script. Line 56 currently reads: var citeselect = document.createElement('div'); --V111P (talk) 02:40, 15 August 2013 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 06:20, 21 August 2013 (UTC)

Protocol relative link
Based on Village_pump_(technical), please change

to

so users don't run into [//blog.mozilla.org/tanvi/2013/04/10/mixed-content-blocking-enabled-in-firefox-23/ mixed content blocking] when using the secure site. Thanks,  Theopolisme ( talk )  15:13, 13 October 2013 (UTC)
 * Yes check.svg Done -- Red rose64 (talk) 19:00, 13 October 2013 (UTC)

Bugfix for caret focus
On line 616, change: to:

On line 650, change: to:

On line 719, change: to:

On line 1062, change: to:

Same as MediaWiki talk:RefToolbarNoDialogs.js, more detailed explanation. Fixes the same bug for users who have enabled neither "Enable enhanced editing toolbar" nor "Enable wizards [...]" at Editing Preferences (i.e. legacy editing settings.) --hydrox (talk) 17:50, 3 April 2014 (UTC)
 * Taken on trust and Yes check.svg Done -- Red rose64 (talk) 18:40, 3 April 2014 (UTC)

Protected edit request on 10 August 2015
Due to the deprecation of the sajax API, please replace all occurrences of with This is without risk, because Javascript on IE6 is no longer supported and that was the only functionality that this function was providing

—Th e DJ (talk • contribs) 11:47, 10 August 2015 (UTC)
 * Yes check.svg Done — Mr. Stradivarius  ♪ talk ♪ 14:00, 10 August 2015 (UTC)

Protected edit request on 8 October 2015
Could some admin with js knowledge change deprecated  to  ? -- Edgars2007  (talk/contribs) 08:13, 8 October 2015 (UTC)
 * Problem is that the admins who patrol CAT:EP are not always the ones with js knowledge. I'll leave it open a couple of days just in case, but otherwise you can try WP:VPT. Regards &mdash; Martin (MSGJ · talk) 14:23, 8 October 2015 (UTC)
 * Is this script still used? Ruslik_ Zero 08:14, 11 October 2015 (UTC)
 * Red information icon with gradient background.svg Not done: Edit requests aren't coding requests. Feel free to reopen this when you have code somewhere that we can review, if indeed this gadget is still in use. — Mr. Stradivarius  ♪ talk ♪ 13:35, 11 October 2015 (UTC)

Category:Pages with empty citations
Any reason why this script appears in Category:Pages with empty citations? -Einstein95 (talk) 01:17, 6 December 2015 (UTC)

normalize parameter names
Hyphenated parameter names are the canonical forms for multiword cs1|2 parameters. WP:RefToolbar has been modified to use these canonical names so it makes sense (to me at least) that we should modify MediaWiki:RefToolbarLegacy.js so that it also uses the canonical-form names. While investigating this, I noticed that, in some cases, WP:RefToolbarLegacy also uses parameter names that are no-longer supported by cs1|2. To remedy these things, I propose that WP:RefToolbarLegacy shall be changed by replacing the code at certain line numbers with the code as listed in the table.

There is one parameter that I left unmodified: coauthors. I do not have sufficient javascript skills to understand how that parameter can be removed from this script so I make no suggestions about that. I do know that it appears relatively rarely in so unless it becomes a problem, we can limp along without 'fixing' that one.

—Trappist the monk (talk) 13:53, 16 March 2021 (UTC)
 * I've made you a sandbox at: User:Trappist the monk/Sandbox/MediaWiki talk:RefToolbarLegacy.js. Please make all the edits you are proposing there, then test the new script.  Once you have validated, please reactivate the edit request. —  xaosflux  Talk 15:50, 24 March 2021 (UTC)
 * @Xaosflux: That's all very fine and I will do it if you will tell me how to 'activate' that sandbox as the editor. None of these in User:Trappist the monk/common.js worked (the latter three from RefToolbar/1.0):
 * ... And yes, I did the cache bypass thing ...
 * I can activate the legacy editor if I select 'Enable the legacy (2006) editing toolbar.' (under Editing at Special:Preferences). But that isn't what is wanted.  How to use the sandbox instead?
 * —Trappist the monk (talk) 16:46, 24 March 2021 (UTC)
 * do you have experience testing this one? — xaosflux  Talk 17:39, 24 March 2021 (UTC)
 * Hmm, let me take a look. The refToolbar is a cofusing jumble at the best of times. Writ Keeper &#9863;&#9812; 17:47, 24 March 2021 (UTC)
 * @Trappist the monk: You should be able to test it by: 1) importing the snadbox as a user script per normal; 2) going to Special:Preferences/Editing and unchecking the "Enable the editing toolbar" option under "Editor", and 3) going to the Gadgets tab and checking the "Enable the legacy (2006) editing toolbar." The language on the legacy toolbar option might need some tightening to make it clear that, if the option in Editing is checked, then the legacy toolbar gadget won't do anything. Let me know if these steps don't resolve the issues. Writ Keeper &#9863;&#9812; 17:57, 24 March 2021 (UTC)
 * @Writ Keeper: Thanks. Yep, all of this is what I did:
 * importScript('User:Trappist the monk/Sandbox/MediaWiki talk:RefToolbarLegacy.js'); (in User:Trappist_the_monk/common.js)
 * unchecked "Enable the editing toolbar This is sometimes called the '2010 wikitext editor'." (under Editor at Special:Preferences)
 * checked 'Enable the legacy (2006) editing toolbar.' (under Editing at Special:Preferences)
 * After doing these things, I get a 'legacy' editor but it doesn't appear to be the version in my sandbox – I changed the 'Coauthors' input text box labels to:
 * Coauthors:
 * so that it would be obvious that the sandbox version is the editor in use; that didn't work. So, on the off-chance that  tags aren't allowed in  tags, I changed those same labels to:
 * coauthors:
 * This also did not work which leads me to suspect that checking 'Enable the legacy (2006) editing toolbar.' (under Editing at Special:Preferences) does, as it is advertised to do, cause the gadget version of the editor to load over whatever user script is loaded (if it's loaded).
 * Unchecking 'Enable the legacy (2006) editing toolbar' removes the editor even though steps 1 and 2 above remain unaltered. So, the question: 'How to use the sandbox?', remains a mystery (at least to me...)
 * —Trappist the monk (talk) 18:51, 24 March 2021 (UTC)
 * @Trappist the_monk: Hmm, it seems to be working for me; I see "coauthors:" there. The editing toolbar gadget itself shouldn't overwrite your RefToolbar; that gadget refers to the buttons next to the cite button, but not the cite button itself, which has always been a separate gadget. In fact, the RefToolbar gadget just adds a button onto the toolbar that the edit toolbar gadget provides, which is why it needs to be enabled for your script to take effect: if it isn't, there's no toolbar for the RefToolbar script to add its button to.
 * Anyway, one thing I missed is that you also have to be sure to have disabled the current RefToolbar gadget (the refToolbar: checkbox in the Gadgets screen, just below the edit toolbar one). Make sure that's unchecked, as well, otherwise it might overwrite the custom script. Writ Keeper &#9863;&#9812; 19:32, 24 March 2021 (UTC)
 * Ding! Ding! Ding! That was it, thanks.
 * —Trappist the monk (talk) 19:37, 24 March 2021 (UTC)
 * I have implemented all of the items listed in the above table in User:Trappist the monk/Sandbox/MediaWiki talk:RefToolbarLegacy.js. The forms used by RefToolbarLegacy.js use html tables to do the form formatting.  In my original post I noted that coauthors is no longer supported by cs1|2  but didn't have a solution for it.  I have discovered a partial solution and that is to blank the table cells that hold the coauthors  and  tags by wrapping the  content in  markup.  As part of this, and because I omitted an access-date tidbit that should have been listed in the table above, I changed line 954 to remove   and hyphenate   (I also normalized whitespace in that line); see line 960 in the sandbox.
 * I made some other adjustments:
 * 'Website or work' label in the cite web form (old: line 244; new: line 244)
 * 'Newspaper or work' label in the cite news form (same)
 * editors → editor in the book cite form (old: lines 432, 433; new: lines 439, 439)
 * the cite web and cite news forms are shared; I blanked the table cell that holds the location label and input in the cite web form (old: lines 254, 255; new: lines 254–261)
 * I removed leading  html entities from the left-column labels of all forms except the cite book form (which did not have left-column leading  )
 * All of the changes can be seen in this comparison between MediaWiki:RefToolbarLegacy.js and User:Trappist the monk/Sandbox/MediaWiki talk:RefToolbarLegacy.js. cs1|2 templates created with this tool can be seen in this version of my sandbox
 * Edit request reactivated.
 * —Trappist the monk (talk) 16:14, 25 March 2021 (UTC)
 * Hey, Trappist the_monk, sorry for the wait. One question (not a dealbreaker, I don't think): when you remove the coauthors field, you leave the empty TDs in place, which leaves a weird hole in the middle of the citation fields. Is there any reason why we shouldn't instead shift the TDs up one, to move that hole to the end of the fields instead? Writ Keeper &#9863;&#9812; 13:54, 5 April 2021 (UTC)
 * Minimal change. I thought about filling that hole but decided to leave it so that nothing else in the form moved.  Editors who use this tool likely have come to expect the various fields to be where they are. No doubt,  doubt, some would not be happy were I to shuffle them (because, you know, Wikipedians hate, hate, hate, change).  If  want to fill the hole, go ahead, that's on you.
 * —Trappist the monk (talk) 14:15, 5 April 2021 (UTC)
 * Haha, no dispute there. :) Actually, what I think I might do, by way of explanation, is leave a plaintext note in that gap indicating that the coauthors field has been deprecated; that way nobody thinks that something has gone wrong. Thanks, I'll go ahead and implement this change. Writ Keeper &#9863;&#9812; 14:23, 5 April 2021 (UTC)
 * ✅ Writ Keeper &#9863;&#9812; 14:45, 5 April 2021 (UTC)
 * Hey, Trappist the_monk, sorry for the wait. One question (not a dealbreaker, I don't think): when you remove the coauthors field, you leave the empty TDs in place, which leaves a weird hole in the middle of the citation fields. Is there any reason why we shouldn't instead shift the TDs up one, to move that hole to the end of the fields instead? Writ Keeper &#9863;&#9812; 13:54, 5 April 2021 (UTC)
 * Minimal change. I thought about filling that hole but decided to leave it so that nothing else in the form moved.  Editors who use this tool likely have come to expect the various fields to be where they are. No doubt,  doubt, some would not be happy were I to shuffle them (because, you know, Wikipedians hate, hate, hate, change).  If  want to fill the hole, go ahead, that's on you.
 * —Trappist the monk (talk) 14:15, 5 April 2021 (UTC)
 * Haha, no dispute there. :) Actually, what I think I might do, by way of explanation, is leave a plaintext note in that gap indicating that the coauthors field has been deprecated; that way nobody thinks that something has gone wrong. Thanks, I'll go ahead and implement this change. Writ Keeper &#9863;&#9812; 14:23, 5 April 2021 (UTC)
 * ✅ Writ Keeper &#9863;&#9812; 14:45, 5 April 2021 (UTC)