MediaWiki:Common.js: Difference between revisions

From Survival Servers
Jump to navigation Jump to search
[wiki] order card: the right picture name for 13 games (Conan Exiles Enhanced, CS2, V Rising and 10 more)
[wiki] order card: the coupon breaks between the code and the discount on phones
Line 524: Line 524:
         }
         }
         var couponHtml = (pricingData && pricingData.coupon && pricingData.discount)
         var couponHtml = (pricingData && pricingData.coupon && pricingData.discount)
             ? '<span class="ssb-coupon">Use code ' + pricingData.coupon + ' for ' + pricingData.discount + '% OFF</span>'
             ? '<span class="ssb-coupon"><span>Use code ' + pricingData.coupon + '</span> <span>for ' + pricingData.discount + '% OFF</span></span>'
             : '';
             : '';
         // The game pictures are not all named one way. Most use the slug with hyphens; these 13 use another
         // The game pictures are not all named one way. Most use the slug with hyphens; these 13 use another
Line 573: Line 573:
         banner.id = 'ss-game-banner';
         banner.id = 'ss-game-banner';
         var couponHtml = (pricingData && pricingData.coupon && pricingData.discount)
         var couponHtml = (pricingData && pricingData.coupon && pricingData.discount)
             ? '<span class="ssb-coupon">Use code ' + pricingData.coupon + ' for ' + pricingData.discount + '% OFF</span>'
             ? '<span class="ssb-coupon"><span>Use code ' + pricingData.coupon + '</span> <span>for ' + pricingData.discount + '% OFF</span></span>'
             : '';
             : '';
         var browseUrl = 'https://www.survivalservers.com/services/game_servers/';
         var browseUrl = 'https://www.survivalservers.com/services/game_servers/';

Revision as of 15:23, 15 November 2026

/**
 * SurvivalServers Wiki - Game Server Banner System v7.1 (hero conversion card: art backdrop, trust stats, ticks; styles in Common.css)
 * Dark theme with gold accents matching main site design
 * Includes affiliate tracking: trckaff=3881, trckit=WIKI<PageName>
 * v7.1 (2026-08-17): tracking params are applied at INTERACTION time (mousedown/
 * touchstart/keydown/contextmenu), never written into the DOM at load. Google's
 * renderer was indexing the rewritten ?trckaff hrefs as canonicals at wiki scale
 * (383 tracked URLs, Feb-Aug 2026); crawlers must only ever see clean hrefs.
 * Fixed dbnames: arksurvivalascended (ASA), citadel, empyriongalacticsurvival, rune2
 * Smart linking: order form if pricing exists, service page if not
 */
