HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/resources/js/kms/paginatorPerPageController.js
export default class PaginatorPerPageController {
    constructor() {
        if(!this.isSupported()) {
            alert('Upgrade uw browser alstublieft. Bepaalde functies werken nu niet. Raadpleeg uw ICTer voor meer informatie');
            return
        }

        this.perPageSelect = document.querySelector('.js-per-page');
        if(!this.perPageSelect) return;

        this.perPageSelectChanged = this.perPageSelectChanged.bind(this);
        this.controlListeners(true);
    }

    isSupported() {
        console.log(!!window.URL, !!window.URLSearchParams)
        if(!!window.URL === false) return false;
        if(!!window.URLSearchParams === false) return false;
        return true;
    }

    controlListeners(enable = true) {
        this.perPageSelect.removeEventListener('change', this.perPageSelectChanged);
        if(enable) this.perPageSelect.addEventListener('change', this.perPageSelectChanged);
    }

    /**
     * @param {Event} changeEvent
     */
    perPageSelectChanged(changeEvent) {
        const url = new URL(location.href);
        const params = new URLSearchParams(url.search);
        params.set('perpage', changeEvent.target.value);
        url.search = params;
        location.href = url;
    }
}