Index: trunk/extensions/UploadWizard/resources/mw.Title.js |
— | — | @@ -26,9 +26,9 @@ |
27 | 27 | * |
28 | 28 | * n.b. this class does not handle URI-escaping |
29 | 29 | * |
30 | | - * n.b. this class relies on the existence of two globals: |
| 30 | + * n.b. this class relies on the existence of the globals: |
31 | 31 | * wgFormattedNamespaces - array of id numbers (as strings) to localized namespace names |
32 | | - * wgNamespaceIds - abstract namespace names to integer ids |
| 32 | + * wgArticlePath |
33 | 33 | */ |
34 | 34 | |
35 | 35 | /** |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | } |
70 | 70 | |
71 | 71 | function text( s ) { |
72 | | - if ( s != null ) { |
| 72 | + if ( typeof s === 'string' ) { |
73 | 73 | return s.replace( /_/g, ' ' ); |
74 | 74 | } else { |
75 | 75 | return ''; |
— | — | @@ -153,10 +153,10 @@ |
154 | 154 | * @return {mw.Title} this |
155 | 155 | */ |
156 | 156 | this.setNamespace = function( s ) { |
157 | | - if ( !mw.isDefined( wgNamespaceIds[ s ] ) ) { |
| 157 | + if ( !mw.isDefined( mw.Title.ns[s] ) ) { |
158 | 158 | throw new Error( 'unrecognized namespace: ' + s ); |
159 | 159 | } |
160 | | - return this.setNamespaceById( wgNamespaceIds[ s ] ); |
| 160 | + return this.setNamespaceById( mw.Title.ns[s] ); |
161 | 161 | }; |
162 | 162 | |
163 | 163 | /** |
— | — | @@ -225,5 +225,25 @@ |
226 | 226 | } |
227 | 227 | |
228 | 228 | }; |
| 229 | + |
| 230 | + // This is similar to the NS_* constants in MediaWiki. |
| 231 | + mw.Title.ns = { |
| 232 | + 'main': 0, |
| 233 | + 'talk': 1, |
| 234 | + 'user': 2, |
| 235 | + 'user_talk': 3, |
| 236 | + 'project': 4, |
| 237 | + 'project_talk': 5, |
| 238 | + 'file': 6, |
| 239 | + 'file_talk': 7, |
| 240 | + 'mediawiki': 8, |
| 241 | + 'mediawiki_talk': 9, |
| 242 | + 'template': 10, |
| 243 | + 'template_talk': 11, |
| 244 | + 'help': 12, |
| 245 | + 'help_talk': 13, |
| 246 | + 'category': 14, |
| 247 | + 'category_talk': 15 |
| 248 | + }; |
229 | 249 | } )( jQuery, mediaWiki ); |
230 | 250 | |