Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показано 40 промежуточных версий 2 участников)
Строка 1: Строка 1:
const pageName = mw.config.get("wgPageName");
const pageName = mw.config.get("wgPageName");
mw.loader.using([], function () {
    importScript("MediaWiki:PageDefaultAttributes.js");
});
// Отображение онлайна


document.querySelectorAll(".server-hook").forEach(function(element) {
document.querySelectorAll(".server-hook").forEach(function(element) {
        var ip = element.getAttribute("data-ip");
    var ip = element.getAttribute("data-ip");
        var port = element.getAttribute("data-port");
    var port = element.getAttribute("data-port");
        var url = "https://wiki.ss13-bluemoon.ru/nodeapi/status?ip="+encodeURIComponent(ip)+"&port="+encodeURIComponent(port);
    var url = "https://wiki.ss13-bluemoon.ru/nodeapi/status?ip=" + encodeURIComponent(ip) + "&port=" + encodeURIComponent(port);
        fetch(url)
    fetch(url).then(function(response) {
            .then(function(response) {
        if (!response.ok) {
                    if (!response.ok) {
            throw new Error(response.status);
                        throw new Error(response.status);
        }
                    }
        return response.json();
                    return response.json();
    }).then(function(data) {
            })
        element.textContent = data.response.players;
            .then(function(data) {
    }).catch(function(error) {
                element.textContent = data.response.players;
        element.textContent = "⨉";
            })
    });
            .catch(function(error) {
});
                element.textContent = "⨉";
            });
  });
 
if (pageName == "Заглавная_страница" || pageName == "Test2") {
  document.documentElement.classList.replace('skin-theme-clientpref-day', 'skin-theme-clientpref-night');
}


// Интерактивная таблица


if (pageName != "Шаблон:Таблица_Космический_Закон") {
if (pageName != "Шаблон:Таблица_Космический_Закон") {
Строка 30: Строка 30:
     const table = document.getElementById("law");
     const table = document.getElementById("law");
     if (table) {
     if (table) {
         table.addEventListener("click", function (event) {
         table.addEventListener("click", function(event) {
        const cell = event.target.closest("td");
            const cell = event.target.closest("td");
        if (!cell) return;
            if (!cell) return;
        if (!cell.dataset.id) return;
            if (!cell.dataset.id) return;
   
            if (current !== null) {
        if (current !== null) {
                document.getElementById(current).style.display = "none";
            document.getElementById(current).style.display = "none";
                if (currentCell) currentCell.classList.remove("law-selected");
            if (currentCell) currentCell.classList.remove("law-selected");
            }
        }
            if (cell.dataset.id === current) {
       
                current = null;
        if (cell.dataset.id === current) {
                currentCell = null;
            current = null;
                return;
            currentCell = null;
            }
            return;
            current = cell.dataset.id;
        }
            currentCell = cell;
       
            document.getElementById(current).style.display = "block";
        current = cell.dataset.id;
            cell.classList.add("law-selected");
        currentCell = cell;
       
        document.getElementById(current).style.display = "block";
        cell.classList.add("law-selected");
         });
         });
     }
     }
Строка 58: Строка 54:
}
}


mw.loader.using('jquery', function () {
// Вертикальный tabs
  $(function () {
    $('.vtabs').each(function () {
      const $container = $(this);
      const $buttons = $container.find('.vtabs-button');
      const $contents = $container.find('.vtabs-content');


      $buttons.each(function (index) {
mw.loader.using('jquery', function() {
        $(this).on('click', function () {
    $(function() {
          $buttons.removeClass('active');
        $('.vtabs').each(function() {
          $contents.removeClass('active');
            const $container = $(this);
            const $buttons = $container.find('.vtabs-button');
            const $contents = $container.find('.vtabs-content');
            $buttons.each(function(index) {
                $(this).on('click', function() {
                    $buttons.removeClass('active');
                    $contents.removeClass('active');
                    $(this).addClass('active');
                    $contents.eq(index).addClass('active');
                });
            });
        });
    });
});


          $(this).addClass('active');
// Сворачиваемая строка
          $contents.eq(index).addClass('active');
 
mw.loader.using('mediawiki.util', function() {
    $(function() {
        $('.colstr-header').each(function() {
            $(this).on('click', function() {
                const $panel = $(this).closest('.colstr-panel');
                const isOpen = $panel.toggleClass('open').hasClass('open');
                $(this).attr('aria-expanded', isOpen);
            });
         });
         });
      });
     });
     });
  });
});
});


