Jump to content

User:PerfektesChaos/js/externalLinkProblem/extlinks/r.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/// User:PerfektesChaos/js/externalLinkProblem/extlinks/r.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#219D39A8#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw){
"use strict";
var Version=2.8,ELP="externalLinkProblem",Sub="extlinks";
if(typeof mw.libs[ELP]!=="object"||!mw.libs[ELP]){
mw.libs[ELP]={};}
mw.libs[ELP].type=ELP;
ELP=mw.libs[ELP];
if(typeof ELP[Sub]!=="object"){
ELP[Sub]={};}
ELP[Sub].vsn=Version;
function facilitated(){
var rls,signature,sub;
if(typeof ELP.signature==="string"){
sub="/"+Sub;
signature=ELP.signature+sub;
if(mw.loader.getState(signature)!=="ready"){
rls={};
rls[signature]="ready";
mw.loader.state(rls);
mw.hook(ELP.type+sub+".ready").fire();}}}
function fair(){
var lapsus,i,j,m,n,o,s;
if(typeof ELP.problems==="object"&&ELP.problems){
if(ELP.extlinks.url){
m=ELP.extlinks.url.length;
}else{
m=0;}
n=ELP.problems.length;
for(i=0;i<n;i++){
o=ELP.problems[i];
o.live=false;
s=o.url;
for(j=0;j<m;j++){
if(ELP.extlinks.url[j]===s){
o.live=true;
break;}}
if(o.live){
lapsus=(lapsus||o.learnt);
}else if(!o.learnt){
lapsus=true;}}}}
function fixing(arrived){
var i,n,q;
if(typeof arrived==="object"&&typeof arrived.query==="object"){
q=arrived.query;
if(typeof q.pageids==="object"&&typeof q.pages==="object"){
ELP.id=q.pageids[0];
q=q.pages[ELP.id];
if(q&&typeof q.extlinks==="object"){
q=q.extlinks;
n=q.length;
if(n>0){
ELP.extlinks.url=new Array(n);
for(i=0;i<n;i++){
ELP.extlinks.url[i]=q[i]["*"];}
}else{
ELP.extlinks.url=null;}}}}
fair();
if(typeof ELP.extlinks.follow==="function"){
ELP.extlinks.follow();}}
function fixings(){
var q=new mw.Api(),w={action:"query",indexpageids:true,prop:"extlinks",ellimit:500
};
if(!ELP.spot){
ELP.spot=mw.config.get("wgTitle");}
if(ELP.nsubject){
if(!ELP.envNS){
ELP.envNS=mw.config.get("wgFormattedNamespaces");}
w.titles=ELP.envNS[ELP.nsubject]+":"+ELP.spot;
}else{
w.titles=ELP.spot;}
w.titles=w.titles.replace(/ /g,"_");
q.get(w).done(fixing);}
ELP[Sub].fire=function(action){
facilitated();
if(action&&typeof ELP.nsubject==="number"&&typeof ELP.extlinks.url!=="object"){
ELP.extlinks.follow=action;
ELP.extlinks.url=null;
if(true){
mw.loader.using(["mediawiki.api"],fixings);}}
};
function first(){
facilitated();}
first();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>externalLinkProblem/extlinks/r.js