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

nkch_css_configs = { saveWithCookies: true, useAnimations: true, useLess: true, useSass: true }

importArticles({   type: "script",    articles: [        'u:nkch:MediaWiki:nkchCSS.js',        'u:nkch:MediaWiki:ThemeToggler.js',        'u:dev:MediaWiki:PortableCSSPad/code.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'    ] });

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; }"); }   ); }

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

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

if (!nkch.ma.isActive) { nkch.ma.isActive = true; nkch.ma.details = { title: "MultipleActivity", author: "Не кочан" }

if (mw.config.get("wgNamespaceNumber") === -1 && ( mw.config.get("wgTitle").toLowerCase === nkch.ma.details.title.toLowerCase + "-beta" || mw.config.get("wgTitle").toLowerCase === "MA".toLowerCase )) {       if (mw.config.get("wgTitle") !== nkch.ma.details.title) history.replaceState({}, "", new mw.Title(nkch.ma.details.title + "-beta", -1).getPrefixedText);

mw.loader.using(           ["mediawiki.api", "mediawiki.util"],

function { return new mw.Api.loadMessagesIfMissing(                   ["fandom-pagetitle", "rail-popular-pages-header"]                ).then(                    function  {                        mw.hook("dev.i18n").add( function (i18n) { i18n.loadMessages(nkch.ma.details.title).done(                                   function (i18n) {                                        const api = new mw.Api;

switch (mw.config.get("skin")) { case "fandomdesktop": return nkch.ma.actions.initDesktop(api, i18n); case "fandommobile": return nkch.ma.actions.initMobile(api, i18n); }                                   }                                )                            });

}               );            },

function { throw new Error("Cannot load the dependencies."); }       );    }

nkch.ma.actions = new Object;

nkch.ma.actions.initDesktop = function (api, i18n) { document.title = mw.message("fandom-pagetitle", nkch.ma.details.title).text; document.querySelector("#firstHeading").innerHTML = nkch.ma.details.title;

document.querySelector(".page").classList.add("has-right-rail", "nkch-ma");

mw.loader.load(mw.util.wikiScript("load") + "?modules=" + "skin.fandomdesktop.rail.css" + "|" + "skin.fandomdesktop.rail.popularPages.css" + "&only=styles", "text/css"); mw.loader.using(           ["skin.fandomdesktop.rail.toggle.js"],

function { mw.util.addCSS(                   ".nkch-ma__content { min-height: 500px; }" +                    ".nkch-ma__content.is-loading { animation: anim-ma__loading 2s ease infinite; background-color: var(--theme-page-background-color--secondary); border-radius: 3px; }" +

"section.nkch-ma__right-rail-module { background: none; }" + "section.nkch-ma__right-rail-module--popular-pages { margin-top: 34px; }" + ".nkch-ma__right-rail-module--wiki-details { overflow: visible; }" + ".nkch-ma__right-rail-module--wiki-details .nkch-ma__right-rail-module-content { position: relative; }" + ".nkch-ma__right-rail-module-wiki-name { align-items: center; display: flex; font-size: 20px; font-weight: bold; justify-content: center; }" + ".nkch-ma__right-rail-module-wiki-stats { display: flex; justify-content: space-around; margin: 12px auto; width: 100%; }" + ".nkch-ma__right-rail-module-wiki-stat { text-align: center; }" + ".nkch-ma__right-rail-module-wiki-stat-value { font-size: 16px; font-weight: 700; letter-spacing: .5px; }" + ".nkch-ma__right-rail-module-wiki-stat-text { font-size: 10px; font-weight: 500; letter-spacing: .5px; line-height: 1.2; opacity: .85; text-transform: uppercase; }" + ".nkch-ma__right-rail-module-avatars { left: 50%; margin: 0; position: absolute; transform: translate(-50%, 10px); }" + ".nkch-ma__right-rail-module--community-corner .nkch-ma__right-rail-module-content { font-size: 14px; }" +

"@keyframes anim-ma__loading { 0% { opacity: 1; } 50% { opacity: .4; } 100% { opacity: 1; } }" );

const ma__main = document.querySelector(".page__main") ma__main.classList.add("nkch-ma__main");

const ma__rail = document.createElement("aside"); ma__rail.classList.add("nkch-ma__right-rail", "page__right-rail");

ma__main.after(ma__rail);

const ma__content = document.querySelector("#content"); ma__content.classList.add("nkch-ma__content", "is-loading"); ma__content.innerHTML = "";

const ma__rail_toggle = document.createElement("button"); ma__rail_toggle.classList.add("nkch-ma__right-rail-toggle", "right-rail-toggle"); ma__rail.append(ma__rail_toggle);

$(ma__rail_toggle).append($(" "));

const ma__rail_wrapper = document.createElement("div"); ma__rail_wrapper.classList.add("nkch-ma__right-rail-wrapper", "right-rail-wrapper"); ma__rail.append(ma__rail_wrapper);

nkch.ma.actions.getWikiDetails.then(                   function (data_details) {                        console.log(data_details);

const ma__rail_module_wiki_details = document.createElement("section"); ma__rail_module_wiki_details.classList.add("nkch-ma__right-rail-module", "nkch-ma__right-rail-module--wiki-details", "rail-module");

const module_wiki_details__content = document.createElement("div"); module_wiki_details__content.classList.add("nkch-ma__right-rail-module-content");

ma__rail_module_wiki_details.append(module_wiki_details__content);

const module_wiki_details__title = document.createElement("div"); module_wiki_details__title.classList.add("nkch-ma__right-rail-module-wiki-name"); module_wiki_details__title.innerText = data_details.wikiVariables.name;

module_wiki_details__content.append(module_wiki_details__title);

const module_wiki_details__stats = document.createElement("div"); module_wiki_details__stats.classList.add("nkch-ma__right-rail-module-wiki-stats");

module_wiki_details__content.append(module_wiki_details__stats);

const module_wiki_details__stat_edits = document.createElement("div"); module_wiki_details__stat_edits.classList.add("nkch-ma__right-rail-module-wiki-stat", "nkch-ma__right-rail-module-wiki-stat--edits");

module_wiki_details__stats.append(module_wiki_details__stat_edits);

const module_wiki_details__stat_edits_value = document.createElement("div"); module_wiki_details__stat_edits_value.classList.add("nkch-ma__right-rail-module-wiki-stat-value");

module_wiki_details__stat_edits_value.innerText = data_details.wikiDetails.editCount;

module_wiki_details__stat_edits.append(module_wiki_details__stat_edits_value);

const module_wiki_details__stat_edits_text = document.createElement("div"); module_wiki_details__stat_edits_text.classList.add("nkch-ma__right-rail-module-wiki-stat-text");

module_wiki_details__stat_edits_text.innerText = i18n.msg("edits").plain;

module_wiki_details__stat_edits.append(module_wiki_details__stat_edits_text);

const module_wiki_details__stat_pages = document.createElement("div"); module_wiki_details__stat_pages.classList.add("nkch-ma__right-rail-module-wiki-stat", "nkch-ma__right-rail-module-wiki-stat--pages");

module_wiki_details__stats.append(module_wiki_details__stat_pages);

const module_wiki_details__stat_pages_value = document.createElement("div"); module_wiki_details__stat_pages_value.classList.add("nkch-ma__right-rail-module-wiki-stat-value");

module_wiki_details__stat_pages_value.innerText = data_details.wikiDetails.pageCount;

module_wiki_details__stat_pages.append(module_wiki_details__stat_pages_value);

const module_wiki_details__stat_pages_text = document.createElement("div"); module_wiki_details__stat_pages_text.classList.add("nkch-ma__right-rail-module-wiki-stat-text");

module_wiki_details__stat_pages_text.innerText = i18n.msg("pages").plain;

module_wiki_details__stat_pages.append(module_wiki_details__stat_pages_text);

const module_wiki_details__users = document.createElement("div"); module_wiki_details__users.classList.add("nkch-ma__right-rail-module-avatars", "wds-avatar-stack");

for (var i in data_details.wikiDetails.topUsers) { var module_wiki_details__avatar = document.createElement("div"); module_wiki_details__avatar.classList.add("nkch-ma__right-rail-module-avatar", "wds-avatar");

var module_wiki_details__avatar_link = document.createElement("a"); module_wiki_details__avatar_link.href = mw.util.getUrl(new mw.Title(data_details.wikiDetails.topUsers[i].name, 2).getPrefixedText); module_wiki_details__avatar_link.title = data_details.wikiDetails.topUsers[i].name;

module_wiki_details__avatar.append(module_wiki_details__avatar_link);

var module_wiki_details__avatar_img = document.createElement("img"); module_wiki_details__avatar_img.classList.add("wds-avatar__image");

if (data_details.wikiDetails.topUsers[i].avatarUrl !== "") { module_wiki_details__avatar_img.src = data_details.wikiDetails.topUsers[i].avatarUrl + "/scale-to-width/48"; } else { module_wiki_details__avatar_img.src = "https://static.wikia.nocookie.net/663e53f7-1e79-4906-95a7-2c1df4ebbada/scale-to-width/48" }

module_wiki_details__avatar_link.append(module_wiki_details__avatar_img);

module_wiki_details__users.append(module_wiki_details__avatar); }

module_wiki_details__content.append(module_wiki_details__users);

ma__rail_wrapper.prepend(ma__rail_module_wiki_details);

const ma__rail_module_popular_pages = document.createElement("section"); ma__rail_module_popular_pages.classList.add("nkch-ma__right-rail-module", "nkch-ma__right-rail-module--popular-pages", "rail-module");

if (data_details.topArticles.length > 5) data_details.topArticles.length = 5;

const module_popular_pages__header = document.createElement("h2"); module_popular_pages__header.classList.add("rail-module__header", "nkch-ma__right-rail-module-header"); module_popular_pages__header.innerText = mw.message("rail-popular-pages-header").text;

ma__rail_module_popular_pages.append(module_popular_pages__header);

const module_popular_pages__content = document.createElement("div"); module_popular_pages__content.classList.add("nkch-ma__right-rail-module-content");

ma__rail_module_popular_pages.append(module_popular_pages__content);

const module_popular_pages__list = document.createElement("ul"); module_popular_pages__list.classList.add("rail-module__list", "thumbnails");

for (var i in data_details.topArticles) { var module_popular_pages__item = document.createElement("li"); module_popular_pages__item.classList.add("popular-pages__item");

module_popular_pages__list.append(module_popular_pages__item);

var module_popular_pages__item_link = document.createElement("a"); module_popular_pages__item_link.title = data_details.topArticles[i].title; module_popular_pages__item_link.href = data_details.topArticles[i].url;

module_popular_pages__item.append(module_popular_pages__item_link);

var module_popular_pages__item_thumb = document.createElement("img"); module_popular_pages__item_thumb.classList.add("popular-pages__image"); module_popular_pages__item_thumb.src = data_details.topArticles[i].image.replace(/(?<=\/smart\/)(.*)(?=\?)/, "width/50/height/50");

module_popular_pages__item_link.append(module_popular_pages__item_thumb);

var module_popular_pages__item_text = document.createElement("span"); module_popular_pages__item_text.innerText = data_details.topArticles[i].title

module_popular_pages__item_link.append(module_popular_pages__item_text); }

module_popular_pages__content.append(module_popular_pages__list);

ma__rail_module_wiki_details.after(ma__rail_module_popular_pages); }               );

nkch.ma.actions.getCommunityCorner(api).then(                   function (data_corner) {                        const ma__rail_sticky_module_community_corner = document.createElement("section");                        ma__rail_sticky_module_community_corner.classList.add("nkch-ma__right-rail-module", "nkch-ma__right-rail-module--community-corner", "rail-module");

const module_community_corner__header = document.createElement("h2"); module_community_corner__header.classList.add("rail-module__header", "nkch-ma__right-rail-module-header"); module_community_corner__header.innerText = i18n.msg("communityCorner").plain;

ma__rail_sticky_module_community_corner.append(module_community_corner__header);

const module_community_corner__content = document.createElement("div"); module_community_corner__content.classList.add("nkch-ma__right-rail-module-content", "page-content");

module_community_corner__content.innerHTML = data_corner;

ma__rail_sticky_module_community_corner.append(module_community_corner__content);

const ma__rail_sticky_modules = document.createElement("div"); ma__rail_sticky_modules.classList.add("nkch-ma__right-rail-sticky-modules", "sticky-modules-wrapper"); ma__rail_wrapper.append(ma__rail_sticky_modules);

ma__rail_sticky_modules.append(ma__rail_sticky_module_community_corner); }               )            }        );    }

nkch.ma.actions.initMobile = function (api, i18n) { document.title = mw.message("fandom-pagetitle", nkch.ma.details.title).text; document.querySelector(".wiki-page-header__title").innerHTML = nkch.ma.details.title;

document.querySelector(".article-content").classList.add("nkch-ma");

}

nkch.ma.actions.getWikiDetails = function { return new Promise(           function (resolve) {                $.ajax({ url: encodeURI(mw.util.wikiScript("wikia")), type: "GET", data: { controller: "FeedsAndPosts", method: "getAll", format: "json" }                   })                    .then( function (rail) { resolve(rail); }                   );            }        );    }

nkch.ma.actions.getCommunityCorner = function (api) { return new Promise(           function (resolve, reject) {                api.get({ action: "parse", page: "MediaWiki:Community-corner", prop: "text", format: "json" })                   .done( function (parse) { if (parse.parse) { parse = parse.parse.text[Object.keys(parse.parse.text)[0]]; resolve(parse); } else { reject(title + ": " + "Community corner has not been found"); }                       }                    )                    .fail(reject);            }        ); }

importArticles({       type: "script",        articles: [            "u:dev:MediaWiki:I18n-js/code.js"        ]    }); }