r99591 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99590‎ | r99591 | r99592 >
Date:22:33, 11 October 2011
Author:kaldari
Status:deferred
Tags:
Comment:
load the article into the page
Modified paths:
  • /trunk/extensions/PageTriage/ext.pageTriage.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/ext.pageTriage.core.js
@@ -1,6 +1,6 @@
22 ( function( $ ) {
33
4 -var $currentArticle = null; // the title of the current article being reviewed
 4+var $currentArticle = 'Hello World'; // the title of the current article being reviewed
55
66 $.pageTriage = {
77 tagArticle: function() {
@@ -15,22 +15,55 @@
1616 'action': 'edit',
1717 'title': $currentArticle,
1818 'text' : $newText,
19 - 'token': $token,
 19+ 'token': mw.user.tokens.get( 'editToken' ), // MW 1.18 and later
2020 'summary': 'Triaging the page',
2121 'notminor': true
2222 };
2323
2424 $.ajax( {
25 - url: mw.util.wikiScript( 'api' ),
26 - data: sendData,
27 - dataType: 'json',
28 - type: 'POST'
 25+ 'url': mw.util.wikiScript( 'api' ),
 26+ 'data': sendData,
 27+ 'dataType': 'json',
 28+ 'type': 'POST'
2929 } );
3030 },
3131
3232 loadPage: function() {
33 - $( '#ptr-stuff' ).append( "Article goes here!" );
34 - // Load in an article
 33+
 34+ // Get some info about the latest revision of the article
 35+ var sendData = {
 36+ 'action': 'query',
 37+ 'prop': 'revisions',
 38+ 'titles': $currentArticle,
 39+ 'rvlimit': 1,
 40+ 'rvprop': 'timestamp',
 41+ 'format': 'json'
 42+ };
 43+ $.ajax( {
 44+ 'url': mw.util.wikiScript( 'api' ),
 45+ 'data': sendData,
 46+ 'dataType': 'json',
 47+ 'type': 'GET',
 48+ 'success': function( data ) {
 49+ if ( !data || !data.query || !data.query.pages ) {
 50+ // Show error
 51+ return;
 52+ }
 53+ $.each( data.query.pages, function( id, page ) {
 54+ if ( page.revisions[0].timestamp && page.revisions[0].timestamp.length ) {
 55+ //$( '#ptr-stuff' ).append( page.revisions[0].timestamp );
 56+ }
 57+ });
 58+ }
 59+ } );
 60+
 61+ // Load the article into the page
 62+ $( '#ptr-stuff' ).load(
 63+ mw.config.get( 'wgServer' )
 64+ + mw.config.get( 'wgScriptPath' )
 65+ + '/index.php?title=' + encodeURIComponent( $currentArticle ) + '&action=render'
 66+ );
 67+
3568 }
3669 };
3770

Status & tagging log