مدیاویکی:Common.js: تفاوت میان نسخه‌ها

admin>Esfandiari
بدون خلاصۀ ویرایش
برچسب: برگردانده‌شده
بدون خلاصۀ ویرایش
برچسب: واگردانی دستی
 
(۵ نسخهٔ میانی ویرایش شده توسط ۲ کاربر نشان داده نشد)
خط ۱: خط ۱:
/* chatbot */
mw.loader.load('/ai-chatbot/mediawiki-chatbot.js');
/* global mw, $ */
/* global mw, $ */
 
// Editing-related javascripts
/**********************************************************************
if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" || mw.config.get("wgCanonicalSpecialPageName") === "Upload") {
*  Load edit.js for edit-related pages
  /* scripts specific to editing pages */
**********************************************************************/
  importScript("مدیاویکی:Common.js/edit.js");
if (
    mw.config.get("wgAction") === "edit" ||
    mw.config.get("wgAction") === "submit" ||
    mw.config.get("wgCanonicalSpecialPageName") === "Upload"
) {
    importScript("مدیاویکی:Common.js/edit.js");
}
}
 
/** Magic editintros ****************************************************
/**********************************************************************
*
  *  Magic editintros
  *  Description: Adds editintros on disambiguation pages and BLP pages.
  **********************************************************************/
  * Maintainers: [[User:RockMFR]]
*/
function addEditIntro(name) {
function addEditIntro(name) {
    $(".mw-editsection, #ca-edit")
  $(".mw-editsection, #ca-edit").find("a").each(function(i, el) {
        .find("a")
    el.href = $(this).attr("href") + "&editintro=" + name;
        .each(function () {
  });
            this.href = $(this).attr("href") + "&editintro=" + name;
        });
}
}


if (mw.config.get("wgNamespaceNumber") === 0) {
if (mw.config.get("wgNamespaceNumber") === 0) {
    $(function () {
  $(function() {
        if (document.getElementById("disambigbox")) {
    if (document.getElementById("disambigbox")) {
            addEditIntro("Template:Disambig_editintro");
      addEditIntro("Template:Disambig_editintro");
        }
    }
    });
  });


    $(function () {
  $(function() {
        var cats = mw.config.get("wgCategories") || [];
    var cats = mw.config.get("wgCategories");
        if (cats.includes("افراد زنده")) {
    if (!cats) {
            addEditIntro("Template:BLP_editintro");
      return;
        }
    }
    });
    if ($.inArray("افراد زنده", cats) !== -1) {
      addEditIntro("Template:BLP_editintro");
    }
  });
}
}


/**********************************************************************
/**
  * Load additional JS/CSS via URL (Secure)
  * @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
  **********************************************************************/
  * @revision 2020-04-04
mw.loader.using(["mediawiki.util"], function () {
*/
    var extraCSS = mw.util.getParamValue("withCSS"),
mw.loader.using( ['mediawiki.util'], function () {
        extraJS = mw.util.getParamValue("withJS");
var extraCSS = mw.util.getParamValue( 'withCSS' ),
extraJS = mw.util.getParamValue( 'withJS' );


    if (extraCSS) {
if ( extraCSS ) {
        if (/^MediaWiki:[^&<>=%#]*\.css$/.test(extraCSS)) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
            mw.loader.load(
if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) {
                "/w/index.php?title=" +
mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraCSS ) + '&action=raw&ctype=text/css', 'text/css' );
                    encodeURIComponent(extraCSS) +
} else {
                    "&action=raw&ctype=text/css",
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
                "text/css"
}
            );
}
        } else {
            mw.notify("Only pages from the MediaWiki namespace are allowed.", {
                title: "Invalid withCSS value",
            });
        }
    }


    if (extraJS) {
if ( extraJS ) {
        if (/^MediaWiki:[^&<>=%#]*\.js$/.test(extraJS)) {
// WARNING: DO NOT REMOVE THIS "IF" - REQUIRED FOR SECURITY (against XSS/CSRF attacks)
            mw.loader.load(
if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) {
                "/w/index.php?title=" +
mw.loader.load( '/w/index.php?title=' + encodeURIComponent( extraJS ) + '&action=raw&ctype=text/javascript' );
                    encodeURIComponent(extraJS) +
} else {
                    "&action=raw&ctype=text/javascript"
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
            );
}
        } else {
}
            mw.notify("Only pages from the MediaWiki namespace are allowed.", {
                title: "Invalid withJS value",
            });
        }
    }
});
});


