Jump to content

User:PerfektesChaos/js/externalLinkProblem/category/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/category/r.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#18419DF9#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw,$){
"use strict";
var Version=2.8,ELP="externalLinkProblem",Sub="category",Section="#deadurl_",SubjectPg="SubjectPg";
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 $factory(area,article){
var s,$r;
if(article){
$r=ELP[Sub].$element.clone();
if(area){
s=ELP[Sub].rooms[area];
if(s){
s=s+":";
}else{
s="";}
}else{
s="";}
s="/wiki/"+s+article;
$r.attr("href",s);
}else{
if(ELP.config.loose){
s="_blank";
}else{
s=SubjectPg;}
$r=$("<a />");
$r.attr({"class":ELP.type+"-article-view","href":"#",
"target":s});
$r.css({"background-color":"#F0F0F0","border-color":"#E0E0E0 #E0E0E0 #707070 #707070",
"border-style":"solid","border-width":"2px",
"display":"inline-block","font-size":"90%",
"margin-left":"3em","padding-bottom":"0",
"padding-left":"0.2em","padding-right":"0.2em",
"text-decoration":"none"});
$r.text("*");
ELP[Sub].$element=$r;}
return $r;}
function facet($aim){
var $a=$aim.children("a"),s=$a.attr("href"),got=/\/wiki\/([^:]+):(.+)$/.exec(s),ns,space;
if(got){
if(ELP[Sub].stamp&&s.indexOf("#")<0){
s=s+ELP[Sub].stamp;
$a.attr("href",s);}
$a.attr("target",ELP[Sub].show);
space=got[1].toLowerCase();
s=got[2];
ns=ELP[Sub].wgNamespaceIds[space];
if(ns){
ns=--ns;
if(ns%2===0){
$aim.append($factory(ns,s));}}}}
function fiat(){
var $pages=$("#mw-pages"),n=$pages.length,env,i,j,k,s,$group,$groups,$h3,$list;
$(".cn-fundraiser-banner, #fundraising").remove();
if(n){
$groups=$pages.find(".mw-category-group");
n=$groups.length;
if(!n){
$groups=$pages;
n=1;}}
if(n){
j=0;
env=mw.config.get(["wgFormattedNamespaces","wgNamespaceIds"]);
ELP[Sub].rooms={};
for(s in env.wgFormattedNamespaces){
k=parseInt(s,10);
if(k>0&&k%2===0){
ELP[Sub].rooms[k]=env.wgFormattedNamespaces[s]
.replace(/\s/,"_");}}
ELP[Sub].wgNamespaceIds=env.wgNamespaceIds;
if(typeof ELP.project.template==="object"&&ELP.project.template&&typeof ELP.project.template.stamp==="string"&&ELP.project.template.stamp){
ELP[Sub].stamp=Section+ELP.project.template.stamp;
}else{
ELP[Sub].stamp=false;}
if(ELP.config.loose){
ELP[Sub].show="_blank";
}else{
ELP[Sub].show="talkELdead";}
$factory();
$h3=$groups.eq(0).find("h3").eq(0);
if($h3.length){
$h3=$h3.eq(0);
if(!$h3.text()){
j=1;}}
for(i=j;i<$groups.length;i++){
$group=$groups.eq(i);
$list=$group.find("li");
for(k=0;k<$list.length;k++){
facet($list.eq(k));}}}}
ELP[Sub].fire=function(){
facilitated();
if(typeof ELP.request==="string"&&ELP.request===Sub&&typeof ELP.config==="object"&&ELP.config){
ELP.request=false;
$(fiat);}
};
function first(){
facilitated();
if(typeof ELP.featuring==="function"){
ELP.featuring(ELP[Sub].fire);}}
first();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>externalLinkProblem/category/r.js