~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/querystring-parse/querystring-parse-debug.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('querystring-parse', function(Y) {
8
 
 
9
 
/**
10
 
 * <p>The QueryString module adds support for serializing JavaScript objects into
11
 
 * query strings and parsing JavaScript objects from query strings format.</p>
12
 
 *
13
 
 * <p>The QueryString namespace is added to your YUI instance including static methods
14
 
 * Y.QueryString.parse(..) and Y.QueryString.stringify(..).</p>
15
 
 *
16
 
 * <p>The <code>querystring</code> module is a rollup of <code>querystring-parse</code> and
17
 
 * <code>querystring-stringify</code>.</p>
18
 
 *
19
 
 * <p>As their names suggest, <code>querystring-parse</code> adds support for parsing
20
 
 * Query String data (Y.QueryString.parse) and <code>querystring-stringify</code> for serializing
21
 
 * JavaScript data into Query Strings (Y.QueryString.stringify).  You may choose to
22
 
 * include either of the submodules individually if you don't need the
23
 
 * complementary functionality, or include the rollup for both.</p>
24
 
 *
25
 
 * @module querystring
26
 
 * @main querystring
27
 
 * @class QueryString
28
 
 * @static
29
 
 */
30
 
var QueryString = Y.namespace("QueryString"),
31
 
 
32
 
// Parse a key=val string.
33
 
// These can get pretty hairy
34
 
// example flow:
35
 
// parse(foo[bar][][bla]=baz)
36
 
// return parse(foo[bar][][bla],"baz")
37
 
// return parse(foo[bar][], {bla : "baz"})
38
 
// return parse(foo[bar], [{bla:"baz"}])
39
 
// return parse(foo, {bar:[{bla:"baz"}]})
40
 
// return {foo:{bar:[{bla:"baz"}]}}
41
 
pieceParser = function (eq) {
42
 
    return function parsePiece (key, val) {
43
 
 
44
 
        var sliced, numVal, head, tail, ret;
45
 
 
46
 
        if (arguments.length !== 2) {
47
 
            // key=val, called from the map/reduce
48
 
            key = key.split(eq);
49
 
            return parsePiece(
50
 
                QueryString.unescape(key.shift()),
51
 
                QueryString.unescape(key.join(eq))
52
 
            );
53
 
        }
54
 
        key = key.replace(/^\s+|\s+$/g, '');
55
 
        if (Y.Lang.isString(val)) {
56
 
            val = val.replace(/^\s+|\s+$/g, '');
57
 
            // convert numerals to numbers
58
 
            if (!isNaN(val)) {
59
 
                numVal = +val;
60
 
                if (val === numVal.toString(10)) {
61
 
                    val = numVal;
62
 
                }
63
 
            }
64
 
        }
65
 
        sliced = /(.*)\[([^\]]*)\]$/.exec(key);
66
 
        if (!sliced) {
67
 
            ret = {};
68
 
            if (key) {
69
 
                ret[key] = val;
70
 
            }
71
 
            return ret;
72
 
        }
73
 
        // ["foo[][bar][][baz]", "foo[][bar][]", "baz"]
74
 
        tail = sliced[2];
75
 
        head = sliced[1];
76
 
 
77
 
        // array: key[]=val
78
 
        if (!tail) {
79
 
            return parsePiece(head, [val]);
80
 
        }
81
 
 
82
 
        // obj: key[subkey]=val
83
 
        ret = {};
84
 
        ret[tail] = val;
85
 
        return parsePiece(head, ret);
86
 
    };
87
 
},
88
 
 
89
 
// the reducer function that merges each query piece together into one set of params
90
 
mergeParams = function(params, addition) {
91
 
    return (
92
 
        // if it's uncontested, then just return the addition.
93
 
        (!params) ? addition
94
 
        // if the existing value is an array, then concat it.
95
 
        : (Y.Lang.isArray(params)) ? params.concat(addition)
96
 
        // if the existing value is not an array, and either are not objects, arrayify it.
97
 
        : (!Y.Lang.isObject(params) || !Y.Lang.isObject(addition)) ? [params].concat(addition)
98
 
        // else merge them as objects, which is a little more complex
99
 
        : mergeObjects(params, addition)
100
 
    );
101
 
},
102
 
 
103
 
// Merge two *objects* together. If this is called, we've already ruled
104
 
// out the simple cases, and need to do the for-in business.
105
 
mergeObjects = function(params, addition) {
106
 
    for (var i in addition) {
107
 
        if (i && addition.hasOwnProperty(i)) {
108
 
            params[i] = mergeParams(params[i], addition[i]);
109
 
        }
110
 
    }
111
 
    return params;
112
 
};
113
 
 
114
 
/**
115
 
 * Provides Y.QueryString.parse method to accept Query Strings and return native
116
 
 * JavaScript objects.
117
 
 *
118
 
 * @module querystring
119
 
 * @submodule querystring-parse
120
 
 * @for QueryString
121
 
 * @method parse
122
 
 * @param qs {String} Querystring to be parsed into an object.
123
 
 * @param sep {String} (optional) Character that should join param k=v pairs together. Default: "&"
124
 
 * @param eq  {String} (optional) Character that should join keys to their values. Default: "="
125
 
 * @public
126
 
 * @static
127
 
 */
128
 
QueryString.parse = function (qs, sep, eq) {
129
 
    // wouldn't Y.Array(qs.split()).map(pieceParser(eq)).reduce(mergeParams) be prettier?
130
 
    return Y.Array.reduce(
131
 
        Y.Array.map(
132
 
            qs.split(sep || "&"),
133
 
            pieceParser(eq || "=")
134
 
        ),
135
 
        {},
136
 
        mergeParams
137
 
    );
138
 
};
139
 
 
140
 
/**
141
 
 * Provides Y.QueryString.unescape method to be able to override default decoding
142
 
 * method.  This is important in cases where non-standard delimiters are used, if
143
 
 * the delimiters would not normally be handled properly by the builtin
144
 
 * (en|de)codeURIComponent functions.
145
 
 * Default: replace "+" with " ", and then decodeURIComponent behavior.
146
 
 * @module querystring
147
 
 * @submodule querystring-parse
148
 
 * @for QueryString
149
 
 * @method unescape
150
 
 * @param s {String} String to be decoded.
151
 
 * @public
152
 
 * @static
153
 
 **/
154
 
QueryString.unescape = function (s) {
155
 
    return decodeURIComponent(s.replace(/\+/g, ' '));
156
 
};
157
 
 
158
 
 
159
 
 
160
 
 
161
 
}, '3.4.1' ,{requires:['array-extras', 'yui-base']});