User:Не кочан/global.js

nkch_css_configs = { themes: { light: "dracula", dark: "darcula" },   saveWithCookies: true, useAnimations: true }

importArticles({   type: "script",    articles: [        'u:dev:MediaWiki:PortableCSSPad/code.js',        'u:nkch:MediaWiki:nkchCSS.js',        'u:dev:MediaWiki:PurgeButton/code.js',        'u:dev:MediaWiki:QuickDiff/code.js',        'u:nkch:MediaWiki:ProfileBanner.js',        'u:nkch:MediaWiki:WhatLeavesHere.js'        //'u:dev:MediaWiki:MultipleActivity.js'    ] });

var nkch = typeof window.nkch != "undefined" ? window.nkch : new Object; window.nkch = nkch;

nkch.tt = typeof nkch.tt != "undefined" ? nkch.css : new Object;

if (!nkch.tt.isActive) { nkch.tt.isActive = true;

mw.loader.using(["mediawiki.api", "mediawiki.util"], function {        const api = new mw.Api;

mw.hook("dev.wds").add(           function (wds) {                var currentTheme = mw.user.options.get("theme");

function addClasses(element) { element.$classes.forEach(                       function (c) {                            element.$e.classList.add(c);                        }                    ); }

mw.util.addCSS(                   ".nkch-theme-toggler__wrapper { background: var(--theme-body-background-color); border: 1px solid var(--theme-community-header-color); border-radius: 15px; display: flex; height: 30px; justify-content: center; margin-inline-end: 6px; position: relative; }" +                    ".nkch-theme-toggler { border-radius: 15px; display: flex; overflow: hidden; position: relative; z-index: 2; }" +

".nkch-theme-toggler__button { align-items: center; background: none; border: none; cursor: pointer; display: flex; height: 28px; justify-content: center; width: 28px; z-index: 2; }" + ".nkch-theme-toggler__button-icon { color: currentColor; height: 18px; width: 18px; }" + ".nkch-theme-toggler__button-icon .wds-icon-small { fill: var(--theme-community-header-color); transition: .5s; }" + ".nkch-theme-toggler__button.is-active .wds-icon-small { fill: var(--theme-body-background-color); transition: .7s; }" +

".nkch-theme-toggler__pointer-wrapper { align-items: center; animation: anim-theme-toggler-jump-in .5s ease; display: flex; height: 28px; justify-content: center; position: absolute; top: 0; transition: .3s; width: 28px; z-index: 1; will-change: transform, z-index ;}" + ".nkch-theme-toggler__pointer { background: var(--theme-community-header-color); border-radius: 15px; height: 26px; margin: 1px; width: 26px; }" );

nkch.tt.el = { theme: { common: { $e: document.createElement("style") },                       nav: { $e: document.createElement("style") }                   },                    wrapper: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler__wrapper"] },                   toggler: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler"], buttons: { dark: { $e: document.createElement("button"), $classes: ["nkch-theme-toggler__button", "nkch-theme-toggler__button-dark"], icon: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler__button-icon", "nkch-theme-toggler__button-icon-dark"] }                           },                            default: { $e: document.createElement("button"), $classes: ["nkch-theme-toggler__button", "nkch-theme-toggler__button-default"], icon: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler__button-icon", "nkch-theme-toggler__button-icon-default"] }                           },                            light: { $e: document.createElement("button"), $classes: ["nkch-theme-toggler__button", "nkch-theme-toggler__button-light"], icon: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler__button-icon", "nkch-theme-toggler__button-icon-light"] }                           }                        }                    },                    pointerWrapper: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler__pointer-wrapper"], pointer: { $e: document.createElement("div"), $classes: ["nkch-theme-toggler__pointer"], }                   }                }

addClasses(nkch.tt.el.wrapper);

addClasses(nkch.tt.el.toggler); nkch.tt.el.wrapper.$e.append(nkch.tt.el.toggler.$e);

addClasses(nkch.tt.el.toggler.buttons.dark); nkch.tt.el.toggler.$e.append(nkch.tt.el.toggler.buttons.dark.$e);

nkch.tt.el.toggler.buttons.dark.$e.animate([{                   opacity: 0,                    transform: "translateY(20px)"                }, {                    transform: "translateY(-5px)",                    offset: 0.6                }, {                    opacity: 1,                    transform: "translateY(0)"                }], {                    duration: 500,                    easing: "ease"                });

addClasses(nkch.tt.el.toggler.buttons.dark.icon); nkch.tt.el.toggler.buttons.dark.$e.append(nkch.tt.el.toggler.buttons.dark.icon.$e); nkch.tt.el.toggler.buttons.dark.icon.$e.append(wds.icon("moon-small"));

addClasses(nkch.tt.el.toggler.buttons.default); nkch.tt.el.toggler.$e.append(nkch.tt.el.toggler.buttons.default.$e);

nkch.tt.el.toggler.buttons.default.$e.animate([{                   opacity: 0,                    transform: "translateY(20px)"                }, {                    transform: "translateY(-5px)",                    offset: 0.65                }, {                    opacity: 1,                    transform: "translateY(0)"                }], {                    duration: 500,                    easing: "ease"                });

addClasses(nkch.tt.el.toggler.buttons.default.icon); nkch.tt.el.toggler.buttons.default.$e.append(nkch.tt.el.toggler.buttons.default.icon.$e); nkch.tt.el.toggler.buttons.default.icon.$e.append(wds.icon("radio-empty-small"));

addClasses(nkch.tt.el.toggler.buttons.light); nkch.tt.el.toggler.$e.append(nkch.tt.el.toggler.buttons.light.$e);

nkch.tt.el.toggler.buttons.light.$e.animate([{                   opacity: 0,                    transform: "translateY(20px)"                }, {                    transform: "translateY(-5px)",                    offset: 0.7                }, {                    opacity: 1,                    transform: "translateY(0)"                }], {                    duration: 500,                    easing: "ease"                });

addClasses(nkch.tt.el.toggler.buttons.light.icon); nkch.tt.el.toggler.buttons.light.$e.append(nkch.tt.el.toggler.buttons.light.icon.$e); nkch.tt.el.toggler.buttons.light.icon.$e.append(wds.icon("sun-small"));

addClasses(nkch.tt.el.pointerWrapper);

if (nkch.tt.el.toggler.buttons.dark.$e.classList.contains("is-active")) { nkch.tt.el.pointerWrapper.$e.style.marginLeft = "-56px"; }

if (nkch.tt.el.toggler.buttons.light.$e.classList.contains("is-active")) { nkch.tt.el.pointerWrapper.$e.style.marginRight = "-56px"; }               nkch.tt.el.wrapper.$e.append(nkch.tt.el.pointerWrapper.$e);

nkch.tt.el.pointerWrapper.$e.animate([{                   transform: "translateY(0)",                    zIndex: -1,                }, {                    transform: "translateY(-30px)",                    zIndex: -1,                    offset: 0.4                }, {                    transform: "translateY(-30px)",                    zIndex: 1,                    offset: 0.5                }, {                    transform: "translateY(2px)",                    zIndex: 1,                    offset: 0.9                }, {                    transform: "translateY(0)",                    zIndex: 1,                }], {                    duration: 500,                    easing: "ease"                });

addClasses(nkch.tt.el.pointerWrapper.pointer); nkch.tt.el.pointerWrapper.$e.append(nkch.tt.el.pointerWrapper.pointer.$e);

switch (currentTheme) { case "light": nkch.tt.el.toggler.buttons.light.$e.classList.add("is-active"); break; case "dark": nkch.tt.el.toggler.buttons.dark.$e.classList.add("is-active"); break; case "wiki": nkch.tt.el.toggler.buttons.default.$e.classList.add("is-active"); break; }

function switchButton(button) { document.querySelectorAll(".nkch-theme-toggler > .nkch-theme-toggler__button").forEach(                       function (e) {                            e.classList.remove("is-active");                        }                    );

button.classList.add("is-active"); }

nkch.tt.el.theme.common.$e.setAttribute("type", "text/css"); document.head.append(nkch.tt.el.theme.common.$e);

nkch.tt.el.theme.nav.$e.setAttribute("type", "text/css"); document.head.append(nkch.tt.el.theme.nav.$e);

function changeTheme(theme) { if (theme === "light" && document.body.classList.contains("theme-fandomdesktop-dark")) { document.body.classList.remove("theme-fandomdesktop-dark"); document.body.classList.add("theme-fandomdesktop-light"); mw.config.set("isDarkTheme", false); } else if (theme === "dark" && document.body.classList.contains("theme-fandomdesktop-light")) { document.body.classList.remove("theme-fandomdesktop-light"); document.body.classList.add("theme-fandomdesktop-dark"); mw.config.set("isDarkTheme", true); }

if (theme !== "wiki" && (theme === "light" || theme === "dark")) { Promise.all([                           $.get({ url: mw.util.wikiScript("wikia"), data: { controller: "ThemeApi", method: "themeVariables", variant: theme }                           }),                            $.get({ url: mw.util.wikiScript("load"), data: { modules: "ext.fandom.DesignSystem.GlobalNavigation.brand." + theme + ".css" + "|" + "ext.fandom.DesignSystem.brand." + theme + ".css", only: "styles" }                           })                        ]).then(                            function (data) {                                nkch.tt.el.theme.common.$e.innerHTML = data[0];                                nkch.tt.el.theme.nav.$e.innerHTML = data[1];

api.postWithToken("csrf", {                                   action: "options",                                    optionname: "theme",                                    optionvalue: theme                                }); }                       );                    } else {                        api.postWithToken("csrf", { action: "options", optionname: "theme", optionvalue: theme });                   }                }

nkch.tt.el.toggler.buttons.dark.$e.addEventListener("click", function {                    switchButton(nkch.tt.el.toggler.buttons.dark.$e);                    changeTheme("dark");                });

nkch.tt.el.toggler.buttons.default.$e.addEventListener("click", function {                    switchButton(nkch.tt.el.toggler.buttons.default.$e);                    changeTheme("wiki");                });

nkch.tt.el.toggler.buttons.light.$e.addEventListener("click", function {                    switchButton(nkch.tt.el.toggler.buttons.light.$e);                    changeTheme("light");                });

function checkIfActive { if (nkch.tt.el.toggler.buttons.default.$e.classList.contains("is-active")) { nkch.tt.el.pointerWrapper.$e.style.marginLeft = null; nkch.tt.el.pointerWrapper.$e.style.marginRight = null; } else if (nkch.tt.el.toggler.buttons.dark.$e.classList.contains("is-active")) { nkch.tt.el.pointerWrapper.$e.style.marginLeft = "-56px"; nkch.tt.el.pointerWrapper.$e.style.marginRight = null; } else if (nkch.tt.el.toggler.buttons.light.$e.classList.contains("is-active")) { nkch.tt.el.pointerWrapper.$e.style.marginLeft = null; nkch.tt.el.pointerWrapper.$e.style.marginRight = "-56px"; }               }

setInterval(checkIfActive, 100);

document.querySelector(".page-counter").after(nkch.tt.el.wrapper.$e); }       );

importArticle({           type: "script",            article: "u:dev:MediaWiki:WDSIcons/code.js"        }); }); }