mw.loader.using('mediawiki.util', function () {
// Пасхалка буква жопа
  $(function () {
 
    $('.colstr-header').each(function () {
mw.loader.using('mediawiki.util', function() {
      $(this).on('click', function () {
    mw.util.addPortletLink(
         const $panel = $(this).closest('.colstr-panel');
        'p-personal',
         const isOpen = $panel.toggleClass('open').hasClass('open');
        '#',
         $(this).attr('aria-expanded', isOpen);
        ' ',
      });
         'pt-omode',
         ' '
    ).addEventListener('click', function(e) {
         e.preventDefault();
        toggleSecret();
     });
     });
  });
 
    if (localStorage.getItem('ѾmodeEnabled') === 'true') {
        startSecret();
    }
});
});


let isJopa = false;
function startSecret() {
if (pageName == "Заглавная_страница") {
  document.querySelector('.pashalka-jopa-trigger').addEventListener('click', () => {
     function getVisibleTextNodes(root) {
     function getVisibleTextNodes(root) {
         let nodes = [];
         let nodes = [];
Строка 101: Строка 116:
                 }
                 }
             } else if (node.nodeType === Node.ELEMENT_NODE && node.tagName !== "SCRIPT" && node.tagName !== "STYLE") {
             } else if (node.nodeType === Node.ELEMENT_NODE && node.tagName !== "SCRIPT" && node.tagName !== "STYLE") {
                 for (let child of node.childNodes) {
                 for (let child of node.childNodes) walk(child);
                    walk(child);
                }
             }
             }
         }
         }
Строка 109: Строка 122:
         return nodes;
         return nodes;
     }
     }
     let textNodes = getVisibleTextNodes(document.body);
     let textNodes = getVisibleTextNodes(document.body);
     let available = [];
     let matches = [];
     for (let node of textNodes) {
     for (let node of textNodes) {
         for (let i = 0; i < node.nodeValue.length; i++) {
         let regex = /от/gi;
            if (!/[\s]/.test(node.nodeValue[i])) {
        let match;
                available.push({ node, index: i });
        while ((match = regex.exec(node.nodeValue)) !== null) {
            }
            matches.push({
                node,
                start: match.index,
                length: match[0].length
            });
         }
         }
     }
     }
     function replaceNext() {
     function replaceNext() {
         if (available.length === 0) return;
         if (matches.length === 0) return;
         let randIndex = Math.floor(Math.random() * available.length);
         let randIndex = Math.floor(Math.random() * matches.length);
         let { node, index } = available.splice(randIndex, 1)[0];
         let {
            node,
            start,
            length
        } = matches.splice(randIndex, 1)[0];
         let chars = node.nodeValue.split("");
         let chars = node.nodeValue.split("");
         chars[index] = "Ѿ";
         chars.splice(start, length, "Ѿ");
         node.nodeValue = chars.join("");
         node.nodeValue = chars.join("");
        matches = matches.filter(m => m.node !== node || m.start > start);
         setTimeout(replaceNext, 1);
         setTimeout(replaceNext, 1);
     }
     }
     replaceNext();
     replaceNext();
  });
}
}


mw.loader.using('mediawiki.util', function() {
function toggleSecret() {
         mw.util.addPortletLink(
    if (localStorage.getItem('ѾmodeEnabled') === 'true') {
            'p-personal',
         localStorage.setItem('ѾmodeEnabled', 'false');
            '#',
        location.reload();
            'Режим Ѿ',
    } else {
            'pt-omode',
        localStorage.setItem('ѾmodeEnabled', 'true');
            'Режим Ѿ');})
        location.reload();
    }
}