Война в Украине

Все мы знаем, какой пиздец сейчас происходит с Украиной и одной известной вам страной-победительницей-фашизма. Если вы хотите почитать об этом, помочь актуализировать информацию или высказать свое мнение — можете сделать это в статье Война в Украине и в обсуждении.

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

Материал из Urbanculture
Перейти к: навигация, поиск
 
(не показано 9 промежуточных версий этого же участника)
Строка 19: Строка 19:
 
     ;
 
     ;
 
/** /Misc common defines ****/
 
/** /Misc common defines ****/
 
 
  
 
/** Processing queue ****/
 
/** Processing queue ****/
Строка 35: Строка 33:
 
mw.loader.using('UC.queue', function () {
 
mw.loader.using('UC.queue', function () {
  
    /**  Edittools ****/
 
    /* Authors: [[User:Anotubus]], [[User:Obvious]] */
 
    Queue.addOnce('UC.edittools', 'tabbedEditTools', (
 
        (!mw.config.get('wgCanonicalSpecialPageName') &&
 
            (
 
                location.href.match(/&action=(?:edit|submit)/) !== null ||
 
                mw.config.get('wgAction') == 'edit' ||
 
                mw.config.get('wgAction') == 'submit'
 
            )) ||
 
        mw.config.get('wgPageName').match(/mediawiki:(?:edittools|topedittools)/i) !== null ||
 
        mw.config.get('wgCanonicalNamespace').match(/talk$/i) !== null ||
 
        mw.config.get('wgPageName') == "Special:Upload" ||
 
        mw.config.get('wgPageName') == "Служебная:Загрузка"
 
    ));
 
    Queue.addOnce('UC.edittools', 'fileInsert', (
 
        (!mw.config.get('wgCanonicalSpecialPageName') &&
 
            (
 
                location.href.match(/&action=(?:edit|submit)/) !== null ||
 
                mw.config.get('wgAction') == 'edit' ||
 
                mw.config.get('wgAction') == 'submit'
 
            )) ||
 
        mw.config.get('wgPageName').match(/mediawiki:(?:edittools|topedittools)/i) !== null ||
 
        mw.config.get('wgCanonicalNamespace').match(/talk$/i) !== null
 
    ));
 
    Queue.addOnce('UC.edittools', 'fullScreenEditTools', (
 
        (!mw.config.get('wgCanonicalSpecialPageName') &&
 
            (
 
                location.href.match(/&action=(?:edit|submit)/) !== null ||
 
                mw.config.get('wgAction') == 'edit' ||
 
                mw.config.get('wgAction') == 'submit'
 
            ))
 
    ));
 
 
     Queue.addOnce(function () {
 
     Queue.addOnce(function () {
 
         $('.boxes a').each(function () {
 
         $('.boxes a').each(function () {
Строка 76: Строка 42:
 
         });
 
         });
 
     });
 
     });
 +
 +
    /** Drafts save ****/
 +
    Queue.addOnce('UC.draftarticle', 'draftArticle', (
 +
        (!mw.config.get('wgCanonicalSpecialPageName') &&
 +
            (
 +
                location.href.match(/&action=(?:edit|submit)/) !== null ||
 +
                mw.config.get('wgAction') == 'edit' ||
 +
                mw.config.get('wgAction') == 'submit'
 +
            ))
 +
    ));
  
 
     /** Collapsible tables ****/
 
     /** Collapsible tables ****/
Строка 184: Строка 160:
 
         };
 
         };
 
     });
 
     });
 
  
 
     /** Needed page **/
 
     /** Needed page **/
