Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 3e758c29e0fde36fc088efcfc88f9a3014432b64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*******************************************************************************
 * 
 * ParsedQueryString version 1.0
 * Copyright 2007, Jeff Mott <Mott.Jeff@gmail.com>. All rights reserved.
 * 
 * Redistribution and use in source and binary forms with or without
 * modification are permitted provided that the above copyright notice,
 * this condition, and the following disclaimer are retained.
 *
 * THIS SOFTWARE IS PROVIDED AS IS, AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT
 * LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 ******************************************************************************/
 
function ParsedQueryString() {
    this._init();
}
 
ParsedQueryString.version = '1.0';
 
ParsedQueryString.prototype =
{
    _init:
        function ()
        {
            this._parameters = {};
 
            if (location.search.length <= 1)
                return;
            var pairs = location.search.substr(1).split(/[&;]/);
            for (var i = 0; i < pairs.length; i++)
            {
                var pair = pairs[i].split(/=/);
                var name = this._decodeURL(pair[0]);
                if (Boolean(pair[1]))
                {
                    var value = this._decodeURL(pair[1]);
                    if (Boolean(this._parameters[name]))
                        this._parameters[name].push(value);
                    else
                        this._parameters[name] = [value];
                }
            }
        },
 
    _decodeURL:
        function (url) {
            return decodeURIComponent(url.replace(/\+/g, " "));
        },
 
    param:
        function (name)
        {
            if (Boolean(this._parameters[name]))
                return this._parameters[name][0];
            else
                return "";
        },
 
    params:
        function (name)
        {
            if (Boolean(name))
            {
                if (Boolean(this._parameters[name]))
                {
                    var values = [];
                    for (var i = 0; i < this._parameters[name].length; i++)
                        values.push(this._parameters[name][i]);
                    return values;
                }
                else
                    return [];
            }
            else
            {
                var names = [];
                for (var name in this._parameters)
                    names.push(name);
                return names;
            }
        }
};