(function() {
    'use strict';

    var TRACK_AFF_ID = '3881';
    var MAX_TRCKIT_LENGTH = 41;
    var API_URL = 'https://www.survivalservers.com/includes/wiki_pricing_api.php';
    var LOGO_URL = 'https://www.survivalservers.com/themes/epona/images/logo.png';
    var GAME_ICON_BASE = 'https://www.survivalservers.com/themes/epona/images/sspanel/game-server-icons-sm/';

    // SVG Icons (inline so no external library needed)
    var ICONS = {
        bolt: '<svg style="width:14px;height:14px;margin-right:5px;vertical-align:middle;" viewBox="0 0 320 512" fill="rgb(219,155,21)"><path d="M296 160H180.6l42.6-129.8C227.2 15 215.7 0 200 0H56C44 0 33.8 8.9 32.2 20.8l-32 240C-1.7 275.2 9.5 288 24 288h118.7L96.6 482.5c-3.6 15.2 8 29.5 23.3 29.5 8.4 0 16.4-4.4 20.8-12l176-304c9.3-15.9-2.2-36-20.7-36z"/></svg>',
        sliders: '<svg style="width:14px;height:14px;margin-right:5px;vertical-align:middle;" viewBox="0 0 512 512" fill="rgb(219,155,21)"><path d="M496 384H160v-16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h80v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h336c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-160h-80v-16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h336v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h80c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-160H288V48c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16C7.2 64 0 71.2 0 80v32c0 8.8 7.2 16 16 16h208v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h208c8.8 0 16-7.2 16-16V80c0-8.8-7.2-16-16-16z"/></svg>',
        rocket: '<svg style="width:14px;height:14px;margin-right:5px;vertical-align:middle;" viewBox="0 0 512 512" fill="rgb(219,155,21)"><path d="M505.12019,19.09375c-1.18945-5.53125-6.65819-11-12.207-12.1875C460.716,0,435.507,0,410.40747,0,307.17523,0,245.26909,55.20312,199.05238,128H94.83772c-16.34763,0-31.08301,9.59375-37.69531,24.5L3.14257,262.5C-.87883,270.625-1.03822,280.28125,2.67739,288.5s11.31445,14.5,19.69531,14.5H131.0701L93.43994,340.65625c-15.64063,15.625-15.64063,40.96875,0,56.59375,15.6289,15.625,40.97656,15.625,56.60547,0L187.92919,360H256v128c0,17.67188,14.32617,32,32,32s32-14.32812,32-32V303.0625c74.38477-46.03125,128-108.75,128-212.09375C448,70.59375,447.84058,50.1875,505.12019,19.09375Z"/></svg>',
        cart: '<svg style="width:14px;height:14px;margin-right:6px;vertical-align:middle;" viewBox="0 0 576 512" fill="currentColor"><path d="M528.12 301.319l47.273-208C578.806 78.301 567.391 64 551.99 64H159.208l-9.166-44.81C147.758 8.021 137.93 0 126.529 0H24C10.745 0 0 10.745 0 24v16c0 13.255 10.745 24 24 24h69.883l70.248 343.435C147.325 417.1 136 435.222 136 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-15.674-6.447-29.835-16.824-40h209.647C430.447 426.165 424 440.326 424 456c0 30.928 25.072 56 56 56s56-25.072 56-56c0-22.172-12.888-41.332-31.579-50.405l5.517-24.276c3.413-15.018-8.002-29.319-23.403-29.319H218.117l-6.545-32h293.145c11.206 0 20.92-7.754 23.403-18.681z"/></svg>',
        gamepad: '<svg style="width:16px;height:16px;margin-right:6px;vertical-align:middle;" viewBox="0 0 640 512" fill="currentColor"><path d="M480 96H160C71.6 96 0 167.6 0 256s71.6 160 160 160c44.8 0 85.2-18.4 114.2-48h91.5c29 29.6 69.5 48 114.2 48 88.4 0 160-71.6 160-160S568.4 96 480 96zM256 276c0 6.6-5.4 12-12 12h-52v52c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-52H76c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h52v-52c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h52c6.6 0 12 5.4 12 12v40zm184 68c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm80-80c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z"/></svg>'
    };


    var STAR = '<svg class="ssb-star" viewBox="0 0 576 512" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true"><path d="M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"/></svg>';
    var TICK = '<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true"><path d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.4c-9.998 9.997-26.207 9.997-36.204 0z"/></svg>';
    function ssbStars(d) {
        if (!d || !d.reviewScore) { return ''; }
        var stars = '';
        for (var i = 0; i < 5; i++) { stars += STAR; }
        return '<span class="ssb-stars">' + stars + '<b>' + d.reviewScore + '/5</b>&nbsp;&middot;&nbsp;' + d.reviewCount + ' reviews</span>';
    }
    function ssbTicks(d) {
        var items = ['Instant Setup', 'Custom Control Panel', 'DDoS Protection',
                     ((d && d.locations) ? d.locations + ' Global Locations' : 'Global Locations'), '24/7 Support'];
        var out = '';
        for (var i = 0; i < items.length; i++) { out += '<span class="ssb-tick">' + TICK + items[i] + '</span>'; }
        return '<div class="ssb-ticks">' + out + '</div>';
    }

    var gameConfig = {
        // 7 Days to Die - including common abbreviation "7D2D"
        '7daystodie': { name: '7 Days to Die', slug: '7_days_to_die', dbname: 'sevendays' },
        '7days': { name: '7 Days to Die', slug: '7_days_to_die', dbname: 'sevendays' },
        '7d2d': { name: '7 Days to Die', slug: '7_days_to_die', dbname: 'sevendays' },
        // the search titles spell the name out; longer than 'ark' so 'Darkness Falls' stays a 7 Days to Die page
        '7 days to die': { name: '7 Days to Die', slug: '7_days_to_die', dbname: 'sevendays' },

        // Alchemy Factory (game 149): the title match is what picks it (MediaWiki strips the SSGAME comment)
        'alchemy factory': { name: 'Alchemy Factory', slug: 'alchemy_factory', dbname: 'alchemyfactory' },
        'alchemyfactory': { name: 'Alchemy Factory', slug: 'alchemy_factory', dbname: 'alchemyfactory' },
        // 19 games we sell whose guides showed the plain box (Ryan 2026-10-16). Keys are whole names: 'schedule i' alone would
        // match 'schedule it', 'dune' alone 'dunes'. dbname = games.gamename, slug = the sales page path.
        'stardew valley': { name: 'Stardew Valley', slug: 'stardew_valley', dbname: 'stardewvalley' },
        'necesse': { name: 'Necesse', slug: 'necesse', dbname: 'necesse' },
        'delverium': { name: 'Delverium', slug: 'delverium', dbname: 'delverium' },
        'bellwright': { name: 'Bellwright', slug: 'bellwright', dbname: 'bellwright' },
        'dimraeth': { name: 'Dimraeth', slug: 'dimraeth', dbname: 'dimraeth' },
        'witchspire': { name: 'Witchspire', slug: 'witchspire', dbname: 'witchspire' },
        'vintage story': { name: 'Vintage Story', slug: 'vintage_story', dbname: 'vintagestory' },
        'sunkenland': { name: 'Sunkenland', slug: 'sunkenland', dbname: 'sunkenland' },
        'solarpunk': { name: 'Solarpunk', slug: 'solarpunk', dbname: 'solarpunk' },
        'sniper elite': { name: 'Sniper Elite 4', slug: 'sniper_elite_4', dbname: 'sniperelite4' },
        'smalland': { name: 'Smalland', slug: 'smalland', dbname: 'smalland' },
        'schedule i server': { name: 'Schedule I', slug: 'schedule_i', dbname: 'schedulei' },
        's1ds': { name: 'Schedule I', slug: 'schedule_i', dbname: 'schedulei' },
        'rising storm 2': { name: 'Rising Storm 2: Vietnam', slug: 'rising_storm_2_vietnam', dbname: 'risingstorm2' },
        'outlaws of the old west': { name: 'Outlaws of the Old West', slug: 'outlaws_of_the_old_west', dbname: 'outlaws' },
        'nomad drive': { name: 'Nomad Drive', slug: 'nomad_drive', dbname: 'nomaddrive' },
        'warband': { name: 'Mount & Blade: Warband', slug: 'warband', dbname: 'warband' },
        'humanitz': { name: 'HumanitZ', slug: 'humanitz', dbname: 'humanitz' },
        'how to fish': { name: 'How to Fish', slug: 'how_to_fish', dbname: 'howtofish' },
        'dune: awakening': { name: 'Dune: Awakening', slug: 'dune_awakening', dbname: 'duneawakening' },
        'dune awakening': { name: 'Dune: Awakening', slug: 'dune_awakening', dbname: 'duneawakening' },

        // ARK: Survival Evolved - including PS4 variants and colon variations
        'ark': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'ark:': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'ark ps4': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'arkps4': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'ark: survival evolved': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'ark:survival evolved': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'arkon': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },
        'beacon': { name: 'ARK: Survival Evolved', slug: 'ark_survival_evolved', dbname: 'ark' },

        // ARK: Survival Ascended - title-form keys are longer than the Evolved keys so they win the length-sorted match
        'ark: survival ascended': { name: 'ARK: Survival Ascended', slug: 'ark_survival_ascended', dbname: 'arksurvivalascended' },
        'ark:survival ascended': { name: 'ARK: Survival Ascended', slug: 'ark_survival_ascended', dbname: 'arksurvivalascended' },
        'ark survival ascended': { name: 'ARK: Survival Ascended', slug: 'ark_survival_ascended', dbname: 'arksurvivalascended' },
        'survival ascended': { name: 'ARK: Survival Ascended', slug: 'ark_survival_ascended', dbname: 'arksurvivalascended' },
        'arksurvivalascended': { name: 'ARK: Survival Ascended', slug: 'ark_survival_ascended', dbname: 'arksurvivalascended' },
        'asa': { name: 'ARK: Survival Ascended', slug: 'ark_survival_ascended', dbname: 'arksurvivalascended' },

        // Arma series
        'arma': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'arma 2': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'arma 3': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'arma3': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'arma reforger': { name: 'Arma Reforger', slug: 'arma_reforger', dbname: 'armareforger' },
        'epoch': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'exile': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'altis': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'wasteland': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'overpoch': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'pbo': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },
        'infistar': { name: 'Arma 3', slug: 'arma3', dbname: 'arma3' },

        // Atlas
        'atlas': { name: 'Atlas', slug: 'atlas', dbname: 'atlas' },

        // Avorion
        'avorion': { name: 'Avorion', slug: 'avorion', dbname: 'avorion' },

        // Barotrauma
        'barotrauma': { name: 'Barotrauma', slug: 'barotrauma', dbname: 'barotrauma' },
        'barotrauam': { name: 'Barotrauma', slug: 'barotrauma', dbname: 'barotrauma' },

        // Battalion 1944
        'battalion': { name: 'Battalion 1944', slug: 'battalion_1944', dbname: 'battalion1944' },
        'battalion 1944': { name: 'Battalion 1944', slug: 'battalion_1944', dbname: 'battalion1944' },

        // Brickadia
        'brickadia': { name: 'Brickadia', slug: 'brickadia', dbname: 'brickadia' },

        // Citadel: Forged With Fire
        'citadel': { name: 'Citadel: Forged With Fire', slug: 'citadel_forged_with_fire', dbname: 'citadel' },

        // Conan Exiles
        'conan': { name: 'Conan Exiles', slug: 'conan_exiles', dbname: 'conanexiles' },
        'conanexiles': { name: 'Conan Exiles', slug: 'conan_exiles', dbname: 'conanexiles' },
        'conan exiles': { name: 'Conan Exiles', slug: 'conan_exiles', dbname: 'conanexiles' },

        // Conan Exiles Enhanced (UE5 remaster — separate game from Legacy)
        'conan exiles enhanced': { name: 'Conan Exiles Enhanced', slug: 'conan_exiles_enhanced', dbname: 'conanexilesenhanced' },
        'conanexilesenhanced': { name: 'Conan Exiles Enhanced', slug: 'conan_exiles_enhanced', dbname: 'conanexilesenhanced' },
        'conan enhanced': { name: 'Conan Exiles Enhanced', slug: 'conan_exiles_enhanced', dbname: 'conanexilesenhanced' },

        // Core Keeper
        'corekeeper': { name: 'Core Keeper', slug: 'core_keeper', dbname: 'corekeeper' },
        'core keeper': { name: 'Core Keeper', slug: 'core_keeper', dbname: 'corekeeper' },

        // Counter-Strike 2 / CS2 / CSGO
        'csgo': { name: 'CS2', slug: 'counter_strike_2', dbname: 'csgo' },
        'cs2': { name: 'CS2', slug: 'counter_strike_2', dbname: 'csgo' },
        'counterstrike': { name: 'CS2', slug: 'counter_strike_2', dbname: 'csgo' },
        'counter strike': { name: 'CS2', slug: 'counter_strike_2', dbname: 'csgo' },
        'counter-strike': { name: 'CS2', slug: 'counter_strike_2', dbname: 'csgo' },

        // Dark and Light
        'dark and light': { name: 'Dark and Light', slug: 'dark_and_light', dbname: 'darkandlight' },
        'darkandlight': { name: 'Dark and Light', slug: 'dark_and_light', dbname: 'darkandlight' },

        // Day of Dragons
        'day of dragons': { name: 'Day of Dragons', slug: 'day_of_dragons', dbname: 'dayofdragons' },
        'dayofdragons': { name: 'Day of Dragons', slug: 'day_of_dragons', dbname: 'dayofdragons' },

        // DayZ
        'dayz': { name: 'DayZ', slug: 'dayz', dbname: 'dayz' },

        // Dead Matter
        'deadmatter': { name: 'Dead Matter', slug: 'dead_matter', dbname: 'deadmatter' },
        'dead matter': { name: 'Dead Matter', slug: 'dead_matter', dbname: 'deadmatter' },

        // Don't Starve Together
        'dontstarve': { name: "Don't Starve Together", slug: 'dont_starve_together', dbname: 'dontstarvetogether' },
        "don't starve": { name: "Don't Starve Together", slug: 'dont_starve_together', dbname: 'dontstarvetogether' },

        // Eco
        'eco': { name: 'Eco', slug: 'eco', dbname: 'eco' },

        // Empyrion
        'empyrion': { name: 'Empyrion', slug: 'empyrion_galactic_survival', dbname: 'empyriongalacticsurvival' },

        // Enshrouded
        'enshrouded': { name: 'Enshrouded', slug: 'enshrouded', dbname: 'enshrouded' },
        // Enshrouded PS5 (game 145): own order form and price, same service page (MediaWiki strips the SSGAME comment, so the title match 'enshrouded ps5' is what picks it)
        'enshroudedps5': { name: 'Enshrouded PS5', slug: 'enshrouded', dbname: 'enshroudedps5' },
        'enshrouded ps5': { name: 'Enshrouded PS5', slug: 'enshrouded', dbname: 'enshroudedps5' },

        // American Truck Simulator
        'american truck simulator': { name: 'American Truck Simulator', slug: 'american_truck_simulator', dbname: 'americantrucksimulator' },

        // Euro Truck Simulator 2
        'euro truck simulator 2': { name: 'Euro Truck Simulator 2', slug: 'euro_truck_simulator_2', dbname: 'eurotrucksimulator2' },
        'ets2': { name: 'Euro Truck Simulator 2', slug: 'euro_truck_simulator_2', dbname: 'eurotrucksimulator2' },

        // Factorio
        'factorio': { name: 'Factorio', slug: 'factorio', dbname: 'factorio' },

        // Ships At Sea
        'ships at sea': { name: 'Ships At Sea', slug: 'ships_at_sea', dbname: 'shipsatsea' },

        // FiveM / RedM
        'fivem': { name: 'FiveM', slug: 'grand_theft_auto_5', dbname: 'fivem' },
        'redm': { name: 'RedM', slug: 'red_dead_redemption', dbname: 'redm' },

        // Foundry
        'foundry': { name: 'Foundry', slug: 'foundry', dbname: 'foundry' },

        // Frozen Flame
        'frozen flame': { name: 'Frozen Flame', slug: 'frozen_flame', dbname: 'frozenflame' },
        'frozenflame': { name: 'Frozen Flame', slug: 'frozen_flame', dbname: 'frozenflame' },

        // Grounded 2 - the sequel has its own game row; there is no Grounded 1 entry here on purpose
        'grounded 2': { name: 'Grounded 2', slug: 'grounded2', dbname: 'grounded2' },
        'grounded2': { name: 'Grounded 2', slug: 'grounded2', dbname: 'grounded2' },

        // Holdfast
        'holdfast': { name: 'Holdfast: Nations At War', slug: 'holdfast', dbname: 'holdfast' },

        // No More Room in Hell
        // FULL key on purpose. The matcher is substring-on-lowercased-title and picks
        // the LONGEST key first, so a short key like 'no more room' would also match
        // the sequel's pages and serve them the original's pricing. The sequel is a
        // different game with no dedicated servers and we do not sell it.
        'no more room in hell': { name: 'No More Room in Hell', slug: 'no_more_room_in_hell', dbname: 'nomoreroominhell' },

        // Hurtworld
        'hurtworld': { name: 'Hurtworld', slug: 'hurtworld', dbname: 'hurtworld' },

        // Hytale
        'hytale': { name: 'Hytale', slug: 'hytale', dbname: 'hytale' },

        // Icarus
        'icarus': { name: 'Icarus', slug: 'icarus', dbname: 'icarus' },

        // Last Oasis
        'last oasis': { name: 'Last Oasis', slug: 'last_oasis', dbname: 'lastoasis' },
        'lastoasis': { name: 'Last Oasis', slug: 'last_oasis', dbname: 'lastoasis' },

        // Left 4 Dead 2
        'left4dead': { name: 'Left 4 Dead 2', slug: 'left_4_dead_2', dbname: 'left4dead2' },
        'l4d2': { name: 'Left 4 Dead 2', slug: 'left_4_dead_2', dbname: 'left4dead2' },

        // Minecraft - including mods and tools
        'minecraft': { name: 'Minecraft', slug: 'minecraft', dbname: 'minecraft' },
        'mcrcon': { name: 'Minecraft', slug: 'minecraft', dbname: 'minecraft' },
        'craftbukkit': { name: 'Minecraft', slug: 'minecraft', dbname: 'minecraft' },
        'pixelmon': { name: 'Minecraft', slug: 'minecraft', dbname: 'minecraft' },

        // Miscreated
        'miscreated': { name: 'Miscreated', slug: 'miscreated', dbname: 'miscreated' },

        // Mordhau
        'mordhau': { name: 'Mordhau', slug: 'mordhau', dbname: 'mordhau' },

        // Mount & Blade 2: Bannerlord
        'bannerlord': { name: 'Mount & Blade 2: Bannerlord', slug: 'mount_and_blade_2_bannerlord', dbname: 'bannerlord' },

        // Myth of Empires
        'myth of empires': { name: 'Myth of Empires', slug: 'myth_of_empires', dbname: 'mythofempires' },
        'mythofempires': { name: 'Myth of Empires', slug: 'myth_of_empires', dbname: 'mythofempires' },

        // Nightingale
        'nightingale': { name: 'Nightingale', slug: 'nightingale', dbname: 'nightingale' },

        // No One Survived
        'no one survived': { name: 'No One Survived', slug: 'no_one_survived', dbname: 'noonesurvived' },
        'noonesurvived': { name: 'No One Survived', slug: 'no_one_survived', dbname: 'noonesurvived' },

        // Oblivion Remastered Multiplayer / OB:MP (game 151): ReadyM's mod, sold as 'oblivion_remastered_multiplayer'
        'oblivion remastered multiplayer': { name: 'Oblivion Remastered Multiplayer', slug: 'oblivion_remastered_multiplayer', dbname: 'oblivionmp' },
        'oblivionmp': { name: 'Oblivion Remastered Multiplayer', slug: 'oblivion_remastered_multiplayer', dbname: 'oblivionmp' },

        // Over the Hill (game 148): the title match is what picks it (MediaWiki strips the SSGAME comment)
        'over the hill': { name: 'Over the Hill', slug: 'over_the_hill', dbname: 'overthehill' },
        'overthehill': { name: 'Over the Hill', slug: 'over_the_hill', dbname: 'overthehill' },

        // Palworld
        'palworld': { name: 'Palworld', slug: 'palworld', dbname: 'palworld' },

        // Path of Titans
        'path of titans': { name: 'Path of Titans', slug: 'path_of_titans', dbname: 'pathoftitans' },
        'pathoftitans': { name: 'Path of Titans', slug: 'path_of_titans', dbname: 'pathoftitans' },

        // Permafrost
        'permafrost': { name: 'Permafrost', slug: 'permafrost', dbname: 'permafrost' },

        // PixARK
        'pixark': { name: 'PixARK', slug: 'pixark', dbname: 'pixark' },

        // Probably Stolen (game 152): co-op through our Accomplice mod, sold as 'probably_stolen'
        'probably stolen': { name: 'Probably Stolen', slug: 'probably_stolen', dbname: 'probablystolen' },
        'probablystolen': { name: 'Probably Stolen', slug: 'probably_stolen', dbname: 'probablystolen' },

        // Project Zomboid
        'projectzomboid': { name: 'Project Zomboid', slug: 'project_zomboid', dbname: 'projectzomboid' },
        'zomboid': { name: 'Project Zomboid', slug: 'project_zomboid', dbname: 'projectzomboid' },
        'project zomboid': { name: 'Project Zomboid', slug: 'project_zomboid', dbname: 'projectzomboid' },

        // Rend
        'rend': { name: 'Rend', slug: 'rend', dbname: 'rend' },

        // Renown
        'renown': { name: 'Renown', slug: 'renown', dbname: 'renown' },

        // Rust
        'rust': { name: 'Rust', slug: 'rust', dbname: 'rust' },
        'rusty': { name: 'Rust', slug: 'rust', dbname: 'rust' },
        'oxide': { name: 'Rust', slug: 'rust', dbname: 'rust' },

        // Satisfactory
        'satisfactory': { name: 'Satisfactory', slug: 'satisfactory', dbname: 'satisfactory' },

        // SCUM
        'scum': { name: 'SCUM', slug: 'scum', dbname: 'scum' },

        // Silica (game 153)
        'silica': { name: 'Silica', slug: 'silica', dbname: 'silica' },

        // Sons of the Forest
        'sonsoftheforest': { name: 'Sons of the Forest', slug: 'sons_of_the_forest', dbname: 'sonsoftheforest' },
        'sons of the forest': { name: 'Sons of the Forest', slug: 'sons_of_the_forest', dbname: 'sonsoftheforest' },
        'sons of forest': { name: 'Sons of the Forest', slug: 'sons_of_the_forest', dbname: 'sonsoftheforest' },

        // Soulmask
        'soulmask': { name: 'Soulmask', slug: 'soulmask', dbname: 'soulmask' },

        // Space Engineers
        'spaceengineers': { name: 'Space Engineers', slug: 'space_engineers', dbname: 'spaceengineers' },
        'space engineers': { name: 'Space Engineers', slug: 'space_engineers', dbname: 'spaceengineers' },

        // Squad
        'squad': { name: 'Squad', slug: 'squad', dbname: 'squad' },

        // Starbound
        'starbound': { name: 'Starbound', slug: 'starbound', dbname: 'starbound' },

        // Stationeers
        'stationeers': { name: 'Stationeers', slug: 'stationeers', dbname: 'stationeers' },

        // StarRupture
        'starrupture': { name: 'StarRupture', slug: 'starrupture', dbname: 'starrupture' },

        // Stormworks: Build and Rescue
        'stormworks': { name: 'Stormworks: Build and Rescue', slug: 'stormworks', dbname: 'stormworks' },

        // Subsistence (game 68)
        'subsistence': { name: 'Subsistence', slug: 'subsistence', dbname: 'subsistence' },

        // Terraria
        'terraria': { name: 'Terraria', slug: 'terraria', dbname: 'terraria' },

        // The Forest
        'theforest': { name: 'The Forest', slug: 'the_forest', dbname: 'theforest' },
        'forest': { name: 'The Forest', slug: 'the_forest', dbname: 'theforest' },
        'the forest': { name: 'The Forest', slug: 'the_forest', dbname: 'theforest' },

        // The Front
        'the front': { name: 'The Front', slug: 'the_front', dbname: 'thefront' },
        'thefront': { name: 'The Front', slug: 'the_front', dbname: 'thefront' },

        // The Isle
        'theisle': { name: 'The Isle', slug: 'the_isle', dbname: 'theisle' },
        'isle': { name: 'The Isle', slug: 'the_isle', dbname: 'theisle' },
        'the isle': { name: 'The Isle', slug: 'the_isle', dbname: 'theisle' },

        // Unturned
        'unturned': { name: 'Unturned', slug: 'unturned', dbname: 'unturned' },

        // V Rising
        'v rising': { name: 'V Rising', slug: 'v_rising', dbname: 'vrising' },
        'vrising': { name: 'V Rising', slug: 'v_rising', dbname: 'vrising' },

        // Valheim
        'valheim': { name: 'Valheim', slug: 'valheim', dbname: 'valheim' },
        'valheim plus': { name: 'Valheim', slug: 'valheim', dbname: 'valheim' },
        'valheimplus': { name: 'Valheim', slug: 'valheim', dbname: 'valheim' },

        // Vein
        'vein': { name: 'Vein', slug: 'vein', dbname: 'vein' },

        // Ylands
        'ylands': { name: 'Ylands', slug: 'ylands', dbname: 'ylands' },

        // Abiotic Factor
        'abiotic': { name: 'Abiotic Factor', slug: 'abiotic_factor', dbname: 'abioticfactor' },
        'abiotic factor': { name: 'Abiotic Factor', slug: 'abiotic_factor', dbname: 'abioticfactor' },

        // Aloft
        'aloft': { name: 'Aloft', slug: 'aloft', dbname: 'aloft' },

        // Assetto Corsa Competizione - MUST stay longer than the 'assetto' key below;
        // the matcher picks the longest matching key, so without this ACC guides
        // render the plain Assetto Corsa order card.
        'assetto corsa competizione': { name: 'Assetto Corsa Competizione', slug: 'assetto_corsa_competizione', dbname: 'assettocorsacompetizione' },

        // Assetto Corsa
        'assettocorsa': { name: 'Assetto Corsa', slug: 'assetto_corsa', dbname: 'assettocorsa' },
        'assetto': { name: 'Assetto Corsa', slug: 'assetto_corsa', dbname: 'assettocorsa' },

        // Motor Town: Behind The Wheel
        'motor town': { name: 'Motor Town: Behind The Wheel', slug: 'motor_town', dbname: 'motortown' },

        // ASKA
        'aska': { name: 'ASKA', slug: 'aska', dbname: 'aska' },

        // Cube World
        'cube world': { name: 'Cube World', slug: 'cube_world', dbname: 'cubeworld' },
        'cubeworld': { name: 'Cube World', slug: 'cube_world', dbname: 'cubeworld' },

        // RuneScape: Dragonwilds - keys MUST be longer than 'rune' below, or every
        // Dragonwilds guide falls through to Rune: Ragnarok on the substring match
        'runescape dragonwilds': { name: 'RuneScape: Dragonwilds', slug: 'runescape_dragonwilds', dbname: 'runescapedragonwilds' },
        'dragonwilds': { name: 'RuneScape: Dragonwilds', slug: 'runescape_dragonwilds', dbname: 'runescapedragonwilds' },

        // Rune / Rune 2
        'rune': { name: 'Rune: Ragnarok', slug: 'rune_ragnarok', dbname: 'rune2' },
        'rune 2': { name: 'Rune: Ragnarok', slug: 'rune_ragnarok', dbname: 'rune2' },

        // Subnautica 2 - keys are longer than 'subnautica' so sequel pages don't fall through to Subnautica 1
        'subnautica 2': { name: 'Subnautica 2', slug: 'subnautica_2', dbname: 'subnautica2' },
        'subnautica2': { name: 'Subnautica 2', slug: 'subnautica_2', dbname: 'subnautica2' },

        // Subnautica
        'subnautica': { name: 'Subnautica', slug: 'subnautica', dbname: 'subnautica' },

        // Torch (Rust-related)
        'torch': { name: 'Rust', slug: 'rust', dbname: 'rust' },

        // Windrose
        'windrose': { name: 'Windrose', slug: 'windrose', dbname: 'windrose' }
    };

    function getPageName() {
        var urlParams = new URLSearchParams(window.location.search);
        var title = urlParams.get('title');
        if (!title) {
            var path = window.location.pathname;
            var match = path.match(/\/wiki\/(.+)$/);
            if (match) title = decodeURIComponent(match[1]);
        }
        if (!title) {
            var heading = document.getElementById('firstHeading');
            if (heading) title = heading.textContent;
        }
        if (title) {
            title = title.replace(/[^a-zA-Z0-9]/g, '_').replace(/_+/g, '_').substring(0, MAX_TRCKIT_LENGTH);
        }
        return title || 'Unknown';
    }

    function buildTrackingUrl(baseUrl, pageName) {
        var separator = baseUrl.indexOf('?') === -1 ? '?' : '&';
        return baseUrl + separator + 'trckaff=' + TRACK_AFF_ID + '&trckit=WIKI' + pageName;
    }

    function detectGame() {
        var pageTitle = document.title.toLowerCase();
        var bodyContent = document.getElementById('bodyContent');

        var manualGame = document.querySelector('[data-ss-game]');
        if (manualGame) return manualGame.getAttribute('data-ss-game').toLowerCase();

        var content = bodyContent ? bodyContent.innerHTML : '';
        var markerMatch = content.match(/<!--\s*SSGAME:\s*(\w+)\s*-->/i);
        if (markerMatch) return markerMatch[1].toLowerCase();

        var keywords = Object.keys(gameConfig).sort(function(a, b) { return b.length - a.length; });
        for (var i = 0; i < keywords.length; i++) {
            if (pageTitle.indexOf(keywords[i]) !== -1) return keywords[i];
        }
        // the search title may name the game differently ("ACC League Server"): fall back to the page name
        var pageName = (window.mw && mw.config ? (mw.config.get('wgTitle') || '') : '').toLowerCase();
        for (var j = 0; j < keywords.length; j++) {
            if (pageName.indexOf(keywords[j]) !== -1) return keywords[j];
        }
        return null;
    }

    function fetchPricing(gameSlug, callback) {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', API_URL + '?game=' + encodeURIComponent(gameSlug), true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    try {
                        var data = JSON.parse(xhr.responseText);
                        callback(data);
                    } catch (e) {
                        callback(null);
                    }
                } else {
                    callback(null);
                }
            }
        };
        xhr.send();
    }

    function createGameBanner(gameKey, pageName, pricingData) {
        var game = gameConfig[gameKey];
        if (!game) return null;
        // If pricing data exists, link to order form; otherwise link to service page.
        // The href stays CLEAN (no tracking params) so crawlers index the real URL;
        // armClickTracking() applies trckaff/trckit the moment a real user interacts.
        var orderUrl = pricingData && pricingData.lowestPrice
            ? 'https://www.survivalservers.com/sspanel/?game=' + game.dbname
            : 'https://www.survivalservers.com/services/game_servers/' + game.slug + '/';
        var gameIconUrl = GAME_ICON_BASE + game.dbname + '.png';

        var banner = document.createElement('div');
        banner.id = 'ss-game-banner';
        var priceHtml = '';
        // Ryan 2026-10-15: the site's "from" price is the lowest 3-day price after the visitor's coupon, with no
        // billing cycle (wiki_pricing_api.php fromPrice / fromDiscounted / fromCycle); monthly-only games keep "/mo"
        if (pricingData && pricingData.fromPrice) {
            var per = pricingData.fromCycle === 'monthly' ? '/mo' : '';
            priceHtml = pricingData.fromDiscounted
                ? '<span class="ssb-price">From <s>$' + pricingData.fromPrice + '</s><b>$' + pricingData.fromDiscounted + per + '</b></span>'
                : '<span class="ssb-price"><b>From $' + pricingData.fromPrice + per + '</b></span>';
        } else if (pricingData && pricingData.lowestPrice) {
            if (pricingData.discount && pricingData.discountedPrice && pricingData.coupon) {
                priceHtml = '<span class="ssb-price"><s>$' + pricingData.lowestPrice + '</s><b>$' + pricingData.discountedPrice + '/mo</b></span>';
            } else {
                priceHtml = '<span class="ssb-price"><b>From $' + pricingData.lowestPrice + '/mo</b></span>';
            }
        }
        var couponHtml = (pricingData && pricingData.coupon && pricingData.discount)
            ? '<span class="ssb-coupon"><span>Use code ' + pricingData.coupon + '</span> <span>for ' + pricingData.discount + '% OFF</span></span>'
            : '';
        // The game pictures are not all named one way. Most use the slug with hyphens; these 13 use another
        // name (each checked 2026-11-15), so they load with no failed request. A game added later tries the
        // hyphen name, then the slug as it is, then the slug without separators; no picture at all = plain card.
        var HERO_NAMES = { battalion_1944: 'battalion1944', conan_exiles_enhanced: 'conan_exiles_enhanced',
            counter_strike_2: 'cs2', dead_matter: 'deadmatter', grand_theft_auto_5: 'fivem', how_to_fish: 'how_to_fish',
            nomad_drive: 'nomad_drive', probably_stolen: 'probably_stolen', rising_storm_2_vietnam: 'rising_storm_2_vietnam',
            rune_ragnarok: 'runeragnarok', the_forest: 'theforest', v_rising: 'vrising', vintage_story: 'vintage_story' };
        var heroBase = 'https://www.survivalservers.com/themes/epona/images/service-headers/game/';
        var heroNames = HERO_NAMES[game.slug] ? [HERO_NAMES[game.slug]]
            : [game.slug.replace(/_/g, '-'), game.slug, game.slug.replace(/_/g, '')];
        heroNames = heroNames.filter(function (n, i) { return heroNames.indexOf(n) === i; });
        var heroUrl = heroBase + heroNames[0] + '.webp';
        banner.innerHTML = '<div class="ssb-card ssb-hero">' +
            '<img class="ssb-bg" src="' + heroUrl + '" alt="" loading="lazy">' +
            '<div class="ssb-shade"></div>' +
            '<div class="ssb-in">' +
                '<div class="ssb-r1">' +
                    '<a class="ssb-title" href="' + orderUrl + '">' +
                        '<img src="' + gameIconUrl + '" alt="" onerror="this.style.display=\'none\'">' +
                        '<span>' + game.name + ' Server Hosting</span>' +
                    '</a>' + ssbStars(pricingData) +
                '</div>' +
                '<div class="ssb-pitch">Reading the setup guide? Skip the hassle: your own ' + game.name + ' server, online in minutes.</div>' +
                ssbTicks(pricingData) +
                '<div class="ssb-r2">' +
                    '<span class="ssb-r2l">' + couponHtml + priceHtml + '</span>' +
                    '<a class="ssb-cta" href="' + orderUrl + '">' + ICONS.cart + 'Order Your Server</a>' +
                '</div>' +
            '</div>' +
        '</div>';
        var heroImg = banner.querySelector('.ssb-bg'), heroTry = 0;
        if (heroImg) {
            heroImg.onerror = function () {
                heroTry++;
                if (heroTry < heroNames.length) { this.src = heroBase + heroNames[heroTry] + '.webp'; } else { this.remove(); }
            };
        }
        return banner;
    }

    function createGenericBanner(pageName, pricingData) {
        // Clean hrefs on purpose - armClickTracking() adds the params on user interaction
        var homeUrl = 'https://www.survivalservers.com/';

        var banner = document.createElement('div');
        banner.id = 'ss-game-banner';
        var couponHtml = (pricingData && pricingData.coupon && pricingData.discount)
            ? '<span class="ssb-coupon"><span>Use code ' + pricingData.coupon + '</span> <span>for ' + pricingData.discount + '% OFF</span></span>'
            : '';
        var browseUrl = 'https://www.survivalservers.com/services/game_servers/';
        banner.innerHTML = '<div class="ssb-card ssb-hero">' +
            '<div class="ssb-shade"></div>' +
            '<div class="ssb-in">' +
                '<div class="ssb-r1">' +
                    '<a class="ssb-title" href="' + homeUrl + '">' + ICONS.gamepad + '<span>Premium <span class="ssb-keep">Game Server Hosting</span></span></a>' +
                    ssbStars(pricingData) +
                '</div>' +
                '<div class="ssb-pitch">Your own game server for any of 100+ games, online in minutes.</div>' +
                ssbTicks(pricingData) +
                '<div class="ssb-r2">' +
                    '<span class="ssb-r2l">' + couponHtml + '</span>' +
                    '<a class="ssb-cta" href="' + browseUrl + '">' + ICONS.gamepad + 'Browse 100+ Games</a>' +
                '</div>' +
            '</div>' +
        '</div>';
        return banner;
    }

    function insertBanner(banner) {
        if (!banner) return;
        var contentDiv = document.getElementById('bodyContent');
        if (contentDiv) contentDiv.insertBefore(banner, contentDiv.firstChild);
    }

    function trackedHref(href, pageName) {
        // Check if link has incomplete trckit=WIKI (without page name)
        // Match trckit=WIKI at end of string or followed by & or nothing after
        if (href.match(/trckit=WIKI(&|$)/)) {
            return href.replace(/trckit=WIKI(&|$)/, 'trckit=WIKI' + pageName + '$1');
        }
        // Already has complete tracking params (hand-written or a prior interaction)
        if (href.indexOf('trckaff=') !== -1) return href;
        return buildTrackingUrl(href, pageName);
    }

    function armClickTracking(pageName) {
        // Crawler-safe affiliate tracking. Hrefs in the DOM stay CLEAN so search
        // engines index the real URLs (Google's renderer was crawling/indexing the
        // trckaff-rewritten hrefs at wiki scale). The tracking params are written
        // onto the anchor only when a real user interacts with it:
        //   - mousedown fires before the browser reads the href for left, middle,
        //     ctrl/cmd and right clicks, so new-tab opens and the context menu's
        //     "Open in new tab" / "Copy link address" all get the tracked URL
        //   - touchstart covers mobile taps
        //   - keydown covers keyboard (Enter) activation
        //   - contextmenu is belt-and-braces for platforms that order events oddly
        // Delegated on document so the injected banner, header chrome and any
        // late-added links are covered too. Crawlers never fire these events.
        function apply(target) {
            if (!target || !target.closest) return;
            var link = target.closest('a[href*="survivalservers.com"]');
            if (!link) return;
            var href = link.getAttribute('href');
            if (!href) return;
            var tracked = trackedHref(href, pageName);
            if (tracked !== href) link.setAttribute('href', tracked);
        }
        document.addEventListener('mousedown', function (e) { apply(e.target); }, true);
        document.addEventListener('touchstart', function (e) { apply(e.target); }, { capture: true, passive: true });
        document.addEventListener('keydown', function (e) {
            if (e.key === 'Enter' || e.key === ' ') { apply(e.target); }
        }, true);
        document.addEventListener('contextmenu', function (e) { apply(e.target); }, true);
    }

    function init() {
        var pageTitle = document.title;
        if (pageTitle.indexOf('Main Page') !== -1) return;
        if (window.location.href.indexOf('Special:') !== -1) return;

        var pageName = getPageName();
        var gameKey = detectGame();
        var game = gameKey ? gameConfig[gameKey] : null;

        // Attach affiliate tracking to survivalservers.com links at interaction
        // time only - never rewrite hrefs in the DOM at load (crawlers see those)
        armClickTracking(pageName);

        if (game) {
            fetchPricing(game.dbname, function(pricingData) {
                // a game we don't sell (disabled, or not in the games table) comes back with no price: show the
                // general card, never an order card for that game (Ryan 2026-10-25)
                var banner = pricingData && pricingData.lowestPrice
                    ? createGameBanner(gameKey, pageName, pricingData)
                    : createGenericBanner(pageName, pricingData);
                insertBanner(banner);
            });
        } else {
            fetchPricing('', function(pricingData) {
                var banner = createGenericBanner(pageName, pricingData);
                insertBanner(banner);
            });
        }
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }
})();

