User:PerfektesChaos/js/pageLinkHelper/d.js: Difference between revisions

Content deleted Content added
-1.6
-2.6
 
(12 intermediate revisions by the same user not shown)
Line 1:
/// Gadget-pageLinkHelper.js
// Some minor link helpers
/// 2021-05-21 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible; dependencies: user, mediawiki.util
// ResourceLoader: compatible;
/// 2014-12-16 PerfektesChaos@de.wikipedia
// dependencies: user, user.options,
/// Fingerprint: #0#0#
// mediawiki.api, mediawiki.user, mediawiki.util
/// Fingerprint: #0#0#
// Documentation: [[w:en:User:PerfektesChaos/js/pageLinkHelper]]
/// <nowiki>
/* global window: false */
/*jshint bitwise:true, curly:true, eqeqeq:true, latedef:true,
/* jshint laxbreakbitwise:true, strictcurly:true, trailingeqeqeq:true, undeflatedef:true,
laxbreak:true,
unused:true, white:false */
/*global window:false nocomma:true, strict:true, undef:true, unused:true */
( function ( mw, $ ) {
"use strict";
var Version = -12.6,
Sign = "pageLinkHelper",
Signature = "ext.gadget." + Sign,
Shop = "w:en:User:PerfektesChaos/js/",
Env, PLH;
Diff = { },
Hist = { },
OPTS = { },
Perm = { },
Purge = { },
QQmsg = { },
Redir = { },
URL2i = { },
Config, Env, PLH;
 
 
 
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" },
purgeLURGtip: { en: "PURGE related pages"
+ " and force recursive link update",
de: "PURGE bezogener Seiten"
+ " mit rekursivem Linkupdate" },
purgeLURGtitle:{ en: "PURGE/recursive related pages",
de: "PURGE/rekursiv bezogene Seiten" },
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",
de: "Neu laden"
+ " und MediaWiki-IDs zeigen" },
qqxTitle: { en: "lang=qqx" },
translate: { "als" : "de",
"bar" : "de",
"dsb" : "de",
"frr" : "de",
"gsw" : "de",
"hsb" : "de",
"ksh" : "de",
"lb" : "de",
"nds" : "de",
"pdc" : "de",
"pdt" : "de",
"pfl" : "de",
"sli" : "de",
"stq" : "de",
"vmf" : "de" }
}; // 2015-01-06 PerfektesChaos@de.wikipedia
 
 
Line 23 ⟶ 84:
// access -- distinguishing selector ID
// Uses:
// > Env.ltr
// > Sign
// 20142015-1201-1106 PerfektesChaos@de.wikipedia
var space = "4px",
style = "#808080B0C4DE 1px solid",
$r = $( "<div>" );
$r.attr( { "class": Sign,
"id": access } );
style$r.css( ={ "#808080border-bottom": 1px solid"; style,
$r.css( { "borderbackground-bottomcolor": style"#FFFFFF",
"border-leftbackground": style "rgba(255, 255, 255, 0.5)",
"floatfont-family": "rightmonospace",
"fontmargin-familybottom": "monospace1em",
"margin-bottomtop": "1em" space,
"marginpadding-leftbottom": "1em"space,
"marginpadding-topright": space,
"padding-bottomleft": space, } );
if ( Env.ltr ) {
"padding-left": space } );
$r.css( { "border-left": style,
"float": "right",
"margin-left": "1em" } );
} else {
$r.css( { "border-right": style,
"float": "left",
"margin-right": "1em" } );
}
return $r;
} // $factory()
Line 45 ⟶ 115:
 
 
function $float( $apply, anchor ) {
// Insert/exchange upper right corner element
// Precondition:
// $apply -- jQuery element to insert
// false to vheckcheck availability
// anchor -- string, with user defined selector, or undefined
// Postcondition:
// Returns true, if insertion possible
Line 55 ⟶ 126:
// > Sign
// >< Env
// 20142021-1205-1121 PerfektesChaos@de.wikipedia
var r, // = undefined
sequence, suitable, $divanchor, $clear;
if ( typeof Env.$anchorcorner === "undefined" ) {
Env.$anchorltr = ( ! $( "#firstHeadingbody.sitedir-rtl" ).length );
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" );
}
switch ( Env.skin ) {
case "cologneblue" :
suitable = "#firstHeading";
sequence = "after";
break;
case "modern" :
suitable = "#contentSub";
sequence = "before";
break;
case "monobook" :
case "vector" :
suitable = ".mw-body-content";
sequence = "prepend";
break;
} // switch Env.skin
$anchor = $( suitable ).eq( 0 );
}
if ( ! $anchor.length ) {
$anchor = $( "#firstHeading" );
sequence = "after";
}
if ( $anchor.length ) {
$anchor[ sequence ]( Env.$corner );
$clear = $( "<div>" );
$clear.css( { "clear": ( Env.ltr ? "left" : "right" ) } );
Env.$corner.after( $clear );
} else {
Env.$corner = false;
}
}
if ( Env.$anchor.lengthcorner ) {
r = true;
if ( $apply ) {
Env.$div = $( "corner." + Sign empty();
Env.$divcorner.removeprepend( $apply );
$div = $( "<div>" );
$div.css( { "clear": "left" } );
Env.$anchor.after( $div );
Env.$anchor.after( $apply );
}
r = true;
}
return r;
Line 77 ⟶ 185:
 
 
function fiatfacility( apply, atavailable ) {
// Localize in user language, GUI only
// Equip diffpage revision with wikilink for permalink c&p
// Precondition:
// applyavailable -- revisiontranslation IDobject
// Postcondition:
// at -- revision column; "n" or "o"
// DOM.readyReturns string, or undefined
// Diffpage
// Uses:
// > SignConfig
// > < Env.spcNS
// mw.config.get()
// mw.util.getParamValue()
// 2014-12-16 PerfektesChaos@de.wikipedia
var $divi, r, = $( "#mw-diff-" + at + "title1" ),slang;
if ( ! Env.userLang id,) s, $a, $span;{
Env.userLang = mw.config.get( "wgUserLanguage" ).toLowerCase();
if ( $div.length ) {
if ( apply ) {}
idslang = applyEnv.userLang;
if ( typeof available[ slang ] if ( apply === "curstring" ) {
idr = mw.config.get(available[ "wgCurRevisionId"slang )];
} else {
i = slang.indexOf( "-", 2 );
if ( i > 0 ) {
slang = slang.substr( 0, i );
if ( typeof available[ slang ] === "string" ) {
r = available[ slang ];
}
}
}
if ( ! r ) {
if ( typeof Config.translate[ slang ] === "string" ) {
slang = Config.translate[ slang ];
if ( typeof available[ slang ] === "string" ) {
r = available[ slang ];
}
}
if ( ! r ) {
r = available.en;
}
}
return r;
} // facility()
 
 
 
function fair( access, adapt, alter ) {
// Localization
// Precondition:
// access -- configuration keyword
// adapt -- false, if project (language) dependant
// else user language dependant
// alter -- default string (en)
// Postcondition:
// Returns value, or keyword 'access'
// Uses:
// > PLH
// > Config
// >< Env
// facility()
// mw.config.get()
// 2017-01-20 PerfektesChaos@de.wikipedia
var el, r, say;
if ( alter ) {
r = alter;
} else {
r = access;
}
if ( typeof PLH.config === "object" &&
PLH.config &&
typeof PLH.config[ access ] === "object" ) {
el = PLH.config[ access ];
}
if ( ! el ) {
el = Config[ access ];
}
if ( el ) {
if ( adapt ) {
say = facility( el );
if ( say ) {
r = say;
} else if ( typeof alter !== "string" ) {
r = "???" + access + "???";
}
} else {
$aif = $div.find( "a"! )Env.eq(wgDBname 0) );{
s Env.wgDBname = $amw.config.attrget( "hrefwgDBname" );
id = mw.util.getParamValue( "oldid", s );}
if ( typeof el[ Env.wgDBname ] === "string" ) {
r = el[ Env.wgDBname ];
} else {
if ( ! Env.wgContentLanguage ) {
Env.wgContentLanguage
= mw.config.get( "wgContentLanguage" );
}
if ( typeof el[ Env.wgContentLanguage ] === "string" ) {
r = el[ Env.wgContentLanguage ];
}
}
}
} else if ( idadapt ) {
s r = "[[" + Env.spcNS + ":PermanentLink/???" + idaccess + "]]???";
}
$span = $( "<span>" );
return r;
$span.attr( { "class": Sign + " " + Sign + "DiffRev" } );
} // fair()
$span.css( { "font-family": "monospace",
 
"margin-left": "1em" } );
 
$span.text( s );
 
$div.append( $span );
function favorite( apply ) {
// Insert portlet link, if appropriate
// Precondition:
// apply -- object
// .signature -- user option keyword
// .skins -- default skins, if any
// true; or "|vector|" etc.
// .fun -- callback for link generation
// .forward -- callback for click
// .show -- link title keyword
// .support -- tooltip keyword
// OPTIONAL:
// .suffix -- selector creation
// DOM.ready
// mediawiki.util loaded
// user resources loaded
// Postcondition:
// Returns DOM of portlet, or undefined
// Uses:
// >< Env
// OPTS.facet()
// mw.config.get()
// fair()
// mw.util.addPortletLink()
// (apply.fun)
// 2016-08-18 PerfektesChaos@de.wikipedia
var opt = OPTS.facet( apply.signature ),
seed = null,
slot = "p-cactions",
start = "ca",
got, r, re, skins, suffix, swap;
switch ( typeof opt ) {
case "boolean" :
if ( opt ) {
seed = false;
skins = true;
} else {
slot = false;
}
break;
case "string" :
seed = opt;
re = /^([a-z]+)-(.+)$/;
got = re.exec( seed );
if ( got ) {
switch ( got[ 1 ] ) {
case "p" :
slot = seed;
seed = false;
switch ( got[ 2 ] ) {
case "navigation" :
start = "n";
break;
case "tb" :
start = "t";
break;
} // switch got.2
break;
case "ca" :
break;
case "n" :
slot = "p-navigation";
break;
case "t" :
slot = "p-tb";
break;
} // switch got.1
}
break;
} // switch typeof opt
if ( slot && seed === null ) {
if ( ! skins ) {
switch ( typeof apply.skins ) {
case "boolean" :
case "string" :
skins = apply.skins;
break;
} // switch typeof apply.skins
}
if ( skins === true ) {
skins = "|vector|";
}
if ( skins ) {
if ( ! Env.skin ) {
Env.skin = mw.config.get( "skin" );
}
if ( skins.indexOf( Env.skin ) < 0 ) {
if ( opt ) {
slot = "p-tb";
start = "t";
} else {
slot = false;
}
}
} else {
slot = false;
}
}
if ( slot ) {
if ( typeof apply.fun === "function" ) {
swap = apply.fun();
} else {
swap = "#";
}
if ( typeof apply.suffix === "string" ) {
suffix = apply.suffix;
} else {
suffix = apply.signature;
}
if ( seed ) {
seed = "#" + seed;
}
r = mw.util.addPortletLink( slot,
swap,
fair( apply.show, true ),
start + "-" + suffix,
fair( apply.support, true ),
null,
seed );
if ( typeof apply.forward === "function" ) {
$( r ).find( "a" ).click( apply.forward );
}
}
return r;
} // favorite()
 
 
 
function feed( about, alter, assign ) {
// Execute URL replacement after some delay
// Precondition:
// about -- object, with reason
// alter -- string, with title
// assign -- string, with new URL
// Uses:
// history.___replaceState()
// 2015-01-03 PerfektesChaos@de.wikipedia
window.history.___replaceState( about, alter, assign );
} // feed()
 
 
 
function fire() {
// Autorun on load
// Uses:
// > Signature
// mw.loader.getState()
// mw.loader.state()
// mw.loader.using()
// (OPTS.fire)
// 2018-08-24 PerfektesChaos@de.wikipedia
var rls;
if ( mw.loader.getState( Signature ) !== "ready" ) {
rls = { };
rls[ Signature ] = "ready";
mw.loader.state( rls );
mw.loader.using( [ "mediawiki.api",
"mediawiki.user",
"mediawiki.util",
"user",
"user.options" ],
OPTS.fire );
}
} // fire()
 
 
 
function first() {
// Initialize
// Precondition:
// mediawiki.user mediawiki.util loaded
// Uses:
// > Sign
// > PLH
// < Env
// mw.config.get()
// mw.util.getParamValue()
// URL2i.forward()
// Diff.flip()
// mw.user.options.get()
// Purge.freshissimo()
// Hist.further()
// Perm.furnish()
// Perm.flip()
// Purge.fresh()
// Redir.from()
// OPTS.facet()
// Purge.fresher()
// Purge.freshest()
// QQmsg.flat()
// mw.hook()
// 2020-01-05 PerfektesChaos@de.wikipedia
var embed, i, linkUpdate, s;
Env = { skin: false,
wgCanonicalSpecialPageName:
mw.config.get( "wgCanonicalSpecialPageName" ),
wgFormattedNamespaces: false,
wgNamespaceNumber: false,
wgPageName: false
};
if ( Env.wgCanonicalSpecialPageName ) {
switch ( Env.wgCanonicalSpecialPageName ) {
case "Contributions" :
URL2i.forward( 2 );
break;
case "Diff" :
Diff.flip();
break;
case "Mobile" :
break;
case "Whatlinkshere" :
Env.wgNamespaceNumber = -1;
if ( OPTS.facet( "forcerecursivelinkupdate" ) ) {
Env.wgFormattedNamespaces =
mw.config.get( "wgFormattedNamespaces" );
Env.wgRelevantPageName =
mw.config.get( "wgRelevantPageName" );
embed = [ 10, 828 ];
for ( i = 0; i < embed.length; i++ ) {
s = embed[ i ] + "";
s = Env.wgFormattedNamespaces[ s ] + ":";
if ( Env.wgRelevantPageName
.substr( 0, s.length ) === s ) {
Purge.freshissimo();
break; // for i
}
} // for i
}
break;
case "Recentchanges" :
case "Watchlist" :
if ( !
mw.user.options.get( "gadget-navigation-popups" ) ) {
URL2i.forward( 1 );
}
break;
case "Gadgets" :
// form();
break;
} // switch wgCanonicalSpecialPageName
} else {
Env.diff = mw.util.getParamValue( "diff" );
Env.oldid = mw.util.getParamValue( "oldid" );
if ( Env.diff ) {
Diff.flip();
} else {
linkUpdate = true;
Env.wgAction = mw.config.get( "wgAction" );
switch ( Env.wgAction ) {
case "history" :
Hist.further();
break;
case "view" :
Env.curid = mw.util.getParamValue( "curid" );
if ( Env.curid || Env.oldid ) {
Perm.furnish( true );
} else {
Perm.flip( true );
}
Purge.fresh( true );
Env.wgRedirectedFrom
= mw.config.get( "wgRedirectedFrom" );
if ( Env.wgRedirectedFrom ) {
Redir.from();
}
Env.wgNamespaceNumber
= mw.config.get( "wgNamespaceNumber" );
if ( Env.wgNamespaceNumber === 14 &&
OPTS.facet( "forcerecursivelinkupdate" ) ) {
Purge.freshissimo();
}
break;
case "info" :
Purge.fresh( true );
break;
case "edit" :
case "submit" :
linkUpdate = false;
// fall through
default:
Perm.flip( true );
} // switch wgAction
if ( linkUpdate ) {
if ( OPTS.facet( "forcelinkupdate" ) ) {
Purge.fresher( true );
}
if ( OPTS.facet( "forcerecursivelinkupdate" ) ) {
Purge.freshest( true );
}
}
}
}
if ( OPTS.facet( "slangQQX" ) ) {
QQmsg.flat( true );
}
mw.hook( Sign + ".ready" ).fire( PLH );
} // fiat()
} // first()
 
 
 
OPTS.facet = function feature( applied ) {
// Check for user option
// Precondition:
Line 125 ⟶ 598:
// Returns value, or undefined
// Uses:
// > mw.libsPLH
// > OPTS.user
// 2017-01-20 PerfektesChaos@de.wikipedia
var r; // = undefined
if ( typeof PLH[ applied ] !== "undefined" ) {
r = PLH[ applied ];
}
if ( OPTS.user &&
typeof OPTS.user[ applied ] !== "undefined" ) {
r = OPTS.user[ applied ];
PLH[ applied ] = r;
}
return r;
}; // OPTS.facet()
 
 
 
OPTS.features = function ( apply ) {
// Receive user options
// Precondition:
// apply -- options object
// module 'user' loaded
// 2017-01-20 PerfektesChaos@de.wikipedia
if ( typeof OPTS.user === "undefined" ) {
if ( typeof apply === "object"
&& apply ) {
OPTS.user = apply;
} else {
OPTS.user = false;
}
}
}; // OPTS.features()
 
 
 
OPTS.fire = function () {
// Consider user options by mw.libs, and run
// Precondition:
// user user.options loaded
// Uses:
// > Sign
// > Version
// >< PLH mw.libs
// 2014-12-11 PerfektesChaos@de.wikipedia > Shop
var// r; // =< undefinedPLH
if// ( typeof mw.libs[ Sign ] === "object" user.options.set() {
// mw.hook()
// (OPTS.features)
// (Purge.foreign)
// (first)
// 2017-01-21 PerfektesChaos@de.wikipedia
mw.user.options.set( "gadget-" + Sign, Version );
if ( typeof mw.libs[ Sign ] === "object" &&
mw.libs[ Sign ] ) {
PLH = mw.libs[ Sign ];
} if ( PLH )else {
PLH.vsn = Version{ };
if ( typeof PLH[ applied ] !== "undefined" ) {
r = PLH[ applied ];
}
}
}
returnPLH.type r= Sign;
} //PLH.vsn feature() = Version;
PLH.doc = "[[" + Shop + Sign + "]]";
mw.hook( Sign + ".before" ).add( OPTS.features );
PLH.fresh = Purge.foreign;
$( first ); // don't hurry
}; // OPTS.fire()
 
 
 
