User:PerfektesChaos/js/prettyPageHeading/r.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/// Gadget-prettyPageHeading.js
/// 2018-08-25 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#C2E22EF1#
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.4,Sign="prettyPageHeading",Shift="0.25em",Shop="w:en:User:PerfektesChaos/js/",Config,Nnsp,Rooms,Store;
function $flip($assembly,apply,ahead,above){
var $el=$(above?"<a>":"<span>");
if(above){
$el.attr("href",Store+encodeURI(above));}
$assembly.prepend($el.attr("class",Sign).css(ahead,Shift).text(apply));}
function fiat(){
var $h1=$("#firstHeading,#section_0"),env,i,k,ns,parts,plus,shift,space,story,superior,support,$ch,$el,$space;
if($h1.length){
$h1=$h1.eq(0);
}else{
$h1=$("<h1>");}
$ch=$h1.children();
ns=$ch.length;
for(i=ns-1;i>=0;i--){
$el=$ch.eq(i);
if($el.get(0).nodeName.toUpperCase()==="MARK"){
ns=i;
}else if($el.hasClass("title-shortlink-container")||$el.hasClass("title-shortlink-icon")){
plus=plus||[];
plus.push($el.detach());
ns=i;
}else{
break;}}
if(!ns){
env=mw.config.get(["wgContentLanguage","wgFormattedNamespaces","wgUserLanguage"]);
if(Store){
space=env.wgFormattedNamespaces[Nnsp+""];
Store=Store+encodeURI(space)+":";
$(".subpages").hide();}
if($("html").attr("dir")==="rtl"){
shift="margin-right";
}else{
shift="margin-left";}
story=$h1.text();
$h1.empty();
ns=story.indexOf(":")+1;
space=story.substr(0,ns);
parts=story.substr(ns).split("/");
for(i=parts.length-1;i>=0;i--){
$flip($h1,parts[i],shift,superior);
if(i){
$flip($h1,"/",shift);}
if(Store){
superior="";
for(k=0;k<i;k++){
superior=superior+(k?"/":"")+parts[k];}}}
$space=$("<span>");
$space.text(space);
if(Nnsp<=15&&env.wgUserLanguage!==env.wgContentLanguage){
if(Nnsp<0){
support="Special";
}else{
Rooms=["(main)","User","Project","File","MediaWiki","Template","Help","Category"];
i=Nnsp%2;
ns=(Nnsp-i)/  2;
support=Rooms[ns];
if(i){
support=support+" Talk";}}
if(support!==space){
$space.attr("title",support);}}
$h1.prepend($space);
if(plus){
for(i=plus.length-1;i>=0;i--){
$h1.append(plus[i]);}}}}
function fire(){
var signature="ext.gadget."+Sign,rls;
if(mw.loader.getState(signature)!=="ready"){
rls={};
rls[signature]="ready";
mw.loader.state(rls);
Nnsp=mw.config.get("wgNamespaceNumber");
if(Nnsp>0){
if(typeof mw.libs[Sign]==="object"){
Config=mw.libs[Sign];
if(Config){
Config.vsn=Version;
Config.doc="[["+Shop+Sign+"]]";
if(typeof Config.link==="boolean"&&Config.link){
Store="/wiki/";}
if(typeof Config.shift==="string"){
Shift=Config.shift;}}}
$(fiat);}}}
fire();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>prettyPageHeading.js