/**********************************************************************
/**
  * Auto-load Preloaded.js when needed
  * Opening preload.js to add interactive training keys
  **********************************************************************/
  */
mw.loader.using(["mediawiki.util"], function () {
mw.loader.using(["mediawiki.util"], function() {
    if (mw.util.getParamValue("preload")) {
  if (mw.util.getParamValue("preload")) {
        mw.loader.load("MediaWiki:Preloaded.js");
    importScript("MediaWiki:Preloaded.js");
    }
  }
});
});


/**********************************************************************
/**
  * Collapsible tables (modern, safe)
* Collapsible tables; reimplemented with mw-collapsible
  **********************************************************************/
* Styling is also in place to avoid FOUC
function makeCollapsibleMwCollapsible($content) {
*
    var $tables = $content
* Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
        .find("table.collapsible:not(.mw-collapsible)")
  * @version 3.0.0 (2018-05-20)
        .addClass("mw-collapsible");
  * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
* @author [[User:R. Koot]]
* @author [[User:Krinkle]]
* @author [[User:TheDJ]]
* @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
* is supported in MediaWiki core. Shimmable since MediaWiki 1.32
*
* @param {jQuery} $content
*/
function makeCollapsibleMwCollapsible( $content ) {
var $tables = $content
.find( 'table.collapsible:not(.mw-collapsible)' )
.addClass( 'mw-collapsible' );


    $.each($tables, function (index, table) {
$.each( $tables, function ( index, table ) {
        if ($(table).hasClass("collapsed")) {
// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
            $(table).addClass("mw-collapsed");
if ( $( table ).hasClass( 'collapsed' ) ) {
        }
$( table ).addClass( 'mw-collapsed' );
    });
// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
}
} );
if ( $tables.length > 0 ) {
mw.loader.using( 'jquery.makeCollapsible' ).then( function () {
$tables.makeCollapsible();
} );
}
}
mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );


    if ($tables.length > 0) {
/**
        mw.loader.using("jquery.makeCollapsible").then(function () {
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
            $tables.makeCollapsible();
*
        });
* Maintainers: TheDJ
    }
*/
function mwCollapsibleSetup( $collapsibleContent ) {
var $element,
$toggle,
autoCollapseThreshold = 2;
$.each( $collapsibleContent, function ( index, element ) {
$element = $( element );
if ( $element.hasClass( 'collapsible' ) ) {
$element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) );
}
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
$element.data( 'mw-collapsible' ).collapse();
} else if ( $element.hasClass( 'innercollapse' ) ) {
if ( $element.parents( '.outercollapse' ).length > 0 ) {
$element.data( 'mw-collapsible' ).collapse();
}
}
// because of colored backgrounds, style the link in the text color
// to ensure accessible contrast
$toggle = $element.find( '.mw-collapsible-toggle' );
if ( $toggle.length ) {
// Make the toggle inherit text color
if ( $toggle.parent()[ 0 ].style.color ) {
$toggle.find( 'a' ).css( 'color', 'inherit' );
}
}
} );
}
}
mw.hook("wikipage.content").add(makeCollapsibleMwCollapsible);
/**********************************************************************
*  AutoCollapse, InnerCollapse, OuterCollapse
**********************************************************************/
function mwCollapsibleSetup($collapsibleContent) {
    var autoCollapseThreshold = 2;


    $.each($collapsibleContent, function (index, element) {
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
        var $element = $(element);


        if ($element.hasClass("collapsible")) {
/**
            $element
* Dynamic Navigation Bars (experimental)
                .find("tr:first-child > th:first-child")
*
                .prepend(
* Description: See [[Wikipedia:NavFrame]].
                    $element.find("tr:first-child > * > .mw-collapsible-toggle")
* Maintainers: UNMAINTAINED
                );
*/
        }


        // Auto collapse
var collapseCaption = 'بسته';
        if (
var expandCaption = 'باز';
            $collapsibleContent.length >= autoCollapseThreshold &&
            $element.hasClass("autocollapse")
        ) {
            $element.data("mw-collapsible").collapse();
        }


        // Inner collapse (requires outercollapse ancestor)
// Set up the words in your language
        if ($element.hasClass("innercollapse")) {
var navigationBarHide = '[' + collapseCaption + ']';
            if ($element.parents(".outercollapse").length > 0) {
var navigationBarShow = '[' + expandCaption + ']';
                $element.data("mw-collapsible").collapse();
            }
        }


        // Ensure toggle inherits proper text color
/**
        var $toggle = $element.find(".mw-collapsible-toggle");
* Shows and hides content and picture (if available) of navigation bars.
        if ($toggle.length && $toggle.parent()[0].style.color) {
*
            $toggle.find("a").css("color", "inherit");
* @param {number} indexNavigationBar The index of navigation bar to be toggled
        }
* @param {jQuery.Event} event Event object
    });
* @return {boolean}
}
*/
mw.hook("wikipage.collapsibleContent").add(mwCollapsibleSetup);
function toggleNavigationBar( indexNavigationBar, event ) {
var navToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var navFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var navChild;


/**********************************************************************
if ( !navFrame || !navToggle ) {
*  Dynamic Navigation Bars (single clean version)
return false;
**********************************************************************/
}
var collapseCaption = "نهفتن";
var expandCaption = "نمایش";
var navigationBarHide = "[" + collapseCaption + "]";
var navigationBarShow = "[" + expandCaption + "]";


function toggleNavigationBar(indexNavigationBar, event) {
// If shown now
    var navToggle = document.getElementById("NavToggle" + indexNavigationBar);
if ( navToggle.firstChild.data === navigationBarHide ) {
    var navFrame = document.getElementById("NavFrame" + indexNavigationBar);
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
    var navChild;
if ( $( navChild ).hasClass( 'NavContent' ) ) {
navChild.style.display = 'none';
}
}
navToggle.firstChild.data = navigationBarShow;


    if (!navFrame || !navToggle) return false;
// If hidden now
} else if ( navToggle.firstChild.data === navigationBarShow ) {
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
if ( $( navChild ).hasClass( 'NavContent' ) ) {
navChild.style.display = 'block';
}
}
navToggle.firstChild.data = navigationBarHide;
}


    var isShown = navToggle.firstChild.data === navigationBarHide;
event.preventDefault();
}


    for (
/**
        navChild = navFrame.firstChild;
* Adds show/hide-button to navigation bars.
        navChild !== null;
*
        navChild = navChild.nextSibling
* @param {jQuery} $content
    ) {
*/
        if (navChild.nodeType === 1) {
function createNavigationBarToggleButton( $content ) {
            if (
var j, navChild, navToggle, navToggleText, isCollapsed,
                $(navChild).hasClass("NavContent") ||
indexNavigationBar = 0;
                $(navChild).hasClass("NavPic")
// Iterate over all < div >-elements
            ) {
var $divs = $content.find( 'div.NavFrame:not(.mw-collapsible)' );
                navChild.style.display = isShown ? "none" : "block";
$divs.each( function ( i, navFrame ) {
            }
indexNavigationBar++;
        }
navToggle = document.createElement( 'a' );
    }
navToggle.className = 'NavToggle';
navToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
navToggle.setAttribute( 'href', '#' );
$( navToggle ).on( 'click', $.proxy( toggleNavigationBar, null, indexNavigationBar ) );


    navToggle.firstChild.data = isShown
isCollapsed = $( navFrame ).hasClass( 'collapsed' );
        ? navigationBarShow
/**
        : navigationBarHide;
* Check if any children are already hidden.  This loop is here for backwards compatibility:
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
* to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
* the content visible without JavaScript support), the new recommended way is to add the class
* "collapsed" to the NavFrame itself, just like with collapsible tables.
*/
for ( navChild = navFrame.firstChild; navChild !== null && !isCollapsed; navChild = navChild.nextSibling ) {
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
if ( navChild.style.display === 'none' ) {
isCollapsed = true;
}
}
}
if ( isCollapsed ) {
for ( navChild = navFrame.firstChild; navChild !== null; navChild = navChild.nextSibling ) {
if ( $( navChild ).hasClass( 'NavPic' ) || $( navChild ).hasClass( 'NavContent' ) ) {
navChild.style.display = 'none';
}
}
}
navToggleText = document.createTextNode( isCollapsed ? navigationBarShow : navigationBarHide );
navToggle.appendChild( navToggleText );


    event.preventDefault();
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for ( j = 0; j < navFrame.childNodes.length; j++ ) {
if ( $( navFrame.childNodes[ j ] ).hasClass( 'NavHead' ) ) {
navToggle.style.color = navFrame.childNodes[ j ].style.color;
navFrame.childNodes[ j ].appendChild( navToggle );
}
}
navFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
} );
}
}