Строка 191: Строка 166:
 
         $('ul').addClass('neededpagelist');
 
         $('ul').addClass('neededpagelist');
 
     }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == 'Urbanculture:R');
 
     }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == 'Urbanculture:R');
 
    /** Wikificator  ************************************* */
 
    function wikification() {
 
        $('<button id="Wikifybutton" onclick="Wikify();" type="button">Викифицировать</button>').insertBefore($('#wpSave'));
 
        if (mw.config.get('wgNamespaceNumber') == -1 || mw.config.get('wgNamespaceNumber') == 108) { $('#Wikifybutton').attr('disabled', 'disabled'); }
 
        $('#editpage-copywarn').insertAfter('.editOptions');
 
    }
 
 
    Queue.addOnce('UC.wikificator', wikification, (!mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgAction') == "edit") || mw.config.get('wgAction') == "submit" || mw.config.get('wgPageName') == "Special:Upload");
 
 
  
 
     /** Image Categorizer  ************************************* */
 
     /** Image Categorizer  ************************************* */
Строка 262: Строка 227:
  
 
     /* LazyLoad EmbedVideo****/
 
     /* LazyLoad EmbedVideo****/
     Queue.addEachFragment(['ext.embedVideo', 'ext.embedVideo-lazy', 'ext.embedVideo-playpause'], 'embedVideoLazyLoad', !mw.config.get( 'wgCanonicalSpecialPageName' ));
+
     Queue.addEachFragment(['ext.embedVideo', 'ext.embedVideo-lazy', 'ext.embedVideo-playpause'], 'embedVideoLazyLoad', !mw.config.get('wgCanonicalSpecialPageName'));
  
  
/***********    Modern gallery Toggler    ***********/
+
    /***********    Modern gallery Toggler    ***********/
Queue.addEachFragment(function (sc) {
+
    Queue.addEachFragment(function (sc) {
    const gallery = $('.combinedgallery, .videogallery', sc)
+
        const gallery = $('.combinedgallery, .videogallery', sc)
    ;
+
            ;
    gallery.each(function() {
+
        gallery.each(function () {
        var t = $(this),
+
            var t = $(this),
 
                 tElLength = t.data('line-elems'),
 
                 tElLength = t.data('line-elems'),
 
                 tElems = t.find('.gallery_content_block').length
 
                 tElems = t.find('.gallery_content_block').length
        ;//console.log(t)
+
                ;//console.log(t)
        if (tElems > tElLength) t.addClass('__hide_content');
+
            if (tElems > tElLength) t.addClass('__hide_content');
    });
+
        });
}, !mw.config.get('wgCanonicalSpecialPageName'));
+
    }, !mw.config.get('wgCanonicalSpecialPageName'));
  
Queue.addOnce(function () {//console.log('Modern gallery Toggler addOnce', $(document))
+
    Queue.addOnce(function () {//console.log('Modern gallery Toggler addOnce', $(document))
    $('body').on('click', '.gallery_toggle', function() {
+
        $('body').on('click', '.gallery_toggle', function () {
        var t = $(this),
+
            var t = $(this),
            tGall = t.closest('.combinedgallery, .videogallery')
+
                tGall = t.closest('.combinedgallery, .videogallery')
        ;//console.log(t)
+
                ;//console.log(t)
        tGall.toggleClass('__hide_content __show_content')
+
            tGall.toggleClass('__hide_content __show_content')
    });
+
        });
}, !mw.config.get('wgCanonicalSpecialPageName'))
+
    }, !mw.config.get('wgCanonicalSpecialPageName'))
  
  
/***********    /Modern gallery Toggler    ***********/
+
    /***********    /Modern gallery Toggler    ***********/
  
 +
    /***********    Scale    ***********/
 +
    Queue.addOnce('UC.scalemap', 'scaleMap', f5s && mw.config.get('skin') == 'vector');
 +
    /***********    /Scale    ***********/
  
 
     /*** define the functions, that will be ran on each Comments display refresh ***/
 
     /*** define the functions, that will be ran on each Comments display refresh ***/
Строка 364: Строка 332:
 
     });
 
     });
 
}
 
}
 
/***********    Scale    ***********/
 
