js/payone/core/safe_invoice.js   A
last analyzed

Complexity

Total Complexity 11
Complexity/F 2.75

Size

Lines of Code 56
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 11
dl 0
loc 56
rs 10
c 2
b 0
f 0
cc 0
nc 2
mnd 1
bc 10
fnc 4
bpm 2.5
cpm 2.75
noi 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A Ajax.Responders.register.onComplete 0 11 4
A Event.observe 0 3 1
1
/**
2
 *
3
 * NOTICE OF LICENSE
4
 *
5
 * This source file is subject to the GNU General Public License (GPL 3)
6
 * that is bundled with this package in the file LICENSE.txt
7
 *
8
 * DISCLAIMER
9
 *
10
 * Do not edit or add to this file if you wish to upgrade Payone_Core to newer
11
 * versions in the future. If you wish to customize Payone_Core for your
12
 * needs please refer to http://www.payone.de for more information.
13
 *
14
 * @category        Payone
15
 * @package         js
16
 * @subpackage      payone
17
 * @copyright       Copyright (c) 2012 <[email protected]> - www.noovias.com
18
 * @author          Matthias Walter <[email protected]>
19
 * @license         <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
20
 * @link            http://www.noovias.com
21
 */
22
23
/**
24
 * @param element
25
 */
26
function payoneSwitchSafeInvoice(element)
27
{
28
    if (element == undefined) {
29
        return;
30
    }
31
32
    var ElementValue = element.value;
33
    var ElementValueSplit = ElementValue.split('_');
34
    var typeId = ElementValueSplit[0];
35
    var typeCode = ElementValueSplit[1];
36
    $("payone_safe_invoice_sin_type").setValue(typeCode);
37
    $("payone_safe_invoice_config_id").setValue(typeId);
38
39
    var divOne = $('payone_klarna_invoice_terms_div');
40
    var divTwo = $('payone_klarna_additional_fields');
41
42
    if (divOne == undefined || divTwo == undefined) {
43
        return;
44
    }
45
46
    if (typeCode == 'KLV'){
47
        divOne.show();
48
        divTwo.show();
49
    } else {
50
        divOne.hide();
51
        divTwo.hide();
52
    }
53
}
54
55
Event.observe(
0 ignored issues
show
Bug introduced by
The variable Event seems to be never declared. If this is a global, consider adding a /** global: Event */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
56
    document, "dom:loaded", function () {
57
    payoneSwitchSafeInvoice($('payone_safe_invoice_sin_type_select'));
58
    }
59
);
60
61
Event.observe(
0 ignored issues
show
Bug introduced by
The variable Event seems to be never declared. If this is a global, consider adding a /** global: Event */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
62
    document, "dom:ready", function () {
63
    payoneSwitchSafeInvoice($('payone_safe_invoice_sin_type_select'));
64
    }
65
);
66
67
Ajax.Responders.register(
0 ignored issues
show
Bug introduced by
The variable Ajax seems to be never declared. If this is a global, consider adding a /** global: Ajax */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
68
    {
69
    onComplete: function (transport, element) {
70
        var typeSelect = $('payone_safe_invoice_sin_type_select');
71
        if (typeSelect == undefined) {
72
            return;
73
        }
74
75
        var url = element.request.url;
76
        if (url.indexOf('checkout/onepage/saveShippingMethod') !== -1 || url.indexOf('checkout/onepage/progress') !== 1) {
77
            payoneSwitchSafeInvoice(typeSelect);
78
        }
79
    }
80
    }
81
);
82