Content deleted Content added
1.91 |
1.93 |
||
Line 1:
/// Gadget-pageLinkHelper.js
///
/// Fingerprint:#0#
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.
Config={PermanentLink:{"*":"PermaLink"},Redirect:{de:"Weiterleitung"},permTitle:{"*":"PermaLink"},purgeLUtip:{en:"PURGE this page and force link update",de:"PURGE mit rekursivem Linkupdate"},purgeLUtitle:{en:"PURGE/linkupdate",de:"PURGE/linkupdate"},purgeLURtip:{en:"PURGE this page and force recursive link update",de:"PURGE mit rekursivem Linkupdate"},purgeLURtitle:{en:"PURGE/recursive",de:"PURGE/rekursiv"},purgeTip:{en:"PURGE this page from server cache",de:"PURGE: Diese Seite im Server-Cache aktualisieren"},purgeTitle:{en:"Purge cache",de:"Seite purgen"},qqxTip:{en:"Reload and show interface element IDs"},qqxTitle:{en:"lang=qqx"},translate:{"als":"de","bar":"de",
"dsb":"de","frr":"de",
Line 15 ⟶ 14:
"sli":"de","stq":"de",
"vmf":"de"}
};
OPTS.face=function(){
if(typeof mw.libs[Sign]==="object"&&mw.libs[Sign]&&!PLH){
PLH=mw.libs[Sign];
PLH.vsn=Version;
PLH.doc="[["+Shop+Sign+"]]";}
};
OPTS.facet=function(applied){
var r;
OPTS.face();
if(PLH&&typeof PLH[applied]!=="undefined"){
r=PLH[applied];}
return r;
};
function $factory(access){
Line 26 ⟶ 38:
"padding-right":space,"padding-left":space});
return $r;}
function $float($apply,anchor){
var r,sequence,suitable,$anchor,$clear;
if(typeof Env.$corner==="undefined"){
Env.$corner=$("<div>");
Env.$corner.attr({"class":Sign,"id":Sign+"Corner"});
if(anchor){
$anchor=$(anchor);
if($anchor.length>1){
$anchor=$anchor.eq(0);}
}else{
if(!Env.skin){
Env.skin=mw.config.get("skin");}
Line 47 ⟶ 64:
sequence="prepend";
break;}
$anchor=$("#"+suitable);}
if(!$anchor.length){
$anchor=$("#firstHeading");
Line 59 ⟶ 76:
Env.$corner=false;}}
if(Env.$corner){
if($apply){
Env.$corner.empty();
Env.$corner.prepend($apply);}
r=true;}
return r;}
function facility(available){
Line 101 ⟶ 108:
}else{
r=access;}
OPTS.face();
if(PLH&&typeof PLH.config==="object"&&PLH.config&&typeof PLH.config[access]==="object"){
el=PLH.config[access];}
Line 127 ⟶ 134:
return r;}
function favorite(apply){
var opt=OPTS.facet(apply.signature),seed=null,slot="p-cactions",start="ca",got,r,re,skins,suffix,swap;
switch(typeof opt){
case "boolean":
Line 192 ⟶ 199:
r=mw.util.addPortletLink(slot,swap,fair(apply.show,true),start+"-"+suffix,fair(apply.support,true),null,seed);}
return r;}
function feed(about,alter,assign){
window.history.___replaceState(about,alter,assign);}
function fiat(apply,at){
var $div=$("#mw-diff-"+at+"title1"),id,s,$a,$span;
Line 229 ⟶ 238:
return r;}
function flip(){
var
switch(typeof opt){
case "boolean":
break;
case "object":
if(opt){
if(typeof opt.link==="boolean"){
link=opt.link;}
if(typeof opt.msec==="number"){
msec=opt.msec;}
if(typeof opt.selector==="string"){
selector=opt.selector;}
}else{
opt=true;}
break;
default:
opt=true;}
if(opt){
$div=$("#"+sign);
if(!$div.length){
opt=$float(false,selector);}}
if(opt){
if(Env.wgCanonicalSpecialPageName){
re=/\/wiki\/[^:]+:[^\/]+\/(\d+)(?:\/(\.+))?$/;
Line 263 ⟶ 292:
if(id1){
Env.spcNS=mw.config.get("wgFormattedNamespaces")["-1"];
if(!Env.wgPageName){
Env.wgPageName=mw.config.get("wgPageName");}
story=":Diff/"+id1+(id2?"/"+id2:"");
story=Env.spcNS+story;
$span=$("<span>");
if(link){
$spanB=$("<span>");
$spanB.text("[[");
$a=$("<a>");
$a.attr({"href":shift});
$a.text(story);
$spanE=$("<span>");
$spanE.text("]]");
$span.append($spanB);
$span.append($a);
$span.append($spanE);
}else{
$span.text("[["+story+"]]");}
$div=$factory(sign);
$div.append($span);
Line 276 ⟶ 320:
fiat(false,"o");
fiat(false,"n");}
if(!link&&typeof window.history.___replaceState==="function"){
caused={caused:Sign};
if(msec>0){
if(id2){
swap=shift+"&diff="+id2+"&oldid="+id1;
}else{
swap=shift+"&diff="+id1;}
window.history.___replaceState(caused,show,swap);
window.setTimeout(feed,msec,caused,show,shift);
}else{
window.history.___replaceState(caused,show,shift);}}}}
freezer(true);}
function forward(amount,alike){
var $results=$("#mw-content-text li"),n=$results.length,i,j,shift,special,start,strip,$a,$li;
if(n){
special="/wiki/"+mw.config.get("wgFormattedNamespaces")["-1"]+":";
for(i=0;i<n;i++){
$li=$results.eq(i).find("a");
for(j=0;j<amount;j++){
$a=$li.eq(j);
strip=$a.attr("href");
start=mw.util.getParamValue("oldid",strip);
if(start){
strip=strip.replace(/&oldid=\d+\b/,"")
.replace(/&curid=\d+\b/,"");
shift=mw.util.getParamValue("diff",strip);
if(shift){
strip=strip.replace(/&diff=\d+\b/,"");
shift="Diff/"+start+"/"+shift;
}else if(alike){
shift=false;
}else{
shift="PermaLink/"+start;}
if(shift){
shift=special+shift+"$1";
strip=strip.replace(/^.+(\?title=.+)$/,shift);
$a.attr("href",strip);}}}}}}
function freeze(){
var sign=Sign+"Permalink",$div=$("#"+sign),show,special,swift,$a,$br,$spanBeg,$spanEnd;
Line 382 ⟶ 457:
last=(window.history.previous.indexOf(swap)>=0);}
if(!last){
opts=OPTS.facet("redirect");
if(opts&&typeof opts==="object"&&typeof opts.legacy==="boolean"){
legacy=opts.legacy;}
Line 394 ⟶ 469:
window.history.___replaceState(caused,show,swap);
window.history.___pushState(caused,showed,state);}}}
function further(
var n=3,opt=OPTS.facet("history"),scan;
switch(typeof opt){
case "boolean":
if(opt===false){
n=0;}
break;
case "string":
if(opt==="diff"){
scan="diff";}
break;}
if(n){
if(scan==="diff"){
n=2;}
if(mw.user.options.get("gadget-navigation-popups")){
n=0;}
if(n>=1){
forward(n,scan);}}}
function fire(){
var linkUpdate;
mw.user.options.set("gadget-"+Sign,Version);
Env={skin:false,wgCanonicalSpecialPageName:
mw.config.get("wgCanonicalSpecialPageName"),wgPageName:false
Line 424 ⟶ 496:
switch(Env.wgCanonicalSpecialPageName){
case "Contributions":
break;
case "Diff":
Line 431 ⟶ 503:
case "Recentchanges":
case "Watchlist":
break;
case "Gadgets":
Line 445 ⟶ 517:
switch(Env.wgAction){
case "history":
further(
break;
case "view":
Line 467 ⟶ 539:
freezer(true);}
if(linkUpdate){
if(OPTS.facet("forcelinkupdate")){
fresher(true);}
if(OPTS.facet("forcerecursivelinkupdate")){
freshest(true);}}}}
if(OPTS.facet("slangQQX")){
flat(true);}}
if(mw.loader.getState(Signature)!=="ready"){
mw.loader.state(Signature,"ready");
mw.loader.using(["mediawiki.user","mediawiki.util","user","user.options"],function(){
$(fire);
});}
|