filterLocations: function()

in media/js/careers/listings/filters.es6.js [133:160]


    filterLocations: function (value) {
        // Note that filtering is based on a data attr, but the position's
        // location shown in the HTML may be different to (or contain _more_
        // items than) the data attribute's value.
        if (!value) return;

        const positions = this.positionTable.getElementsByClassName('position');

        for (let i = 0; i < positions.length; i++) {
            const data = positions.item(i).dataset.location + ',';

            // When user selects 'Remote' only list jobs explicitly marked
            // Remote otherwise list jobs matching value (which is a mozilla
            // office) and those marked as 'All Offices'
            if (value === 'Remote') {
                if (data.indexOf(value + ',') === -1) {
                    positions.item(i).classList.add('hidden');
                }
            } else if (value.indexOf('Remote') !== -1 && data === 'Remote,') {
                continue;
            } else if (
                data.indexOf(value + ',') === -1 &&
                data.indexOf('All Offices,') === -1
            ) {
                positions.item(i).classList.add('hidden');
            }
        }
    }