window.nkch_navLinks = [{ link: "ru.community", title: "Вики Сообщества" }, {   link: "community", title: "Community Central" }, {   link: "ru.wikies", title: "Викии Вики" }, {   link: "ru.dayr", title: "Day R Wiki" }, {   link: "ru.rabi-ribi", title: "Rabi-Ribi вики" }, {   link: "ru.nkch", title: "Не вики" }];

if (typeof window.nkch_navLinks !== "undefined" && Array.isArray(window.nkch_navLinks)) { mw.loader.using(["mediawiki.api", "oojs-ui"]).then(       function  {            const api = new mw.Api;            var originalLinks = document.querySelectorAll(".global-navigation__link:not(.start-a-wiki):not(div)");

originalLinks.forEach(               function (el) {                    el.remove;                }            );

var navLinksWrapper = document.createElement("div");

navLinksWrapper.classList.add("navLinksWrapper")

Object.assign(navLinksWrapper.style, {               width: "100%",                overflowY: "auto",                maxHeight: "500px"            });

if (skin == "fandomdesktop") { document.querySelector(".global-navigation__search.global-navigation__icon").after(navLinksWrapper); };

for (var i in window.nkch_navLinks) { if (typeof window.nkch_navLinks[i].link !== "undefined") { var link = window.nkch_navLinks[i].link.split(".");

var l;                   if (link.length === 1) { l = "https://" + link[0] + ".fandom.com"; } else if (link.length === 2) { l = "https://" + link[1] + ".fandom.com/" + link[0]; };

var favicon = l + "/wiki/Special:Filepath/Site-favicon.ico";

var linkWrapper = document.createElement("a"); linkWrapper.classList.add("global-navigation__link", "navLink");

linkWrapper.href = l;

linkTooltip = document.createElement("div"); linkTooltip.classList.add("wds-tooltip", "is-right");

linkTooltip.style.transform = "translate(65px, -30px)";

if (typeof window.nkch_navLinks[i].title !== "undefined") { linkTooltip.innerHTML = window.nkch_navLinks[i].title; } else { linkTooltip.innerHTML = "[ " + window.nkch_navLinks[i].link + " ]"; };

var linkIcon = document.createElement("span"); linkIcon.classList.add("global-navigation__icon", "has-background");

var linkIconSrc = document.createElement("img");

linkIconSrc.src = favicon; linkIconSrc.setAttribute("width", "16px");

navLinksWrapper.appendChild(linkWrapper); linkWrapper.appendChild(linkIcon); linkWrapper.after(linkTooltip); linkIcon.appendChild(linkIconSrc); }           };

mw.util.addCSS(".navLink + .wds-tooltip { display: none; }"); mw.util.addCSS(".navLink:hover + .wds-tooltip { display: inline-block; }"); mw.util.addCSS(".global-navigation__link { margin-top: 10px; }"); mw.util.addCSS(".global-navigation__link:first-child { margin-top: 0; }"); mw.util.addCSS(".global-navigation__link:nth-of-type(3) { margin-top: 10px; }"); }   ); }

