User:Technical 13/Scripts/OrphanStatus.js: Difference between revisions

Content deleted Content added
Technical 13 (talk | contribs)
This is a starting point which will notify the user in the main heading of the page if the article is an orphan, has 1 or 2 links to it or is not an orphan with 3 or more.
 
Technical 13 (talk | contribs)
Only run on articles tagged as an orphan.
Line 1:
if(mw.config.get('wgNamespaceNumber') === 0 && $.inArray("All orphaned articles", wgCategories)){
$('#firstHeading').append('&nbsp; <span class="loadinganimation" style="font-size: medium !important; color: #000 !important; font-family: sans-serif !important;">•   •&nbsp;&nbsp;•&nbsp;&nbsp;</span> ');
$('#firstHeading').append('&nbsp; <span class="loadinganimation" style="font-size: medium !important; color: #000 !important; font-family: sans-serif !important;">•   •&nbsp;&nbsp;•&nbsp;&nbsp;</span> ');
var loadingAnimation = window.setInterval( function() { ($(".loadinganimation").html() == "•   •&nbsp;&nbsp;•&nbsp;&nbsp;" ? $(".loadinganimation").html("&nbsp;•   •&nbsp;&nbsp;•&nbsp;") : ($(".loadinganimation").html() == "&nbsp;•   •&nbsp;&nbsp;•&nbsp;" ? $(".loadinganimation").html("&nbsp;&nbsp;•   •&nbsp;&nbsp;•") : ($(".loadinganimation").html() == "&nbsp;&nbsp;•   •&nbsp;&nbsp;•" ? $(".loadinganimation").html("&nbsp;•&nbsp;&nbsp;•   •&nbsp;") : $(".loadinganimation").html("•   •&nbsp;&nbsp;•&nbsp;&nbsp;")))) }, 250);
var requestBacklinks = {
action: "query",
list: "backlinks",
format: "json",
blfilterredir: "nonredirects",
bllimit: 3,
blnamespace: 0,
bltitle: mw.config.get('wgTitle')
};
$.get(mw.config.get( 'wgScriptPath' )+"/api.php", requestBacklinks, function(responseBacklinks){
switch (responseBacklinks.query.backlinks.length){
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/' + 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/' + mw.config.get('wgTitle') + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other article</a>. ';
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/' + mw.config.get('wgTitle') + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other articles</a>. ';
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/' + mw.config.get('wgTitle') + '&namespace=0&hideredirs=1&hidetrans=1" style="font-weight: bold;">other articles</a>.';
break;
}
clearInterval(loadingAnimation);
$(".loadinganimation").html(blStatement);
});
}