User:Professor Hershel Theodore Layton/global.js

/* FandomDesktop Übergangszeit */

/* Preserve ?useskin when clicking on links */

/** window.SkinPropagation = { skin: '', init: function { if (window.location.href.indexOf('useskin=') == -1) return; var url = SkinPropagation.parseURL(window.location.href); if (url.query.useskin) { SkinPropagation.skin = (url.query.propagateskin || url.query.useskin); }		if (SkinPropagation.skin != '') { $(document.body).bind('click.skinpropagation', SkinPropagation.clicEvent); $('form').bind('submit.skinpropagation', SkinPropagation.submitEvent); }	},	parseURL: function(url) { var ret = {base:,qs:,query:{},hash:''}; var loc = url.indexOf('#'); if (loc != -1) { ret.hash = url.substr(loc+1); url = url.substr(0,loc); }		loc = url.indexOf('?'); if (loc != -1) { ret.qs = url.substr(loc+1); url = url.substr(0,loc); var paras = ret.qs.split('&'); for (var i = 0; i < paras.length; i++) { var p = paras[i].split('='); if (p.length == 2) { ret.query[p[0]] = p[1]; }			}		}		ret.base = url; return ret; },	getURL: function(url) { var nurl = url.base + '?'; for (var p in url.query) { nurl += p + '=' + url.query[p] + '&'; }		nurl = nurl.substr(0,nurl.length-1); if (url.hash != '') { nurl += '#'+ url.hash; }		return nurl; },	clicEvent: function(e) { if (e.target.tagName.toLowerCase != 'a') return; if (e.target.href.indexOf(window.wgServer) != 0) return; var url = SkinPropagation.parseURL(e.target.href); var thisloc = SkinPropagation.parseURL(window.location.href); if (url.base == thisloc.base && url.qs == thisloc.qs && url.hash != '') { return; }		if (url.query.useskin && url.query.useskin != SkinPropagation.skin) { url.query.propagateskin = SkinPropagation.skin; } else { url.query.useskin = SkinPropagation.skin; }		e.target.href = SkinPropagation.getURL(url); },	submitEvent: function(e) { if (this.action.indexOf(window.wgServer) != 0) return; if (this.method == 'post') { var url = SkinPropagation.parseURL(this.action); url.query.useskin = SkinPropagation.skin; this.action = SkinPropagation.getURL(url); } else { $(this).append(''); }	},	stop: function { $(document.body).unbind('click.skinpropagation'); $('form').unbind('submit.skinpropagation'); } };
 * SkinPropagation. Thank you Jesús for this script :)
 * Copyright (C) 2010 Jesús Martínez Novo (User:Ciencia Al Poder)
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version
 * (at your option) any later version

$(SkinPropagation.init);

/* Ende FandomDesktop Übergangszeit */

/* FandomDesktop */ /** * Make the "Explore" dropdown of the local navigation the last one again * and restore the former RecentChanges link inside of it. * * @author Professor Hershel Theodore Layton * @version 2021-06-15 */ (function {	if (window.hasOwnProperty('oasisExploreNavigation')) return;	window.oasisExploreNavigation = {};	$('.fandom-community-header__local-navigation').each(function { var exploreMenu = $(this).find('.wds-dropdown').first var exploreMenuParent = exploreMenu.parent; exploreMenu = exploreMenu.detach; exploreMenuParent.append(exploreMenu); exploreMenu.find('.wds-list').append(			$('').html( $('', {					href: mw.config.get('wgArticlePath').replace("$1", "Special:RecentChanges"),					text: "Letzte Änderungen"				}) )		);	}); });

