r90220 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90219‎ | r90220 | r90221 >
Date:17:58, 16 June 2011
Author:kaldari
Status:resolved (Comments)
Tags:
Comment:
include localized prefix per comments at r90191
Modified paths:
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -320,7 +320,7 @@
321321 msg = msg.replace( '$2', $( '#mw-wikilove-title' ).val() ); // replace the title
322322 var imageName = $( '#mw-wikilove-image' ).val();
323323 // if the image name doesn't start with a prefix, add one
324 - if ( imageName.indexOf( 'File:' ) !== 0 && imageName.indexOf( 'Image:' ) !== 0 ) {
 324+ if ( imageName.indexOf( 'File:' ) !== 0 && imageName.indexOf( 'Image:' ) !== 0 && imageName.indexOf( wgFormattedNamespaces[6] !== 0 ) ) {
325325 imageName = 'File:' + imageName;
326326 }
327327 msg = msg.replace( '$3', imageName ); // replace the image
@@ -446,7 +446,7 @@
447447 // get a random image from imageList and add it to the list of titles to be retrieved
448448 var id = Math.floor( Math.random() * imageList.length );
449449 // make sure the image name has a prefix
450 - if ( imageList[id].indexOf( 'File:' ) === 0 || imageList[id].indexOf( 'Image:' ) === 0 ) {
 450+ if ( imageList[id].indexOf( 'File:' ) === 0 || imageList[id].indexOf( 'Image:' ) === 0 || imageList[id].indexOf( wgFormattedNamespaces[6] ) === 0) {
451451 titles = titles + imageList[id] + '|';
452452 } else {
453453 titles = titles + 'File:' + imageList[id] + '|';

Follow-up revisions

RevisionCommit summaryAuthorDate
r90880Fixed adding file prefix as mentioned in the comments of r90220janpaul12315:11, 27 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90191make it so that images always work regardless of whether they include the pre...kaldari00:55, 16 June 2011

Comments

#Comment by MZMcBride (talk | contribs)   00:58, 17 June 2011

\o/

> if ( imageName.indexOf( 'File:' ) !== 0 && imageName.indexOf( 'Image:' ) !== 0 && imageName.indexOf( wgFormattedNamespaces[6] !== 0 ) ) {

My only comment here is that wgFormattedNamespaces[6] will return "Foo" instead of "Foo:". It might make sense to add a colon in the code, dunno.

#Comment by Kaldari (talk | contribs)   05:08, 28 June 2011

This was fixed by Jan Paul I believe.

#Comment by JanPaul123 (talk | contribs)   15:06, 27 June 2011

This is broken as the closing bracket in the end is incorrect...

wgFormattedNamespaces[6] !== 0 ) should be wgFormattedNamespaces[6] ) !== 0

Also, needs to be refactored to separate function. Will do this.

#Comment by Kaldari (talk | contribs)   05:08, 28 June 2011

Good idea.

Status & tagging log