r101620 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101619‎ | r101620 | r101621 >
Date:12:34, 2 November 2011
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
Followup r101618: actually make things work. You can't feed HTML to mw.msg() (or it'll be escaped) and I was using .html() wrong
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
@@ -45,9 +45,18 @@
4646 $typeList.append( $( '<li tabindex="0"></li>' ).append( $button ) );
4747 }
4848
49 - var $termsLink = $( '<a> ')
50 - .attr( 'href', mw.msg( 'wikilove-commons-url' ) )
51 - .text( mw.msg( 'wikilove-commons-link' ) );
 49+ var commonsLink = $( '<a>' )
 50+ .attr( 'href', mw.msg( 'wikilove-commons-url' ) )
 51+ .text( mw.msg( 'wikilove-commons-link' ) )
 52+ .wrap( '<div>' ) // or .html() will only return the link text
 53+ .parent()
 54+ .html();
 55+ termsLink = $( '<a> ')
 56+ .attr( 'href', mw.msg( 'wikilove-terms-url' ) )
 57+ .text( mw.msg( 'wikilove-terms-link' ) )
 58+ .wrap( '<div>' )
 59+ .parent()
 60+ .html();
5261
5362 $dialog = $( '\
5463 <div id="mw-wikilove-dialog">\
@@ -96,7 +105,7 @@
97106 <span class="mw-wikilove-note" id="mw-wikilove-image-note"><html:msg key="wikilove-image-example"/></span>\
98107 <input type="text" class="text" id="mw-wikilove-image"/>\
99108 <div id="mw-wikilove-commons-text">\
100 - ' + mw.msg( 'wikilove-commons-text', $termsLink.html() ) + '\
 109+ ' + mw.html.escape( mw.msg( 'wikilove-commons-text' ) ).replace( /\$1/, commonsLink ) + '\
101110 </div>\
102111 <label for="mw-wikilove-message" id="mw-wikilove-message-label"><html:msg key="wikilove-enter-message"/></label>\
103112 <span class="mw-wikilove-note" id="mw-wikilove-message-note"><html:msg key="wikilove-omit-sig"/></span>\
@@ -114,7 +123,7 @@
115124 <h3><html:msg key="wikilove-preview"/></h3>\
116125 <div id="mw-wikilove-preview-area"></div>\
117126 <div id="mw-wikilove-terms">\
118 - ' + mw.msg( 'wikilove-terms', '<a href="' + mw.msg( 'wikilove-terms-url' ) + '" target="_blank">' + mw.msg( 'wikilove-terms-link' ) +'</a>' ) + '\
 127+ ' + mw.html.escape( mw.msg( 'wikilove-terms' ) ).replace( /\$1/, termsLink ) + '\
119128 </div>\
120129 <form id="mw-wikilove-send-form">\
121130 <button class="submit" id="mw-wikilove-button-send" type="submit"></button>\

Follow-up revisions

RevisionCommit summaryAuthorDate
r101621Followup r101618, r101620: forgot target="_blank"catrope12:36, 2 November 2011
r1016601.18wmf1: Merge stuff for editor engagement deployment...catrope19:01, 2 November 2011
r106395follow-up to r101620 - 2nd variable is proceeded by a semicolon, not a comma,...kaldari23:46, 15 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101618Followup r101548: build the link in a less scary way, with proper escapingcatrope11:34, 2 November 2011

Comments

#Comment by Kaldari (talk | contribs)   23:48, 15 December 2011
+			var 	commonsLink = $( '<a>' )
+					.attr( 'href', mw.msg( 'wikilove-commons-url' ) )
+					.text( mw.msg( 'wikilove-commons-link' ) )
+					.wrap( '<div>' ) // or .html() will only return the link text
+					.parent()
+					.html();
+				termsLink = $( '<a> ')
+					.attr( 'href', mw.msg( 'wikilove-terms-url' ) )
+					.text( mw.msg( 'wikilove-terms-link' ) )
+					.wrap( '<div>' )
+					.parent()
+					.html();

Looks like you probably either meant to use a comma instead of a semicolon, or are missing the 2nd var declaration. Fixed in r106395.

#Comment by Catrope (talk | contribs)   17:55, 16 December 2011

Whoops, good catch.

Status & tagging log