Перейти к содержанию

MediaWiki:Common.js: различия между версиями

нет описания правки
Нет описания правки
Нет описания правки
Строка 9: Строка 9:
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Контакты').attr('title', 'Заголовок 2').append($('<span>').text('Контакты'))));
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Контакты').attr('title', 'Заголовок 2').append($('<span>').text('Контакты'))));
     node.before(content);
     node.before(content);
  // Get the current page title
  var currentPageHref = window.location.href;
  var currentPageTitle = document.title;
 
   // Get all links on the page
   // Get all links on the page
   var links = document.querySelectorAll('.custom-top-menu a');
   var links = document.querySelectorAll('.custom-top-menu a');
   // Loop through each link
   // Loop through each link
   links.forEach(function(link) {
   links.forEach(function(link) {
     // Get the link title
     // Get the link title
     var linkTitle = link.getAttribute('title').trim() + ' — ЮУГМУ Вики';
     var linkhref = link.getAttribute('href').trim();
     console.log(currentPageTitle + '=' + linkTitle);
     console.log(currentPageHref + '=' + linkhref);
     // Check if the link title is equal to the current page title
     // Check if the link title is equal to the current page title
    if (linkTitle === currentPageTitle) {
  if (window.location.href.indexOf(linkhref) > -1) {
      // Make the link bold
       link.closest('li').classList.add('a-current');
       link.closest('li').classList.add('a-current');
    }
   }
    if (linkTitle === ('Главная — ' + currentPageTitle)) {
      // Make the link bold
      link.closest('li').classList.add('a-current');
    }
   });
});
});