MediaWiki
Gadget-breadcrumbs.js
From Dogcraft Wiki
No edit summary |
No edit summary |
||
Line 42: | Line 42: | ||
"Worlds" | "Worlds" | ||
], | ], | ||
pageCategories = config.wgCategories; | pageCategories = config.wgCategories, | ||
links = []; | |||
if (pageCategories.includes('Site Content')) { | if (pageCategories.includes('Site Content')) { | ||
siteContent = 'Site Content | links[siteContent] = 'Site Content'; | ||
} | } | ||
if (pageCategories.includes('Server Information')) { | if (pageCategories.includes('Server Information')) { | ||
serverInfo = 'Server Information | links[serverInfo] = 'Server Information'; | ||
} | } | ||
var world = ''; | var world = ''; | ||
if ( worldCat( pageCategories ) != false) { | if ( worldCat( pageCategories ) != false) { | ||
world = worldCat( pageCategories ); | links[world] = worldCat( pageCategories ); | ||
} | } | ||
if (pageCategories.includes('Bases')) { | if (pageCategories.includes('Bases')) { | ||
type = 'Builds | links[type] = 'Builds'; | ||
links[base] = 'Bases'; | |||
} | } | ||
else | |||
var typesOnPage = pageCategories.filter(function(x){ return typeCategories.includes(x) }); | { | ||
var typesOnPage = pageCategories.filter(function(x){ return typeCategories.includes(x) }); | |||
if ( typesOnPage.lenght > 1) { | |||
//page has more then one type category | |||
} | |||
links[type] = typesOnPage[0]; | |||
} | } | ||
if (pageCategories.includes('Lists')) { | if (pageCategories.includes('Lists')) { | ||
list = 'Lists | links[list] = 'Lists'; | ||
} | } | ||
links.forEach( function( elem ) { | |||
elem = '<a href="/wiki/Category:' + elem + '">' + elem + '</a>'; | |||
}); | |||
$('#breadcrumbs-test').text('' + siteContent + serverInfo + world + ' > ' + type + list + config.wgTitle ); | $('#breadcrumbs-test').text('' + links[siteContent] + links[serverInfo] + links[world] + ' > ' + links[type] + links[list] + config.wgTitle ); | ||
} | } | ||
}); | }); |
Revision as of 18:04, 3 July 2021
$(document).ready(function() {
/*$("#alertbutton-domino").click(function(){
mw.messages.set({'sandbox-test': 'Testing'});
var wiki_sandbox_obj = new mw.Message( mw.messages, 'sandbox-test' );
mw.log( wiki_sandbox_obj.text() );
mw.notify( mw.message( 'sandbox-test' ) );
});*/
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 == 4 || 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 = [];
if (pageCategories.includes('Site Content')) {
links[siteContent] = 'Site Content';
}
if (pageCategories.includes('Server Information')) {
links[serverInfo] = 'Server Information';
}
var world = '';
if ( worldCat( pageCategories ) != false) {
links[world] = worldCat( pageCategories );
}
if (pageCategories.includes('Bases')) {
links[type] = 'Builds';
links[base] = 'Bases';
}
else
{
var typesOnPage = pageCategories.filter(function(x){ return typeCategories.includes(x) });
if ( typesOnPage.lenght > 1) {
//page has more then one type category
}
links[type] = typesOnPage[0];
}
if (pageCategories.includes('Lists')) {
links[list] = 'Lists';
}
links.forEach( function( elem ) {
elem = '<a href="/wiki/Category:' + elem + '">' + elem + '</a>';
});
$('#breadcrumbs-test').text('' + links[siteContent] + links[serverInfo] + links[world] + ' > ' + links[type] + links[list] + config.wgTitle );
}
});
This page was last modified on 3 July 2021, at 18:04. (3 months ago)