Diff.flip = function flip() {
// Equip diffpage with wikilink for c&p
// Precondition:
Line 153 ⟶ 674:
// > Sign
// > ___location
// > history
// > document
// >< Env
// mwOPTS.config.getfacet()
// $float()
// $factory()
// Perm.fiat()
// freezermw.config.get()
// 2014-12-14 PerfektesChaos@de mw.util.wikipediawikiUrlencode()
var// sign = Sign + "Difflink",setTimeout()
// $div = $history.___replaceState( "#" + sign ),
// got, i, id1, id2, j, re, show, $span;Perm.flip()
if// ( ! $div.length && $float(feed) ) {
// 2015-01-07 PerfektesChaos@de.wikipedia
var link = false,
msec = 500,
opt = OPTS.facet( "diff" ),
sign = Sign + "Difflink",
caused, got, i, id1, id2, j,
re, selector, shift, show, story, swap,
$a, $div, $span, $spanB, $spanE;
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;
} // switch typeof opt
if ( opt ) {
$div = $( "#" + sign );
if ( ! $div.length ) {
opt = $float( false, selector );
}
}
if ( opt ) {
if ( Env.wgCanonicalSpecialPageName ) {
// 2014 redirected to &diff=
Line 205 ⟶ 764:
if ( id1 ) {
Env.spcNS = mw.config.get( "wgFormattedNamespaces" )[ "-1" ];
showif ( = "[[" +! Env.spcNS + ":Diff/"wgPageName +) id1{
Env.wgPageName = + mw.config.get( id2 ? "/" + id2 : "wgPageName" );
+ "]]";}
$span story = $( "<span>:Diff/" );+ id1
$span.text + ( showid2 ? "/" + id2 : "" );
shift = "/wiki/"
+ mw.util.wikiUrlencode( Env.spcNS ) + story
+ "?title="
+ mw.util.wikiUrlencode( Env.wgPageName );
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 );
$float( $div );
if ( id2 ) {
Perm.fiat( id1, "o" );
Perm.fiat( id2, "n" );
} else {
Perm.fiat( false, "o" );
Perm.fiat( false, "n" );
}
if ( ! link &&
typeof window.history.___replaceState === "function" ) {
caused = { caused: Sign };
show = window.document.title;
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 );
}
}
}
}
Perm.flip( true );
}; // Diff.flip()
 
 
 
