Difference between revisions of "MediaWiki:Common.js"
From Pathfinder Wiki
DesignerThan (talk | contribs) (Created page with "→Any JavaScript here will be loaded for all users on every page load.: console.log('Test')") |
DesignerThan (talk | contribs) |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
− | console.log('Test') | + | console.log('Test'); |
+ | |||
+ | const interfaceLang = document.documentElement.lang; | ||
+ | const navItems = [ | ||
+ | 'n-Home', | ||
+ | 'n-All-Honors', | ||
+ | 'n-Arts.2C-Crafts.2C-and-Hobbies', | ||
+ | 'n-Health-and-Science', | ||
+ | 'n-Household-Arts', | ||
+ | 'n-Nature', | ||
+ | 'n-Outdoor-Industries', | ||
+ | 'n-Recreation', | ||
+ | 'n-Spiritual-Growth.2C-Outreach-and-Heritage', | ||
+ | 'n-Vocational', | ||
+ | 'n-Honor-Pilots', | ||
+ | 'n-Investiture-Achievement', | ||
+ | 'n-Master-Guide', | ||
+ | 'n-Club-Ministries' | ||
+ | ]; | ||
+ | |||
+ | if (interfaceLang !== 'en') { | ||
+ | navItems.forEach((item) => { | ||
+ | const parent = document.getElementById(item); | ||
+ | if (parent) { | ||
+ | if (parent.childNodes[0] && parent.childNodes[0].tagName === 'A' ) { | ||
+ | parent.childNodes[0].href += `/${interfaceLang}`; | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | } |
Revision as of 21:42, 29 July 2022
/* Any JavaScript here will be loaded for all users on every page load. */
console.log('Test');
const interfaceLang = document.documentElement.lang;
const navItems = [
'n-Home',
'n-All-Honors',
'n-Arts.2C-Crafts.2C-and-Hobbies',
'n-Health-and-Science',
'n-Household-Arts',
'n-Nature',
'n-Outdoor-Industries',
'n-Recreation',
'n-Spiritual-Growth.2C-Outreach-and-Heritage',
'n-Vocational',
'n-Honor-Pilots',
'n-Investiture-Achievement',
'n-Master-Guide',
'n-Club-Ministries'
];
if (interfaceLang !== 'en') {
navItems.forEach((item) => {
const parent = document.getElementById(item);
if (parent) {
if (parent.childNodes[0] && parent.childNodes[0].tagName === 'A' ) {
parent.childNodes[0].href += `/${interfaceLang}`;
}
}
});
}