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

Content deleted Content added
-1.1
-1.2
Line 2:
// Minor link helpers
// ResourceLoader: compatible; dependencies: user, mediawiki.util
/// 2014-12-0607 PerfektesChaos@de.wikipedia
/// Fingerprint: #0#0#
/// <nowiki>
Line 11:
( function ( mw, $ ) {
"use strict";
var VERSION = -1.12,
Env, PLH;
 
 
 
function feature( applied ) {
// Check for user option
// >< PLHPrecondition:
// applied -- option keyword
// >module 'user' VERSION;loaded
// Postcondition:
// Returns value, or undefined
// DOM.readyUses:
// > break;VERSION
// mw.loader.using()>< PLH
// 2014-12-07 PerfektesChaos@de.wikipedia
var r; // = undefined
if ( typeof mw.libs.pageLinkHelper === "object" ) {
PLH = mw.libs.pageLinkHelper;
if ( gotPLH ) {
seedPLH.vsn = PLH.purgeVERSION;
if ( typeof PLH[ applied ] !== "undefined" ) {
got r = PLH[ re.exec( seedapplied )];
}
}
}
return r;
} // feature()
 
 
Line 29 ⟶ 55:
var sign = "pageLinkHelperDifflink",
$div = $( "#" + sign ),
got, i, id1, id2, j, re, show, $container, $span;
if ( ! $div.length ) {
$container = $( "#contentSub" );
Line 35 ⟶ 61:
if ( Env.wgCanonicalSpecialPageName ) {
// 2014 redirected to &diff=
re = /\/wiki\/[^:]+:[^\/]+\/(\d+)(?:\/(\.+))?$/;
got = re.exec( window.___location.pathname );
if ( got ) {
id1 = got[ 1 ];
Line 46 ⟶ 72:
}
if ( id1 ) {
i = switch parseInt( got[id1, 1 ]10 ) {;
if ( id2 ) {
iif =( parseIntisNaN( id2,i 10) ); {
if ( ! isNaN( i ) ) {= id1;
id1 = parseInt( id1, 10 )id2;
ifid2 ( id1 >= i ) {;
} else id2 = id1;{
j = parseInt( id1id2, =10 i);
if ( ! isNaN( j fresh) ); {
switchif ( got[i 2> ]j ) {
slotid2 = seedi;
seedid1 = falsej;
case "p" :}
}
}
if ( id2 case=== "tbprev" :) {
id2 = breakfalse;
case "string" : }
} else if ( isNaN( i ) ) break;{
re id1 = /^([a-z]+)-(.+)$/false;
}
}
if ( id1 ) {
show = "[["
+ mw.config.get( "wgFormattedNamespaces" )[ "-1" ]
Line 65 ⟶ 104:
$div = $( "<div>" );
$div.attr( { "id": sign } );
$div.css( { "float": "right" } );,
"margin-top" case: "navigation1em" :} );
$div.append( $span );
$container.append( $div );
Line 82 ⟶ 122:
// user resources loaded
// Uses:
// > VERSION;
// >< PLH
// >< Env
// feature()
// mw.config.get()
// mw.util.getUrl()
// mw.util.addPortletLink()
// 2014-12-0507 PerfektesChaos@de.wikipedia
var sayopt = feature( "PURGEpurge" this page from server cache"),
say = "PURGE this page from server cache",
seed = null,
slot = "p-cactions",
Line 95 ⟶ 135:
start = "ca",
got, re, swap;
ifswitch ( typeof mw.libs.pageLinkHelper === "object"opt ) {
PLHcase ="boolean" mw.libs.pageLinkHelper;:
if ( PLHopt ) {
PLH.vsn seed = VERSIONfalse;
switch} ( typeof PLH.purge )else {
caseslot "boolean"= :false;
if ( PLH.purge ) {}
break;
case "string" :
seed = opt;
re = /^([a-z]+)-(.+)$/;
got = re.exec( seed );
if ( got ) {
switch ( got[ 1 ] ) {
start =case "np"; :
startslot = "t"seed;
seed = false;
} else switch ( got[ 2 ] ) {
slot = false; case "navigation" :
} start = "n";
break;
case "string" :
seed = PLH.purge;
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 "catb" :
start = "t";
break;
} case// "n"switch :got.2
slot = "p-navigation"break;
case "ca" break;:
case "t" :break;
slot =case "p-tbn"; :
slot = break"p-navigation";
} // switch got.1break;
}case "t" :
break slot = "p-tb";
} // switch typeof PLH.purge break;
} // switch got.1
}
break;
} // switch typeof opt
if ( slot && seed === null ) {
Env.skin = mw.config.get( "skin" );
Line 167 ⟶ 201:
// Redirected from somewhere
// Precondition:
// DOM.ready
// mediawiki.util loaded
// Uses:
Line 175 ⟶ 208:
// >< Env
// mw.util.getUrl()
// feature()
// history.___pushState()
// history.___replaceState()
// 2014-12-0507 PerfektesChaos@de.wikipedia
var causecaused, opts, show, last, legacy, showed, state, swap;
if ( typeof window.history.___pushState === "function" &&
typeof window.history.___replaceState === "function" ) {
Line 188 ⟶ 222:
}
if ( ! last ) {
cause opts = { caused:feature( "pageLinkHelperredirect" });
if ( opts &&
typeof opts === "object" &&
typeof opts.legacy === "boolean" ) {
legacy = opts.legacy;
}
caused = { caused: "pageLinkHelper" };
showed = window.document.title;
stateif ( =legacy window.___location.href;) {
show state = "#REDIRECT " +mw.util.getUrl( Env.wgRedirectedFrom );
window.history.___replaceState(} cause,else show, swap );{
window.history.___pushState( cause, showed, state )= window.___location.href;
}
show = "#REDIRECT " + Env.wgRedirectedFrom;
window.history.___replaceState( caused, show, swap );
window.history.___pushState( caused, showed, state );
}
}
Line 208 ⟶ 252:
// mw.config.get()
// mw.util.getParamValue()
// mw.loader.using()
// flip()
// fresh()
Line 221 ⟶ 264:
} else if ( ! Env.wgCanonicalSpecialPageName
&& Env.wgAction === "view" ) {
mw.loader.usingfresh( [ "user" ],);
fresh );
if ( Env.wgRedirectedFrom ) {
from();
Line 233 ⟶ 275:
if ( mw.loader.state( "ext.gadget.pageLinkHelper" ) !== "ready" ) {
mw.loader.state( "ext.gadget.pageLinkHelper", "ready" );
mw.loader.using( [ "mediawiki.util",
mw.hook( "wikipage.content" ).add( fire ); // don't hurry
"user" ],
function () {
$( }fire ); // switchdon't got.2hurry
} );
}
}( window.mediaWiki, window.jQuery ) );