// $Id: $
// Copyright (c) 2004 Kurt M. Brown, x2ii.info.
// This file is subject to the terms and conditions of the GNU General Public
// License. See the file COPYING for more details.

xi.QueryFields = function()
{
    if (location.search) {
        // location.search == '?abc=123&def=345'
        const fields = location.search.substr(1).split('&');
        for each (var pair in fields) {
            const [field, value] = pair.split('=');
            // tab-seperate fields with > 1 values, since the tab is
            // less likely to occur than a comma.
            if (!this.hasOwnProperty(field))
                this[field] = value;
            else
                this[field] += '\t' + value;
        }
    }
}
xi.QueryFields.prototype.get = function(field, noFoundValue)
{
    return this.hasOwnProperty(field) ? this[field] : noFoundValue;
}