function createNavigationBarToggleButton($content) {
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
    var indexNavigationBar = 0;


    $content.find("div.NavFrame:not(.mw-collapsible)").each(function (_, navFrame) {
/** Dynamic Navigation Bars (experimental) *************************************
        indexNavigationBar++;
*
*  Description: See [[Wikipedia:NavFrame]].
*  Maintainers: UNMAINTAINED
*/


        var $navFrame = $(navFrame);
// set up the words in your language
        var navToggle = document.createElement("a");
var NavigationBarHide = "[" + collapseCaption + "]";
        navToggle.className = "NavToggle";
var NavigationBarShow = "[" + expandCaption + "]";
        navToggle.id = "NavToggle" + indexNavigationBar;
        navToggle.href = "#";


        $(navToggle).on(
// shows and hides content and picture (if available) of navigation bars
            "click",
// Parameters:
            $.proxy(toggleNavigationBar, null, indexNavigationBar)
//    indexNavigationBar: the index of navigation bar to be toggled
        );
window.toggleNavigationBar = function(indexNavigationBar, event) {
  var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
  var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
  var NavChild;


        var isCollapsed = $navFrame.hasClass("collapsed");
  if (!NavFrame || !NavToggle) {
    return false;
  }


        // Determine if any child is hidden (compatibility)
  /* if shown now */
        $(navFrame)
  if (NavToggle.firstChild.data === NavigationBarHide) {
            .children()
    for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            .each(function () {
      if ($(NavChild).hasClass("NavContent") || $(NavChild).hasClass("NavPic")) {
                if (
        NavChild.style.display = "none";
                    this.nodeType === 1 &&
      }
                    (this.style.display === "none") &&
    }
                    ($(this).hasClass("NavContent") || $(this).hasClass("NavPic"))
    NavToggle.firstChild.data = NavigationBarShow;
                ) {
                    isCollapsed = true;
                }
            });


        // Apply initial collapsed state
    /* if hidden now */
        if (isCollapsed) {
  } else if (NavToggle.firstChild.data === NavigationBarShow) {
            $(navFrame)
    for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
                .children()
      if ($(NavChild).hasClass("NavContent") || $(NavChild).hasClass("NavPic")) {
                .each(function () {
        NavChild.style.display = "block";
                    if (
      }
                        $(this).hasClass("NavContent") ||
    }
                        $(this).hasClass("NavPic")
    NavToggle.firstChild.data = NavigationBarHide;
                    ) {
  }
                        this.style.display = "none";
                    }
                });
        }


        navToggle.appendChild(
  event.preventDefault();
            document.createTextNode(
};
                isCollapsed ? navigationBarShow : navigationBarHide
            )
        );


        // Attach toggle to NavHead
/* adds show/hide-button to navigation bars */
        $(navFrame)
function createNavigationBarToggleButton() {
            .children()
  var indexNavigationBar = 0;
            .each(function () {
  var NavFrame;
                if ($(this).hasClass("NavHead")) {
  var NavChild;
                    navToggle.style.color = this.style.color;
  /* iterate over all < div >-elements */
                    this.appendChild(navToggle);
  var divs = document.getElementsByTagName("div");
                }
  for (var i = 0;
            });
    (NavFrame = divs[i]); i++) {
    /* if found a navigation bar */
    if ($(NavFrame).hasClass("NavFrame")) {


        navFrame.id = "NavFrame" + indexNavigationBar;
      indexNavigationBar++;
    });
      var NavToggle = document.createElement("a");
}
      NavToggle.className = "NavToggle";
      NavToggle.setAttribute("id", "NavToggle" + indexNavigationBar);
      NavToggle.setAttribute("href", "#");
      $(NavToggle).on("click", $.proxy(window.toggleNavigationBar, window, indexNavigationBar));


mw.hook("wikipage.content").add(createNavigationBarToggleButton);
      var isCollapsed = $(NavFrame).hasClass("collapsed");
      /**
      * Check if any children are already hidden. This loop is here for backwards compatibility:
      * the old way of making NavFrames start out collapsed was to manually add style="display:none"
      * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
      * the content visible without JavaScript support), the new recommended way is to add the class
      * "collapsed" to the NavFrame itself, just like with collapsible tables.
      */
      for (NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
        if ($(NavChild).hasClass("NavPic") || $(NavChild).hasClass("NavContent")) {
          if (NavChild.style.display === "none") {
            isCollapsed = true;
          }
        }
      }
      if (isCollapsed) {
        for (NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
          if ($(NavChild).hasClass("NavPic") || $(NavChild).hasClass("NavContent")) {
            NavChild.style.display = "none";
          }
        }
      }
      var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
      NavToggle.appendChild(NavToggleText);


/**********************************************************************
      /* Find the NavHead and attach the toggle link (Must be this complicated because Moz"s firstChild handling is borked) */
*  Add “Complete list of languages” link on Main Page
      for (var j = 0; j < NavFrame.childNodes.length; j++) {
**********************************************************************/
        if ($(NavFrame.childNodes[j]).hasClass("NavHead")) {
mw.loader.using(["mediawiki.util"], function () {
          NavToggle.style.color = NavFrame.childNodes[j].style.color;
    mw.log.deprecate(
          NavFrame.childNodes[j].appendChild(NavToggle);
        window,
         }
        "addPortletLink",
      }
        mw.util.addPortletLink,
      NavFrame.setAttribute("id", "NavFrame" + indexNavigationBar);
        "Use mw.util.addPortletLink instead"
    );
 
    if (["صفحهٔ_اصلی", "بحث:صفحه_اصلی"].includes(mw.config.get("wgPageName"))) {
         $(function () {
            mw.util.addPortletLink(
                "p-lang",
                "//meta.wikimedia.org/wiki/List_of_Wikipedias/fa",
                "فهرست کامل",
                "interwiki-completelist",
                "فهرست کامل"
            );
        });
     }
     }
});
  }
}