/** * On pages related to a specific user, add a link to their Discussions profile * in the Page Tools module of the Right Rail. * * @author Professor Hershel Theodore Layton * @version 2021-06-15 */ (function {	if (window.hasOwnProperty('pageToolsDiscussionsProfile')) return;	window.pageToolsDiscussionsProfile = {};	// Retrieve username from URL	var namespace = mw.config.get('wgCanonicalNamespace'),		pagetitle = mw.config.get('wgTitle'),		username = '';	switch(namespace) {		case 'User':		case 'User talk':		case 'Message Wall':			username = pagetitle;			if (username.indexOf('/') !== -1) return;		break;		case 'Special':			if (mw.config.get('wgCanonicalSpecialPageName') !== 'Contributions') return;			username = pagetitle.substr(pagetitle.indexOf('/') + 1);		break;		default: return;	}	var apiEndpoint = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/wikia.php';	$.ajax({ url: apiEndpoint, type: 'GET', format: 'json', data: { controller: 'DiscussionPost', method: 'getPosts', limit: 0 }	}).fail(function(err) { // Checking whether Discussions are enabled for the wiki: In either case, we're getting an // error. If the status code is 404, we can assume that the wiki doesn't have Discussions // enabled. Since we have set the limit to 0, we're getting a 400 bad request response in // case Discussions are enabled. if (err.status !== 404) { (new mw.Api).get({				action: 'query',				list: 'users',				ususers: username			}).then(function(data) {				var user = data.query.users[0];				if (user.hasOwnProperty('missing')) return;				var discussionsProfile = mw.config.get('wgServer') +					mw.config.get('wgScriptPath') + '/f/u/' + user.userid;				$('#page-tools-module .rail-module__list').prepend( $('', { id: 't-script-discussionsprofile' }).html(						$('', { href: discussionsProfile, text: "Profil in Diskussionen" })					)				);			});		}	}); }); /* Ende FandomDesktop */

window.globalNavButtons = [ {		text: 'Layton', icon: '', url: 'https://layton.fandom.com/de/wiki/Hauptseite', isMain: true, whoIsMain: false, shortName: 'layton' },	{		text: 'Deutsch: Letzte Änderungen', url: 'https://layton.fandom.com/de/wiki/Spezial:Letzte_Änderungen', isMain: false, whoIsMain: 'layton', shortName: 'layton-de' },	{		text: 'Englisch: Letzte Änderungen', url: 'https://layton.fandom.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'layton', shortName: 'layton-en' }, 	{		text: 'Weitere', url: '', isMain: true, whoIsMain: false, shortName: 'weitere' },	{		text: 'Deutsch: Maze Runner', url: 'https://mazerunner.fandom.com/de/wiki/Spezial:Letzte_Änderungen', isMain: false, whoIsMain: 'weitere', shortName: 'mazerunner-de' },	{		text: 'Englisch: Maze Runner', url: 'https://mazerunner.fandom.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'weitere', shortName: 'mazerunner-en' },	{		text: 'Fandom', icon: '    ', url: 'https://community.fandom.com/de/wiki/Spezial:Letzte_Änderungen', isMain: true, whoIsMain: false, shortName: 'fandom-related' }, {    text: 'Community RC (De)', url: 'https://community.fandom.com/de/wiki/Spezial:Letzte_Änderungen', isMain: false, whoIsMain: 'fandom-related', shortName: 'cc-de-rc' }, {    text: 'Community /f (De)', url: 'https://community.fandom.com/de/f', isMain: false, whoIsMain: 'fandom-related', shortName: 'cc-de-f' }, {    text: 'Dev', url: 'https://dev.fandom.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'fandom-related', shortName: 'dev' }, {    text: 'Helpers', url: 'https://helpers.fandom.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'fandom-related', shortName: 'helpers' }, {    text: 'Helpers Mergetest', url: 'https://helpers-mergetest.fandom.com/wiki/Special:RecentChanges', isMain: false, whoIsMain: 'fandom-related', shortName: 'helpers-mergetest' }, {    text: 'Council', url: 'https://communitycouncil.fandom.com/wiki/Blog:Recent_posts', isMain: false, whoIsMain: 'fandom-related', shortName: 'council' }, ];

importArticles({	type: 'script',	articles: [		// FandomDesktop interim fixes		'u:dev:MediaWiki:ThemeToggler.js',		// FandomDesktop interim fixes		'u:dev:MediaWiki:AjaxBatchDelete.js',		'u:dev:MediaWiki:AnalyticsShortcut.js',		'u:dev:MediaWiki:AvatarLink.js',		'u:dev:MediaWiki:Bang.js',		'u:dev:MediaWiki:DeleteTalkpage.js',		'u:dev:MediaWiki:GlobalNavButtons.js',		'u:dev:MediaWiki:MassCategorization/code.js',		'u:dev:MediaWiki:MassEdit/code.js',		'u:dev:MediaWiki:MassNullEdit/code.js',		'u:dev:MediaWiki:NewImages.js',		'u:dev:MediaWiki:NullEditButton/code.js',		'u:dev:MediaWiki:PortableListUsers.js',		'u:dev:MediaWiki:PurgeButton/code.js',	] });