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

Complexity

Total Complexity 7
Complexity/F 1.4

Size

Lines of Code 73
Function Count 5

Duplication

Duplicated Lines 21
Ratio 28.77 %

Importance

Changes 0
Metric Value
eloc 51
dl 21
loc 73
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: 'ALERTA: ',
18
        error: 'ERROR: ',
19
        heading: 'MENSAJE DE DEPURACION JAXON:\n',
20
        request: {
21
            uri: 'URI: ',
22
            init: 'INICIALIZANDO PETICION',
23
            creating: 'INICIALIZANDO PETICION DEL OBJETO',
24
            starting: 'INICIANDO PETICION JAXON',
25
            preparing: 'PREPARANDO PETICION',
26
            calling: 'LLAMADA: ',
27
            sending: 'ENVIANDO PETICION',
28
            sent: 'ENVIADO [{length} bytes]'
29
        },
30
        response: {
31
            long: '...\n[RESPUESTA LARGA]\n...',
32
            success: 'RECIBIDO [status: {status}, tamaño: {length} bytes, tiempo: {duration}ms]:\n',
33
            content: 'El servidor retorno el siguiente estado HTTP: {status}\nRECIBIDO:\n{text}',
34
            redirect: 'El servidor retorno una redireccion a:<br />{location}',
35
            no_processor: 'Ningun procesador de respuesta esta disponible para tratar la respuesta del servidor.\n',
36
            check_errors: '.\nRevisa mensajes de error del servidor.'
37
        },
38
        processing: {
39
            parameters: 'PROCESANDO PARAMETROS [{count}]',
40
            no_parameters: 'NO HAY PARAMETROS QUE PROCESAR',
41
            calling: 'INICIANDO LLAMADA JAXON (En desuso: use jaxon.request)',
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: 'LLAMADA JAXON ({cmd}, {options})',
43
            done: 'HECHO [{duration}ms]'
44
        }
45
    };
46
     
47
    jaxon.debug.exceptions = [];
48
    jaxon.debug.exceptions[10001] = 'Respuesta XML invalida: La respuesta contiene una etiqueta desconocida: {data}.';
49
    jaxon.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest no disponible, jaxon esta deshabilitado.';
50
    jaxon.debug.exceptions[10003] = 'Queue overflow: No se puede colocar objeto en cola porque esta llena.';
51
    jaxon.debug.exceptions[10004] = 'Respuesta XML invalida: La respuesta contiene una etiqueta o texto inesperado: {data}.';
52
    jaxon.debug.exceptions[10005] = 'Solicitud URI invalida: URI invalida o perdida; autodeteccion fallida; por favor especifica una explicitamente.';
53
    jaxon.debug.exceptions[10006] = 'Comando de respuesta invalido: Orden de respuesta mal formado recibido.';
54
    jaxon.debug.exceptions[10007] = 'Comando de respuesta invalido: Comando [{data}] no es un comando conocido.';
55
    jaxon.debug.exceptions[10008] = 'Elemento con ID [{data}] no encontrado en el documento.';
56
    jaxon.debug.exceptions[10009] = 'Respuesta invalida: Nombre parametro de funcion perdido.';
57
    jaxon.debug.exceptions[10010] = 'Respuesta invalida: Objeto parametro de funcion perdido.';
58
59
    jaxon.debug.lang = {
60
        isLoaded: true
61
    };
62
}
63
64 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...
65
    /*
66
        Object: update
67
    */
68
    jaxon.config.status.update = function() {
69
        return {
70
            onRequest: function() {
71
                window.status = 'Enviando Peticion...';
72
            },
73
            onWaiting: function() {
74
                window.status = 'Esperando Respuesta...';
75
            },
76
            onProcessing: function() {
77
                window.status = 'Procesando...';
78
            },
79
            onComplete: function() {
80
                window.status = 'Hecho.';
81
            }
82
        }
83
    }
84
}
85