app/js/main/bw/fileinput.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 59
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 33
mnd 0
bc 0
fnc 2
dl 0
loc 59
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0
1
// jshint esversion: 8
2
3
const electron = require('electron'),
4
  debug = require('debug')('main.bw.fileinput');
5
6
const {
7
  app,
8
  BrowserWindow,
9
  Menu,
10
  ipcMain,
11
  dialog
12
} = electron;
13
14
var settings = require('../../common/settings').load();
15
16
/*
17
  ipcMain.on('bw:input.file', function(...) {...});
18
    On event: Bulk whois input file, select file dialog
19
  parameters
20
    event (object) - renderer object
21
 */
22
ipcMain.on('bw:input.file', function(event) {
23
  debug("Waiting for file selection");
24
  var filePath = dialog.showOpenDialogSync({
25
    title: "Select wordlist file",
26
    buttonLabel: "Open",
27
    properties: ['openFile', 'showHiddenFiles']
28
  });
29
30
  var {
31
    sender
32
  } = event;
33
34
  debug("Using selected file at {0}".format(filePath));
35
  sender.send('bw:fileinput.confirmation', filePath);
36
});
37
38
/*
39
  ipcMain.on('ondragstart', function(...) {...});
40
    On event: drag and dropping file
41
  parameters
42
    event (object) - renderer object
43
    filePath (string) - dropped file path
44
 */
45
ipcMain.on('ondragstart', function(event, filePath) {
46
  const {
47
    'app.window': appWindow
48
  } = settings;
49
50
  var {
51
    sender
52
  } = event;
53
54
  sender.startDrag({
55
    file: filePath,
56
    icon: appWindow.icon
0 ignored issues
show
Bug introduced by
The variable appWindow seems to be never declared. If this is a global, consider adding a /** global: appWindow */ 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...
57
  });
58
  
59
  debug('File drag filepath: {0}'.format(filePath));
60
  sender.send('bw:fileinput.confirmation', filePath, true);
61
});
62