/**********************************************************************
// $(createNavigationBarToggleButton);
*  WikiMiniAtlas loader
**********************************************************************/
(function () {
    var require_wikiminiatlas = false;
    var coord_filter = /geohack/;


    $(function () {
/** Main Page layout fixes *********************************************************
        $("a.external.text").each(function (_, link) {
*
            if (link.href && coord_filter.test(link.href)) {
*  Description: Adds an additional link to the complete list of languages available.
                require_wikiminiatlas = true;
*  Maintainers: [[User:AzaToth]], [[User:R. Koot]], [[User:Alex Smotrov]]
                return false;
*/
            }
mw.loader.using(["mediawiki.util"], function() {
        });
  if (["صفحهٔ_اصلی", "بحث:صفحه_اصلی"].indexOf(mw.config.get("wgPageName")) !== -1) {
 
    $(function() {
        if ($("div.kmldata").length) {
      mw.util.addPortletLink("p-lang", "//meta.wikimedia.org/wiki/List_of_Wikipedias/fa", "فهرست کامل", "interwiki-completelist", "فهرست کامل");
            require_wikiminiatlas = true;
    });
        }
  }
});


        if (require_wikiminiatlas) {
/**
            mw.loader.load(
* WikiMiniAtlas
                "//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript"
*
            );
* Description: WikiMiniAtlas is a popup click and drag world map.
        }
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
*              The script itself is located on meta because it is used by many projects.
*              See [[Meta:WikiMiniAtlas]] for more information.
* Maintainers: [[User:Dschwen]]
*/
(function() {
  var require_wikiminiatlas = false;
  var coord_filter = /geohack/;
  $(function() {
    $("a.external.text").each(function(key, link) {
      if (link.href && coord_filter.exec(link.href)) {
        require_wikiminiatlas = true;
        // break from loop
        return false;
      }
     });
     });
    if ($("div.kmldata").length) {
      require_wikiminiatlas = true;
    }
    if (require_wikiminiatlas) {
      mw.loader.load("//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript");
    }
  });
})();
})();


