Issues (171)

rest/rest-module.js (2 issues)

1
// formToObject
2
// Rest
3
function restModule(modulename, classname_prefix, domain, restfile, error, success) {
4
5
    if (classname_prefix === undefined || classname_prefix.length < 1) {
6
        classname_prefix = 'module-';
7
    }
8
9
    if (domain === undefined || domain.length < 1) {
10
        domain = '/visitor/';
11
    }
12
13
    if (restfile === undefined || restfile.length < 1) {
14
        restfile = '/php/index.php';
15
    }
16
17
    var url = domain + modulename + restfile;
18
19
    var rest_form = new Rest(url, '?', error, success);
20
21
22
    // var forms = document.getElementsByTagName('form');
23
    var testElements = document.getElementsByClassName(classname_prefix + modulename);
24
    var forms = Array.prototype.filter.call(testElements, function (testElement) {
25
        return testElement.nodeName === 'FORM';
26
    });
27
28
    // console.log(forms);
29
    for (var i = 0; i < forms.length; i++) {
30
        formData(forms[i], rest_form, error, success);
31
    }
32
}
33
34
function formData(form, rest_form, error, success) {
0 ignored issues
show
The parameter success is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter error is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
35
    console.log(form);
36
37
    form.addEventListener("submit", function (event) {
38
        console.log(this);
39
40
        var data = formToObject(this);
41
        var method = data.method;
42
        delete data.method;
43
        delete data.submit;
44
45
        console.log(method);
46
47
        rest_form.byMethod(method, data);
48
        console.log(data);
49
50
        event.preventDefault();
51
    });
52
}
53