Index: trunk/extensions/ApiSandbox/ext.apiSandbox.js |
— | — | @@ -26,8 +26,9 @@ |
27 | 27 | var param = this.params[i], |
28 | 28 | name = this.prefix + param.name; |
29 | 29 | |
30 | | - s += '<tr><td class="api-sandbox-label"><label for="param-' + name + '">' + name + '=</label></td>' |
31 | | - + '<td class="api-sandbox-value">' + this.input( param, name ) |
| 30 | + s += '<tr><td class="api-sandbox-label">' |
| 31 | + + mw.html.element( 'label', { 'for': 'param-' + name }, name + '=' ) |
| 32 | + + '</td><td class="api-sandbox-value">' + this.input( param, name ) |
32 | 33 | + '</td><td>' + smartEscape( param.description ) + '</td></tr>'; |
33 | 34 | } |
34 | 35 | s += '\n</tbody>\n</table>\n'; |
— | — | @@ -42,7 +43,7 @@ |
43 | 44 | var desc = smartEscape( this.info.description ); |
44 | 45 | if ( isset( this.info.helpurls ) && isset( this.info.helpurls[0] ) && this.info.helpurls[0] ) { |
45 | 46 | desc = desc.replace( /^([^\r\n\.]*)/, |
46 | | - '<a target="_blank" href="' + mw.html.escape( this.info.helpurls[0] ) + '">$1</a>' |
| 47 | + mw.html.element( 'a', { 'target': '_blank', 'href': this.info.helpurls[0] }, '$1' ) |
47 | 48 | ); |
48 | 49 | } |
49 | 50 | $container.html( desc ); |
— | — | @@ -58,12 +59,12 @@ |
59 | 60 | case 'timestamp': |
60 | 61 | case 'integer': |
61 | 62 | case 'string': |
62 | | - s = '<input class="api-sandbox-input" id="param-' + name + '" value="' + value + '"/>'; |
| 63 | + s = mw.html.element( 'input', { 'class': 'api-sandbox-input', 'id': 'param-' + name, 'value': value } ); |
63 | 64 | break; |
64 | 65 | case 'bool': |
65 | 66 | param.type = 'boolean'; // normalisation for later use |
66 | 67 | case 'boolean': |
67 | | - s = '<input id="param-' + name + '" type="checkbox"/>'; |
| 68 | + s = mw.html.element( 'input', { 'id': 'param-' + name, 'type': 'checkbox' } ); |
68 | 69 | break; |
69 | 70 | case 'namespace': |
70 | 71 | param.type = namespaces; |
— | — | @@ -78,7 +79,7 @@ |
79 | 80 | s = this.select( param.type, attributes, true ); |
80 | 81 | } |
81 | 82 | } else { |
82 | | - s = mw.html.element( 'code', [], mw.msg( 'parentheses', param.type ) ); |
| 83 | + s = mw.html.element( 'code', {}, mw.msg( 'parentheses', param.type ) ); |
83 | 84 | } |
84 | 85 | } |
85 | 86 | return s; |
— | — | @@ -127,7 +128,7 @@ |
128 | 129 | if ( $.isArray( value ) ) { |
129 | 130 | value = value.join( '|' ); |
130 | 131 | } |
131 | | - params += '&' + name + '=' + encodeURIComponent( value ); |
| 132 | + params += '&' + encodeURIComponent( name ) + '=' + encodeURIComponent( value ); |
132 | 133 | } |
133 | 134 | } |
134 | 135 | return params; |
— | — | @@ -357,7 +358,7 @@ |
358 | 359 | return; |
359 | 360 | } |
360 | 361 | query = query.replace( /^.*=/, '' ); |
361 | | - data = {}; |
| 362 | + var data = {}; |
362 | 363 | if (isQuery ) { |
363 | 364 | data.querymodules = query; |
364 | 365 | } else { |
— | — | @@ -395,8 +396,9 @@ |
396 | 397 | function smartEscape( s ) { |
397 | 398 | s = mw.html.escape( s ); |
398 | 399 | if ( s.indexOf( '\n ' ) >= 0 ) { |
399 | | - s = s.replace( /^(.*?)((?:\n\s+\*?[^\n]*)+)(.*?)$/m, '$1<ul>$2</ul>$3' ); |
400 | | - s = s.replace( /\n\s+\*?([^\n]*)/g, '\n<li>$1</li>' ); |
| 400 | + // turns *-bulleted list into a HTML list |
| 401 | + s = s.replace( /^(.*?)((?:\n\s+\*?[^\n]*)+)(.*?)$/m, '$1<ul>$2</ul>$3' ); // outer tags |
| 402 | + s = s.replace( /\n\s+\*?([^\n]*)/g, '\n<li>$1</li>' ); // <li> around bulleted lines |
401 | 403 | } |
402 | 404 | s = s.replace( /\n(?!<)/, '\n<br/>' ); |
403 | 405 | return s; |
— | — | @@ -426,4 +428,4 @@ |
427 | 429 | $generatorBox.hide(); |
428 | 430 | } |
429 | 431 | |
430 | | -}); |
\ No newline at end of file |
| 432 | +}); |