MediaWiki

Gadget-breadcrumbs.js

From Dogcraft Wiki

m (Domino moved page MediaWiki:Gadget-sandbox.js to MediaWiki:Gadget-breadcrumbs.js without leaving a redirect: Moving out of sandbox)
(Disabling breadcrumbs outside the main namespace)
Line 19: Line 19:
]);
]);
if ( config.wgIsArticle && ( config.wgNamespaceNumber == 4 || config.wgNamespaceNumber == 0)) {
if ( config.wgIsArticle && ( config.wgNamespaceNumber == 0)) {
//var namespace = mw.config.get('wgFormattedNamespaces')[mw.config.get('wgNamespaceNumber')];
//var namespace = mw.config.get('wgFormattedNamespaces')[mw.config.get('wgNamespaceNumber')];
var serverInfo = "",
var serverInfo = "",

Revision as of 23:23, 14 July 2021

$(document).ready(function() {
	
	function worldCat( pageCats ) {
		var world;
		for (var i = 0; i < pageCats.length; i++) {
			if ( pageCats[i].indexOf('Survival ') > -1) {
	    		world = pageCats[i] + '';
	        	return world;
			}
		}
		return false;
	}
	
	var config =  mw.config.get([
		"wgIsArticle",
		"wgNamespaceNumber",
		"wgCategories",
		"wgTitle"
		]);
	
	if ( config.wgIsArticle && ( config.wgNamespaceNumber == 0)) {
		//var namespace = mw.config.get('wgFormattedNamespaces')[mw.config.get('wgNamespaceNumber')];
		var serverInfo = "",
			siteContent = "",
			type = "",
			list = "",
			typeCategories = [
				"Stations",
				"Builds",
				"Events",
				"Settlements",
				"Groups",
				"Phenomenon",
				"Projects",
				"Worlds"
				],
			pageCategories = config.wgCategories,
			links = [],
			crumbs = "";
		
		if (pageCategories.includes('Site Content')) {
			links.push( "Site Content" );
		}	
		
		if (pageCategories.includes('Server Information')) {
			links.push( "Server Information" );
		}
		
		var world = '';
		if ( worldCat( pageCategories ) != false) {
			links.push( worldCat( pageCategories ) );
		}
		
		if (pageCategories.includes('Bases')) {
			links.push( "Builds" );
			links.push( "Bases" );
		}
		else
		{
			var typesOnPage = pageCategories.filter(function(x){ return typeCategories.includes(x) });
			if ( typesOnPage.lenght > 1) {
				//page has more then one type category
			}
			links.push( typesOnPage[0] + "" );
		}
		
		if (pageCategories.includes('Lists')) {
			links.push( "Lists" );
		}
		
		console.log(links);
		console.log(links[type]);
		
		links.forEach( function( elem ) {
			crumbs += '<a href="/wiki/Category:' + elem + '">' + '<span>' + elem + '</span>' + '</a>';
		});
		
		console.log(crumbs);
		
		$('.top .indicators').prepend('<div id="breadcrumbs"></div>');
		$('#breadcrumbs').html('' + crumbs + '<span>' + config.wgTitle + '</span>' );
	
	}
		
});
This page was last modified on 14 July 2021, at 23:23. (9 months ago)
Background Valentine's Day Event 2024 by TheWhiteTigerNL