MediaWiki:Common.js: различия между версиями
User (обсуждение | вклад) Нет описания правки |
User (обсуждение | вклад) Нет описания правки |
||
| Строка 7: | Строка 7: | ||
} | } | ||
function myInitCode() { | function myInitCode() { | ||
var currentPageHref = decodeURI(window.location.href); | var currentPageHref = decodeURI(window.location.href); | ||
var links = document.querySelectorAll('.custom-top-menu a'); | var links = document.querySelectorAll('.custom-top-menu a'); | ||
Версия от 14:51, 15 мая 2024
if (document.readyState !== 'loading') {
myInitCode();
} else {
document.addEventListener('DOMContentLoaded', function () {
myInitCode();
});
}
function myInitCode() {
var currentPageHref = decodeURI(window.location.href);
var links = document.querySelectorAll('.custom-top-menu a');
links.forEach(function (link) {
var linkhref = location.protocol + '//' + location.host + link.getAttribute('href').trim();
console.log(currentPageHref + '=' + linkhref);
if (currentPageHref === linkhref) {
link.closest('li').classList.add('a-current');
}
});
}