Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -41,23 +41,20 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | | - * Adds the required module and edit token JS if we are on a user (talk) page. |
| 45 | + * Adds the required module if we are on a user (talk) page. |
46 | 46 | * |
47 | 47 | * @param $output |
48 | 48 | * @param $skin Skin |
49 | 49 | */ |
50 | 50 | public static function beforePageDisplay( $out, $skin ) { |
51 | 51 | global $wgWikiLoveGlobal, $wgUser; |
52 | | - if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) return true; |
| 52 | + if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) { |
| 53 | + return true; |
| 54 | + } |
53 | 55 | |
54 | 56 | $title = self::getUserTalkPage( $skin->getTitle() ); |
55 | 57 | if ( !is_null( $title ) ) { |
56 | 58 | $out->addModules( 'ext.wikiLove' ); |
57 | | - $out->addInlineScript( |
58 | | - 'jQuery( document ).ready( function() { |
59 | | - jQuery.wikiLove.editToken = ' . FormatJson::encode( $wgUser->edittoken() ) . '; |
60 | | - } );' |
61 | | - ); |
62 | 59 | } |
63 | 60 | return true; |
64 | 61 | } |
Index: trunk/extensions/WikiLove/wikiLove.js |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | ( function( $ ) { $.wikiLove = { |
3 | 3 | |
4 | 4 | $dialog: null, // dialog jQuery object |
5 | | - editToken: '', // edit token used for the final AJAX call |
6 | 5 | currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown') |
7 | 6 | currentSubtypeId: null, // id of the currently selected subtype (e.g. 'original' or 'special') |
8 | 7 | currentTypeOrSubtype: null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.) |
— | — | @@ -213,14 +212,14 @@ |
214 | 213 | */ |
215 | 214 | sendEmail: function( subject, text ) { |
216 | 215 | $.ajax({ |
217 | | - url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?', |
| 216 | + url: mw.util.wikiScript( 'api' ), |
218 | 217 | data: { |
219 | 218 | 'action': 'emailuser', |
220 | 219 | 'target': wgTitle, |
221 | 220 | 'subject': subject, |
222 | 221 | 'text': text, |
223 | 222 | 'format': 'json', |
224 | | - 'token': $.wikiLove.editToken |
| 223 | + 'token': mw.user.tokens.get( 'editToken' ) |
225 | 224 | }, |
226 | 225 | dataType: 'json', |
227 | 226 | type: 'POST' |
— | — | @@ -445,7 +444,7 @@ |
446 | 445 | 'type': type, |
447 | 446 | 'text': wikitext, |
448 | 447 | 'subject': subject, |
449 | | - 'token': $.wikiLove.editToken |
| 448 | + 'token': mw.user.tokens.get( 'editToken' ) |
450 | 449 | }, |
451 | 450 | dataType: 'json', |
452 | 451 | type: 'POST', |