r102857 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102856‎ | r102857 | r102858 >
Date:11:34, 12 November 2011
Author:catrope
Status:ok
Tags:
Comment:
[RL2] Update JS for r102796, IDs have been mangled by bin2hex(). Also fix global scope leakage
Modified paths:
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js
@@ -6,16 +6,28 @@
77 * @license GNU General Public Licence 2.0 or later
88 */
99 ( function( $ ) {
 10+ function hexEncode( s ) {
 11+ var retval = '', i, c;
 12+ for ( i = 0; i < s.length; i++ ) {
 13+ c = s.charCodeAt( i ).toString( 16 );
 14+ if ( c.length % 2 == 1 ) {
 15+ c = '0' + c;
 16+ }
 17+ retval += c;
 18+ }
 19+ return retval;
 20+ }
 21+
1022 function fixPreferenceForm( gadgetsByCategory, categoryNames ) {
 23+ var repo, gadget, category;
1124 for ( repo in gadgetsByCategory ) {
1225 for ( category in gadgetsByCategory[repo] ) {
13 - $( document.getElementById( 'mw-htmlform-gadgetcategory-' + repo + '-' + category ) )
 26+ $( '#mw-htmlform-gadgetcategory-' + hexEncode( repo ) + '-' + hexEncode( category ) )
1427 .siblings( 'legend' )
1528 .text( categoryNames[repo][category] );
1629
1730 for ( gadget in gadgetsByCategory[repo][category] ) {
18 - // Use getElementById() because we'd have to escape gadget for selector stuff otherwise
19 - $( document.getElementById( 'mw-input-wpgadget-' + gadget ) )
 31+ $( '#mw-input-wpgadget-' + hexEncode( gadget ) )
2032 .siblings( 'label' )
2133 .text( gadgetsByCategory[repo][category][gadget].title );
2234 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r102859[RL2] Followup r102857: wpgadget has been changed to gadgetpref as wellcatrope11:42, 12 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102796[RL2] Followup r102789, use bin2hex() instead of md5() to encode gadget IDs. ...catrope16:18, 11 November 2011

Status & tagging log