Passed
Push — master ( 937909...503c6a )
by Eduardo
02:32
created

$(ꞌ#bwWordlistinputButtonConfirmꞌ).click   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
dl 0
loc 4
rs 10
nop 0
1
/** global: appSettings */
2
const conversions = require('../../common/conversions.js'); // Conversions helper
3
4
var bwWordlistContents; // Global wordlist input contents
5
6
require('../../common/stringformat.js'); // String format override
7
8
const {
9
  ipcRenderer
10
} = require('electron');
11
12
const {
13
  tableReset
14
} = require('./auxiliary.js');
15
16
// Wordlist input, contents confirmation container
17
ipcRenderer.on('bw:wordlistinput.confirmation', function() {
18
  var bwFileStats = [];
19
  const {
20
    lookup
21
  } = appSettings;
22
23
  bwWordlistContents = $('#bwWordlistTextareaDomains').val().toString();
24
  if (bwWordlistContents == '' && bwWordlistContents === null) {
25
    $('#bwWordlistconfirm').addClass('is-hidden');
26
    $('#bwEntry').removeClass('is-hidden');
27
  } else {
28
    $('#bwWordlistSpanInfo').text('Loading wordlist stats...');
29
    $('#bwWordlistSpanInfo').text('Getting line count...');
30
    bwFileStats['linecount'] = bwWordlistContents.toString().split('\n').length;
31
32
    if (lookup.randomize.timebetween === true) {
33
      bwFileStats['minestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.randomize.timebetweenmin);
34
      bwFileStats['maxestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.randomize.timebetweenmax);
35
      $('#bwWordlistSpanTimebetweenmin').text('{0}ms '.format(lookup.randomize.timebetweenmin));
36
      $('#bwWordlistSpanTimebetweenmax').text('/ {0}ms'.format(lookup.randomize.timebetweenmax));
37
      $('#bwWordlistTdEstimate').text('{0} to {1}'.format(bwFileStats['minestimate'], bwFileStats['maxestimate']));
38
    } else {
39
      bwFileStats['minestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.timebetween);
40
      $('#bwWordlistSpanTimebetweenminmax').addClass('is-hidden');
41
      $('#bwWordlistSpanTimebetweenmin').text(lookup.timebetween + 'ms');
42
      $('#bwWordlistTdEstimate').text('> {0}'.format(bwFileStats['minestimate']));
43
    }
44
45
    bwFileStats['filepreview'] = bwWordlistContents.toString().substring(0, 50);
46
    //console.log(readLines(filePath[0]));
47
    //console.log(bwFileStats['filepreview']);
48
49
    //console.log(lineCount(bwFileContents));
50
    $('#bwWordlistloading').addClass('is-hidden');
51
    $('#bwWordlistconfirm').removeClass('is-hidden');
52
53
    // stats
54
    $('#bwWordlistTdDomains').text('{0} line(s)'.format(bwFileStats['linecount']));
55
    $('#bwWordlistTdFilepreview').text(bwFileStats['filepreview'] + '...');
56
  }
57
});
58
59
// Wordlist Input, Entry container button
60
$('#bwEntryButtonWordlist').click(function() {
61
  $('#bwEntry').addClass('is-hidden');
62
  $('#bwWordlistinput').removeClass('is-hidden');
63
});
64
65
// Wordlist Input, cancel input
66
$('#bwWordlistinputButtonCancel').click(function() {
67
  $('#bwWordlistinput').addClass('is-hidden');
68
  $('#bwEntry').removeClass('is-hidden');
69
});
70
71
// Wordlist Input, go to confirm
72
$('#bwWordlistinputButtonConfirm').click(function() {
73
  $('#bwWordlistinput').addClass('is-hidden');
74
  ipcRenderer.send("bw:input.wordlist");
75
});
76
77
// Wordlist input, cancel confirmation
78
$('#bwWordlistconfirmButtonCancel').click(function() {
79
  $('#bwWordlistconfirm').addClass('is-hidden');
80
  $('#bwEntry').removeClass('is-hidden');
81
});
82
83
// Wordlist input, proceed to bulk whois
84
$('#bwWordlistconfirmButtonStart').click(function() {
85
  var bwDomainArray = bwWordlistContents.toString().split('\n').map(Function.prototype.call, String.prototype.trim),
86
    bwTldsArray = $('#bwWordlistTextareaDomains').val().toString().split(',');
87
88
  console.log(bwDomainArray);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
89
90
  tableReset(bwDomainArray.length, bwTldsArray.length);
91
  $('#bwWordlistconfirm').addClass('is-hidden');
92
  $('#bwProcessing').removeClass('is-hidden');
93
94
  ipcRenderer.send("bw:lookup", bwDomainArray, bwTldsArray);
95
});
96
97
$('#bwWordlistInputTlds').keyup(function() {
98
  // Cancel the default action, if needed
99
  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...
100
  // Number 13 is the "Enter" key on the keyboard
101
  if (event.keyCode === 13) {
102
    // Trigger the button element with a click
103
    $('#bwWordlistconfirmButtonStart').click();
104
  }
105
});
106