r78171 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78170‎ | r78171 | r78172 >
Date:11:20, 10 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added redlink support
Modified paths:
  • /trunk/extensions/Push/includes/Push_Tab.php (modified) (history)
  • /trunk/extensions/Push/includes/ext.push.tab.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Push/includes/Push_Tab.php
@@ -249,6 +249,9 @@
250250 protected static function getPushItem( $name, $url ) {
251251 global $wgTitle;
252252
 253+ static $targetId = 0;
 254+ $targetId++;
 255+
253256 return Html::rawElement(
254257 'tr',
255258 array(),
@@ -262,7 +265,11 @@
263266 array(),
264267 Html::element(
265268 'a',
266 - array( 'href' => $url . '/index.php?title=' . $wgTitle->getFullText(), 'rel' => 'nofollow' ),
 269+ array(
 270+ 'href' => $url . '/index.php?title=' . $wgTitle->getFullText(),
 271+ 'rel' => 'nofollow',
 272+ 'id' => 'targetlink' . $targetId
 273+ ),
267274 wfMsgExt( 'push-remote-page-link', 'parsemag', $wgTitle->getFullText(), $name )
268275 )
269276 ) .
@@ -275,6 +282,7 @@
276283 'class' => 'push-button',
277284 'pushtarget' => $url,
278285 'style' => 'width: 125px; height: 30px',
 286+ 'targetid' => $targetId
279287 ),
280288 wfMsg( 'push-button-text' )
281289 )
Index: trunk/extensions/Push/includes/ext.push.tab.js
@@ -12,11 +12,21 @@
1313 if ( typeof mediaWiki === 'undefined' ) {
1414 mediaWiki = new Object();
1515
16 - mediaWiki.msg = function( message ) {
17 - return window.wgPushMessages[message];
 16+ mediaWiki.msg = function() {
 17+ message = window.wgPushMessages[arguments[0]];
 18+
 19+ for ( var i = arguments.length - 1; i > 0; i-- ) {
 20+ message = message.replace( '$' + i, arguments[i] );
 21+ }
 22+
 23+ return message;
1824 }
1925 }
2026
 27+ $.each($(".push-button"), function(i,v) {
 28+ getRemoteArticleInfo( $(v).attr( 'targetid' ), $(v).attr( 'pushtarget' ) );
 29+ });
 30+
2131 $('.push-button').click(function() {
2232 this.disabled = true;
2333 this.innerHTML = mediaWiki.msg( 'push-button-pushing' );
@@ -36,6 +46,27 @@
3747 });
3848 });
3949
 50+ function getRemoteArticleInfo( targetId, targetUrl ) {
 51+ $.getJSON(
 52+ targetUrl + '/api.php?callback=?',
 53+ {
 54+ 'action': 'query',
 55+ 'format': 'json',
 56+ 'prop': 'revisions',
 57+ 'rvprop': 'timestamp|user|comment',
 58+ 'titles': $('#pageName').attr('value'),
 59+ },
 60+ function( data ) {
 61+ if ( data.query ) {
 62+ for ( first in data.query.pages ) break;
 63+ if ( first == '-1' ) {
 64+ $( '#targetlink' + targetId ).attr( {'class': 'new'} );
 65+ }
 66+ }
 67+ }
 68+ );
 69+ }
 70+
4071 function initiatePush( sender, pageName, targetUrl ) {
4172 $.getJSON(
4273 wgScriptPath + '/api.php',

Status & tagging log