Content deleted Content added
-2.2 |
-2.6 |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1:
/// Gadget-pageLinkHelper.js
// Some minor link helpers
///
// ResourceLoader: compatible;
// dependencies: user, user.options,
Line 14:
( function ( mw, $ ) {
"use strict";
var Version = -2.
Sign = "pageLinkHelper",
Signature = "ext.gadget." + Sign,
Line 76:
"vmf" : "de" }
}; // 2015-01-06 PerfektesChaos@de.wikipedia
Line 171 ⟶ 126:
// > Sign
// >< Env
//
var r, // = undefined
sequence, suitable, $anchor, $clear;
Line 190 ⟶ 145:
switch ( Env.skin ) {
case "cologneblue" :
suitable = "#firstHeading";
sequence = "after";
break;
case "modern" :
suitable = "#contentSub";
sequence = "before";
break;
case "monobook" :
case "vector" :
suitable = "
sequence = "prepend";
break;
} // switch Env.skin
$anchor = $(
}
if ( ! $anchor.length ) {
Line 286 ⟶ 241:
// > Config
// >< Env
// facility()
// mw.config.get()
//
var el, r, say;
if ( alter ) {
Line 296 ⟶ 250:
r = access;
}
if ( typeof PLH.config === "object" &&
PLH.config &&
typeof PLH.config[ access ] === "object" ) {
Line 482 ⟶ 434:
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
// >
// < Env
// mw.config.get()
// mw.util.getParamValue()
Line 504 ⟶ 480:
// Purge.freshest()
// QQmsg.flat()
//
// 2020-01-05 PerfektesChaos@de.wikipedia
Env = { skin: false,
wgCanonicalSpecialPageName:
Line 521 ⟶ 497:
case "Diff" :
Diff.flip();
break;
case "Mobile" :
break;
case "Whatlinkshere" :
Env.
if ( OPTS.facet( "forcerecursivelinkupdate" ) ) {
Env.wgFormattedNamespaces =
mw.config.get( "wgFormattedNamespaces" );
Env.wgRelevantPageName =
mw.config.get( "wgRelevantPageName" );
s = Env.
.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 );
}
Line 599 ⟶ 585:
QQmsg.flat( true );
}
} // first()
OPTS.facet = function ( applied ) {
// Check for user option
// Precondition:
// applied -- option keyword
// module 'user' loaded
// Postcondition:
// Returns value, or undefined
// Uses:
// > PLH
// > 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
// > mw.libs
// > Shop
// < PLH
// mw.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 ];
} else {
PLH = { };
}
PLH.type = Sign;
PLH.vsn = Version;
PLH.doc = "[[" + Shop + Sign + "]]";
mw.hook( Sign + ".before" ).add( OPTS.features );
PLH.fresh = Purge.foreign;
$( first ); // don't hurry
}; // OPTS.fire()
Line 988 ⟶ 1,051:
.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()
Line 1,007 ⟶ 1,094:
Purge.
//
// Precondition:
// additional --
// array -- Attay of page titles, or page IDs, or not
// allow -- number of permitted array elements, or not
// Uses:
//
//
// 2017-01-21 PerfektesChaos@de.wikipedia
var
switch
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;
}
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()
Line 1,135 ⟶ 1,293:
Purge.full = function ( additional ) {
// Start API purging of a generator
// Precondition:
Line 1,145 ⟶ 1,303:
// mw.Api() .post()
// Purge.feed()
//
var many = 20,
p;
Line 1,166 ⟶ 1,324:
} // 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();
}
Line 1,338 ⟶ 1,502:
fire();
}( window.mediaWiki, window.jQuery ) );
/// EOF </nowiki> pageLinkHelper/d.js
|