Hist.further = function () {
// Deal with history page
// Precondition:
// loaded user.options mediawiki.user
// Uses:
// OPTS.facet()
// mw.user.options.get()
// 2015-01-03 PerfektesChaos@de.wikipedia
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;
} // switch opt
if ( n ) {
if ( scan === "diff" ) {
n = 2;
}
if ( mw.user.options.get( "gadget-navigation-popups" ) ) {
n = 0;
}
if ( n >= 1 ) {
URL2i.forward( n, scan );
}
}
}; // Hist.further()
 
 
 
Perm.fiat = function ( apply, at ) {
// Equip diffpage revision with wikilink for permalink c&p
// Precondition:
// apply -- revision ID, or some keyword
// at -- revision column; "n" or "o"
// DOM.ready
// Diffpage
// Uses:
// > Sign
// > Env.spcNS
// mw.config.get()
// mw.util.getParamValue()
// 2014-12-16 PerfektesChaos@de.wikipedia
var $div = $( "#mw-diff-" + at + "title1" ),
id, s, $a, $span;
if ( $div.length ) {
if ( apply ) {
id = apply;
if ( apply === "cur" ) {
id = mw.config.get( "wgCurRevisionId" );
} else if ( typeof apply === "string" &&
! /^\d+$/.test( apply ) ) { // "next"
id = false;
}
}
if ( ! id ) {
$a = $div.find( "a" ).eq( 0 );
s = $a.attr( "href" );
id = mw.util.getParamValue( "oldid", s );
}
if ( id ) {
s = "[[" + Env.spcNS + ":PermanentLink/" + id + "]]";
$span = $( "<span>" );
$span.attr( { "class": Sign + " " + Sign + "DiffRev" } );
$span.css( { "font-family": "monospace",
"margin-left": "1em" } );
$span.text( s );
$div.append( $span );
}
}
}; // Perm.fiat()
 
 
 
