Difference between revisions of "MediaWiki:Common.js"
From Pathfinder Wiki
DesignerThan (talk | contribs) |
DesignerThan (talk | contribs) |
||
Line 20: | Line 20: | ||
if (interfaceLang !== 'en') { | if (interfaceLang !== 'en') { | ||
− | navItems.forEach((item) => { | + | //navItems.forEach((item) => { |
− | const parent = document.getElementById( | + | for (let i = 0; i < navItems.length; i++) { |
+ | const parent = document.getElementById(navItems[i]); | ||
if (parent) { | if (parent) { | ||
− | if (parent.childNodes[0] && parent.childNodes[0].tagName === 'A' ) { | + | if (parent.childNodes[0] && parent.childNodes[0].tagName === 'A') { |
parent.childNodes[0].href += `/${interfaceLang}`; | parent.childNodes[0].href += `/${interfaceLang}`; | ||
} | } | ||
} | } | ||
− | }); | + | } |
+ | //}); | ||
} | } |
Revision as of 21:49, 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',
];
if (interfaceLang !== 'en') {
//navItems.forEach((item) => {
for (let i = 0; i < navItems.length; i++) {
const parent = document.getElementById(navItems[i]);
if (parent) {
if (parent.childNodes[0] && parent.childNodes[0].tagName === 'A') {
parent.childNodes[0].href += `/${interfaceLang}`;
}
}
}
//});
}