js/payone/migrator/migration.js   A
last analyzed

Complexity

Total Complexity 8
Complexity/F 1.33

Size

Lines of Code 67
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
dl 0
loc 67
rs 10
cc 0
nc 1
mnd 2
bc 10
fnc 6
bpm 1.6666
cpm 1.3333
noi 5

1 Function

Rating   Name   Duplication   Size   Complexity  
A PAYONE.Migrator.Migration 0 59 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
PAYONE = {};
0 ignored issues
show
Bug introduced by
The variable PAYONE seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.PAYONE.
Loading history...
24
PAYONE.Migrator = {};
25
26
/**
27
 *
28
 * @param url
29
 * @constructor
30
 */
31
PAYONE.Migrator.Migration = function (url) {
32
    this.url = url;
33
    this.currentStep = '';
34
35
    this.nextStep = function (step) {
36
        this.currentStep = step;
37
38
        this.markStepLoading(step);
39
40
        var request = new Ajax.Request(
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...
Unused Code introduced by
The variable request seems to be never used. Consider removing it.
Loading history...
41
            this.url,
42
            {
43
                method:'post',
44
                onSuccess:migration.onSuccess,
0 ignored issues
show
Bug introduced by
The variable migration seems to be never declared. If this is a global, consider adding a /** global: migration */ 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...
45
                onFailure:migration.onFailure,
46
                parameters:{
47
                    'step':step
48
                }
49
            }
50
        );
51
    };
52
53
    this.onSuccess = function (responseRaw) {
54
        var response = (responseRaw.responseJSON);
55
        if (response.success == true) {
56
            migration.markStepSuccess(migration.currentStep);
0 ignored issues
show
Bug introduced by
The variable migration seems to be never declared. If this is a global, consider adding a /** global: migration */ 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...
57
            if (response.next_step !== 0) {
58
                migration.nextStep(response.next_step);
59
            }
60
            else {
61
                $('payone_wizard_form_buttons').setStyle({display:'block'});
62
            }
63
        }
64
        else {
65
            migration.markStepFailure(migration.currentStep);
66
        }
67
    };
68
69
    this.markStepLoading = function (step) {
70
        var stepHtmlId = 'payone_migration_' + step + '_status';
71
        $(stepHtmlId).removeClassName('hidden');
72
        $(stepHtmlId).addClassName('payone_migration_loading');
73
    };
74
75
    this.markStepSuccess = function (step) {
76
        var stepHtmlId = 'payone_migration_' + step + '_status';
77
        $(stepHtmlId).removeClassName('hidden');
78
        $(stepHtmlId).removeClassName('payone_migration_loading');
79
        $(stepHtmlId).addClassName('payone_migration_success');
80
    };
81
82
    this.markStepFailure = function (step) {
83
        var stepHtmlId = 'payone_migration_' + step + '_status';
84
        $(stepHtmlId).removeClassName('hidden');
85
        $(stepHtmlId).removeClassName('payone_migration_loading');
86
        $(stepHtmlId).addClassName('payone_migration_failure');
87
    };
88
89
};
90
91