Jump to content
Toggle menu
  • 83 articles
  • 443 files
  • 32 users
  • 1K edits
Fruit Juice Tycoon: Refreshed
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Citizen.js

MediaWiki interface page
Revision as of 03:56, 15 November 2026 by Werty (talk | contribs) (Created page with "→All JavaScript here will be loaded for users of the Citizen skin: →Location infobox image descriptions: (function () { "use strict"; function InitializeLocationInfoboxes(Content) { $(Content).find(".portable-infobox.pi-theme-fjtr-location").addBack( ".portable-infobox.pi-theme-fjtr-location" ).each(function () { const Infobox = this; const Gallery = Infobox.querySelector(".pi-media-collection");...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* All JavaScript here will be loaded for users of the Citizen skin */

/* Location infobox image descriptions */

(function () {
    "use strict";

    function InitializeLocationInfoboxes(Content) {
        $(Content).find(".portable-infobox.pi-theme-fjtr-location").addBack(
            ".portable-infobox.pi-theme-fjtr-location"
        ).each(function () {
            const Infobox = this;
            const Gallery = Infobox.querySelector(".pi-media-collection");

            if (!Gallery || Gallery.dataset.fjtrDescriptionsReady) {
                return;
            }

            const Tabs = Array.from(
                Gallery.querySelectorAll("ul.pi-media-collection-tabs li")
            );

            const Rows = Array.from(Infobox.querySelectorAll(".pi-data"));

            const FindRow = function (Name) {
                return Rows.find(function (Row) {
                    const Label = Row.querySelector(".pi-data-label");
                    return Label && Label.textContent.trim() === Name;
                });
            };

            const DetailsRow = FindRow("Details");
            const FeaturesRow = FindRow("Features");

            if (!DetailsRow || !Tabs.length) {
                return;
            }

            const DetailsValue = DetailsRow.querySelector(".pi-data-value");

            if (!DetailsValue) {
                return;
            }

            const Descriptions = DetailsValue.textContent
                .trim()
                .split(";;")
                .map(function (Description) {
                    return Description.trim();
                });

            if (!Descriptions.length || !Descriptions[0]) {
                return;
            }

            const DetailsLabel = DetailsRow.querySelector(".pi-data-label");

            if (DetailsLabel) {
                DetailsLabel.textContent = "Features";
            }

            if (FeaturesRow) {
                FeaturesRow.style.display = "none";
            }

            function UpdateDescription(Index) {
                DetailsValue.textContent =
                    Descriptions[Index] || Descriptions[0];
            }

            Tabs.forEach(function (Tab, Index) {
                Tab.addEventListener("click", function () {
                    UpdateDescription(Index);
                });
            });

            const InitialIndex = Tabs.findIndex(function (Tab) {
                return Tab.classList.contains("current");
            });

            UpdateDescription(InitialIndex >= 0 ? InitialIndex : 0);

            Gallery.dataset.fjtrDescriptionsReady = "true";
        });
    }

    mw.hook("wikipage.content").add(InitializeLocationInfoboxes);
})();
Last modified