/**
 * SurvivalServers Wiki - Site Header / Dark Skin behavior v1.3 (2026-07)
 * The header chrome (topbar/header/breadcrumb) is normally emitted
 * SERVER-SIDE by SSWikiHeader.php (zero layout shift); this script then only
 * adds dynamic behavior: panel login chip, scrolled-state rail tuck, editor
 * toolbar relocation. If the server chrome is absent (cache skew), it falls
 * back to injecting the same markup client-side.
 */
(function () {
    'use strict';

    // first-touch attribution capture with the real wiki landing context
    try {
        fetch('/includes/wiki_ref_capture.php?path=' + encodeURIComponent(location.pathname)
            + '&qs=' + encodeURIComponent(location.search.replace(/^\?/, ''))
            + '&r=' + encodeURIComponent(document.referrer || ''), { credentials: 'same-origin' })
            .catch(function () { /* attribution is best-effort */ });
    } catch (e) { /* older browsers: skip */ }

    // web font (Open Sans) - server injects it; this is the cache-skew fallback
    if (!document.querySelector('link[href*="Open+Sans"]')) {
    var pre = document.createElement('link');
    pre.rel = 'preconnect'; pre.href = 'https://fonts.googleapis.com';
    document.head.appendChild(pre);
    var font = document.createElement('link');
    font.rel = 'stylesheet';
    font.href = 'https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap';
    document.head.appendChild(font);
    }

    function svg(vb, path, cls) {
        return '<svg class="' + (cls || 'ssw-icon') + '" viewBox="' + vb + '" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true"><path d="' + path + '"/></svg>';
    }
    var icoUser = svg('0 0 448 512', 'M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z', 'ssw-chip-ico');

    function buildFallbackChrome() {
        // cache-skew fallback: same markup SSWikiHeader.php emits
        var vp = document.querySelector('meta[name="viewport"]');
        if (vp) { vp.setAttribute('content', 'width=device-width, initial-scale=1'); }
        var searchSvg = '<svg class="ssw-sicon" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#666" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"/></svg>';
        var icoX = svg('0 0 512 512', 'M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z');
        var icoUsers = svg('0 0 640 512', 'M144 0a80 80 0 1 1 0 160A80 80 0 1 1 144 0zM512 0a80 80 0 1 1 0 160A80 80 0 1 1 512 0zM0 298.7C0 239.8 47.8 192 106.7 192h42.7c15.9 0 31 3.5 44.6 9.7c-1.3 7.2-1.9 14.7-1.9 22.3c0 38.2 16.8 72.5 43.3 96c-.2 0-.4 0-.7 0H21.3C9.6 320 0 310.4 0 298.7zM405.3 320c-.2 0-.4 0-.7 0c26.6-23.5 43.3-57.8 43.3-96c0-7.6-.7-15-1.9-22.3c13.6-6.3 28.7-9.7 44.6-9.7h42.7C592.2 192 640 239.8 640 298.7c0 11.8-9.6 21.3-21.3 21.3H405.3zM224 224a96 96 0 1 1 192 0 96 96 0 1 1 -192 0zM128 485.3C128 411.7 187.7 352 261.3 352H378.7C452.3 352 512 411.7 512 485.3c0 14.7-11.9 26.7-26.7 26.7H154.7c-14.7 0-26.7-11.9-26.7-26.7z');
        var icoReddit = svg('0 0 512 512', 'M373 138.6c-25.2 0-46.3-17.5-51.9-41l0 0c-30.6 4.3-54.2 30.7-54.2 62.4l0 .2c47.4 1.8 90.6 15.1 124.9 36.3c12.6-9.7 28.4-15.5 45.5-15.5c41.3 0 74.7 33.4 74.7 74.7c0 29.8-17.4 55.5-42.7 67.5c-2.4 86.8-97 156.6-213.2 156.6S45.5 410.1 43 323.4C17.6 311.5 0 285.7 0 255.7c0-41.3 33.4-74.7 74.7-74.7c17.2 0 33 5.8 45.7 15.6c34-21.1 76.8-34.4 123.7-36.4l0-.3c0-44.3 33.7-80.9 76.8-85.5C325.8 50.2 347.2 32 373 32c29.4 0 53.3 23.9 53.3 53.3s-23.9 53.3-53.3 53.3zM157.5 255.3c-20.9 0-38.9 20.8-40.2 47.9s17.1 38.1 38 38.1s36.6-9.8 37.8-36.9s-14.7-49.1-35.7-49.1zM395 303.1c-1.2-27.1-19.2-47.9-40.2-47.9s-36.9 22-35.7 49.1c1.2 27.1 16.9 36.9 37.8 36.9s39.3-11 38-38.1zm-60.1 70.8c1.5-3.6-1-7.7-4.9-8.1c-23-2.3-47.9-3.6-73.8-3.6s-50.8 1.3-73.8 3.6c-3.9 .4-6.4 4.5-4.9 8.1c12.9 30.8 43.3 52.4 78.7 52.4s65.8-21.6 78.7-52.4z');
        var icoFacebook = svg('0 0 320 512', 'M80 299.3V512H196V299.3h86.5l18-97.8H196V166.9c0-51.7 20.3-71.5 72.7-71.5c16.3 0 29.4 .4 37 1.2V7.9C291.4 4 256.4 0 236.2 0C129.3 0 80 50.5 80 159.4v42.1H14v97.8H80z');
        var icoYoutube = svg('0 0 576 512', 'M549.7 124.1c-6.3-23.7-24.8-42.3-48.3-48.6C458.8 64 288 64 288 64S117.2 64 74.6 75.5c-23.5 6.3-42 24.9-48.3 48.6-11.4 42.9-11.4 132.3-11.4 132.3s0 89.4 11.4 132.3c6.3 23.7 24.8 41.5 48.3 47.8C117.2 448 288 448 288 448s170.8 0 213.4-11.5c23.5-6.3 42-24.2 48.3-47.8 11.4-42.9 11.4-132.3 11.4-132.3s0-89.4-11.4-132.3zm-317.5 213.5V175.2l142.7 81.2-142.7 81.2z');
        var isMain = mw.config.get('wgPageName') === 'Main_Page';

        var topbar = document.createElement('div');
        topbar.className = 'ssw-topbar';
        topbar.innerHTML = '<div class="ssw-topbar-in">' +
            '<a class="ssw-btn-contact" href="https://www.survivalservers.com/sspanel/user/?support&new">Contact Us</a>' +
            '<span class="ssw-social">' +
            '<a href="https://x.com/survivalservers" target="_blank" rel="noopener" aria-label="Follow us on X">' + icoX + '</a>' +
            '<a href="https://www.survivalservers.com/community/" target="_blank" rel="noopener" aria-label="Discussion Forum">' + icoUsers + '</a>' +
            '<a href="https://reddit.com/r/SurvivalServers" target="_blank" rel="noopener" aria-label="Our Subreddit">' + icoReddit + '</a>' +
            '<a href="https://www.facebook.com/SurvivalServerscom" target="_blank" rel="noopener" aria-label="Visit us on Facebook">' + icoFacebook + '</a>' +
            '<a href="https://www.youtube.com/user/SurvivalServers?sub_confirmation=1" target="_blank" rel="noopener" aria-label="Subscribe on YouTube">' + icoYoutube + '</a>' +
            '</span></div>';
        var header = document.createElement('div');
        header.className = 'ssw-header';
        header.innerHTML = '<div class="ssw-header-in">' +
            '<span class="ssw-logo">' +
            '<a class="ssw-logo-site" href="https://www.survivalservers.com/" title="SurvivalServers home">' +
            '<img src="https://www.survivalservers.com/themes/epona/images/logo.png" alt="SurvivalServers"></a>' +
            '<a class="ssw-wikitag" href="/wiki/Main_Page" title="Wiki home">WIKI</a></span>' +
            '<form class="ssw-search" action="/wiki/index.php" method="get">' + searchSvg +
            '<input type="search" name="search" placeholder="Search the wiki...">' +
            '<input type="hidden" name="title" value="Special:Search"></form>' +
            '<nav class="ssw-nav">' +
            '<a href="https://www.survivalservers.com/services/game_servers/">GAME SERVERS</a>' +
            '<a href="https://www.survivalservers.com/order/">ORDER</a>' +
            '<span class="ssw-account"></span>' +
            '<a class="ssw-cta" href="https://www.survivalservers.com/sspanel/">CONTROL PANEL</a>' +
            '</nav></div>';
        var crumb = document.createElement('div');
        crumb.className = 'ssw-crumb';
        crumb.innerHTML = '<a href="https://www.survivalservers.com/">Home</a><span class="sep">/</span>' +
            (isMain ? '<span class="ssw-cur">Wiki</span>'
                    : '<a href="/wiki/Main_Page">Wiki</a><span class="sep">/</span><span class="ssw-cur"></span>');
        document.body.insertBefore(crumb, document.body.firstChild);
        document.body.insertBefore(header, crumb);
        document.body.insertBefore(topbar, header);
        var cur = crumb.querySelector('.ssw-cur');
        if (cur && !isMain) { cur.textContent = mw.config.get('wgTitle') || ''; }
    }

    function init() {
        if (!document.querySelector('.ssw-header')) {
            buildFallbackChrome();
        }
        var header = document.querySelector('.ssw-header');
        var crumb = document.querySelector('.ssw-crumb');

        // wiki-editor chrome for logged-in wiki users
        if (window.mw && mw.config && mw.config.get('wgUserName')) {
            document.body.className += ' ssw-user';
            var head = document.getElementById('mw-head');
            if (head && crumb) { document.body.insertBefore(head, crumb.nextSibling); }
        }

        // rails tuck up under the stuck header once scrolled
        var scrolled = false;
        function onScroll() {
            var s = (window.pageYOffset || 0) > 60;
            if (s !== scrolled) {
                scrolled = s;
                document.body.classList.toggle('ssw-scrolled', s);
            }
        }
        window.addEventListener('scroll', onScroll, { passive: true });
        onScroll();

        // panel login state: precise mirror of the panel's user dropdown
        try {
            fetch('/includes/wiki_user_status.php', { credentials: 'same-origin' })
                .then(function (r) { return r.json(); })
                .then(function (d) {
                    if (!d || !d.loggedIn || !d.username || !header) { return; }
                    var slot = header.querySelector('.ssw-account');
                    if (!slot || slot.firstChild) { return; }
                    function ddsvg(vb, path) {
                        return '<svg class="ssw-dd-ico" viewBox="' + vb + '" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true"><path d="' + path + '"/></svg>';
                    }
                    var icoCog = ddsvg('0 0 512 512', 'M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z');
                    var icoBag = ddsvg('0 0 448 512', 'M352 160v-32C352 57.42 294.579 0 224 0 153.42 0 96 57.42 96 128v32H0v272c0 44.183 35.817 80 80 80h288c44.183 0 80-35.817 80-80V160h-96zm-192-32c0-35.29 28.71-64 64-64s64 28.71 64 64v32H160v-32zm160 120c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zm-192 0c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24z');
                    var icoUp = ddsvg('0 0 448 512', 'M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z');
                    var icoGrp = ddsvg('0 0 640 512', 'M144 0a80 80 0 1 1 0 160A80 80 0 1 1 144 0zM512 0a80 80 0 1 1 0 160A80 80 0 1 1 512 0zM0 298.7C0 239.8 47.8 192 106.7 192h42.7c15.9 0 31 3.5 44.6 9.7c-1.3 7.2-1.9 14.7-1.9 22.3c0 38.2 16.8 72.5 43.3 96c-.2 0-.4 0-.7 0H21.3C9.6 320 0 310.4 0 298.7zM405.3 320c-.2 0-.4 0-.7 0c26.6-23.5 43.3-57.8 43.3-96c0-7.6-.7-15-1.9-22.3c13.6-6.3 28.7-9.7 44.6-9.7h42.7C592.2 192 640 239.8 640 298.7c0 11.8-9.6 21.3-21.3 21.3H405.3zM224 224a96 96 0 1 1 192 0 96 96 0 1 1 -192 0zM128 485.3C128 411.7 187.7 352 261.3 352H378.7C452.3 352 512 411.7 512 485.3c0 14.7-11.9 26.7-26.7 26.7H154.7c-14.7 0-26.7-11.9-26.7-26.7z');
                    var icoLayers = ddsvg('0 0 512 512', 'M12.41 148.02l232.94 105.67c6.8 3.09 14.49 3.09 21.29 0l232.94-105.67c16.55-7.51 16.55-32.52 0-40.03L266.65 2.31a25.607 25.607 0 0 0-21.29 0L12.41 107.98c-16.55 7.51-16.55 32.53 0 40.04zm487.18 88.28l-58.09-26.33-161.64 73.27c-7.56 3.43-15.59 5.17-23.86 5.17s-16.29-1.74-23.86-5.17L70.51 209.97l-58.1 26.33c-16.55 7.5-16.55 32.5 0 40l232.94 105.59c6.8 3.08 14.49 3.08 21.29 0L499.59 276.3c16.55-7.5 16.55-32.5 0-40zm0 127.8l-57.87-26.23-161.86 73.37c-7.56 3.43-15.59 5.17-23.86 5.17s-16.29-1.74-23.86-5.17L70.29 337.87 12.41 364.1c-16.55 7.5-16.55 32.5 0 40l232.94 105.59c6.8 3.08 14.49 3.08 21.29 0L499.59 404.1c16.55-7.5 16.55-32.5 0-40z');
                    var icoOut = ddsvg('0 0 512 512', 'M497 273L329 441c-15 15-41 4.5-41-17v-96H152c-13.3 0-24-10.7-24-24v-96c0-13.3 10.7-24 24-24h136V88c0-21.4 25.9-32 41-17l168 168c9.3 9.4 9.3 24.6 0 34zM192 436v-40c0-6.6-5.4-12-12-12H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h84c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12H96c-53 0-96 43-96 96v192c0 53 43 96 96 96h84c6.6 0 12-5.4 12-12z');
                    var icoPen = ddsvg('0 0 512 512', 'M362.7 19.3L314.3 67.7 444.3 197.7l48.4-48.4c25-25 25-65.5 0-90.5L453.3 19.3c-25-25-65.5-25-90.5 0zm-71 71L58.6 323.5c-10.4 10.4-18 23.3-22.2 37.4L1 481.2C-1.5 489.7 .8 498.8 7 505s15.3 8.5 23.7 6L141.1 475.6c14.1-4.2 27-11.8 37.4-22.2L411.7 220.3 291.7 90.3z');
                    var base = 'https://www.survivalservers.com/sspanel/user/';
                    var av = 'https://www.survivalservers.com/uploads/avatars/' + (d.avatar ? d.avatar : 'avatar-default.png');
                    var menu;
                    if (d.staff) {
                        // Death Star session outranks any impersonated customer login
                        var ds = 'https://www.survivalservers.com/sspanel/deathstar/';
                        var wikiUser = (window.mw && mw.config) ? mw.config.get('wgUserName') : null;
                        var pageName = (window.mw && mw.config && mw.config.get('wgPageName')) || 'Main_Page';
                        menu =
                            '<li><a href="' + ds + '">' + icoCog + ' Death Star</a></li>' +
                            (d.customer ? '<li><a href="' + base + '">' + icoGrp + ' Customer: ' + d.customer + '</a></li>' : '') +
                            (!wikiUser ? '<li><a href="/wiki/index.php?title=Special:UserLogin&returnto=' + encodeURIComponent(pageName) + '">' + icoPen + ' Wiki Login</a></li>' : '') +
                            '<li class="ssw-dd-divider"></li>' +
                            '<li><a href="' + ds + '?logout">' + icoOut + ' Logout</a></li>';
                    } else {
                        menu =
                            '<li><a href="' + base + '?myaccount">' + icoCog + ' Account Details</a></li>' +
                            '<li><a href="' + base + '?orders">' + icoBag + ' Orders</a></li>' +
                            '<li><a href="' + base + '?upgrades">' + icoUp + ' Upgrades</a></li>' +
                            '<li><a href="' + base + '?subusers">' + icoGrp + ' Sub Users</a></li>' +
                            '<li><a href="' + base + '?massactions">' + icoLayers + ' Batch Actions</a></li>' +
                            '<li class="ssw-dd-divider"></li>' +
                            '<li><a href="' + base + '?logout">' + icoOut + ' Logout</a></li>';
                    }
                    var dd = document.createElement('span');
                    dd.className = 'ssw-user-dd';
                    dd.innerHTML =
                        '<a role="button" aria-haspopup="true" aria-expanded="false">' +
                        '<img class="avatarCirclefy" src="' + av + '" width="20" height="20" alt="">' +
                        '</a>' +
                        '<ul class="ssw-dd-menu">' + menu + '</ul>';
                    var trig = dd.querySelector('a[role=button]');
                    var nameEl = document.createElement('span');
                    nameEl.textContent = d.username;
                    trig.appendChild(nameEl);
                    var caret = document.createElement('span');
                    caret.className = 'caret';
                    trig.appendChild(caret);
                    trig.addEventListener('click', function (e) {
                        e.preventDefault();
                        dd.classList.toggle('open');
                        trig.setAttribute('aria-expanded', dd.classList.contains('open') ? 'true' : 'false');
                    });
                    document.addEventListener('click', function (e) {
                        if (!dd.contains(e.target)) { dd.classList.remove('open'); }
                    });
                    document.addEventListener('keydown', function (e) {
                        if (e.key === 'Escape') { dd.classList.remove('open'); }
                    });
                    slot.appendChild(dd);
                })
                .catch(function () { /* logged-out look is the fallback */ });
        } catch (e) { /* older browsers: no dropdown */ }
    }

    if (document.body) {
        init();
    } else {
        document.addEventListener('DOMContentLoaded', init);
    }
})();
/**
 * SurvivalServers Wiki — v2 content enhancements (2026-07)
 * Pairs with the v2 Common.css pass. Appended to MediaWiki:Common.js AFTER
 * the header-injection block. Vanilla JS, no libraries, every feature
 * degrades gracefully if it can't run.
 *
 * Features:
 *   1. Article header meta (kicker + last-updated + read time + sections)
 *   2. NOTE/WARNING/TIP paragraph -> callout card conversion
 *   3. Terminal frames around .toccolours collapsibles (+ copy-keys button)
 *   4. Copy buttons on <pre> blocks
 *   5. TOC: body flag for the right rail, long-TOC columns, scroll-spy
 *   6. Image lightbox
 *   7. Sidebar active-page highlight (+ optional "Popular guides" portal)
 */
