client/js/etc/global_helper.js
/**
     * Read all URL parameters into a map.
     * @returns {Map} the url parameters as a key-value store (ES6 map)
     */
Read all URL parameters into a map.
@returns {Map} the url parameters as a key-value store (ES6 map)
Read all URL parameters into a map . @returns { Map } the url parameters as a key - value store ( ES6 map )
static parameters() {
        const query = window.location.search.substring(1);
        const vars = query.split('&');
        const urlParameters = new Map();
        const isInt = x => (/^[0-9]+$/).test(x);
        const isFloat = x => (/^[0-9]+\.[0-9]*$/).test(x);
        vars.forEach(v => {
            if (v.length > 0) {
                const splits = v.split('=');
                const key = decodeURIComponent(splits[0]);
                let raw_value = decodeURIComponent(splits[1]);
                const isArray = raw_value.startsWith('..');
                if (isArray) {
                    raw_value = raw_value.slice(2);
                }
                if (raw_value.length < 1) {
                    urlParameters.set(key, isArray ? [] : '');
                } else {
                    const [first, ...rest] = raw_value.split(',').map(val => {
                        if (isInt(val)) {
                            return Number.parseInt(val, 10);
                        } else if (isFloat(val)) {
                            return Number.parseFloat(val);
                        }
                        return val;
                    });
                    urlParameters.set(key, isArray ? [first, ...rest] : first);
                }
            }
        });
        return urlParameters;
    }
static parameters ( ) { const query = window . location . search . substring ( 1 ) ; const vars = query . split ( '&' ) ; const urlParameters = new Map ( ) ; const isInt = x => ( / ^[0-9]+$ / ) . test ( x ) ; const isFloat = x => ( / ^[0-9]+\.[0-9]*$ / ) . test ( x ) ; vars . forEach ( v => { if ( v . length > 0 ) { const splits = v . split ( '=' ) ; const key = decodeURIComponent ( splits [ 0 ] ) ; let raw_value = decodeURIComponent ( splits [ 1 ] ) ; const isArray = raw_value . startsWith ( '..' ) ; if ( isArray ) { raw_value = raw_value . slice ( 2 ) ; } if ( raw_value . length < 1 ) { urlParameters . set ( key , isArray ? [ ] : '' ) ; } else { const [ first , ... rest ] = raw_value . split ( ',' ) . map ( val => { if ( isInt ( val ) ) { return Number . parseInt ( val , 10 ) ; } else if ( isFloat ( val ) ) { return Number . parseFloat ( val ) ; } return val ; } ) ; urlParameters . set ( key , isArray ? [ first , ... rest ] : first ) ; } } } ) ; return urlParameters ; }
Read all URL parameters into a map.
Read all URL parameters into a map .
// Adapted from:  http://stackoverflow.com/questions/2090551/parse-query-string-in-javascript