Perm.flip = function ( assign ) {
// Change portlet for permalink
// Precondition:
// assign -- true if link to be diverted, false to gray out
// DOM.ready
// Uses:
// > Sign
// > Version
// fair()
// (Perm.furnish)
// 2014-12-19 PerfektesChaos@de.wikipedia
var $portlet = $( "#t-permalink" ),
show, support, $a, $span;
if ( $portlet.length ) {
support = Sign + " " + Version;
if ( assign ) {
$a = $( "<a>" );
$a.attr( { "title": support } );
$a.click( Perm.furnish );
$a.text( fair( "permTitle", false, "PermaLink" ) );
$portlet.empty();
$portlet.append( $a );
} else {
$a = $portlet.find( "a" );
show = $a.text();
if ( show ) {
$span = $( "<span>" );
$span.css( { "color": "#808080" } );
$span.text( show );
$span.attr( { "title": support } );
$portlet.empty();
$portlet.append( $span );
}
}
}
}; freezer// Perm.flip( true );
} // flip()
 
 
 
Perm.furnish = function freeze() {
// Equip page with wikilink to perma for c&p
// Precondition:
Line 240 ⟶ 956:
// mw.util.wikiUrlencode()
// mw.util.getUrl()
// freezerfair()
// 2014-12-14 PerfektesChaos@de Perm.wikipediaflip()
// 2016-08-30 PerfektesChaos@de.wikipedia
var sign = Sign + "Permalink",
$div = $( "#" + sign ),
show, special, swift, $a, $br, $spanBeg, $spanEnd;
if ( ! $div.length && $float() ) {
Env.wgPageNameif =( mw! Env.config.get( "wgPageName" ); {
Env.wgPageName = mw.config.get( "wgPageName" );
}
if ( Env.curid ) {
Env.curid = parseInt( Env.curid, 10 );
Line 257 ⟶ 976:
Env.oldid = mw.config.get( "wgCurRevisionId" );
}
$div = $factory( sign );
specialif ( =! mwEnv.config.get( "wgFormattedNamespaces" )[ "-1" ]{
+ ":";Env.wgFormattedNamespaces
= mw.config.get( "wgFormattedNamespaces" );
}
special = Env.wgFormattedNamespaces[ "-1" ] + ":";
swift = "?title="
+ mw.util.wikiUrlencode( Env.wgPageName );
Line 269 ⟶ 991:
if ( Env.oldid ) {
$div.append( $spanBeg.clone() );
show = special + "PermanentLink/" + Env.oldid;
+ fair( "PermanentLink", false, "PermaLink" )
+ "/" + Env.oldid;
$a.attr( { "href": mw.util.getUrl( show ) + swift } );
$a.text( show );
Line 279 ⟶ 1,003:
}
$div.append( $spanBeg );
show = special + "Redirect/page/" + Env.curid;
+ fair( "Redirect", false )
+ "/page/" + Env.curid;
$a.attr( { "href": mw.util.getUrl( show ) + swift } );
$a.text( show );
Line 285 ⟶ 1,011:
$div.append( $spanEnd );
$float( $div );
freezerPerm.flip( false );
}
}; // freezePerm.furnish()
 
 
 
Purge.fail = function freezer( assignarrived, add ) {
// ChangeAPI portletpurging for permalinkfailed
// Precondition:
// assignarrived -- truestring ifwith linkbasic to be diverted, false to gray outmessage
// add -- object with additional information
// Uses:
// window.console
// 2016-08-30 PerfektesChaos@de.wikipedia
if ( typeof window.console === "object" &&
typeof arrived === "string" ) {
if ( typeof window.console.log === "function" ) {
window.console.log( arrived );
}
if ( typeof add === "object" && add &&
typeof window.console.dir === "function" ) {
window.console.dir( add );
}
}
}; // Purge.fail()
 
 
 
Purge.feed = function () {
// Launch API generator query
// Uses:
// > Purge.Api
// > Purge.request
// (Purge.further)
// (Purge.fail)
// 2016-08-30 PerfektesChaos@de.wikipedia
Purge.Api.post( Purge.request )
.done( Purge.further )
.fail( Purge.fail );
}; // Purge.feed()
 
 
 
Purge.fiat = function ( additional, already ) {
// Start API purging of a single page
// Precondition:
// additional -- some keyword, or not
// already -- request parameters, or not
// Uses:
// mw.Api() .post()
// 2017-01-20 PerfektesChaos@de.wikipedia
var o = new mw.Api( { parameters: { action: "purge" } } ),
p;
if ( already ) {
p = already;
} else {
p = { pageids: Env.curid };
}
if ( additional ) {
p[ additional ] = true;
}
o.post( p )
.done( function () { window.___location.reload( true ); } );
}; // Purge.fiat()
 
 
 
Purge.first = function () {
// Ensure curid=pageid and purgeable revision
// Postcondition:
// Returns curid=pageid, or undefined
// Uses:
// >< Env.curid
// mw.config.get()
// 2016-08-18 PerfektesChaos@de.wikipedia
if ( typeof Env.curid !== "number" ) {
Env.curid = mw.config.get( "wgArticleId" );
}
return Env.curid;
}; // Purge.first()
 
 
 
Purge.foreign = function ( additional, array, allow ) {
// External access to purge function
// Precondition:
// additional -- string, number, or false
// array -- Attay of page titles, or page IDs, or not
// allow -- number of permitted array elements, or not
// Uses:
// Purge.fiat()
// Purge.full()
// 2017-01-21 PerfektesChaos@de.wikipedia
var many = 50,
e, i, m, p, q, s, stage;
switch ( additional ) {
case 1 :
stage = "forcelinkupdate";
break;
case 2 :
stage = "forcerecursivelinkupdate";
break;
case "forcelinkupdate" :
case "forcerecursivelinkupdate" :
stage = additional;
break;
default:
stage = "";
} // switch additional
if ( typeof allow === "number"
&& allow > many ) {
many = allow;
}
if ( typeof array === "object"
&& array &&
typeof array.length === "number"
&& array.length ) {
e = array[ 0 ];
s = typeof e;
switch ( s ) {
case "number" :
p = { pageids: e };
q = p.pageids;
break;
case "" :
p = { titles: e };
q = p.titles;
break;
} // typeof array[ 0 ]
if ( p ) {
m = many - 1;
for ( i = 1; i < array.length; i++ ) {
if ( m ) {
e = array[ i ];
if ( typeof e === s ) {
if ( s === "number" && e < 0 ) {
e = 0;
}
if ( e ) {
q = q + "|" + e;
m--;
}
}
} else {
break; // for i
}
} // for i
}
}
if ( ! p ) {
switch ( Env.wgNamespaceNumber ) {
case -1 :
switch ( Env.wgCanonicalSpecialPageName ) {
case "Whatlinkshere" :
p = false;
break;
} // switch wgCanonicalSpecialPageName
break;
case 14 :
p = false;
break;
} // switch wgNamespaceNumber
}
if ( p === false ) {
Purge.full( stage );
} else {
Purge.fiat( stage, p );
}
}; // Purge.foreign()
 
 
 
Purge.fresh = function ( ahead ) {
// Provide purge link
// Precondition:
// ahead -- true if initializing, false to link
// DOM.ready
// user resources loaded
// Uses:
// > SignPurge.first()
// > Versionfavorite()
// Purge.fiat(freeze)
// 2014-12-11 PerfektesChaos@de (Purge.wikipediafresh)
// 2016-08-18 PerfektesChaos@de.wikipedia
var $portlet = $( "#t-permalink" ),
if ( ahead === show,true support,) $a, $span;{
if ( $portletPurge.lengthfirst() ) {
support = Sign +favorite( "{ signature: " + Version;purge",
if ( assign ) { skins: true,
$a = $( "<a>" ); forward: Purge.fresh,
$a.attr( { "title" show: support } ); "purgeTitle",
$a.click( freeze ); support: "purgeTip",
$a.text( suffix: "PermaLinkpurge" );
$portlet.empty( } );
$portlet.append( $a );}
} else {
$a = $portletPurge.findfiat( "a" );
show = $a.text();}
}; // if Purge.fresh( show ) {
 
$span = $( "<span>" );
 
$span.css( { "color": "#808080" } );
 
$span.text( show );
Purge.fresher = function ( ahead ) {
$span.attr( { "title": support } );
// Provide forcelinkupdate purge link
$portlet.empty();
// Precondition:
$portlet.append( $span );
// ahead -- true if initializing, false to link
// DOM.ready
// user resources loaded
// Postcondition:
// Returns link, or undefined
// Uses:
// Purge.first()
// favorite()
// Purge.fiat()
// (Purge.fresher)
// 2016-08-18 PerfektesChaos@de.wikipedia
if ( ahead === true ) {
if ( Purge.first() ) {
favorite( { signature: "forcelinkupdate",
skins: false,
forward: Purge.fresher,
show: "purgeLUtitle",
support: "purgeLUtip",
suffix: "purgeLinkUpd"
} );
}
} else {
Purge.fiat( "forcelinkupdate" );
}
}; // Purge.fresher()
 
 
 
Purge.freshest = function ( ahead ) {
// Provide forcerecursivelinkupdate purge link
// Precondition:
// ahead -- true if initializing, false to link
// DOM.ready
// user resources loaded
// Uses:
// Purge.first()
// favorite()
// Purge.fiat()
// (Purge.fresher)
// 2016-08-18 PerfektesChaos@de.wikipedia
if ( ahead === true ) {
if ( Purge.first() ) {
favorite( { signature: "forcerecursivelinkupdate",
skins: false,
forward: Purge.freshest,
show: "purgeLURtitle",
support: "purgeLURtip",
suffix: "purgeLinkUpdRec"
} );
}
} else {
Purge.fiat( "forcerecursivelinkupdate" );
}
}; // Purge.freshest()
 
 
 
Purge.freshissimo = function () {
// Provide generator forcerecursivelinkupdate purge link
// Precondition:
// DOM.ready
// user resources loaded
// Uses:
// < Purge.portlet
// favorite()
// (Purge.full)
// 2016-08-30 PerfektesChaos@de.wikipedia
Purge.portlet = favorite( { signature: "forcerecursivelinkupdate",
skins: false,
forward: Purge.full,
show: "purgeLURGtitle",
support: "purgeLURGtip",
suffix: "purgeGenLinkUpdRec"
} );
}; // Purge.freshissimo()
 
 
 
Purge.full = function ( additional ) {
// Start API purging of a generator
// Precondition:
// additional -- some keyword, or not
// Uses:
// > Env
// < Purge.Api
// < Purge.request
// mw.Api() .post()
// Purge.feed()
// 2017-01-21 PerfektesChaos@de.wikipedia
var many = 20,
p;
switch ( Env.wgNamespaceNumber ) {
case -1 :
switch ( Env.wgCanonicalSpecialPageName ) {
case "Whatlinkshere" :
p = { generator: "embeddedin",
geititle: Env.wgRelevantPageName,
geilimit: many };
break;
} // switch wgCanonicalSpecialPageName
break;
case 14 :
p = { generator: "categorymembers",
gcmpageid: Env.curid,
gcmtype: "page|file",
gcmlimit: many };
break;
} // switch wgNamespaceNumber
if ( p ) {
if ( typeof additional === "string" ) {
if ( additional ) {
p[ additional ] = true;
}
} else {
p.forcerecursivelinkupdate = true;
}
Purge.Api = new mw.Api( { parameters: { action: "purge" } } );
Purge.request = p;
Purge.feed();
}
}; // freezerPurge.full()
 
 
 
Purge.further = function fresh( arrived ) {
// ProvideStart purgeAPI linkpurging of a generator
// Precondition:
// arrived -- object with answers
// Uses:
// >< Purge.portlet
// >< Purge.request
// (Purge.feed)
// 2016-08-30 PerfektesChaos@de.wikipedia
var msec = 61000;
if ( typeof Purge.portlet === "object" ) {
$( Purge.portlet ).remove();
Purge.portlet = false;
}
if ( typeof arrived[ "continue" ] === "object" &&
typeof arrived.warnings !== "object" ) {
$.extend( Purge.request, arrived[ "continue" ] );
window.setTimeout( Purge.feed, msec );
}
}; // Purge.further()
 
 
 
QQmsg.flat = function ( ahead ) {
// Provide "uselang=qqx" link
// Precondition:
// ahead -- true if initializing, false to link
// DOM.ready
// mediawiki.util loaded
// user resources loaded
// Postcondition:
// Returns link, or undefined
// Uses:
// >< Env ___location
// featurefavorite()
// mw(QQmsg.config.get(flat)
// 2014-12-19 mw.utilPerfektesChaos@de.getUrl()wikipedia
var r;
// mw.util.addPortletLink()
if ( ahead ) {
// 2014-12-07 PerfektesChaos@de.wikipedia
var opt favorite( ={ feature(signature: "purgeslangQQX" ),
say = "PURGE this page from server cache" skins: false,
seed = null fun: QQmsg.flat,
slot = show: "p-cactionsqqxTitle",
show = "Purge cache support: "qqxTip",
start = suffix: "calangQQX",
got, re, swap } );
switch} ( typeof opt )else {
caser "boolean"= :window.___location.href;
r = r.replace( if /^(.+)#.+$/, opt"$1" ) {
.replace( seed /([?&])uselang=[^&]*(&.*)?$/, "$1$2" false);
if ( ! /[?&]$/.test( r ) ) {
if ( r.indexOf( "?" ) > 0 ) {
r = r + "&";
} else {
slotr = falser + "?";
}
break;
case "string" :
seed = opt;
re = /^([a-z]+)-(.+)$/;
got = re.exec( seed );
if ( got ) {
switch ( got[ 1 ] ) {
case "p" :
slot = seed;
seed = false;
switch ( got[ 2 ] ) {
case "navigation" :
start = "n";
break;
case "tb" :
start = "t";
break;
} // switch got.2
break;
case "ca" :
break;
case "n" :
slot = "p-navigation";
break;
case "t" :
slot = "p-tb";
break;
} // switch got.1
}
break;
} // switch typeof opt
if ( slot && seed === null ) {
Env.skin = mw.config.get( "skin" );
if ( Env.skin !== "vector" ) {
slot = false;
}
r = r + "uselang=qqx";
}
ifreturn ( slot ) {r;
}; // QQmsg.flat()
Env.wgPageName = mw.config.get( "wgPageName" );
swap = mw.util.getUrl( Env.wgPageName,
{ action: "purge" } );
if ( seed ) {
seed = "#" + seed;
}
mw.util.addPortletLink( slot,
swap,
show,
start + "-purge",
say,
null,
seed );
}
} // fresh()
 
 
 
Redir.from = function from() {
// Redirected from somewhere
// Precondition:
Line 423 ⟶ 1,414:
// >< Env
// mw.util.getUrl()
// featureOPTS.facet()
// history.___pushState()
// history.___replaceState()
// 2014-12-07 PerfektesChaos@de.wikipedia
var caused, opts, showopt, last, legacy, show, showed, state, swap;
if ( typeof window.history.___pushState === "function" &&
typeof window.history.___replaceState === "function" ) {
swap = mw.util.getUrl( Env.wgRedirectedFrom,
{ redirect: "no" } );
Line 437 ⟶ 1,428:
}
if ( ! last ) {
optsopt = featureOPTS.facet( "redirect" );
if ( optsopt &&
typeof optsopt === "object" &&
typeof optsopt.legacy === "boolean" ) {
legacy = optsopt.legacy;
}
showed = window.document.title;
Line 455 ⟶ 1,446:
}
}
}; // Redir.from()
 
 
 
URL2i.forward = function further( amount, alike ) {
// Convert links on page into Special: format
// Precondition:
// amount -- number of links per item to inspect
// alike -- if string "diff", required to occur
// DOM.ready
// mediawiki.util loaded
// Uses:
// mw.util.getParamValue()
// 20142015-1201-1411 PerfektesChaos@de.wikipedia
var $results = $( "#mw-content-text li" ),
n = $results.length,
Line 480 ⟶ 1,472:
$a = $li.eq( j );
strip = $a.attr( "href" );
startif = mw.util.getParamValue( "oldid",strip strip );&&
if strip.substr( start0, 3 ) === "/w/" ) { // wikidata
stripstart = stripmw.replaceutil.getParamValue( /&"oldid=\d+\b/", ""strip );
if .replace( /&curid=\d+\b/,start "") );{
shift strip = mwstrip.util.getParamValuereplace( "diff"/&oldid=\d+\b/, strip"" );
if .replace( shift/&curid=\d+\b/, )"" {);
stripshift = stripmw.replaceutil.getParamValue( /&"diff=\d+\b/", ""strip );
shiftif =( "Diff/"shift +) start + "/" + shift;{
} else { strip = strip.replace( /&diff=\d+\b/, "" );
shift = "PermanentLinkDiff/" + 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 );
}
}
shift = special + shift + "$1";
strip = strip.replace( /^.+(\?title=.+)$/,
shift );
$a.attr( "href", strip );
}
} // for j
} // for i
}
}; // furtherURL2i.forward()
 
 
 