/**********************************************************************
/**
  * Source code pages should be LTR
  * Source codes pages direction and and pre white-space
  **********************************************************************/
  */
mw.loader.using(["mediawiki.util"], function () {
mw.loader.using(["mediawiki.util"], function() {
    if ([2, 4, 8].includes(mw.config.get("wgNamespaceNumber"))) {
  if ([2, 4, 8].indexOf(mw.config.get("wgNamespaceNumber")) !== -1) {
        if (/\.(js|css|py)$/.test(mw.config.get("wgPageName"))) {
    if (/\.(js|css|py)$/.test(mw.config.get("wgPageName"))) {
            mw.util.addCSS(
      mw.util.addCSS(".diff-addedline, .diff-deletedline, .diff-context { direction: ltr; } " +
                ".diff-addedline, .diff-deletedline, .diff-context { direction: ltr; } " +
        "#wpTextbox1 { direction: ltr; }");
                    "#wpTextbox1 { direction: ltr; }"
            );
        }
     }
     }
  }


    // Hide WikiLove for newbies
  // Newbies are misusing wikilove instead using talk pages add new section
    if (
  // hiding WikiLove from not autoconfirmed users or without more than 100 edits
        !mw.config.get("wgUserGroups").includes("autoconfirmed") ||
  if ($.inArray("autoconfirmed", mw.config.get("wgUserGroups")) === -1 || mw.config.get("wgUserEditCount") < 100) {
        mw.config.get("wgUserEditCount") < 100
    mw.util.addCSS("#ca-wikilove { display: none; }");
    ) {
  }
        mw.util.addCSS("#ca-wikilove { display: none; }");
});
/**
* قراردادن فرمول‌های ریاضی در سمت چپ مناسب برای ویکی‌های راست به چپ
*/
$(function() {
  $("span.mwe-math-mathml-inline").each(function() {
    if ($(this).parent().parent().text().trim() === $(this).parent().text().trim() && $(this).parent().parent().is("p, dd")) {
      $(this).parent().parent().css({
        direction: "ltr",
        padding: "1em 0"
      });
     }
     }
  });
});
});


