web/public/s/js/captcha.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 3.5

Size

Lines of Code 35
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 23
mnd 5
bc 5
fnc 2
dl 0
loc 35
rs 10
bpm 2.5
cpm 3.5
noi 2
c 0
b 0
f 0
1
2
var captcha_version = 17;
3
var captcha_done = false;
4
var captcha_label = document.currentScript.getAttribute('label');
5
var captcha_enemies = parseInt(document.currentScript.getAttribute('enemies'));
6
if (!captcha_enemies) {
7
    captcha_enemies = 4;
8
}
9
10
var captcha_html = '';
11
if (captcha_label) {
12
    captcha_html = '<p>' + captcha_label + '<br>';
13
}
14
15
captcha_html += '<iframe id="doom_captcha" src="https://vivirenremoto.github.io/doomcaptcha/captcha.html?version=' + captcha_version + '&countdown=' + document.currentScript.getAttribute('countdown') + '&enemies=' + captcha_enemies + '" style="width:300px;height:150px;border:2px black solid;"></iframe>';
16
17
if (captcha_label) {
18
    captcha_html += '</p>';
19
}
20
21
document.write(captcha_html);
22
23
window.addEventListener('message', function (e) {
24
    if (e.origin.indexOf('vivirenremoto.github.io') > -1) {
25
        captcha_done = true;
26
        document.getElementById('doom_captcha').style.borderColor = 'black';
27
    }
28
}, false);
29
30
document.getElementById('doom_captcha').closest('form').addEventListener('submit', function () {
31
    if (!captcha_done) {
32
        document.getElementById('doom_captcha').style.borderColor = 'red';
33
        event.preventDefault();
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...
34
        return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
35
    }
36
});