Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.preferences.js |
— | — | @@ -6,16 +6,28 @@ |
7 | 7 | * @license GNU General Public Licence 2.0 or later |
8 | 8 | */ |
9 | 9 | ( 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 | + |
10 | 22 | function fixPreferenceForm( gadgetsByCategory, categoryNames ) { |
| 23 | + var repo, gadget, category; |
11 | 24 | for ( repo in gadgetsByCategory ) { |
12 | 25 | for ( category in gadgetsByCategory[repo] ) { |
13 | | - $( document.getElementById( 'mw-htmlform-gadgetcategory-' + repo + '-' + category ) ) |
| 26 | + $( '#mw-htmlform-gadgetcategory-' + hexEncode( repo ) + '-' + hexEncode( category ) ) |
14 | 27 | .siblings( 'legend' ) |
15 | 28 | .text( categoryNames[repo][category] ); |
16 | 29 | |
17 | 30 | 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 ) ) |
20 | 32 | .siblings( 'label' ) |
21 | 33 | .text( gadgetsByCategory[repo][category][gadget].title ); |
22 | 34 | } |