<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://webtest.nocxstratum.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://webtest.nocxstratum.com/wp-sitemap-posts-page-1.xml</loc></sitemap></sitemapindex>

<style id="nocx-webtest-approved-css">

/*
 * ============================================================
 * CLASSIC BUTTON ONLY
 * PMS 2727 C
 * Web/screen value: #307FE2
 * ============================================================
 */

.nocx-classic-pms2727,
.nocx-classic-pms2727:hover,
.nocx-classic-pms2727:focus,
.nocx-classic-pms2727:active {
    background: #307FE2 !important;
    background-color: #307FE2 !important;
    border-color: #307FE2 !important;
    color: #FFFFFF !important;
}

</style>


<script id="nocx-webtest-approved-js">

(function () {

    'use strict';


    /*
     * ============================================================
     * HELPERS
     * ============================================================
     */

    function normalize(value) {

        return String(value || '')
            .replace(/\u00a0/g, ' ')
            .replace(/\s+/g, ' ')
            .trim()
            .toLowerCase();
    }


    function exactMatch(value, choices) {

        var current =
            normalize(value);

        return choices.some(
            function (choice) {

                return (
                    current ===
                    normalize(choice)
                );

            }
        );
    }


    /*
     * Find the specific section that contains:
     * - normal participating categories
     * - Platinum service categories
     */

    function getNetworkSection() {

        var sections =
            Array.prototype.slice.call(
                document.querySelectorAll(
                    'section'
                )
            );


        return sections.find(
            function (section) {

                var text =
                    normalize(
                        section.innerText
                    );

                return (
                    text.indexOf(
                        'merchants / participating network'
                    ) !== -1
                    &&
                    text.indexOf(
                        'platinum service categories'
                    ) !== -1
                );

            }
        ) || null;
    }


    function findCard(section, names) {

        if (!section) {
            return null;
        }


        var cards =
            Array.prototype.slice.call(
                section.querySelectorAll(
                    'article'
                )
            );


        return cards.find(
            function (card) {

                var elements =
                    Array.prototype.slice.call(
                        card.querySelectorAll(
                            'h1,h2,h3,h4,h5,h6,p,span,strong'
                        )
                    );


                return elements.some(
                    function (element) {

                        return exactMatch(
                            element.textContent,
                            names
                        );

                    }
                );

            }
        ) || null;
    }


    function renameCard(
        card,
        oldNames,
        newName
    ) {

        if (!card) {
            return;
        }


        Array.prototype.slice.call(
            card.querySelectorAll(
                'h1,h2,h3,h4,h5,h6,p,span,strong'
            )
        ).forEach(
            function (element) {

                if (
                    exactMatch(
                        element.textContent,
                        oldNames
                    )
                ) {

                    element.textContent =
                        newName;
                }

            }
        );
    }



    /*
     * ============================================================
     * CHANGE #1
     *
     * CLASSIC BUTTON ONLY -> PMS 2727 C
     *
     * GOLD = untouched
     * PLATINUM = untouched
     * ============================================================
     */

    function fixClassicButton() {

        var clickables =
            Array.prototype.slice.call(
                document.querySelectorAll(
                    'button,a,[role="button"]'
                )
            );


        clickables.forEach(
            function (element) {

                var text =
                    normalize(
                        element.innerText ||
                        element.textContent
                    );


                /*
                 * ONLY CLASSIC.
                 *
                 * DO NOT include:
                 * choose gold
                 * choose platinum
                 */

                if (
                    text ===
                    'choose classic'
                ) {

                    element.classList.add(
                        'nocx-classic-pms2727'
                    );
                }

            }
        );
    }



    /*
     * ============================================================
     * CHANGE #2 + #3
     *
     * CATEGORY STRUCTURE
     * ============================================================
     */

    function fixCategories() {

        var section =
            getNetworkSection();


        if (!section) {
            return;
        }



        /*
         * --------------------------------------------------------
         * FIND EXISTING MAIN CATEGORY CARDS
         * --------------------------------------------------------
         */

        var dining =
            findCard(
                section,
                [
                    'Dining & Cafes',
                    'Dining & Café',
                    'Dining and Café',
                    'Dining and Cafe'
                ]
            );


        var retail =
            findCard(
                section,
                [
                    'Retail',
                    'Retail & Lifestyle'
                ]
            );


        var fitness =
            findCard(
                section,
                [
                    'Fitness',
                    'Fitness & Wellness',
                    'Fitness, Health & Wellness',
                    'Fitness, Health and Wellness'
                ]
            );


        var beauty =
            findCard(
                section,
                [
                    'Beauty & Wellness',
                    'Beauty and Wellness',
                    'Beauty & Personal Care'
                ]
            );


        var hotels =
            findCard(
                section,
                [
                    'Hotels',
                    'Hotels & Resorts'
                ]
            );


        var other =
            findCard(
                section,
                [
                    'Other Services'
                ]
            );


        var automotive =
            findCard(
                section,
                [
                    'Automotive',
                    'Automotive & Car Care'
                ]
            );


        var construction =
            findCard(
                section,
                [
                    'Construction'
                ]
            );



        /*
         * --------------------------------------------------------
         * EXACT APPROVED DISPLAY NAMES
         * --------------------------------------------------------
         */

        renameCard(
            dining,
            [
                'Dining & Cafes',
                'Dining & Café',
                'Dining and Cafe'
            ],
            'Dining and Café'
        );


        renameCard(
            retail,
            [
                'Retail & Lifestyle'
            ],
            'Retail'
        );


        renameCard(
            fitness,
            [
                'Fitness & Wellness',
                'Fitness, Health & Wellness',
                'Fitness, Health and Wellness'
            ],
            'Fitness'
        );


        renameCard(
            beauty,
            [
                'Beauty & Wellness',
                'Beauty & Personal Care'
            ],
            'Beauty and Wellness'
        );


        renameCard(
            hotels,
            [
                'Hotels & Resorts'
            ],
            'Hotels'
        );



        /*
         * --------------------------------------------------------
         * EXACT APPROVED MAIN CATEGORY ORDER
         *
         * 1 Dining and Café
         * 2 Retail
         * 3 Fitness
         * 4 Beauty and Wellness
         * 5 Hotels
         * 6 Other Services
         * --------------------------------------------------------
         */

        var approvedCards = [

            dining,
            retail,
            fitness,
            beauty,
            hotels,
            other

        ];


        var validCards =
            approvedCards.filter(Boolean);


        /*
         * Only reorder when all six
         * approved cards were found.
         */

        if (
            validCards.length === 6
        ) {

            var categoryParent =
                validCards[0]
                    .parentElement;


            var sameParent =
                validCards.every(
                    function (card) {

                        return (
                            card.parentElement ===
                            categoryParent
                        );

                    }
                );


            if (
                categoryParent &&
                sameParent
            ) {

                approvedCards.forEach(
                    function (card) {

                        card.style
                            .removeProperty(
                                'display'
                            );

                        card.removeAttribute(
                            'aria-hidden'
                        );


                        /*
                         * Appending existing elements
                         * reorders them without
                         * recreating the cards.
                         */

                        categoryParent
                            .appendChild(card);

                    }
                );
            }
        }



        /*
         * --------------------------------------------------------
         * AUTOMOTIVE
         *
         * NOT one of the six approved
         * main categories.
         * --------------------------------------------------------
         */

        if (automotive) {

            automotive.style
                .setProperty(
                    'display',
                    'none',
                    'important'
                );

            automotive.setAttribute(
                'aria-hidden',
                'true'
            );
        }



        /*
         * --------------------------------------------------------
         * CONSTRUCTION
         *
         * Remove it from the normal
         * category grid because it is
         * moving to PLATINUM.
         * --------------------------------------------------------
         */

        if (construction) {

            construction.style
                .setProperty(
                    'display',
                    'none',
                    'important'
                );

            construction.setAttribute(
                'aria-hidden',
                'true'
            );
        }



        /*
         * ========================================================
         * PLATINUM SECTION
         *
         * Existing:
         * 1 Travel Agencies
         * 2 Petrol & Gasoline
         * 3 Car Dealers
         *
         * NEW:
         * 4 Construction
         * ========================================================
         */

        var travel =
            findCard(
                section,
                [
                    'Travel Agencies'
                ]
            );


        var petrol =
            findCard(
                section,
                [
                    'Petrol & Gasoline'
                ]
            );


        var dealers =
            findCard(
                section,
                [
                    'Car Dealers'
                ]
            );


        /*
         * Prevent duplicate Construction
         * if JavaScript runs multiple times.
         */

        var existingPlatinumConstruction =
            document.getElementById(
                'nocx-platinum-construction'
            );


        if (
            construction &&
            travel &&
            petrol &&
            dealers &&
            !existingPlatinumConstruction
        ) {

            var platinumParent =
                dealers.parentElement;


            if (platinumParent) {


                /*
                 * Clone a current Platinum
                 * card so Construction gets
                 * exactly the same Platinum
                 * visual architecture.
                 */

                var constructionPlatinum =
                    travel.cloneNode(true);


                constructionPlatinum.id =
                    'nocx-platinum-construction';



                /*
                 * Change the cloned
                 * Travel title to Construction.
                 */

                Array.prototype.slice.call(
                    constructionPlatinum
                        .querySelectorAll(
                            'h1,h2,h3,h4,h5,h6,p,span,strong'
                        )
                ).forEach(
                    function (element) {

                        if (
                            exactMatch(
                                element.textContent,
                                [
                                    'Travel Agencies'
                                ]
                            )
                        ) {

                            element.textContent =
                                'Construction';
                        }

                    }
                );



                /*
                 * Change Travel description
                 * to Construction description.
                 */

                Array.prototype.slice.call(
                    constructionPlatinum
                        .querySelectorAll('p')
                ).forEach(
                    function (paragraph) {

                        var text =
                            normalize(
                                paragraph.textContent
                            );


                        if (
                            text.indexOf(
                                'participating travel'
                            ) !== -1
                        ) {

                            paragraph.textContent =
                                'Explore participating construction and building-service businesses and review the benefit published for eligible Platinum members.';
                        }

                    }
                );



                /*
                 * ------------------------------------------------
                 * USE EXISTING CONSTRUCTION IMAGE
                 *
                 * Do NOT invent or replace
                 * the approved Construction image.
                 * ------------------------------------------------
                 */

                var originalImage =
                    construction
                        .querySelector(
                            'img'
                        );


                var platinumImage =
                    constructionPlatinum
                        .querySelector(
                            'img'
                        );


                if (
                    originalImage &&
                    platinumImage
                ) {

                    [
                        'src',
                        'srcset',
                        'sizes',
                        'data-src',
                        'data-srcset'
                    ].forEach(
                        function (attribute) {

                            var value =
                                originalImage
                                    .getAttribute(
                                        attribute
                                    );


                            if (value) {

                                platinumImage
                                    .setAttribute(
                                        attribute,
                                        value
                                    );
                            }

                        }
                    );


                    platinumImage.alt =
                        'Construction';
                }



                /*
                 * ------------------------------------------------
                 * BACKGROUND IMAGE FALLBACK
                 *
                 * Some Culture cards use
                 * CSS backgrounds instead of IMG.
                 * ------------------------------------------------
                 */

                var constructionElements =
                    [construction].concat(
                        Array.prototype.slice.call(
                            construction
                                .querySelectorAll(
                                    '*'
                                )
                        )
                    );


                var sourceBackgroundElement =
                    constructionElements.find(
                        function (element) {

                            var background =
                                window
                                    .getComputedStyle(
                                        element
                                    )
                                    .backgroundImage;


                            return (
                                background &&
                                background !==
                                'none'
                            );

                        }
                    );


                var platinumElements =
                    [constructionPlatinum]
                        .concat(
                            Array.prototype.slice.call(
                                constructionPlatinum
                                    .querySelectorAll(
                                        '*'
                                    )
                            )
                        );


                var targetBackgroundElement =
                    platinumElements.find(
                        function (element) {

                            var background =
                                window
                                    .getComputedStyle(
                                        element
                                    )
                                    .backgroundImage;


                            return (
                                background &&
                                background !==
                                'none'
                            );

                        }
                    );


                if (
                    sourceBackgroundElement &&
                    targetBackgroundElement
                ) {

                    var approvedBackground =
                        window
                            .getComputedStyle(
                                sourceBackgroundElement
                            )
                            .backgroundImage;


                    targetBackgroundElement
                        .style
                        .setProperty(
                            'background-image',
                            approvedBackground,
                            'important'
                        );
                }



                /*
                 * Append after Car Dealers.
                 *
                 * Because Car Dealers is
                 * currently the final Platinum
                 * card, Construction becomes #4.
                 */

                platinumParent
                    .appendChild(
                        constructionPlatinum
                    );
            }
        }

    }



    /*
     * ============================================================
     * CATEGORY SEARCH DROPDOWN
     *
     * Keep ONLY the six approved
     * general categories.
     * ============================================================
     */

    function fixCategoryDropdown() {

        var selects =
            Array.prototype.slice.call(
                document.querySelectorAll(
                    'select'
                )
            );


        selects.forEach(
            function (select) {

                var originalOptions =
                    Array.prototype.slice.call(
                        select.options || []
                    );


                /*
                 * Identify actual category
                 * selector by its
                 * "All categories" option.
                 */

                var allCategories =
                    originalOptions.find(
                        function (option) {

                            return (
                                normalize(
                                    option.textContent
                                ).indexOf(
                                    'all categories'
                                ) !== -1
                            );

                        }
                    );


                if (!allCategories) {
                    return;
                }



                var approved = [

                    {
                        names: [
                            'Dining & Cafes',
                            'Dining & Café',
                            'Dining and Café',
                            'Dining and Cafe'
                        ],

                        label:
                            'Dining and Café'
                    },


                    {
                        names: [
                            'Retail',
                            'Retail & Lifestyle'
                        ],

                        label:
                            'Retail'
                    },


                    {
                        names: [
                            'Fitness',
                            'Fitness & Wellness',
                            'Fitness, Health & Wellness',
                            'Fitness, Health and Wellness'
                        ],

                        label:
                            'Fitness'
                    },


                    {
                        names: [
                            'Beauty & Wellness',
                            'Beauty and Wellness',
                            'Beauty & Personal Care'
                        ],

                        label:
                            'Beauty and Wellness'
                    },


                    {
                        names: [
                            'Hotels',
                            'Hotels & Resorts'
                        ],

                        label:
                            'Hotels'
                    },


                    {
                        names: [
                            'Other Services'
                        ],

                        label:
                            'Other Services'
                    }

                ];


                var approvedOptions = [];


                approved.forEach(
                    function (definition) {

                        var option =
                            originalOptions.find(
                                function (candidate) {

                                    return definition
                                        .names
                                        .some(
                                            function (
                                                name
                                            ) {

                                                return (
                                                    normalize(
                                                        candidate
                                                            .textContent
                                                    )
                                                    ===
                                                    normalize(
                                                        name
                                                    )
                                                );

                                            }
                                        );

                                }
                            );


                        if (option) {

                            option.textContent =
                                definition.label;


                            approvedOptions
                                .push(option);
                        }

                    }
                );



                /*
                 * Remove every non-approved
                 * category from THIS selector.
                 */

                Array.prototype.slice.call(
                    select.options
                ).forEach(
                    function (option) {

                        if (
                            option ===
                            allCategories
                        ) {
                            return;
                        }


                        if (
                            approvedOptions
                                .indexOf(
                                    option
                                ) !== -1
                        ) {
                            return;
                        }


                        option.remove();
                    }
                );



                /*
                 * Rebuild exact order.
                 */

                select.appendChild(
                    allCategories
                );


                approvedOptions.forEach(
                    function (option) {

                        select.appendChild(
                            option
                        );

                    }
                );

            }
        );
    }



    /*
     * ============================================================
     * APPLY PATCH
     * ============================================================
     */

    function applyApprovedChanges() {

        fixClassicButton();

        fixCategories();

        fixCategoryDropdown();
    }



    /*
     * ============================================================
     * CULTURE APP LOADS DYNAMICALLY
     *
     * Re-run after rendering without
     * changing any unrelated areas.
     * ============================================================
     */

    function startPatch() {

        applyApprovedChanges();


        [
            200,
            500,
            1000,
            2000,
            4000
        ].forEach(
            function (delay) {

                setTimeout(
                    applyApprovedChanges,
                    delay
                );

            }
        );


        var debounceTimer;


        var observer =
            new MutationObserver(
                function () {

                    clearTimeout(
                        debounceTimer
                    );


                    debounceTimer =
                        setTimeout(
                            applyApprovedChanges,
                            100
                        );

                }
            );


        observer.observe(
            document.documentElement,
            {
                childList: true,
                subtree: true
            }
        );
    }



    if (
        document.readyState ===
        'loading'
    ) {

        document.addEventListener(
            'DOMContentLoaded',
            startPatch,
            {
                once: true
            }
        );

    } else {

        startPatch();
    }

})();

</script>