(function () {
    'use strict';

    // Optional curated portal in the sidebar. Leave empty to disable.
    // Entries: { title: 'ARK Advanced Configuration', href: '/wiki/index.php?title=ARK:_Survival_Evolved_Advanced_Configuration' }
    var POPULAR_GUIDES = [];

    function ready(fn) {
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', fn);
        } else { fn(); }
    }

    function mwConf(key) {
        try { return window.mw && mw.config ? mw.config.get(key) : null; } catch (e) { return null; }
    }

    // ---------------------------------------------------- 1. article header
    function pageHeader() {
        var h1 = document.querySelector('#content h1.firstHeading');
        var parser = document.querySelector('.mw-parser-output');
        if (!h1 || h1.dataset.sswDone) { return; }
        h1.dataset.sswDone = '1';

        var isMain = (mwConf('wgPageName') || '') === 'Main_Page' ||
            /Main[_ ]Page/i.test(h1.textContent);

        var kicker = document.createElement('div');
        kicker.className = 'ssw-kicker';
        var sswNs = (window.mw && mw.config) ? mw.config.get('wgNamespaceNumber') : 0;
        kicker.textContent = (isMain || sswNs !== 0) ? 'SurvivalServers Wiki' : 'Server Guide';
        h1.parentNode.insertBefore(kicker, h1);

        var bits = [];
        var lastmod = document.getElementById('footer-info-lastmod');
        if (lastmod) {
            var m = lastmod.textContent.match(/last edited on (.+?), at/i);
            if (m) { bits.push('Updated <b>' + m[1] + '</b>'); }
        }
        if (parser) {
            var words = (parser.innerText || '').split(/\s+/).length;
            bits.push('<b>' + Math.max(1, Math.round(words / 220)) + ' min</b> read');
            var sections = parser.querySelectorAll(':scope > h2').length;
            if (sections > 1) { bits.push('<b>' + sections + '</b> sections'); }
        }
        if (bits.length) {
            var meta = document.createElement('div');
            meta.className = 'ssw-pagemeta';
            meta.innerHTML = bits.map(function (b) { return '<span>' + b + '</span>'; }).join('');
            h1.parentNode.insertBefore(meta, h1.nextSibling);
        }
        document.body.classList.add('ssw-meta-done');
    }

    // --------------------------------------------------------- 2. callouts
    var CALLOUT_MAP = {
        NOTE: 'ssw-note', NOTICE: 'ssw-note', INFO: 'ssw-note', IMPORTANT: 'ssw-warn',
        WARNING: 'ssw-warn', WARN: 'ssw-warn', CAUTION: 'ssw-danger', DANGER: 'ssw-danger',
        TIP: 'ssw-tip', HINT: 'ssw-tip'
    };
    function callouts() {
        var ps = document.querySelectorAll('.mw-parser-output p > b:first-child');
        for (var i = 0; i < ps.length; i++) {
            var b = ps[i], p = b.parentNode;
            if (p.classList.contains('ssw-callout')) { continue; }
            // <b> must be the first thing in the paragraph
            if (b.previousSibling && (b.previousSibling.textContent || '').trim() !== '') { continue; }
            var word = (b.textContent || '').replace(/[:\s]/g, '').toUpperCase();
            var cls = CALLOUT_MAP[word];
            if (!cls) { continue; }
            p.classList.add('ssw-callout', cls);
            b.textContent = word;
            // strip a leading ": " from the text node after the badge
            var next = b.nextSibling;
            if (next && next.nodeType === 3) {
                next.nodeValue = next.nodeValue.replace(/^[:\s]+/, ' ');
            }
        }
    }

    // ---------------------------------------------- 3. terminal collapsibles
    function copyToClipboard(text, btn) {
        function flash() {
            var old = btn.textContent;
            btn.textContent = 'COPIED';
            btn.classList.add('ssw-copied');
            setTimeout(function () { btn.textContent = old; btn.classList.remove('ssw-copied'); }, 1400);
        }
        if (navigator.clipboard && navigator.clipboard.writeText) {
            navigator.clipboard.writeText(text).then(flash, flash);
        } else {
            var ta = document.createElement('textarea');
            ta.value = text; ta.style.position = 'fixed'; ta.style.opacity = '0';
            document.body.appendChild(ta); ta.select();
            try { document.execCommand('copy'); } catch (e) { /* no-op */ }
            document.body.removeChild(ta);
            flash();
        }
    }

    function configKeyLines(box) {
        // top-level dd entries are "Key=Value" lines; nested dls are descriptions
        var lines = [];
        var dds = box.querySelectorAll('.mw-collapsible-content > dl > dd, :scope > dl > dd');
        for (var i = 0; i < dds.length; i++) {
            var clone = dds[i].cloneNode(true);
            var nested = clone.querySelectorAll('dl');
            for (var j = 0; j < nested.length; j++) { nested[j].parentNode.removeChild(nested[j]); }
            var t = (clone.textContent || '').trim();
            if (t) { lines.push(t); }
        }
        return lines.join('\n');
    }

    function terminals() {
        var boxes = document.querySelectorAll('.mw-parser-output .toccolours.mw-collapsible');
        for (var i = 0; i < boxes.length; i++) {
            (function (box) {
                if (box.parentNode.classList && box.parentNode.classList.contains('ssw-term')) { return; }

                var wrap = document.createElement('div');
                wrap.className = 'ssw-term';
                box.parentNode.insertBefore(wrap, box);

                var head = document.createElement('div');
                head.className = 'ssw-term-head';

                var hasImg = !!box.querySelector('img');
                var label = hasImg ? 'PANEL WALKTHROUGH' : 'CONFIG REFERENCE';

                head.innerHTML =
                    '<span class="ssw-dots"><i></i><i></i><i></i></span>' +
                    '<span class="ssw-term-label">' + label + '</span>';

                if (!hasImg && box.querySelector('dl > dd')) {
                    var copyBtn = document.createElement('button');
                    copyBtn.type = 'button';
                    copyBtn.className = 'ssw-copy';
                    copyBtn.textContent = 'COPY KEYS';
                    copyBtn.addEventListener('click', function (e) {
                        e.stopPropagation();
                        copyToClipboard(configKeyLines(box), copyBtn);
                    });
                    head.appendChild(copyBtn);
                }

                var chev = document.createElement('span');
                chev.className = 'ssw-term-chev';
                head.appendChild(chev);

                wrap.appendChild(head);
                wrap.appendChild(box);

                // whole header toggles the MW collapsible
                head.addEventListener('click', function () {
                    var toggle = box.querySelector('.mw-collapsible-toggle');
                    if (toggle) { toggle.click(); }
                });
            })(boxes[i]);
        }
    }

    // wait for jquery.makeCollapsible to have initialized (toggle spans exist);
    // fall back after ~5s so uninitialized boxes still get framed.
    function terminalsWhenReady() {
        var tries = 0;
        (function poll() {
            var anyBox = document.querySelector('.mw-parser-output .toccolours.mw-collapsible');
            if (!anyBox) { return; }
            if (anyBox.classList.contains('mw-made-collapsible') || tries >= 25) {
                terminals();
                return;
            }
            tries++;
            setTimeout(poll, 200);
        })();
    }

    // ------------------------------------------------------ 4. pre copy chip
    function preCopy() {
        var pres = document.querySelectorAll('.mw-parser-output pre');
        for (var i = 0; i < pres.length; i++) {
            (function (pre) {
                if (pre.querySelector('.ssw-copy')) { return; }
                var btn = document.createElement('button');
                btn.type = 'button';
                btn.className = 'ssw-copy';
                btn.textContent = 'COPY';
                btn.addEventListener('click', function () {
                    var clone = pre.cloneNode(true);
                    var b = clone.querySelector('.ssw-copy');
                    if (b) { b.parentNode.removeChild(b); }
                    copyToClipboard((clone.textContent || '').trim(), btn);
                });
                pre.appendChild(btn);
            })(pres[i]);
        }
    }

    // ----------------------------------------------- 5. TOC rail + scrollspy
    function toc() {
        var t = document.getElementById('toc');
        if (!t) { return; }
        document.body.classList.add('ssw-has-toc');
        var links = t.querySelectorAll('a[href^="#"]');
        if (links.length > 14) { t.classList.add('ssw-toc-long'); }

        // scroll-spy
        var targets = [];
        for (var i = 0; i < links.length; i++) {
            var id = decodeURIComponent(links[i].getAttribute('href').slice(1));
            var el = document.getElementById(id);
            if (el) { targets.push({ el: el, li: links[i].parentNode }); }
        }
        if (!targets.length) { return; }

        var current = null, ticking = false;
        function update() {
            ticking = false;
            var line = 110; // just under the sticky header
            var active = null;
            for (var i = 0; i < targets.length; i++) {
                if (targets[i].el.getBoundingClientRect().top <= line) { active = targets[i].li; }
                else { break; }
            }
            if (active === current) { return; }
            if (current) { current.classList.remove('ssw-current'); }
            current = active;
            if (current) {
                current.classList.add('ssw-current');
                // keep the highlighted row visible inside a scrolling rail
                if (t.scrollHeight > t.clientHeight + 4) {
                    var a = current.querySelector('a');
                    if (a) {
                        var rTop = a.offsetTop - t.scrollTop;
                        if (rTop < 40) { t.scrollTop = Math.max(0, a.offsetTop - 60); }
                        else if (rTop > t.clientHeight - 60) { t.scrollTop = a.offsetTop - t.clientHeight + 80; }
                    }
                }
            }
        }
        window.addEventListener('scroll', function () {
            if (!ticking) { ticking = true; requestAnimationFrame(update); }
        }, { passive: true });
        update();
    }

    // --------------------------------------------------------- 6. lightbox
    function lightbox() {
        document.addEventListener('click', function (e) {
            var a = e.target.closest && e.target.closest('.mw-parser-output a.image');
            if (!a) { return; }
            var img = a.querySelector('img');
            if (!img) { return; }
            e.preventDefault();
            var overlay = document.createElement('div');
            overlay.className = 'ssw-lightbox';
            var big = document.createElement('img');
            big.src = img.currentSrc || img.src;
            big.alt = img.alt || '';
            overlay.appendChild(big);
            if (img.alt) {
                var cap = document.createElement('figcaption');
                cap.textContent = img.alt.replace(/\.(png|jpe?g|gif|webp)$/i, '');
                overlay.appendChild(cap);
            }
            function close() {
                if (overlay.parentNode) { overlay.parentNode.removeChild(overlay); }
                document.removeEventListener('keydown', onKey);
            }
            function onKey(ev) { if (ev.key === 'Escape') { close(); } }
            overlay.addEventListener('click', close);
            document.addEventListener('keydown', onKey);
            document.body.appendChild(overlay);
        });
    }

    // ------------------------------------- 7. sidebar active + popular guides
    function sidebar() {
        var panel = document.getElementById('mw-panel');
        if (!panel) { return; }

        var page = mwConf('wgPageName');
        if (page) {
            var anchors = panel.querySelectorAll('.portal li a');
            for (var i = 0; i < anchors.length; i++) {
                var href = anchors[i].getAttribute('href') || '';
                var m = href.match(/[?&]title=([^&#]+)/) || href.match(/\/wiki\/(?:index\.php\/)?([^?&#]+)$/);
                if (m && decodeURIComponent(m[1]).replace(/\+/g, '_') === page) {
                    anchors[i].classList.add('ssw-side-active');
                }
            }
        }

        if (POPULAR_GUIDES.length) {
            var portal = document.createElement('div');
            portal.className = 'portal';
            portal.setAttribute('role', 'navigation');
            var items = '';
            for (var j = 0; j < POPULAR_GUIDES.length; j++) {
                items += '<li><a href="' + POPULAR_GUIDES[j].href + '">' + POPULAR_GUIDES[j].title + '</a></li>';
            }
            portal.innerHTML = '<h3>Popular guides</h3><div class="body"><ul>' + items + '</ul></div>';
            var first = panel.querySelector('.portal');
            if (first && first.nextSibling) { panel.insertBefore(portal, first.nextSibling); }
            else { panel.appendChild(portal); }
        }
    }

    ready(function () {
        try { pageHeader(); } catch (e) { /* no-op */ }
        try { callouts(); } catch (e) { /* no-op */ }
        try { terminalsWhenReady(); } catch (e) { /* no-op */ }
        try { preCopy(); } catch (e) { /* no-op */ }
        try { toc(); } catch (e) { /* no-op */ }
        try { lightbox(); } catch (e) { /* no-op */ }
        try { sidebar(); } catch (e) { /* no-op */ }
    });
})();


/**
 * SurvivalServers Wiki - Community Comments v1.0 (2026-07)
 * Native replacement for Disqus: logged-in panel customers comment, reply
 * (one level) and upvote; everyone can read. Renders a design-system card
 * after the article. All user data rendered via textContent (no injection).
 */
(function () {
    'use strict';
    if (!(window.mw && mw.config)) { return; }
    if (mw.config.get('wgNamespaceNumber') !== 0) { return; }
    if (mw.config.get('wgAction') !== 'view') { return; }
    if (mw.config.get('wgPageName') === 'Main_Page') { return; }

    var API = '/includes/wiki_comments_api.php';
    var page = mw.config.get('wgPageName');
    var content = document.getElementById('content');
    if (!content) { return; }

    var AV_BASE = 'https://www.survivalservers.com/uploads/avatars/';
    var UP = '<svg viewBox="0 0 448 512" xmlns="http://www.w3.org/2000/svg" fill="currentColor" aria-hidden="true"><path d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"/></svg>';

    function ago(ts) {
        var s = Math.max(1, Math.floor(Date.now() / 1000 - ts));
        if (s < 60) { return 'just now'; }
        if (s < 3600) { return Math.floor(s / 60) + 'm ago'; }
        if (s < 86400) { return Math.floor(s / 3600) + 'h ago'; }
        if (s < 2592000) { return Math.floor(s / 86400) + 'd ago'; }
        return new Date(ts * 1000).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
    }

    var wrap = document.createElement('div');
    wrap.id = 'ssw-comments';
    content.parentNode.insertBefore(wrap, content.nextSibling);

    var state = { comments: [], viewer: null };

    function post(fields) {
        var fd = new FormData();
        fd.append('page', page);
        Object.keys(fields).forEach(function (k) { fd.append(k, fields[k]); });
        return fetch(API, { method: 'POST', credentials: 'same-origin', body: fd })
            .then(function (r) { return r.json(); });
    }

    function composer(parentId, onDone) {
        var c = document.createElement('div');
        c.className = 'ssw-cmt-composer';
        var ta = document.createElement('textarea');
        ta.maxLength = 2000;
        ta.placeholder = parentId ? 'Write a reply...' : 'Share your experience or ask a question...';
        var row = document.createElement('div');
        row.className = 'ssw-cmt-composer-row';
        var btn = document.createElement('button');
        btn.type = 'button';
        btn.className = 'ssw-cmt-post';
        btn.textContent = parentId ? 'Reply' : 'Post Comment';
        var err = document.createElement('span');
        err.className = 'ssw-cmt-err';
        btn.addEventListener('click', function () {
            var body = ta.value.trim();
            if (!body) { return; }
            btn.disabled = true;
            var fields = { action: 'comment', body: body };
            if (parentId) { fields.parent_id = parentId; }
            post(fields).then(function (d) {
                btn.disabled = false;
                if (d && d.success) { ta.value = ''; onDone(); }
                else { err.textContent = (d && d.error) || 'Something went wrong'; }
            }).catch(function () { btn.disabled = false; err.textContent = 'Network error'; });
        });
        row.appendChild(err);
        row.appendChild(btn);
        c.appendChild(ta);
        c.appendChild(row);
        return c;
    }

    function commentEl(c, depth) {
        var el = document.createElement('div');
        el.className = 'ssw-cmt' + (depth > 0 ? ' ssw-cmt-reply' : '');
        if (depth > 0) { el.style.marginLeft = (Math.min(depth, 4) * 44) + 'px'; }

        var vote = document.createElement('button');
        vote.type = 'button';
        vote.className = 'ssw-cmt-vote' + (c.viewer_voted ? ' voted' : '');
        vote.innerHTML = UP;
        var cnt = document.createElement('span');
        cnt.textContent = c.upvotes;
        vote.appendChild(cnt);
        vote.title = state.viewer ? 'Upvote' : 'Log in to vote';
        vote.addEventListener('click', function () {
            if (!state.viewer) { return; }
            post({ action: 'vote', comment_id: c.id }).then(function (d) {
                if (d && d.success) {
                    cnt.textContent = d.upvotes;
                    vote.classList.toggle('voted', d.voted);
                }
            });
        });

        var main = document.createElement('div');
        main.className = 'ssw-cmt-main';
        var head = document.createElement('div');
        head.className = 'ssw-cmt-head';
        var av = document.createElement('img');
        av.className = 'ssw-cmt-av';
        var avSrc = c.avatar || 'avatar-default.png';
        av.src = avSrc.indexOf('http') === 0 ? avSrc : AV_BASE + avSrc;
        av.alt = '';
        av.onerror = function () { this.onerror = null; this.src = AV_BASE + 'avatar-default.png'; };
        var name = document.createElement('span');
        name.className = 'ssw-cmt-name';
        name.textContent = c.username;
        var when = document.createElement('span');
        when.className = 'ssw-cmt-when';
        when.textContent = ago(c.created);
        head.appendChild(av);
        head.appendChild(name);
        if (c.staff) {
            // a reply posted by SurvivalServers staff from the Death Star wears the mark
            var staffMark = document.createElement('span');
            staffMark.className = 'ssw-cmt-staffbadge';
            staffMark.textContent = 'STAFF';
            head.appendChild(staffMark);
        }
        head.appendChild(when);

        var body = document.createElement('div');
        body.className = 'ssw-cmt-body';
        body.textContent = c.body;

        var actions = document.createElement('div');
        actions.className = 'ssw-cmt-actions';
        if (state.viewer) {
            var reply = document.createElement('a');
            reply.textContent = 'Reply';
            reply.addEventListener('click', function () {
                if (main.querySelector('.ssw-cmt-composer')) {
                    main.querySelector('.ssw-cmt-composer').remove();
                    return;
                }
                main.appendChild(composer(c.id, load));
            });
            actions.appendChild(reply);
        }
        if (c.can_delete) {
            var del = document.createElement('a');
            del.textContent = c.own ? 'Delete' : 'Remove';
            del.addEventListener('click', function () {
                post({ action: 'delete', comment_id: c.id }).then(load);
            });
            actions.appendChild(del);
        }

        main.appendChild(head);
        main.appendChild(body);
        if (actions.childNodes.length) { main.appendChild(actions); }
        el.appendChild(vote);
        el.appendChild(main);
        return el;
    }

    function render() {
        wrap.innerHTML = '';
        var card = document.createElement('div');
        card.className = 'ssw-cmt-card';

        var top = state.comments.filter(function (c) { return c.parent_id === null; });
        top.sort(function (a, b) { return (b.upvotes - a.upvotes) || (b.created - a.created); });

        var head = document.createElement('div');
        head.className = 'ssw-cmt-cardhead';
        head.innerHTML = '<span class="ssw-cmt-kick"></span>';
        head.querySelector('.ssw-cmt-kick').textContent = 'Community';
        var h = document.createElement('h2');
        h.className = 'ssw-cmt-title';
        h.textContent = 'Comments' + (state.comments.length ? ' (' + state.comments.length + ')' : '');
        if (state.isStaff) {
            var badge = document.createElement('span');
            badge.className = 'ssw-cmt-staffbadge';
            badge.textContent = 'STAFF MODERATION';
            badge.title = 'Your admin session is active - you can Remove any comment';
            h.appendChild(badge);
        }
        head.appendChild(h);
        card.appendChild(head);

        if (state.viewer) {
            card.appendChild(composer(null, load));
        } else {
            var login = document.createElement('div');
            login.className = 'ssw-cmt-login';
            login.innerHTML = 'Have a SurvivalServers account? <a href="https://www.survivalservers.com/sspanel/">Log in</a> to join the discussion.';
            card.appendChild(login);
        }

        if (!top.length) {
            var empty = document.createElement('div');
            empty.className = 'ssw-cmt-empty';
            empty.textContent = 'No comments yet - be the first to share your experience.';
            card.appendChild(empty);
        }

        var byParent = {};
        state.comments.forEach(function (c) {
            var k = c.parent_id === null ? 'root' : c.parent_id;
            (byParent[k] = byParent[k] || []).push(c);
        });
        function walk(c, depth) {
            card.appendChild(commentEl(c, depth));
            (byParent[c.id] || [])
                .sort(function (a, b) { return a.created - b.created; })
                .forEach(function (r) { walk(r, depth + 1); });
        }
        top.forEach(function (c) { walk(c, 0); });

        wrap.appendChild(card);
    }

    function load() {
        fetch(API + '?page=' + encodeURIComponent(page), { credentials: 'same-origin' })
            .then(function (r) { return r.json(); })
            .then(function (d) {
                if (!d || !d.success) { return; }
                state.comments = d.comments;
                state.viewer = d.viewer;
                state.isStaff = !!d.is_staff;
                render();
            })
            .catch(function () { /* comments are optional chrome */ });
    }

    load();
})();
/* Merch: SHOP in the wiki header and a hoodie box in the left column (Ryan approved 2026-10-15; merch lane
   ss-claude-9933, mockup goals/2026-09-22-merch-line/lootdrop/hoodie-wiki.js). English wiki only: the store is
   English, like the main site's SHOP tab. The header link hides at 600px and below (no room on phones). */
(function () {
    if (!/^\/wiki\//.test(location.pathname)) { return; }
    var M = 'https://www.survivalservers.com/themes/epona/images/merch/';
    var SHOP = 'https://shop.survivalservers.com/';
    var STORE = SHOP + 'products/survival-servers-classic-hoodie';
    function run() {
        if (document.getElementById('p-merch') || document.querySelector('.ssw-nav .hsw-shop')) { return; }
        var css = [
            '.ssw-nav .hsw-shop{display:inline-flex;align-items:center;gap:7px}',
            '.ssw-nav .hsw-glyph{display:inline-block;width:15px;height:15px;background-color:currentColor;opacity:.75;-webkit-mask:url(' + M + 'hoodie-icon-64-20261015.webp) center/contain no-repeat;mask:url(' + M + 'hoodie-icon-64-20261015.webp) center/contain no-repeat}',
            '.ssw-nav .hsw-shop:hover .hsw-glyph{opacity:1;color:#eaa824}',
            '@media (max-width:600px){.ssw-nav .hsw-shop{display:none}}',
            '#p-merch{position:sticky;top:16px}',
            '#p-merch .hsw-prod{display:block;text-decoration:none!important;padding:2px 0 4px}',
            '#p-merch .hsw-photo{position:relative;display:block;height:168px;margin:2px 0 12px;border-radius:6px;background:radial-gradient(closest-side,rgba(255,255,255,.09),rgba(255,255,255,0) 80%),#19191b;border:1px solid rgba(255,255,255,.06);overflow:hidden}',
            '#p-merch .hsw-photo img{position:absolute;left:10%;top:7%;width:80%;height:86%;object-fit:contain;filter:brightness(1.5) drop-shadow(0 6px 10px rgba(0,0,0,.5));transition:opacity .35s,transform .35s}',
            '#p-merch .hsw-pb{opacity:0;transform:scale(.97)}',
            '#p-merch .hsw-prod:hover .hsw-pf{opacity:0}',
            '#p-merch .hsw-prod:hover .hsw-pb{opacity:1;transform:none}',
            '#p-merch .hsw-name{display:block;font-weight:700;font-size:14px;color:#ececec;line-height:1.3}',
            '#p-merch .hsw-row{display:flex;align-items:baseline;justify-content:space-between;margin-top:5px}',
            '#p-merch .hsw-price{font-weight:700;font-size:14px;color:#eaa824}',
            '#p-merch .hsw-go{font-size:13px;color:#b5b5b5}',
            '#p-merch .hsw-prod:hover .hsw-go{color:#eaa824}',
            '#p-merch .hsw-prod:hover .hsw-photo{border-color:rgba(234,168,36,.35)}'
        ].join('\n');
        var st = document.createElement('style'); st.textContent = css; document.head.appendChild(st);
        var nav = document.querySelector('.ssw-nav'), order = nav && nav.querySelector('a[href*="/order/"]');
        if (order) {
            var a = document.createElement('a'); a.className = 'hsw-shop'; a.href = SHOP;
            a.innerHTML = '<i class="hsw-glyph" aria-hidden="true"></i>SHOP';
            order.parentNode.insertBefore(a, order.nextSibling);
        }
        var tools = document.getElementById('p-tb');
        if (tools) {
            var box = tools.cloneNode(true);
            box.id = 'p-merch'; box.setAttribute('aria-labelledby', 'p-merch-label');
            var h = box.querySelector('h3');
            if (h) { h.id = 'p-merch-label'; var lab = h.querySelector('.vector-menu-heading-label') || h; lab.textContent = 'Merch'; }
            var content = box.querySelector('.vector-menu-content') || box;
            content.innerHTML = '<a class="hsw-prod" href="' + STORE + '">' +
                '<span class="hsw-photo"><img class="hsw-pf" alt="Survival Servers Hoodie, front" src="' + M + 'hoodie-front-260-20261015.webp">' +
                '<img class="hsw-pb" alt="Survival Servers Hoodie, back" src="' + M + 'hoodie-back-260-20261015.webp"></span>' +
                '<span class="hsw-name">Survival Servers Hoodie</span>' +
                '<span class="hsw-row"><span class="hsw-price">$39</span><span class="hsw-go">Shop &rarr;</span></span></a>';
            tools.parentNode.insertBefore(box, tools.nextSibling);
        }
    }
    if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', run); } else { run(); }
})();