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

Материал из ЮУГМУ Вики
Нет описания правки
Метка: ручная отмена
Нет описания правки
Строка 1: Строка 1:
$(document).ready(function() {
document.addEventListener("DOMContentLoaded", function() {
    var node = $('#content');
  const node = document.getElementById("content");
    var content = $('<ul>').addClass('custom-top-menu');
  const content = document.createElement("ul");
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Вики-энциклопедия_университета').attr('title', 'Главная').append($('<span>').text('Главная'))));
  content.classList.add("custom-top-menu");
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Правила').attr('title', 'Правила').append($('<span>').text('Правила'))));
 
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Служебная:Все_страницы').attr('title', 'Все страницы').append($('<span>').text('Статьи'))));
  const items = [
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Служебная:Свежие_правки').attr('title', 'Свежие правки').append($('<span>').text('История правок'))));
     {
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Инструкции').attr('title', 'Инструкции').append($('<span>').text('Инструкции'))));
      href: "/wiki/Вики-энциклопедия_университета",
     content.append($('<li>').append($('<a>').attr('href', '/wiki/Контакты').attr('title', 'Заголовок 2').append($('<span>').text('Контакты'))));
      title: "Главная",
    node.before(content);
      text: "Главная",
      spanText: "Главная"
    },
     {
      href: "/wiki/Правила",
      title: "Правила",
      text: "Правила",
      spanText: "Правила"
    },
     {
      href: "/wiki/Служебная:Все_страницы",
      title: "Все страницы",
      text: "Статьи",
      spanText: "Статьи"
    },
     {
      href: "/wiki/Служебная:Свежие_правки",
      title: "Свежие правки",
      text: "История правок",
      spanText: "История правок"
    },
     {
      href: "/wiki/Инструкции",
      title: "Инструкции",
      text: "Инструкции",
      spanText: "Инструкции"
    },
    {
      href: "/wiki/Контакты",
      title: "Заголовок 2",
      text: "Контакты",
      spanText: "Контакты"
    }
  ];
 
  items.forEach((item) => {
    const li = document.createElement("li");
     const a = document.createElement("a");
    a.href = item.href;
    a.title = item.title;
    a.textContent = item.text;
    const span = document.createElement("span");
    span.textContent = item.spanText;
    a.appendChild(span);
    li.appendChild(a);
    content.appendChild(li);
  });
 
  node.parentNode.insertBefore(content, node);
     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:21, 14 мая 2024

document.addEventListener("DOMContentLoaded", function() {
  const node = document.getElementById("content");
  const content = document.createElement("ul");
  content.classList.add("custom-top-menu");

  const items = [
    {
      href: "/wiki/Вики-энциклопедия_университета",
      title: "Главная",
      text: "Главная",
      spanText: "Главная"
    },
    {
      href: "/wiki/Правила",
      title: "Правила",
      text: "Правила",
      spanText: "Правила"
    },
    {
      href: "/wiki/Служебная:Все_страницы",
      title: "Все страницы",
      text: "Статьи",
      spanText: "Статьи"
    },
    {
      href: "/wiki/Служебная:Свежие_правки",
      title: "Свежие правки",
      text: "История правок",
      spanText: "История правок"
    },
    {
      href: "/wiki/Инструкции",
      title: "Инструкции",
      text: "Инструкции",
      spanText: "Инструкции"
    },
    {
      href: "/wiki/Контакты",
      title: "Заголовок 2",
      text: "Контакты",
      spanText: "Контакты"
    }
  ];

  items.forEach((item) => {
    const li = document.createElement("li");
    const a = document.createElement("a");
    a.href = item.href;
    a.title = item.title;
    a.textContent = item.text;
    const span = document.createElement("span");
    span.textContent = item.spanText;
    a.appendChild(span);
    li.appendChild(a);
    content.appendChild(li);
  });

  node.parentNode.insertBefore(content, node);
    var currentPageHref = decodeURI(window.location.href);
    var links = document.querySelectorAll('.custom-top-menu a');
    links.forEach(function(link) {
    var linkhref = link.getAttribute('href').trim();
    console.log(currentPageHref + '=' + linkhref);
    if (currentPageHref.indexOf(linkhref) > -1) {
        link.closest('li').classList.add('a-current');
    }
});
});