/**********************************************************************
// هشدار به کاربرها در مورد عنوان ایمیل
*  بهتر کردن نمایش فرمول‌ها در RTL
$(function() {
**********************************************************************/
  if ( $('#mw-input-wpSubject').parents('tr').length > 0 ) {
$(function () {
     $('#mw-input-wpSubject').parents('tr').before('<tr><td></td><td style="color: red; font-weight: bold">لطفاً عبارت Wikipedia e-mail ‌را با یک عنوان مناسب جایگزین کنید!</td><tr>');
    $("span.mwe-math-mathml-inline").each(function () {
  }
        var $parent = $(this).parent();
        var $grand = $parent.parent();
 
        if (
            $grand.is("p, dd") &&
            $grand.text().trim() === $parent.text().trim()
        ) {
            $grand.css({
                direction: "ltr",
                padding: "1em 0",
            });
        }
    });
});
 
/**********************************************************************
*  هشدار برای عنوان نادرست ایمیل
**********************************************************************/
$(function () {
     var row = $("#mw-input-wpSubject").parents("tr");
    if (row.length) {
        row.before(
            '<tr><td></td><td style="color:red;font-weight:bold">لطفاً عبارت Wikipedia e-mail ‌را با یک عنوان مناسب جایگزین کنید!</td></tr>'
        );
    }
});
});


