js/lib/jQuerytoObject.js   A
last analyzed

Complexity

Total Complexity 8
Complexity/F 4

Size

Lines of Code 21
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
c 0
b 0
f 0
nc 32
dl 0
loc 21
rs 10
wmc 8
mnd 2
bc 5
fnc 2
bpm 2.5
cpm 4
noi 0
1
jQuery.fn.serializeObject = function()
2
{
3
    var o = {};
4
    var a = this.serializeArray();
5
    jQuery.each(a, function() {
6
        var value;
7
        if (o[this.name] !== undefined) {
8
            if (!o[this.name].push) {
9
                o[this.name] = [o[this.name]];
10
            }
11
            value = (this.value === 'on') ? true : this.value;
12
            value = (value === 'off') ? false : value;
13
            o[this.name].push(value || '');
14
        } else {
15
            value = (this.value === 'on') ? true : this.value;
16
            value = (value === 'off') ? false : value;
17
            o[this.name] = value;
18
        }
19
    });
20
    return o;
21
};
22