jaxon-examples/public/js/lang/jaxon.en.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1.4

Size

Lines of Code 76
Function Count 5

Duplication

Duplicated Lines 21
Ratio 27.63 %

Importance

Changes 0
Metric Value
eloc 51
dl 21
loc 76
rs 10
c 0
b 0
f 0
wmc 7
mnd 2
bc 2
fnc 5
bpm 0.4
cpm 1.4
noi 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
/**
2
 * translation for: jaxon v.x.x
3
 * @version: 1.0.0
4
 * @author: mic <[email protected]>
5
 * @copyright jaxon project
6
 * @license GNU/GPL
7
 * @package jaxon x.x.x
8
 * @since v.x.x.x
9
 * save as UTF-8
10
 */
11
12
if ('undefined' != typeof jaxon.debug) {
0 ignored issues
show
Bug introduced by
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
13
    /*
14
        Array: text
15
    */
16
    jaxon.debug.messages = {
17
        warning: 'WARNING: ',
18
        error: 'ERROR: ',
19
        heading: 'JAXON DEBUG MESSAGE:\n',
20
        request: {
21
            uri: 'URI: ',
22
            init: 'INITIALIZING REQUEST',
23
            creating: 'INITIALIZING REQUEST OBJECT',
24
            starting: 'STARTING JAXON REQUEST',
25
            preparing: 'PREPARING REQUEST',
26
            calling: 'CALLING: ',
27
            sending: 'SENDING REQUEST',
28
            sent: 'SENT [{length} bytes]'
29
        },
30
        response: {
31
            long: '...\n[LONG RESPONSE]\n...',
32
            success: 'RECEIVED [status: {status}, size: {length} bytes, time: {duration}ms]:\n',
33
            content: 'The server returned the following HTTP status: {status}\nRECEIVED:\n{text}',
34
            redirect: 'The server returned a redirect to:<br />{location}',
35
            no_processor: 'No response processor is available to process the response from the server.\n',
36
            check_errors: '.\nCheck for error messages from the server.'
37
        },
38
        processing: {
39
            parameters: 'PROCESSING PARAMETERS [{count}]',
40
            no_parameters: 'NO PARAMETERS TO PROCESS',
41
            calling: 'STARTING JAXON CALL (deprecated: use jaxon.request instead)',
0 ignored issues
show
Unused Code Bug introduced by
The key calling is used more than once in this object expression.
Loading history...
42
            calling: 'JAXON CALL ({cmd}, {options})',
43
            done: 'DONE [{duration}ms]'
44
        }
45
    };
46
47
    /*
48
        Array: exceptions
49
    */
50
    jaxon.debug.exceptions = [];
51
    jaxon.debug.exceptions[10001] = 'Invalid response XML: The response contains an unknown tag: {data}.';
52
    jaxon.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest is not available, jaxon is disabled.';
53
    jaxon.debug.exceptions[10003] = 'Queue overflow: Cannot push object onto queue because it is full.';
54
    jaxon.debug.exceptions[10004] = 'Invalid response XML: The response contains an unexpected tag or text: {data}.';
55
    jaxon.debug.exceptions[10005] = 'Invalid request URI: Invalid or missing URI; autodetection failed; please specify a one explicitly.';
56
    jaxon.debug.exceptions[10006] = 'Invalid response command: Malformed response command received.';
57
    jaxon.debug.exceptions[10007] = 'Invalid response command: Command [{data}] is not a known command.';
58
    jaxon.debug.exceptions[10008] = 'Element with ID [{data}] not found in the document.';
59
    jaxon.debug.exceptions[10009] = 'Invalid request: Missing function name parameter.';
60
    jaxon.debug.exceptions[10010] = 'Invalid request: Missing function object parameter.';
61
62
    jaxon.debug.lang = {
63
        isLoaded: true
64
    };
65
}
66
67 View Code Duplication
if (typeof jaxon.config != 'undefined' && typeof jaxon.config.status != 'undefined') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
68
    /*
69
        Object: update
70
    */
71
    jaxon.config.status.update = function() {
72
        return {
73
            onRequest: function() {
74
                window.status = 'Sending request...';
75
            },
76
            onWaiting: function() {
77
                window.status = 'Waiting for response...';
78
            },
79
            onProcessing: function() {
80
                window.status = 'Processing...';
81
            },
82
            onComplete: function() {
83
                window.status = 'Done.';
84
            }
85
        }
86
    }
87
}
88