Content deleted Content added
Technical 13 (talk | contribs) It WORKS! Add a "reload" link and add a 2.5 timeout for automatic deOrphaning of pages with 3 or more links to. |
fix script |
||
(12 intermediate revisions by one other user not shown) | |||
Line 1:
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 && mw.config.get( 'wgAction' ) === 'view' &&
$.inArray( function deOrphan( backLinks ){
$( '.loadinganimation' ).html( 'Article deOrphaning in progress...' );
var deOrphanerRequest = {
action:
titles: mw.config.get( 'wgPageName' ),
prop:
intoken:
rvprop:
indexpageids: 1,
dataType:
format:
};
$.get( mw.config.get( 'wgScriptPath' ) +
var deOrphanerContent = $( deOrphanerResponse ).find( 'rev' ).text();
var oldMIparameter = false;
deOrphanerContent = deOrphanerContent.replace(/\{\{Orphan(.*?)\}\}\n/gi, "")▼
if ( deOrphanerContent.search( /\| *Orphan *=[\d\w\s\n]*(.*?\}\})/gi ) != -1 ) { oldMIparameter = true; }
.replace( /\{\{Orphan(.*?)\}\}[\|\n]/gi, '' )// Parse out orphan template (not) in multiple issues
.replace( /\| *Orphan *=[\d\w\s\n]*(.*?\}\})/gi, '$1' );// Parse out old style multiple issues orphan parameter
var deOrphanerSubmit = {
action:
pageid: mw.config.get( 'wgArticleId' ),
text: deOrphanerContent,
summary:
token: mw.user.tokens.get( '
};
$.when(
$.post( mw.config.get( 'wgScriptPath' ) +
var deOrphanedText = 'Article deOrphaned! <small>( ';
).done(function() {▼
if( oldMIparameter ){
$(".loadinganimation").html("Article deOrphaned! <small>(<a href="#reLoad" onClick="___location.reload();" style="font-weight: bold;">reload</a>)</small>");▼
deOrphanedText += '<b style="font-variant: small-caps;">Load</b> ';
});▼
}
▲
}
deOrphanedText += '<a href="//en.wikipedia.org/w/index.php?title=' + encodeURIComponent( mw.config.get( 'wgTitle' ) ) + '&diff=cur&oldid=prev" style="font-weight: bold;">diff</a> )</small>';
$( '.loadinganimation' ).html( deOrphanedText );
▲ } );
} );
}
$( '.ambox-Orphan' ).css( 'display', 'inherit' );
$( '#firstHeading' ).append( ' <span class="loadinganimation" style="font-size: medium !important; color: #000 !important; font-family: sans-serif !important;">• • • </span> ' );
var loadingAnimation = window.setInterval( function() { ( $( $( $( $( $( $( $( )
) }, 250);
var requestBacklinks = {
action:
list:
format:
blfilterredir:
bllimit:
blnamespace: 0,
bltitle: mw.config.get( 'wgTitle' )
};
$.get( mw.config.get( 'wgScriptPath' ) +
var backLinks = responseBacklinks.query.backlinks.length;
switch ( backLinks ){
case 0:
var blStatement = 'This page is an <a href="//en.wikipedia.org/wiki/Wikipedia:Orphan" style="font-weight: bold;">orphan</a> as no <a href="//en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/' + encodeURIComponent( mw.config.get( 'wgTitle' ) ) + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other articles</a> link to it.';
break;
case 1:
var blStatement = 'There is <b>1 link to this page</b> from an <a href="//en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/' + encodeURIComponent( mw.config.get( 'wgTitle' ) ) + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other article</a>. <small>(<a href="#deOrphan" onClick="deOrphan(' + backLinks + ');" style="font-weight: bold;">deOrphan</a>)</small>';
break;
case 2:
var blStatement = 'There are <b>2 links to this page</b> from <a href="//en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/' + encodeURIComponent( mw.config.get( 'wgTitle' ) ) + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other articles</a>. <small>(<a href="#deOrphan" onClick="deOrphan(' + backLinks + ');" style="font-weight: bold;">deOrphan</a>)</small>';
break;
default:
var blStatement = 'This page is not an <a href="//en.wikipedia.org/wiki/Wikipedia:Orphan" style="font-weight: bold;">orphan</a> as it meets the "Rule of Three" by having three or more links from <a href="//en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/' + encodeURIComponent( mw.config.get( 'wgTitle' ) ) + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other articles</a>. <small>(<a href="#deOrphan" onClick="deOrphan(' + backLinks + ');" style="font-weight: bold;">deOrphan</a>)</small>';
// setTimeout( function() { deOrphan( backLinks ); }, 2500 );
break;
}
clearInterval( loadingAnimation );
$(
} );
}
|