This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 |
((editprotected))
Came across a bug upon porting to Norwegian Wikipedia. According to Wikipedia:RefToolbar_2.0#Autofilling the script checks for three different situations for inserting authors, but currently only the first works. The problem is that ($j('.classname')) always evaluates as true, even if no objects with such a class exists, since an empty array also evaluates as true. There was also a mixup of the variables i and j. And third, I switched from colon to semicolon to separate multiple authors.
--- MediaWiki-RefToolbar.js 2012-03-26 16:59:47.000000000 +0200
+++ MediaWiki-RefToolbar2.js 2012-03-26 17:37:53.000000000 +0200
@@ -469,7 +469,7 @@
CiteTB.autoFill = function(data, template, type) {
var cl = 'cite-'+template+'-';
$j('.'+cl+'title').val(data.title);
- if ($j('.'+cl+'last1')) {
+ if ($j('.'+cl+'last1').length != 0) {
for(var i=0; i<data.authors.length; i++) {
if ($j('.'+cl+'last'+(i+1)).length) {
$j('.'+cl+'last'+(i+1)).val(data.authors[i][0]);
@@ -483,7 +483,7 @@
break;
}
}
- } else if($j('.'+cl+'author1')) {
+ } else if($j('.'+cl+'author1').length != 0) {
for(var i=0; i<data.authors.length; i++) {
if ($j('.'+cl+'author'+(i+1)).length) {
$j('.'+cl+'author'+(i+1)).val(data.authors[i].join(', '));
@@ -498,10 +498,10 @@
}
} else {
var authors = [];
- for(var i=0; j<data.authors.length; j++) {
- authors.push(data.authors[j].join(', '));
+ for(var i=0; i<data.authors.length; i++) {
+ authors.push(data.authors[i].join(', '));
}
- $j('.'+cl+'authors').val(authors.join(', '));
+ $j('.'+cl+'authors').val(authors.join('; '));
}
if (type == 'pmid' || type == 'doi') {
if (type == 'doi') {
I've tested the diff locally on nowp, and it should work fine. – Danmichaelo (talk) 15:46, 26 March 2012 (UTC)
}
} else {
var authors = [];
for(var i=0; j<data.authors.length; j++) {
authors.push(data.authors[j].join(', '));
}
$j('.'+cl+'authors').val(authors.join(', '));
}
if (type == 'pmid' || type == 'doi') {
if (type == 'doi') {
}
} else {
var authors = [];
for(var i=0; i<data.authors.length; i++) {
authors.push(data.authors[i].join(', '));
}
$j('.'+cl+'authors').val(authors.join('; '));
}
if (type == 'pmid' || type == 'doi') {
if (type == 'doi') {
This is one of the great tools on Wikipedia. I was recently reading ((Cite/doc)) and an idea for an improvement occurred to me. First, the "coauthors" parameters is deprecated yet the RefToolbar is still encouraging people too use it. The rational for the deprecation is that coauthors are already covered by author1, author2, and so on. This seems sound reasoning to me. I use the Reftoolbar a lot and of the inconviences is having to cite multiple authors. Here's my idea. Have a small clickable "add additional author" link below the "last" and "first" fields. Upon clicking of this link it adds boxes for the next author! For example, the first click would add fields for "last2" and "first2". Another click would add fields for "last3" and "first3". The size of the form would grow with each click but that's okay. The script would have to be smart enough to know to stop at the maximum number of authors, of course. To somebody's whose javascript-foo is sharp, this should be a very easy modification. It adds needed functionality while fixing a deprecation issue. Comments? Jason Quinn (talk) 02:42, 23 August 2012 (UTC)
|coauthors=
is described as deprecated, but using it will not put the page into Category:Pages containing cite templates with deprecated parameters. Anyway, I do like the "add additional author" proposal. --Redrose64 (talk) 08:27, 23 August 2012 (UTC)The following are usability improvment ideas for the cite template entry forms in the Reftoolbar 2.0b:
These are just a few thoughts. All these things should be very easy to change. I think it would make the forms much more user friendly. Jason Quinn (talk) 23:12, 26 September 2012 (UTC)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please check the dependencies used by this (default) gadget, because the line
mw.usability.addMessages( {
from MediaWiki:RefToolbarMessages-en.js is causing the following error on Google Chrome 22.0.1229.79:
That code should not be executed if mw.usability
is not defined. Helder 12:10, 8 October 2012 (UTC)
mw.loader.using
// Enhanced editing toolbar is on with dialogs. Load standard refToolbar. mw.loader.using( ['ext.wikiEditor.toolbar', 'reftoolbar-base'] , function () {
mw.loader.using( 'mediawiki.util', ...)
mw.user.options.get
, but it should explicitly require the module user.options
where this is definedimportScriptURI
to get the code from MediaWiki:Gadget-refToolbarBase.js, where mw.usability
will be defined.importScriptURI
is asynchronous, but if it is, the script MediaWiki:RefToolbar.js (which uses mw.usability
and also load MediaWiki:RefToolbarMessages-en.js), NoDialogs.js & Legacy.js should be loaded inside of a callback (for this, importScriptURI
could be replaced by $.getScript(url, callback);, because mw.loader.load doesn't accept a callback)Who considers themselves maintainers of this extension? Are there any official WMF maintainers? I have many ideas for how it could be improved — some of which I've posted above — that should be extremely easy for somebody who's familiar with the codebase. Maybe here isn't the best place to propose them. My ideas not have received any replies except for Redrose's supportive comment. Is there a better place to suggest them? If the WMF isn't directly involved with its maintenance, why not? It seems like a very high reward-to-effort project. Jason Quinn (talk) 21:01, 21 November 2012 (UTC)
Can you add provisions for Norwegian to the script? Code can be something like:
// Load local data - messages, cite templates, etc.
$j(document).ready( function() {
switch( wgUserLanguage ) {
case 'de': // German
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-de.js');
break;
case 'no': // Norwegian
case 'nb': // Norwegian Bokmål
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-nb.js');
break;
default: // English
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-en.js');
}
});
An unfinished Norwegian message version is at no:MediaWiki:RefToolbarMessages-nb.js and can probably also be maintained there. ZorroIII (talk) 20:42, 23 March 2012 (UTC)
Another issue is that the messages are bound to closely to the field names. We have localised Template:cite web into no:Kilde www with Norwegian field names. For instance accessdate is besøksdato. Then a double set of messages is needed:
So there should ideally be some way to specify local field names as well, say, fields['accessdate'] = besøksdato
. – Danmichaelo (talk) 17:08, 26 March 2012 (UTC)
May anyone provide update upon the subject? Wizardist (talk) 23:33, 8 January 2013 (UTC)
The function object CiteTB.getQuotedString
// Returns a string quoted as necessary for name/group attributes
CiteTB.getQuotedString = function(s) {
var sp = /\s/.test(s); // spaces
var sq = /\'/.test(s); // single quotes
var dq = /\"/.test(s); // double quotes
if (!sp && !sq && !dq) { // No quotes necessary
return s;
} else if (!dq) { // Can use double quotes
return '"'+s+'"';
} else if (!sq) { // Can use single quotes
return "'"+s+"'";
} else { // Has double and single quotes
s = s.replace(/\"/g, '\"');
return '"'+s+'"';
}
}
has a bug in the "else" section. The function's purpose is to put quotes around certain strings when they are necessary for that string to be used as the value of an HTML parameter. The line s = s.replace(/\"/g, '\"');
does a global search-n-replace but it replaces double quotes with double quotes. It appears that single quotes were intended for the search instead of double quotes. (Alternatively, double quotes could be replaced with single quotes.) [This function is easily tested by typing into the "ref name" field of one of the cite templates. Doing this you easily see that typing a mixture of single and double quotes can mess up the quoting on the generated reference string.] A fix might be to replace single quotes (aka apostrophes) with the HTML apostrophe code "'" although that's really ugly. Another workaround might be s = s.replace(/\'/g, '\"');
but this changes what the user entered. The most conservative change would be to simply comment the line out. I intend to implement choose one of these choices (probably replace single quote with double) and implement it if no comments are given. Jason Quinn (talk) 03:41, 10 February 2013 (UTC)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
As suggested on Wikipedia talk:RefToolbar/2.0/Archive 2#Ported to portuguese, please add Portuguese translations from pt:MediaWiki:RefToolbarMessages-pt.js. Helder 12:37, 6 February 2013 (UTC)
'MediaWiki:RefToolbarMessages-en.js'
'MediaWiki:RefToolbarMessages-' + mw.config.get( 'wgContentLanguage' ) + '.js'
switch( wgUserLanguage ) {
case 'de': // German
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-de.js');
break;
case 'en': // English
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-en.js');
break;
case 'pt': // Portuguese
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-pt.js');
break;
default: // default language of wiki
var RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-' + mw.config.get( 'wgContentLanguage' ) + '.js');
}
The snippet has three changes: the generalization you mention, the edition of an explicit "en" case, and the edition of an explicit "pt" case. This will require me to create MediaWiki:RefToolbarMessages-pt.js here at the English Wikipedia, which I will copy from the pt:MediaWiki:RefToolbarMessages-en.js (which, despite the name is currently in Portuguese). Please confirm that this is what you are asking to be done and discuss your thoughts on the new code. At the present I am slowly digesting how the Reftoolbar works globally. Forgive me if I move slowly on this even after you confirm. I just got my ability to edit protected pages so I wish to make sure I don't screw anything up on my first tries. Jason Quinn (talk) 05:40, 8 February 2013 (UTC)
var RefToolbarMessages;
switch( wgUserLanguage ) {
case 'de': // German
RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-de.js');
break;
case 'pt': // Portuguese
case 'pt-BR': // Brazilian Portuguese
RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-pt.js');
break;
default: // default language of wiki
RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-' + mw.config.get('wgContentLanguage') + '.js');
}
wgUserLanguage
.var langMap = {
'de': 'de', // German
'pt': 'pt', // Portuguese
'pt-br': 'pt', // Brazilian Portuguese
'nb': 'nb', // Norwegian Bokmål
'no': 'nb', // Norwegian
}[ mw.config.get('wgUserLanguage') ] || mw.config.get('wgContentLanguage'),
RefToolbarMessages = importScript('MediaWiki:RefToolbarMessages-' + langMap + '.js');
importScript
call is not cheap, so we should do as few of these as possibly (ideally, none, but this would require Gadgets 2.0, which is expected to come with support for MediaWiki messages for i18n).This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Could someone apply these changes to the code? Helder 17:20, 21 January 2013 (UTC)
mw.loader.using( ['mediawiki.util', ... )
, so this would not make any difference in this case. What would improve the situation is adding the missing dependency I suggested above (user.options). Helder 13:23, 30 January 2013 (UTC)This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
The example given under "Help > Discussion" is throwing a parse error: "wikieditor-toolbar-help-content-signaturetimestamp-result: Parse error at position 19 in input" Jason Quinn (talk) 06:30, 2 October 2012 (UTC)
As it turns out, this isn't a RefToolbar problem but a known WikiEditor issue. It is Bug 42107. At the time I wrote this I didn't realize that the Reftoolbar is just an additional button on WikiEditor. Jason Quinn (talk) 04:03, 12 May 2013 (UTC)
This edit request to MediaWiki:RefToolbarLocal.js has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Just a typo - "Mutiple refs are given the name" should be "Multiple" -- John of Reading (talk) 11:18, 7 October 2013 (UTC)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
I fixed one issue in the lookup.php script in which dates where the month/day weren't zero-padded to 2 digits didn't work. While working on that, I also noticed that some journals don't actually provide the full date with their DOI information, only giving year/month. So JS assumes you're referring to the first of the month. Now this needs to be modified to support using year/month when the full date isn't available. I've already made the fixes to lookup.php, and kept it backwards compatible for caching. You can see the new output here - [1]. I think the new end of CiteTB.autoFill should look like this:
if (type === 'pmid' || type === 'doi') {
if (type === 'doi' && data.fulldate) {
var DT = new Date(data.date);
$('.'+cl+'date').val(CiteTB.formatDate(DT));
} else if (type === 'doi' && !data.fulldate) {
if (data.month) { // lookup.php sets month to false if it isn't provided
$('.'+cl+'month').val( CiteTB.getOption('months')[parseInt(data.month)] );
}
$('.'+cl+'year').val(data.year);
} else {
$('.'+cl+'date').val(data.date);
}
$('.'+cl+'journal').val(data.journal);
$('.'+cl+'volume').val(data.volume);
$('.'+cl+'issue').val(data.issue);
$('.'+cl+'pages').val(data.pages);
} else if (type === 'isbn') {
$('.'+cl+'publisher').val(data.publisher);
$('.'+cl+'location').val(data.location);
$('.'+cl+'year').val(data.year);
$('.'+cl+'edition').val(data.edition);
}
};
This should set month/year if fulldate is false, otherwise set date. I'd just like to have some other eyes on the code for this to make sure nothing is broken. I may also fix the PMID autofiller too in the future. Mr.Z-man 19:59, 12 October 2013 (UTC)
TypeError: data.authors is undefined
https://en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript Line 482
(results from using an incorrect ISBN and using autofill). Also, Firefox Dev Toolbar seems to think that each autofill uses four asynchronous requests in an old version of Firefox 15, but I can't recreate on a newer version. - Jarry1250 [Vacation needed] 15:42, 15 November 2013 (UTC)
The cite-form-submit function currently adds a blank after the template by using a preceding 'peri' addition (showing only one of two places in the code):
buttons: {
'cite-form-submit': function() {
$.wikiEditor.modules.toolbar.fn.doAction( $(this).data( 'context' ), {
type: 'encapsulate',
options: {
peri: ' '
}
}, $(this) );
var ref = CiteTB.getRef(false, true);
$(this).dialog( 'close' );
$.wikiEditor.modules.toolbar.fn.doAction( $(this).data( 'context' ), {
type: 'encapsulate',
options: {
pre: ref
}
}, $(this) );
},
This breaks compatibility with wikEd and is a rather strange way to add the blank ('peri' is for example/prefilled text added at cursor position that gets selected). I would like to change the code so that the space is added by a 'pre' call after template addition. I have tested it and it positions the cursor exactly the same position:
buttons: {
'cite-form-submit': function() {
var ref = CiteTB.getRef(false, true);
$(this).dialog( 'close' );
$.wikiEditor.modules.toolbar.fn.doAction( $(this).data( 'context' ), {
type: 'encapsulate',
options: {
pre: ref
}
}, $(this) );
var ref = CiteTB.getRef(false, true);
$(this).dialog( 'close' );
$.wikiEditor.modules.toolbar.fn.doAction( $(this).data( 'context' ), {
type: 'encapsulate',
options: {
pre: ' '
}
}, $(this) );
},
Actually, I have no idea why this space has to be added in the first place. It usually has to be removed manually. Also, none of the other toolbar buttons adds blanks after inserted code. Therefore, I suggest to remove the blank addition altogether. Mr.Z-man, Kaldari Jason Quinn: are you OK with that? Cacycle (talk) 13:23, 7 May 2014 (UTC)
(copied from enwp -- not sure of the best place to report)
Hi, If you go to extra fields in cite book, and try to add the "article=" field, it changes it to "authorlink1" instead on rendering. These are two very different things :) -- phoebe / (talk to me) 05:34, 8 September 2014 (UTC)
Please see phab:T109781 for more information. Thanks! --AKlapper (WMF) (talk) 13:18, 21 August 2015 (UTC)
This is based on a report at Wikipedia:Teahouse/Questions#Methinks there is a bug. WP:REFNAME says:
!$%&()*,-.:;<@[]^_`{|}~
CiteTB.getQuotedString only checks for spaces, single quotes and double quotes.
Confusingly, it appears that with disallowed characters like é, the original ref definition works without quotes but the ref can only be reused if the original definition and reuse both have quotes. See examples below. Cite errors are not displayed in MediaWiki talk. Copy it elsewhere to see the error messages. PrimeHunter (talk) 10:45, 1 June 2014 (UTC)
<ref name=Linné>((cite book||title=This ref has name=Linné and can be displayed but not reused))</ref>: [1]
<ref name=Linné />. [1]
<ref name="Linné" />. [1]
<ref name="CarlLinné">((cite book||title=This ref has name="CarlLinné" and can be reused))</ref>. [2]
<ref name="CarlLinné" />. [2]
<ref name=CarlLinné />. [2]
Could the autofills for journals also include pmc when it is available? Have to add that manually now. Thanks. Jytdog (talk) 21:27, 15 November 2016 (UTC)
There have been three threads raised at WP talk page here and here and here.
Will not autofill using pmid parameter anymore. Only works with doi. Can this be fixed please? Super valuable tool; i really miss this. Thanks. Jytdog (talk) 21:20, 15 November 2016 (UTC)
When using the Grammarly Extension, the reference tool bar does not work properly. The pull down menu is hidden behind the text box. Can this be fixed?
TheBigJagielka (talk) 15:55, 3 May 2017 (UTC)
|vauthors=
?One disadvantage of RefToolbar is that it currently only supports the default CS1 author format (|first1=
, |last1=
, ...). Many science related articles in contrast use Vancouver system formatted authors. These were previously specified by the deprecated |author(s)=
parameter that is systematically being replaced with |vauthors=
(currently used in 41,574 articles). If RefToolbar is used to insert citations into an article that already uses |vauthors=
, an inconsistent citation style is introduced which is contrary to WP:CITEVAR. Hence I would like to request that an vauthors option be added to RefToolbar. This should be straight forward to implement if the PMID is used for autofilling as RefToolbar is already returning Vancouver style first name initials from the PubMed database. Boghog (talk) 02:37, 27 December 2016 (UTC)
MediaWiki developers found that this page probably breaks JavaScript for users (example: not seeing the buttons when editing a page). You probably need to edit this .js page and/or MediaWiki:Gadgets-definition as in the examples at phabricator:T122755. List more pages to check.
If you have questions or need help, please ask at phabricator:T164242. You can login with your wiki account. Best wishes, Nemo 09:49, 14 May 2017 (UTC)
The main page is appearing in Category:Pages using invalid self-closed HTML tags. This is due to one or more of the following:
<option />
<div id="cite-nref-preview-label" style="display:none;" />
<div id="cite-namedref-preview" style="padding:0.5em; font-size:110%" />
<span id="cite-parsed-label" style="display:none;" />
<div id="cite-namedref-parsed" style="padding-bottom:0.5em; font-size:110%" />
<a href="#" id="cite-nref-parse" style="margin:0 1em 0 1em; display:none; color:darkblue" />
<div id="cite-errorcheck-heading" />
<ul id='cite-errcheck-list' />
<table id="cite-err-report" style="width:100%; border:1px solid #A9A9A9; background-color:#FFEFD5; padding:0.25em; margin-top:0.5em" />
<tr style="width:100%" />
<th style="width:60%; font-size:110%" />
<th style="text-align:right; width:40%" />
<a id="cite-err-check-close" />
<tr style="width:100%;" />
<td style="text-align:center; margin:1.5px;" />
<tr style="width:100%;" />
<td style="border: 1px solid black; margin:1.5px; width:60%" />
<td style="border: 1px solid black; margin:1.5px; width:40%" />
Is it important that this syntax be used, or would something like
<option></option>
<div id="cite-nref-preview-label" style="display:none;"></div>
<span id="cite-parsed-label" style="display:none;"></span>
<a href="#" id="cite-nref-parse" style="margin:0 1em 0 1em; display:none; color:darkblue"></a>
<ul id='cite-errcheck-list'></ul>
<table id="cite-err-report" style="width:100%; border:1px solid #A9A9A9; background-color:#FFEFD5; padding:0.25em; margin-top:0.5em"></table>
<tr style="width:100%"></tr>
<th style="width:60%; font-size:110%"></th>
<td style="text-align:center; margin:1.5px;"></td>
(etc.) work just as well? --Redrose64 🌹 (talk) 10:40, 28 July 2018 (UTC)
I would like to request an additional feature with RefToolbar. In the Web Citation popover, can we please have a checkbox (or a select menu) to specify url-status=dead/live
? I can fill in Archive URL and Archive Date in the form, but after I have inserted the reference into the article, I have to go in and type the "deadurl" bit manually, which is a bit fiddly.
This is the 5th time I have requested this, so I would really appreciate an answer - if it is possible of not, and if someone is able add this feature. Thank you. Cnbrb (talk) 14:00, 19 September 2019 (UTC)
It's been a month now. Would anyone please like to do me the courtesy of replying?
🔲 Yes it can be done
🔲 No it can't be done
🔲 Thanks for your constructive idea, we'll give it some thought
20:36, 21 October 2019 (UTC)
Url-status
field to the citation popoup. My preference would have been for a radio button/checkbox interface, but I guess I can't be too picky. I do not know who to thank for this, but whoever did it, THANK YOU. It's a pity nobody has been prepared to acknowledge a reasonable feature request on the various talk pages, but I'm glad it's done at last. Cnbrb (talk) 12:15, 31 October 2019 (UTC)This edit request to MediaWiki:RefToolbar.js has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Change
var url = '//tools.wmflabs.org/reftoolbar/lookup.php?'
to
var url = '//reftoolbar.toolforge.org/lookup.php?'
per wikitech:News/Toolforge.org --Ahecht (TALK
PAGE) 16:03, 9 July 2020 (UTC)