mw.loader.using(["mediawiki.api", "mediawiki.cookie"]).then(   function  {        function checkCookie(cookie, prefix) {            var result;            var c = mw.cookie.get(cookie, prefix);            if (c === null || c === "false") {                result = false;            } else if (c === "true") {                result = true;            }

return result; }

const toolbarButtonWrapper = document.createElement("li"); document.querySelector("#WikiaBar .toolbar .tools").appendChild(toolbarButtonWrapper);

const toolbarButton = document.createElement("a"); toolbarButtonWrapper.appendChild(toolbarButton);

Object.assign(toolbarButton.style, {           display: "flex",            alignItems: "center"        });

const icon = document.createElementNS("http://www.w3.org/2000/svg", "svg"); icon.setAttributeNS(null, "viewBox", "0 0 18 18");

icon.classList.add("wds-icon", "wds-icon-small");

Object.assign(icon.style, {           background: "white",            borderRadius: "3px",            cursor: "pointer",            padding: "2px"        });

switch (checkCookie("openLinksInEditMode", "nkch_")) { case true: icon.style.fill = "var(--theme-success-color)"; break; case false: icon.style.fill = "var(--theme-alert-color)"; break; }

toolbarButton.appendChild(icon);

const iconSrc = document.createElementNS("http://www.w3.org/2000/svg", "use"); iconSrc.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#wds-icons-external-small"); icon.appendChild(iconSrc);

toolbarButton.addEventListener("click", function {            switch (checkCookie("openLinksInEditMode", "nkch_")) {                case true:                    mw.cookie.set("openLinksInEditMode", "false", { prefix: "nkch_", });                   icon.style.fill = "var(--theme-alert-color)";                    break;                case false:                    mw.cookie.set("openLinksInEditMode", "true", { prefix: "nkch_", });                   icon.style.fill = "var(--theme-success-color)";                    break;            }        });

document.querySelectorAll("#content a:not(.extiw):not(.external):not([href*='?action']):not([href*='" + encodeURI(mw.config.get("wgFormattedNamespaces")[-1]) + ":'])").forEach(           function (link) {                if (link.href.indexOf(location.protocol + "//" + location.hostname) === 0) {                    const linkHref = link.getAttribute("href");

link.addEventListener("mouseover", function (event) {                       setInterval(checkKey(event), 100);                    })

link.addEventListener("mouseout", function (event) {                       link.setAttribute("href", linkHref);                    })

function checkKey(e) { if (checkCookie("openLinksInEditMode", "nkch_") === true) { if (e.ctrlKey) { link.setAttribute("href", linkHref + "?action=edit"); } else { link.setAttribute("href", linkHref); }                       }                    };                };            }        );    } );