/**********************************************************************
// Make refrence number that you clicked on bold for proper navigation
*  Bold reference numbers on click
// Author: User:Ladsgroup
**********************************************************************/
$( 'sup.reference' ).click( function () {
$("sup.reference").click(function () {
     var citeId = $( this ).attr( 'id' );
     var citeId = $(this).attr("id");
    $( 'sup > a[href="#' + citeId + '"]').css('color', '#2a4b8d').css('font-weight', 'bold');
     var selector = 'sup > a[href="#' + citeId + '"]';
     $( 'sup > a[href="#' + citeId + '"]').click( function() {
        $( this ).css('color', '').css('font-weight', '');
    } );
} );


    $(selector).css({ color: "#2a4b8d", "font-weight": "bold" });
// Hide the FileExporter portlet link if the file is not free content
    $(selector).one("click", function () {
$(function() {
        $(this).css({ color: "", "font-weight": "" });
  if ($('#ca-fileExporter').length == 1 & $(mw.config.get('wgCategories')).filter(['محتویات غیر آزاد', 'تصویرهای با منبع نامعلوم', 'تصویرهای با پدیدآور نامشخص']).length > 0) {
    });
  $('#ca-fileExporter').hide();
  }
});
});


/**********************************************************************
/* اضافه کردن تیتر برای یادداشت ها */
*  Hide FileExporter for non-free files  (fixed)
$( function() {
**********************************************************************/
     if($('#reflist-notes .references').text().length>10) {
$(function () {
         $('#reflist-notes').before('<h2>یادداشت‌ها</h2>');
    var nonFreeCats = [
        "محتویات غیر آزاد",
        "تصویرهای با منبع نامعلوم",
        "تصویرهای با پدیدآور نامشخص",
    ];
 
     if (
        $("#ca-fileExporter").length === 1 &&
        (mw.config.get("wgCategories") || []).some(function (cat) {
            return nonFreeCats.includes(cat);
        })
    ) {
         $("#ca-fileExporter").hide();
     }
     }
});
});


/**********************************************************************
/* پاسخ تاشو */
*  Advertisement banner (only for logged-out users)
/* پاسخ تاشو */
**********************************************************************/
mw.hook('wikipage.content').add(function($content) {
mw.loader.using("jquery", function () {
     const questions = $content.find('.question');
     $(function () {
    const answers = $content.find('.answer');
         var disableAd = false;
   
 
    questions.each(function(index) {
         if (mw.config.get("wgUserName") !== null || disableAd) return;
         const question = this;
 
        const answer = answers[index];
         var adBanner = $(
       
            '<div id="site-ad-banner">' +
         // حذف event listener های قبلی برای جلوگیری از تکرار
                '<a href="https://ble.ir/iranian_law" target="_blank">' +
        $(question).off('click.collapsible');
                '<img src="https://www.illrc.ac.ir/wp-content/uploads/2026/03/1.jpg" alt="Advertisement" class="ad-img">' +
         $(answer).off('click.collapsible');
                "</a>" +
       
                '<button id="close-ad" title="بستن">✖</button>' +
        // اضافه کردن event listener جدید
                "</div>"
        $(question).on('click.collapsible', function() {
        );
            $(this).toggleClass('active');
 
            $(answer).toggleClass('expanded');
        $("body").append(adBanner);
        });
 
       
         $("#close-ad").on("click", function () {
         $(answer).on('click.collapsible', function() {
             $("#site-ad-banner").fadeOut();
             $(question).toggleClass('active');
            $(this).toggleClass('expanded');
         });
         });
     });
     });
});
});
`