function fire() {;
}( window.mediaWiki, window.jQuery ) );
// Autorun on load
// Precondition:
// mediawiki.util loaded
// Uses:
// < Env
// mw.config.get()
// mw.util.getParamValue()
// flip()
// further()
// freeze()
// freezer()
// fresh()
// from()
// 2014-12-16 PerfektesChaos@de.wikipedia
Env = { wgCanonicalSpecialPageName:
mw.config.get( "wgCanonicalSpecialPageName" ) };
if ( Env.wgCanonicalSpecialPageName ) {
switch ( Env.wgCanonicalSpecialPageName ) {
case "Diff" :
flip();
break;
case "Contributions" :
further( 2 );
break;
case "Watchlist" :
further( 1 );
break;
case "Gadgets" :
break;
} // switch wgCanonicalSpecialPageName
} else {
Env.diff = mw.util.getParamValue( "diff" );
Env.oldid = mw.util.getParamValue( "oldid" );
if ( Env.diff ) {
flip();
} else {
Env.wgAction = mw.config.get( "wgAction" );
switch ( Env.wgAction ) {
case "history" :
further( 3 );
break;
case "view" :
Env.curid = mw.util.getParamValue( "curid" );
if ( Env.curid || Env.oldid ) {
freeze( true );
} else {
freezer( true );
}
fresh();
Env.wgRedirectedFrom
= mw.config.get( "wgRedirectedFrom" );
if ( Env.wgRedirectedFrom ) {
from();
}
break;
default:
freezer( true );
} // switch wgAction
}
}
} // fire()
 
/// EOF </nowiki> pageLinkHelper/d.js
 
 
if ( mw.loader.getState( Signature ) !== "ready" ) {
mw.loader.state( Signature, "ready" );
mw.loader.using( [ "mediawiki.util",
"user" ],
function () {
$( fire ); // don't hurry
} );
}
}( window.mediaWiki, window.jQuery ) );
/// EOF </nowiki> pageLinkHelper.js