$(function() { const _us_dev = window._us_dev; if (!window._us_dev) {
 
    'use strict';
 
    /* Scale fix for :focus pseudoclass */
 
 
    const scales = $(".scale")
 
    ;
 
    var _rt
 
    ;
 
    document.querySelectorAll('.line, .map_pointer').forEach(function (e) {
 
        e.setAttribute('tabindex', '-1');
 
    });
 
 
    function doScales (init) { _us_dev&&console.log('doScales', init);
 
        scales.each(function() {
 
            var scale = $(this),
 
                scaleHeight = scale.prop('scrollHeight'),
 
                map = scale.siblings('.map'),
 
                mapHeight = map.outerHeight(),
 
                lines = map.find('.lines'),
 
                pointers = map.find('.map_pointer')
 
            ;
 
            if (map.length && lines.length) {
 
                lines.css({ 'height': scaleHeight });
 
                lines.get(0).style.setProperty("--real_height", mapHeight);
 
            }
 
            init && scale.off('.scales').on('scroll.scales', function () {
 
                var scaleOffset = $(this).scrollTop();
 
 
                lines.css('transform', 'translate3d(0, -'+scaleOffset+'px, 0)');
 
                pointers.css('transform', 'translate3d(0, '+scaleOffset+'px, 0)');
 
            });
 
            _rt = null;
 
        });
 
    }
 
    doScales(true);
 
 
    $(window).on('resize', function(ev) {
 
        if (!_rt) {
 
            _rt = setTimeout(doScales, 250);
 
        }
 
    });
 
 
    $('.__click').on('click', function(e) { _us_dev&&console.log('.__click', e);
 
        if (!e.which===1) {return}
 
        e.preventDefault();
 
 
        var t = $(this),
 
            tMap = t.parents('.map'),
 
            tScaleParent = tMap.siblings('.scale'),
 
            tSibling = t.is('.map_pointer') ? t.prev() : t.next();
 
 
        if(!t.is('.active')) {
 
            t.addClass('active');
 
            tSibling.addClass('active');
 
 
            $('.__click')
 
                .not(t).not(tSibling)
 
                .removeClass('active')
 
            ;
 
        }
 
 
        if (t.is('.map_pointer')) {
 
            var tLineOffset = tSibling.position().top
 
            ;
 
            tScaleParent.animate({ scrollTop: tLineOffset }, 200);
 
        }
 
        return false;
 
    });
 
 
    $('.point_content__close').on('click', function(e) { _us_dev&&console.log('.point_content__close', e)
 
        var $t = $(this),
 
            $mp = $t.closest('.map_pointer.active'),
 
            $l = $mp.siblings('.line')
 
        ;
 
        _us_dev&&console.log($mp, $l)
 
        $mp[0] && $mp.add($l).removeClass('active')
 
        return false;
 
    });
 
} });
 
/***********    /Scale    ***********/
 
  
 
/***********    NSFW    ***********/
 
/***********    NSFW    ***********/
$(document).on('click', '.NSFW', function(e) {
+
$(document).on('click', '.NSFW', function (e) {
 
     e.preventDefault();
 
     e.preventDefault();
  
Строка 454: Строка 340:
 
});
 
});
 
/***********    /NSFW    ***********/
 
/***********    /NSFW    ***********/
 
  
 
/* Saladificator */
 
/* Saladificator */
Строка 464: Строка 349:
 
