MediaWiki
Gadget-breadcrumbs.js
From Dogcraft Wiki
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
} | } | ||
} | } | ||
return | return ""; | ||
} | } | ||
Line 48: | Line 48: | ||
var world = ''; | var world = ''; | ||
if ( worldCat( pageCategories ) != | if ( worldCat( pageCategories ) !== "") { | ||
links.push( worldCat( pageCategories ) ); | links.push( worldCat( pageCategories ) ); | ||
} | } | ||
Line 59: | Line 59: | ||
{ | { | ||
var typesOnPage = pageCategories.filter(function(x){ return typeCategories.includes(x) }); | var typesOnPage = pageCategories.filter(function(x){ return typeCategories.includes(x) }); | ||
if ( typesOnPage.lenght | if ( typesOnPage.lenght !== 1) { | ||
console.log('Page has more then one type category'); | console.log('Page has more or less then one type category'); | ||
} | |||
else { | |||
links.push( typesOnPage[0] + "" ); | |||
} | } | ||
} | } | ||
Line 79: | Line 81: | ||
} | } | ||
else { console.log(' | else { console.log(' Breadcrumbs: links is undefined '); } | ||
} | } | ||
}); | }); |
Revision as of 23:47, 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 "";
}
var config = mw.config.get([
"wgIsArticle",
"wgNamespaceNumber",
"wgCategories",
"wgTitle"
]);
if ( config.wgIsArticle && ( config.wgNamespaceNumber == 0 /*&& config.wgTitle !== "Main Page"*/)) {
//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 = "<a href='/wiki/Main_Page'>Main Page</a>";
if (pageCategories.includes('Site Content')) {
links.push( "Site Content" );
}
if (pageCategories.includes('Server Information')) {
links.push( "Server Information" );
}
var world = '';
if ( worldCat( pageCategories ) !== "") {
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) {
console.log('Page has more or less then one type category');
}
else {
links.push( typesOnPage[0] + "" );
}
}
if (pageCategories.includes('Lists')) {
links.push( "Lists" );
}
links.forEach( function( elem ) {
crumbs += '<a href="/wiki/Category:' + elem + '">' + '<span>' + elem + '</span>' + '</a>';
});
if( links !== "undefined") {
$('.top .indicators').prepend('<div id="breadcrumbs"></div>');
$('#breadcrumbs').html('' + crumbs + '<span>' + config.wgTitle + '</span>' );
}
else { console.log(' Breadcrumbs: links is undefined '); }
}
});
This page was last modified on 14 July 2021, at 23:47. (3 months ago)