MediaWiki talk:RefToolbarLegacy.js
Hyphen conversion
[edit]There is a chunk that is supposed to convert a hyphen to an ndash:
value = value.replace(/-/g, "â"); //Replace hyphens with en dashes [[WP:ENDASH]]
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.
citevalue = citevalue.replace(/-/g, "–"); //Replace hyphens with en dashes [[WP:ENDASH]]
---— 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: . pp. 1–2.
{{cite book}}
: Missing or empty|title=
(help) works for me! I did control-shift-R to reload .js files. Graeme Bartlett (talk) 21:09, 27 November 2011 (UTC)- Fixed 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)
- 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)
- Fixed 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)
- My test here: . pp. 1–2.
- 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)
- Now testing at http://test.wikipedia.org/wiki/User:Gadget850/RefToolbarLegacy.js ---— Gadget850 (Ed) talk 20:49, 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)
exceptions on ie-9
[edit]- Move in comment left on an administrator's talk page. — billinghurst sDrewth 03:38, 14 March 2012 (UTC)
hi. i saw your name in the history of this file, so i write it here - maybe it should belong elsewhere.
so here is the deal: the line that reads
document.getElementById('citeselect').appendChild( reftoolformarea );"
throws exceptions on ie-9 when *not* in compatibility mode. the problem is that the brain-damaged browser returns "null" for document.getElementById('citeselect')
, 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
var
citemain = $('<div>', {id: 'citeselest'})
.css({display: 'none', margin: '0.2em 0 -0.2em 0'})
.append(addOption(citeWeb, "Web"))
.append(addOption(citeNews, "News"))
.append(addOption(citeBook, "Book"))
.append(addOption(citeJournal, "Journal"))
.append(addOption(citeNamedRef, "Named references"))
.append(addOption(dispErrors, "Error check"))
.append(addOption(showMore, "More"))
.append(addOption(hideInitial, "Cancel"));
var
citemore = $('<div>', {id: 'citemore'})
.css({display: 'none'})
.append(addOption(citeEncyclopedia, "Encyclopedia"));))
.append(addOption(citePressRelease, "Press release"));))
.append(addOption(citeMap, "Map"))
.append(addOption(showRefSectionOptions, "Ref Section"))
.append($('<span>', {id: 'refToolFormArea'});
citemain.append(citemore);
$('#toolbar').append(citemain);
function addOption(script, text) {
return $('<input>', {type: 'button', value: text}).click(script);
}
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)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
- 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 {{Cite}} 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 {{Cite}} 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)
Protocol relative link
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Based on Wikipedia:Village_pump_(technical)#Wikipedia:RefToolbar_1.0_does_not_autofill_from_ISBN.2C_DOI.2C_URL.2C_etc., please change
var defaultRefTagURL = 'http://reftag.appspot.com/';
to
var defaultRefTagURL = '//reftag.appspot.com/';
so users don't run into mixed content blocking when using the secure site. Thanks, Theopolisme (talk) 15:13, 13 October 2013 (UTC)
- Done --Redrose64 (talk) 19:00, 13 October 2013 (UTC)
Bugfix for caret focus
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
On line 616, change:
insertTags(cite, '', '');
to:
$("#wpTextbox1").focus();
insertTags(cite, '', '');
On line 650, change:
insertTags(wikicode, '', '');
to:
$("#wpTextbox1").focus();
insertTags(wikicode, '', '');
On line 719, change:
insertTags(ref, '', '');
to:
$("#wpTextbox1").focus();
insertTags(ref, '', '');
On line 1062, change:
insertTags(cite, '', '');
to:
$("#wpTextbox1").focus();
insertTags(cite, '', '');
Same as MediaWiki talk:RefToolbarNoDialogs.js#Bugfix for caret focus, 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 Done --Redrose64 (talk) 18:40, 3 April 2014 (UTC)
Protected edit request on 10 August 2015
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Due to the deprecation of the sajax API, please replace all occurrences of
sajax_init_object(); // new XMLHttpRequest();
with
new XMLHttpRequest();
This is without risk, because Javascript on IE6 is no longer supported and that was the only functionality that this function was providing —TheDJ (talk • contribs) 11:47, 10 August 2015 (UTC)
Protected edit request on 8 October 2015
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Could some admin with js knowledge change deprecated mwCustomEditButtons
to mw.toolbar
? --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 — Martin (MSGJ · talk) 14:23, 8 October 2015 (UTC)
- Is this script still used? Ruslik_Zero 08:14, 11 October 2015 (UTC)
- 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
[edit]Any reason why this script appears in Category:Pages with empty citations? -Einstein95 (talk) 01:17, 6 December 2015 (UTC)
normalize parameter names
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
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.
line # | new code |
---|---|
162 | document.getElementById('access-date').value = getTime();
|
252 | '<tr><td width="120"><label for="access-date"> Access date: </label></td>'+
|
253 | '<td width="400"><input type="text" tabindex=1 style="width:100%" id="access-date" value="'+ newtime +'"></td>'+
|
291 | <td><label for="author-link'+i+'"> Author link: </label></td> \
|
292 | <td><input type="text" tabindex=1 style="width:100%" id="author-link'+i+'"> \
|
337 | <td><label for="access-date"> Access date:</label></td> \
|
338 | <td><input type="text" tabindex=1 style="width:100%" id="access-date"></td></tr> \
|
402 | '<td width="120"><label for="access-date"> Access date: </label></td>'+
|
403 | '<td width="400"><input type="text" tabindex=1 style="width:100%" id="access-date"></td></tr>'+
|
452 | '<td width="120"><label for="access-date"> Access date: </label></td>'+
|
453 | '<td width="400"><input type="text" tabindex=1 style="width:100%" id="access-date"></td></tr>'+
|
486 | '<td width="120"><label for="access-date"> Access date: </label></td>'+
|
487 | '<td width="400"><input type="text" tabindex=1 style="width:100%" id="access-date" value="'+ getTime() +'"></td></tr>'+
|
514 | '<td width="120"><label for="access-date"> Access date: </label></td>'+
|
515 | '<td width="400"><input type="text" tabindex=1 style="width:100%" id="access-date"></td></tr>'+
|
938 | var authorlink = document.getElementById('author-link' + i).value;
|
941 | authorcite = '|author-link' + i + '=' + authorlink + authorcite;
|
982 | cite += '|author-mask=';
|
984 | cite += '|trans-title=';
|
987 | cite += '|orig-date=';
|
994 | cite += '|trans-chapter=';
|
996 | cite += '|chapter-url=';
|
999 | cite += '|lay-url=';
|
1000 | cite += '|lay-date=';
|
1142 | document.getElementById('access-date').value = formatDate(document.getElementById('access-date').value, dateformat);
|
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 Category:CS1 errors: deprecated parameters so unless it becomes a problem, we can limp along without 'fixing' that one.
—Trappist the monk (talk) 13:53, 16 March 2021 (UTC)
- On hold @Trappist the monk: 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 Wikipedia:RefToolbar/1.0):
//importScript('User:Trappist the monk/Sandbox/MediaWiki talk:RefToolbarLegacy.js'); //importScript('MediaWiki:RefToolbarLoader.js'); //importScript('User:Mr.Z-man/refToolbar.js'); //importScript('User:Apoc2400/refToolbar.js'); importScript('User:Apoc2400/refToolbarPlus.js');
- ... 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#mw-prefsection-gadgets). But that isn't what is wanted. How to use the sandbox instead?
- —Trappist the monk (talk) 16:46, 24 March 2021 (UTC)
- @Writ Keeper: 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 ⚇♔ 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 ⚇♔ 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#mw-prefsection-editing)
- checked 'Enable the legacy (2006) editing toolbar.' (under Editing at Special:Preferences#mw-prefsection-gadgets)
- 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:
<label for="coauthors"> <s>Coauthors: </s></label>
- 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
<s>...</s>
tags aren't allowed in<label>...</label>
tags, I changed those same labels to:<label for="coauthors"> coauthors: </label>
- This also did not work which leads me to suspect that checking 'Enable the legacy (2006) editing toolbar.' (under Editing at Special:Preferences#mw-prefsection-gadgets) 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 ⚇♔ 19:32, 24 March 2021 (UTC)
- Ding! Ding! Ding! That was it, thanks.
- —Trappist the monk (talk) 19:37, 24 March 2021 (UTC)
- @Writ Keeper: Thanks. Yep, all of this is what I did:
- @Writ Keeper: do you have experience testing this one? — xaosflux Talk 17:39, 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=
<label>...</label>
and<input />
tags by wrapping the<td>...</td>
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"coauthors",
and hyphenate"accessdate"
(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 ⚇♔ 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, no doubt, some would not be happy were I to shuffle them (because, you know, Wikipedians hate, hate, hate, change). If you 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 ⚇♔ 14:23, 5 April 2021 (UTC)
- Done Writ Keeper ⚇♔ 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 ⚇♔ 13:54, 5 April 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 Wikipedia:RefToolbar/1.0):