/// User:PerfektesChaos/js/clickDivertimento/r.js
/// 2019-07-24 [email protected]
/// Fingerprint:#0#5887D8CD#
/// @license:CC-by-sa/4.0
/// Documentation:]
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.9,CDV="clickDivertimento",Config={},Prego={};
if(typeof mw.libs!=="object"||!mw.libs){
mw.libs={};}
mw.libs.type=CDV;
CDV=mw.libs;
if(typeof CDV.vsn!=="number"){
CDV.vsn=Version;
CDV.signature="ext.gadget."+CDV.type;
CDV.support="User:PerfektesChaos/js/"+CDV.type;
CDV.doc="]";
Config.pages=;
Config.texts={
"^show":{"en":"Click-Divertimento",
"de":"Click-Divertimento"},
"^suffix":{"en":"&#8211; Open links in new browser window",
"de":"&#8211; Links in neuem Browserfenster öffnen"},
"^^large":{"en":"Include more list pages",
"de":"Weitere Seiten mit Listen einschließen"},
"^^leave":{"en":"All external links shall be opened in new browser window",
"de":"Alle externen Links in neuem Browserfenster öffnen"},
"^^mode":{"en":"Create entirely new window",
"de":"Völlig neues Fenster öffnen"},
"^^mode0":{"en":"For all diverted targets",
"de":"Immer, wenn ein Link beeinflusst wird"},
"^^mode1":{"en":"Shared windows for the same tasks",
"de":"Wiederbenutzung für gleiche Aufgaben"},
"^^mode2":{"en":"All in the same different window",
"de":"Alle im selben Zweitfenster"}
};}
function fiat(){
var $hype=$(this),src=$hype.attr("href"),k=src.charCodeAt(0),cond,conds,i,shift;
if(k===35){
$hype=false;
}else{
i=src.indexOf("#");
if(i>0&&src.substr(0,i)===Config.source){
$hype=false;}
if($hype&&k!==47&&src.indexOf("//")<0){
$hype=false;}}
if($hype){
shift=Config.shift;
if(Config.kind===1){
if($hype.hasClass("external")){
if(Config.mode){
shift="WikiExtern";}
}else{
shift=false;}}
if(typeof Config.targets==="object"){
for(k in Config.targets){
conds=Config.targets;
for(i=0;i<conds.length;i++){
cond=conds;
switch(typeof cond){
case "string":
if(src.indexOf(cond)>=0){
conds=false;}
break;
case "object":
if(cond.test(src)){
conds=false;}
break;}
if(!conds){
break;}}
if(!conds){
shift=k;
break;}}}
if(shift&&!$hype.attr("target")){
$hype.attr("target",shift);}}}
function fit(){
var $hype=$(this);
if(!$hype.attr("target")){
$hype.attr("target",Config.shift);}}
function flyout(){
var suggestion="a.mw-searchSuggest-link",observer,$div;
if(typeof MutationObserver==="function"){
$div=$(".suggestions-results");
if($div.length){
observer=new MutationObserver(function(mutations){
mutations.forEach(function(){
$(suggestion).each(fit);
});
});
observer.observe($div.get(0),{childList:true});}}}
function furnish($area){
var scope,$hypes;
switch(Config.kind){
case 1:
$hypes=$area.find(".external");
break;
case 2:
case 3:
switch(Config.special){
case "Contributions":
$hypes=$area.find("ul,ol");
break;
case "LinkSearch":
$hypes=$area.find(".special");
break;
case "Whatlinkshere":
$hypes=$area.find("#mw-whatlinkshere-list");
break;
case "Recentchanges":
case "Watchlist":
$hypes=$area.find(".mw-changeslist");
break;
default:
$hypes=$area;}
$hypes=$hypes.find("a");
break;
case 4:
$hypes=$("a");
Config.kind=3;
break;}
$hypes.each(fiat);
if(Config.kind>1){
scope="#searchform, .searchbox";
if(Config.kind===2&&Config.start==="history"){
scope=scope+", #mw-history-compare";}
$(scope).each(fit);
mw.loader.using(,flyout);}}
Config.features=function(){
var pars=,,],n=pars.length,i,s,v,vals;
for(i=0;i<n;i++){
v=pars;
s=v;
if(typeof CDV===v){
this=CDV;
}else{
this=false;}}
Prego.lib=mw.libs;
if(typeof Prego.lib==="object"&&Prego.lib&&typeof Prego.lib.fetch==="function"){
vals=Prego.lib.fetch(CDV.type);
if(vals&&typeof vals==="object"){
for(i=0;i<n;i++){
v=pars;
s=v;
if(typeof vals===v){
this=vals;}}}
}else{
Prego.lib=false;}
if(typeof CDV.targets==="object"&&CDV.targets&&this.mode){
this.targets={};
for(s in CDV.targets){
v=CDV.targets;
if(v){
switch(typeof v){
case "string":
v=;
break;
case "object":
if(typeof v.length!=="number"){
if(typeof v.ignoreCase==="boolean"){
v=;
}else{
v=false;}}
break;
default:
v=false;}
if(v){
this.targets=v;}}}}
};
Config.fire=function(){
var i;
Config.features();
if(Config.learn){
Config.kind=4;
if(Prego.lib){
Prego.form();}
}else{
Config.kind=false;
if(typeof Config.special==="string"){
switch(Config.special){
case "Contributions":
case "LinkSearch":
case "Whatlinkshere":
if(Config.large){
Config.kind=2;}
break;
default:
Config.kind=2;}
}else{
switch(Config.start){
case "edit":
case "submit":
Config.kind=4;
$(".cancelLink").hide();
break;
case "history":
if(Config.large){
Config.kind=2;}
break;
case "view":
if(Config.leave){
Config.kind=1;}
break;}}}
if(Config.kind){
Config.source=window.location.href;
i=Config.source.indexOf("#");
if(i>0){
Config.source=Config.source.substr(0,i);}
switch(Config.mode){
case 1:
Config.shift="_blank";
break;
case 2:
Config.shift="clickDiver";
break;
default:
Config.shift="_blank";}
mw.hook("wikipage.content").add(furnish);}
};
Prego.fire=function(){
var rls,signature;
this.supply="preferencesGadgetOptions";
signature="ext.gadget."+this.supply;
if(!mw.loader.getState(signature)){
rls={};
rls="loading";
mw.loader.state(rls);
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/"+this.supply+"/r.js&action=raw&bcache=1&maxage=604809&ctype=text/javascript","text/javascript");}
};
Prego.firing=function(){
mw.hook(Prego.supply+".ready").add(Config.fire);
};
Prego.form=function(){
var pages={},poly=,txt=Config.texts,dialog,i,s;
for(i=0;i<Config.pages.length;i++){
s=Config.pages;
pages="//"+s+".wikipedia.orghttps://wikines.com/en/"+CDV.support;}
for(i=0;i<3;i++){
poly.push({val:i,show:txt});}
dialog={script:CDV.type,show:txt,support:pages,suffix:txt,opts:,val:Config.large
},{signature:"leave",type:"checkbox",show:txt,val:Config.leave
},{signature:"mode",type:"radio",show:txt,val:Config.mode,poly:poly}]};
Prego.lib.form(dialog);
};
CDV.fire=function(){
var env,launch,rls;
if(mw.loader.getState(CDV.signature)!=="ready"){
rls={};
rls="ready";
mw.loader.state(rls);
env=mw.config.get();
launch=true;
Config.learn=false;
if(env.wgNamespaceNumber===-1){
Config.special=env.wgCanonicalSpecialPageName;
switch(Config.special){
case "Blankpage":
case "Gadgets":
Config.learn=true;
break;
case "Contributions":
case "EditWatchlist":
case "LinkSearch":
case "Recentchanges":
case "Watchlist":
case "Whatlinkshere":
break;
default:
launch=false;}
}else{
Config.start=env.wgAction;}
if(launch){
Prego.fire();
mw.loader.using(,Prego.firing);}}
};
CDV.fire();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>clickDivertimento/r.js