$(document).ready(function () {
 
$(document).ready(function () {
 
     if ((now_month + '' + now_day) > 1228 || (now_month + '' + now_day) < 13) {
 
     if ((now_month + '' + now_day) > 1228 || (now_month + '' + now_day) < 13) {
         $('#mw-panel').addClass('saladificator')
+
         //$('#mw-panel').addClass('saladificator')
 
     }
 
     }
  
Строка 481: Строка 366:
 
         var goToTopButton = document.createElement('div');
 
         var goToTopButton = document.createElement('div');
  
         goToTopButton.addEventListener('click', function(e) {
+
         goToTopButton.addEventListener('click', function (e) {
             window.scrollTo({top: 0, behavior: 'smooth'});
+
             window.scrollTo({ top: 0, behavior: 'auto' });
 
         });
 
         });
  
Строка 490: Строка 375:
 
         toc.appendChild(goToTopButton);
 
         toc.appendChild(goToTopButton);
  
         toc.querySelectorAll(':scope a').forEach(function(anchor) {
+
         toc.querySelectorAll(':scope a').forEach(function (anchor) {
 
             anchor.addEventListener('click', function (e) {
 
             anchor.addEventListener('click', function (e) {
 
                 e.preventDefault();
 
                 e.preventDefault();
Строка 496: Строка 381:
 
                 var anchorText = this.getAttribute('href'),
 
                 var anchorText = this.getAttribute('href'),
 
                     anchorId = anchorText.substring(1, anchorText.length);
 
                     anchorId = anchorText.substring(1, anchorText.length);
       
+
 
 
                 document.getElementById(anchorId).scrollIntoView({
 
                 document.getElementById(anchorId).scrollIntoView({
                     behavior: 'auto'
+
                     behavior: 'smooth'
 
                 });
 
                 });
  
Строка 525: Строка 410:
 
             document.addEventListener('scroll', function (e) {
 
             document.addEventListener('scroll', function (e) {
 
                 topPos = toc.getBoundingClientRect().top;
 
                 topPos = toc.getBoundingClientRect().top;
 
+
                 setTimeout(function () {
                 if (topPos <= tocHeight) {
+
                    if (topPos <= tocHeight) {
                    toc.classList.add('__sticky', '__ontop', '__hidden');
+
                        toc.classList.add('__sticky', '__ontop', '__hidden');
                } else if (topPos > 0) {
+
                    } else if (topPos && topPos >= 1) {
                    toc.classList.remove('__sticky', '__ontop');
+
                        toc.classList.remove('__sticky', '__ontop');
                 }
+
                    }
 +
                 }, 50);
 
             });
 
             });
 
         }
 
         }

Текущая версия на 22:20, 27 января 2024

/** Misc common defines ****/
 
 
/* Неоднократно нужные проверки: */
/*** _is_editpage - я на странице редактирования? */
/*** _is_editable - у меня есть права на правку текущей страницы? */
/*** _is_autoconfirmed  */
var _is_editpage = mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit';
var _is_editable = (function isEditable() {
    var restrict = mw.config.get('wgRestrictionEdit') || [], g;
    if (restrict.length < 1) { return true; }
    if (!mw.config.get('wgUserGroups')) { return false; }
    for (g = 0; g < mw.config.get('wgUserGroups').length; g++) { if ($.inArray(mw.config.get('wgUserGroups')[g], restrict) != -1) { return true; } }
    return false;
}());
var _is_autoconfirmed = mw.config.get('wgUserGroups') && ($.inArray('autoconfirmed', mw.config.get('wgUserGroups')) != -1),
    f5s = ('localStorage' in window) && window.localStorage !== null ? window.localStorage : false,
    Queue
    ;
/** /Misc common defines ****/
 
/** Processing queue ****/
 
/**** Queue.addOnce(function(){}, condition = true) - adds a function to run once on page load */
/**** Queue.addOnce('module.name', [function(){} | function name string string], condition = true) - loads a module and adds a function to run once on page load */
/**** Queue.addEachFragment(function(scope){}, condtion = true) - adds function to run on page load AND on each AJAX loaded fragment */
/**** Queue.addEachFragment('module.name', [function(scope){} | function name string string], condtion = true) - loads a module and adds function to run on page load AND on each AJAX loaded fragment */
/****     Function must take a single parameter - currently processed fragment */
/**** Both functions take optional second parameter - if false, function won't be run on current page */
/**** Queue.runOnce - self-descriptive, shouldn't be run directly */
/**** Queue.runEachFragment(scope) - scope can be an html element or array of elements */
 
mw.loader.using('UC.queue', function () {
 
    Queue.addOnce(function () {
        $('.boxes a').each(function () {
            var parentalt = $(this).parent().attr('title');
            $(this).attr('alt', parentalt);
            if ($(this).parent().hasClass('menuicon')) {
                $(this).html('<span class="glyphicon"></span>')
            };
        });
    });
 
    /** Drafts save ****/
    Queue.addOnce('UC.draftarticle', 'draftArticle', (
        (!mw.config.get('wgCanonicalSpecialPageName') &&
            (
                location.href.match(/&action=(?:edit|submit)/) !== null ||
                mw.config.get('wgAction') == 'edit' ||
                mw.config.get('wgAction') == 'submit'
            ))
    ));
 
    /** Collapsible tables ****/
    // Используется в коллапсерах
    Queue.addEachFragment('UC.tablecollapsers', 'createTableCollapsers', !mw.config.get('wgCanonicalSpecialPageName'));
    Queue.addEachFragment('UC.tablecollapsers', 'createHiderButtons', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** NSFW Gallery Items ****/
    /* Description: Hides images with |NSFW in description from galleries */
    /* Authors: [[User:Anotubus]], [[User:Obvious]] */
    Queue.addEachFragment('UC.gallerymodify', 'processNSFWGalleryItems', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Dynamic gallery ****/
    Queue.addEachFragment('UC.gallerymodify', 'dynamicGallery', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Ajaxed *****/
    Queue.addEachFragment('UC.ajaxed', 'ajaxed', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Sidebar scroll *****/
    Queue.addOnce('jquery.slimscroll', function () {
        if ($(window).width() > '980') {
            $('#mw-panel').slimScroll({
                color: '#ffffff',
                distance: '3px'
            });
        };
 
        $('#toc > ul').slimScroll({
            color: '#333333',
            distance: '3px',
            allowPageScroll: false
        });
    });
 
 
    /** Ref tooltips******************************************
      *
      *  Description: Replace references with JQuery-based tooltips
      *  Made by:  Tachikoma
      */
 
    Queue.addOnce(function () {
        $(window).click(function (e) {
            if (!($(e.target).hasClass('areference') || $(e.target).parents().andSelf().hasClass('tooltip'))) {
                $('.tooltip').hide(250); $('.curreference').removeClass('curreference');
            }
        });
    }, !mw.config.get('wgCanonicalSpecialPageName')).addEachFragment(function (scope) {
        var refs = $('ol.references', scope);
        if (!refs.size()) { return; }
        refs.before($('<a href="#">[показать примечания]</a>').click(function (e) { e.preventDefault(); refs.toggle(); })).hide();
        $('.reference a', scope).click(function (e) {
            e.preventDefault();
            var x = $(this), iscurrent = x.hasClass('curreference'), i = $('.tooltip').hide(250),
                par = x.parent(), o = par.offset(), l = o.left, t = o.top + 13,
                b = $('body'), mh = b.height(), mw = b.width(),
                c = $(x.attr('href'), refs).clone().find('a:first').remove().end().html();
            $('.curreference').removeClass('curreference');
            if (iscurrent) { return; }
 
            x.addClass('areference').addClass('curreference');
            if (!i.size()) { i = $('<div/>').addClass('tooltip'); }
            i.appendTo(b).queue(function () {
                i.empty().append(c).css({ 'left': l - ((l + i.width() >= mw) && i.width()), 'top': t - ((t + i.height() >= mh) && (i.height() + 26)) }).dequeue();
            }).show(250);
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Morph LM Edition **************************************/
    Queue.addEachFragment('UC.morphobjects', 'createMorphObjects', !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** Pre lines******************************************
      *
      *  Description: add lines to <pre> tags
      *  Made by: Munhgauzen
      */
 
    Queue.addOnce(function () {
        $('pre').each(function () {
            var rows_count = Math.round($(this).height() / parseInt($(this).css('line-height')));
            var $pre = $(this);
            var html = $pre.html();
            var nl = /\n|\r|\r\n/g;
            $pre.html(('\n' + html).replace(nl, '</div><div class="row">'));
        });
    });
 
    /** Linkchecker ***/
    function linkchecker(scope) {
        $('.linkchecker', scope).each(function (i, e) {
            var lc_if = $(".linkcheckerif a", this),
                lc_then = $(".linkcheckerthen", this),
                lc_else = $(".linkcheckerelse", this)
                ;
 
            if (lc_if.size() && lc_then.size()) {
                if (lc_if.hasClass('new')) { lc_then.hide(); } else { lc_else.hide(); }
                lc_if.parent().hide();
            } else { $(this).hide(); }
        });
    }
    Queue.addEachFragment(linkchecker, !mw.config.get('wgCanonicalSpecialPageName'));
 
    /** ShortDiffURL ****/
    Queue.addOnce(function shortdiffurl() {
        if (!mw.config.get('wgCanonicalSpecialPageName') && window.location.href.indexOf("diff=") != '-1' && $("#ca-history").size() > 0) {
            $("#ca-history").after('<li id="ca-diff" class="collapsible"><span><a href="' + location.href.replace(/^(.+\?).*&?(diff=(?:\d+|prev|next|curr)).*?(&oldid=\d+)?.*$/, "$1$2$3") + '" title="Короткая ссылка на дифф">Дифф</a></span></li>');
        };
    });
 
    /** Needed page **/
    Queue.addOnce(function () {
        $('.mw-redirect').addClass('neededpagerdrcts');
        $('ul').addClass('neededpagelist');
    }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == 'Urbanculture:R');
 
    /** Image Categorizer  ************************************* */
    /** Author: Anotubus   */
    /* if ( (mw.config.get( 'wgCanonicalNamespace' ) == 'File' || mw.config.get( 'wgNamespaceNumber' ) == 6) && _is_autoconfirmed && _is_editable ) importScriptURI("/skins/common/imgcat.js");*/
 
 
    /** Section menus ****************************************** */
    /* Authors: [[User:Tachikoma]], [[User:T_kns]], [[User:Мопец Ципельман]] */
    window.excludedSectionHeaders = $('.c-comment :header');
    Queue.addOnce('UC.sectionmenus', 'addSectionMenus', !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('skin') == 'vector');
 
 
    /** collapsibledivs *****/
    Queue.addOnce('UC.collapsiblesidebar', 'collapsibleSideBar', f5s && mw.config.get('skin') == 'vector');
 
    /* empty pagename ****/
    Queue.addOnce(function () {
        $('#bodySearch').submit(function (e) {
            var wrap = $(this).children(".bodySearchWrap");
            if (/^\s*$/.test(wrap.children('#bodySearchInput').val())) {
                if (wrap.children('.pagenameneeded').size() === 0) {
                    wrap.append($('<p class="pagenameneeded">Введите имя статьи</p>').delay(1500).fadeOut('slow', function () { $(this).remove(); }));
                }
                return false;
            }
        });
    }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == "Urbanculture:Новая_статья");
 
    /* b-yauser ****/
    Queue.addEachFragment(function (sc) { $('.b-yauser a', sc).each(function (i) { $(this).html($(this).html().replace(/^([^<])/, '<b>$1</b>')); }); });
 
 
    /* prettyPhoto ****/
    Queue.addOnce('UC.prettyphotify', 'prettyPhotifyOptions', f5s && mw.config.get('wgCanonicalSpecialPageName') == 'Preferences');
    Queue.addEachFragment('UC.prettyphotify', 'prettyPhotify', f5s && localStorage.getItem('gallery_slideshow') != 'false');
 
    /* By ****/
    Queue.addOnce(function () {
        $('body').addClass('ns-talk');
    }, !mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgPageName') == "Urbanculture:Вниманию_участников");
 
    /* Spoilers ****/
    Queue.addEachFragment(function (scope) {
        $('.spoiler', scope).click(function () {
            $(this).toggleClass('spoilered');
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'));
 
    /* new gallerytemplate ****/
    //Queue.addEachFragment('UC.newgallerytemplate', 'newGalleryTemplate', !mw.config.get( 'wgCanonicalSpecialPageName' ));
 
 
    /*** Resize textarea ***/
    //Queue.addOnce('jquery.autoSizeTextArea', function () {
    //    $('#wpTextbox1').autoSizeTextArea();
    //    $(document).ready(function () {
    //        $('#wpTextbox1').autoSizeTextArea('update')
    //    });
    //});
 
    /* LazyLoad EmbedVideo****/
    Queue.addEachFragment(['ext.embedVideo', 'ext.embedVideo-lazy', 'ext.embedVideo-playpause'], 'embedVideoLazyLoad', !mw.config.get('wgCanonicalSpecialPageName'));
 
 
    /***********     Modern gallery Toggler    ***********/
    Queue.addEachFragment(function (sc) {
        const gallery = $('.combinedgallery, .videogallery', sc)
            ;
        gallery.each(function () {
            var t = $(this),
                tElLength = t.data('line-elems'),
                tElems = t.find('.gallery_content_block').length
                ;//console.log(t)
            if (tElems > tElLength) t.addClass('__hide_content');
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'));
 
    Queue.addOnce(function () {//console.log('Modern gallery Toggler addOnce', $(document))
        $('body').on('click', '.gallery_toggle', function () {
            var t = $(this),
                tGall = t.closest('.combinedgallery, .videogallery')
                ;//console.log(t)
            tGall.toggleClass('__hide_content __show_content')
        });
    }, !mw.config.get('wgCanonicalSpecialPageName'))
 
 
    /***********    /Modern gallery Toggler    ***********/
 
    /***********     Scale    ***********/
    Queue.addOnce('UC.scalemap', 'scaleMap', f5s && mw.config.get('skin') == 'vector');
    /***********    /Scale    ***********/
 
    /*** define the functions, that will be ran on each Comments display refresh ***/
    window.commentJSrunMultiHooks = function (scope) { };
 
});
 
/** /Processing queue ****/
 
 
/*** Scroll menu ***/
 
var scrollmenu = false;
$(document).ready(function () {
    var windowWidth = $(window).width();
    $(document).scroll(function () {
        if ((scrollmenu == false) && ($(window).scrollTop() > 112) && ($(window).height() > 900) && ($('#content').outerHeight() > 950) && (mw.config.get('skin') == 'vector')) {
            $(".editbox").css('position', 'fixed');
            $(".editbox").css('top', '0');
            scrollmenu = true;
        } else if ((scrollmenu === true) && ($(window).scrollTop() < 113)) {
            $(".editbox").css('position', 'absolute');
            $(".editbox").css('top', '');
            scrollmenu = false;
        }
    });
});
 
/*** /Scroll menu ***/
 
/*** Title page ***/
$('#write-article a').click(function () {
    $(this).hide();
    $('#create-page-lay').fadeIn();
    $('#create-page-lay .createboxInput').focus();
    $("#create-page-lay .createboxInput").focusout(function () {
        if ($(this).val() === "") {
            $('#create-page-lay').hide();
            $('#write-article a').fadeIn();
        }
    });
    return false;
});
 
/*** Blog page ***/
$(document).ready(function () {
    $('div.news.old').first().before("<div id='oldnews'></div>");
    $('div.news.old').appendTo($('#oldnews'));
    $('#oldnews').after("<div id='showarchive'><a class='show-link' href='#' class='showarchive'><span>Показать архив</span></a><a class='hide-link' href='#' class='showarchive' style='display:none'><span>Скрыть архив</span></a></div>");
    $('#showarchive a').click(function () {
        if ($(this).hasClass('show-link')) {
            $('#oldnews').fadeIn();
            $(this).hide().siblings().show()
                .stop();
        } else {
            $('#oldnews').hide();
            $(this).hide().siblings().show()
                .stop();
        }
    });
});
 
 
/*** Mobile menu ***/
if (mw.config.get('skin') == 'mobile') {
    $('.portlet h5').click(function () {
        var portlet = $(this);
        $('#portlet-bg').fadeIn('slow');
        portlet.parent().addClass('visible');
    });
    $('#close-portlet').click(function () {
        $(this).parent().fadeOut('slow');
        $('.portlet').removeClass('visible');
    });
}
 
/***********     NSFW     ***********/
$(document).on('click', '.NSFW', function (e) {
    e.preventDefault();
 
    $(this).removeClass('NSFW');
});
/***********    /NSFW     ***********/
 
/* Saladificator */
var now = new Date(),
    now_month = now.getMonth() + 1,
    now_day = now.getDate(),
    hash = window.location.hash.substr(1);
 
$(document).ready(function () {
    if ((now_month + '' + now_day) > 1228 || (now_month + '' + now_day) < 13) {
        //$('#mw-panel').addClass('saladificator')
    }
 
    if (!hash.includes("WG7Pg4o"))
        $('#mw-panel').addClass('ukraine');
    else
        $('#siteNotice').hide();
 
 
    /* TOC sticky */
    const toc = document.getElementById('toc');
 
    if (toc) {
        const directParent = toc.parentElement.classList.contains('tocright');
 
        var goToTopButton = document.createElement('div');
 
        goToTopButton.addEventListener('click', function (e) {
            window.scrollTo({ top: 0, behavior: 'auto' });
        });
 
        goToTopButton.setAttribute("id", "go_to_top");
        goToTopButton.innerHTML = '<span class="icon"></span>';
 
        toc.appendChild(goToTopButton);
 
        toc.querySelectorAll(':scope a').forEach(function (anchor) {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
 
                var anchorText = this.getAttribute('href'),
                    anchorId = anchorText.substring(1, anchorText.length);
 
                document.getElementById(anchorId).scrollIntoView({
                    behavior: 'smooth'
                });
 
                toc.classList.add('__hidden');
 
                // Update the URL without reloading the page
                var url = window.location.href.split('#')[0] + anchorText;
                history.pushState(null, null, url);
            });
        });
 
        if (!directParent) {
 
            var tocHeight = -toc.offsetHeight,
                topPos = toc.getBoundingClientRect().top - tocHeight,
                tocToggler = document.getElementById('toctitle');
 
            if (topPos <= tocHeight) {
                toc.classList.add('__sticky', '__ontop', '__hidden');
            }
 
            tocToggler.addEventListener("click", function () {
                toc.classList.toggle("__hidden");
            });
 
            document.addEventListener('scroll', function (e) {
                topPos = toc.getBoundingClientRect().top;
                setTimeout(function () {
                    if (topPos <= tocHeight) {
                        toc.classList.add('__sticky', '__ontop', '__hidden');
                    } else if (topPos && topPos >= 1) {
                        toc.classList.remove('__sticky', '__ontop');
                    }
                }, 50);
            });
        }
    }
 
});