| @@ 19-85 (lines=67) @@ | ||
| 16 | } = require('./auxiliary.js'); |
|
| 17 | ||
| 18 | // File input, path and information confirmation container |
|
| 19 | ipcRenderer.on('bw:fileinput.confirmation', function(event, filePath = null, isDragDrop = false) { |
|
| 20 | const { |
|
| 21 | misc, |
|
| 22 | lookup |
|
| 23 | } = appSettings; |
|
| 24 | var bwFileStats; // File stats, size, last changed, etc |
|
| 25 | ||
| 26 | //console.log(filePath); |
|
| 27 | if (filePath === undefined || filePath == '' || filePath === null) { |
|
| 28 | //console.log(filePath); |
|
| 29 | $('#bwFileinputloading').addClass('is-hidden'); |
|
| 30 | $('#bwEntry').removeClass('is-hidden'); |
|
| 31 | } else { |
|
| 32 | $('#bwLoadingInfo').text('Loading file stats...'); |
|
| 33 | if (isDragDrop === true) { |
|
| 34 | $('#bwEntry').addClass('is-hidden'); |
|
| 35 | $('#bwFileinputloading').removeClass('is-hidden'); |
|
| 36 | bwFileStats = fs.statSync(filePath); |
|
| 37 | bwFileStats['filename'] = filePath.replace(/^.*[\\\/]/, ''); |
|
| 38 | bwFileStats['humansize'] = conversions.byteToHumanFileSize(bwFileStats['size'], misc.usestandardsize); |
|
| 39 | $('#bwFileSpanInfo').text('Loading file contents...'); |
|
| 40 | bwFileContents = fs.readFileSync(filePath); |
|
| 41 | } else { |
|
| 42 | bwFileStats = fs.statSync(filePath[0]); |
|
| 43 | bwFileStats['filename'] = filePath[0].replace(/^.*[\\\/]/, ''); |
|
| 44 | bwFileStats['humansize'] = conversions.byteToHumanFileSize(bwFileStats['size'], misc.usestandardsize); |
|
| 45 | $('#bwFileSpanInfo').text('Loading file contents...'); |
|
| 46 | bwFileContents = fs.readFileSync(filePath[0]); |
|
| 47 | } |
|
| 48 | $('#bwFileSpanInfo').text('Getting line count...'); |
|
| 49 | bwFileStats['linecount'] = bwFileContents.toString().split('\n').length; |
|
| 50 | ||
| 51 | if (lookup.randomize.timebetween === true) { |
|
| 52 | bwFileStats['minestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.randomize.timebetweenmin); |
|
| 53 | bwFileStats['maxestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.randomize.timebetweenmax); |
|
| 54 | ||
| 55 | $('#bwFileSpanTimebetweenmin').text('{0}ms '.format(lookup.randomize.timebetweenmin)); |
|
| 56 | $('#bwFileSpanTimebetweenmax').text('/ {0}ms'.format(lookup.randomize.timebetweenmax)); |
|
| 57 | $('#bwFileTdEstimate').text('{0} to {1}'.format(bwFileStats['minestimate'], bwFileStats['maxestimate'])); |
|
| 58 | } else { |
|
| 59 | bwFileStats['minestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.timebetween); |
|
| 60 | $('#bwFileSpanTimebetweenminmax').addClass('is-hidden'); |
|
| 61 | $('#bwFileSpanTimebetweenmin').text(lookup.timebetween + 'ms'); |
|
| 62 | $('#bwFileTdEstimate').text('> {0}'.format(bwFileStats['minestimate'])); |
|
| 63 | } |
|
| 64 | ||
| 65 | ||
| 66 | ||
| 67 | bwFileStats['filepreview'] = bwFileContents.toString().substring(0, 50); |
|
| 68 | //console.log(readLines(filePath[0])); |
|
| 69 | //console.log(bwFileStats['filepreview']); |
|
| 70 | ||
| 71 | //console.log(lineCount(bwFileContents)); |
|
| 72 | $('#bwFileinputloading').addClass('is-hidden'); |
|
| 73 | $('#bwFileinputconfirm').removeClass('is-hidden'); |
|
| 74 | ||
| 75 | // stats |
|
| 76 | $('#bwFileTdName').text(bwFileStats['filename']); |
|
| 77 | $('#bwFileTdLastmodified').text(bwFileStats['mtime']); |
|
| 78 | $('#bwFileTdLastaccess').text(bwFileStats['atime']); |
|
| 79 | $('#bwFileTdFileSize').text(bwFileStats['humansize'] + ' ({0} line(s))'.format(bwFileStats['linecount'])); |
|
| 80 | $('#bwFileTdFilepreview').text(bwFileStats['filepreview'] + '...'); |
|
| 81 | //$('#bwTableMaxEstimate').text(bwFileStats['maxestimate']); |
|
| 82 | //console.log('cont:'+ bwFileContents); |
|
| 83 | ||
| 84 | //console.log(bwFileStats['linecount']); |
|
| 85 | } |
|
| 86 | }); |
|
| 87 | ||
| 88 | // File Input, Entry container button |
|
| @@ 15-81 (lines=67) @@ | ||
| 12 | } = require('electron'); |
|
| 13 | ||
| 14 | // File input, path and information confirmation container |
|
| 15 | ipcRenderer.on('bwa:fileinput.confirmation', function(event, filePath = null, isDragDrop = false) { |
|
| 16 | const { |
|
| 17 | misc, |
|
| 18 | lookup |
|
| 19 | } = appSettings; |
|
| 20 | var bwFileStats; // File stats, size, last changed, etc |
|
| 21 | ||
| 22 | //console.log(filePath); |
|
| 23 | if (filePath === undefined || filePath == '' || filePath === null) { |
|
| 24 | //console.log(filePath); |
|
| 25 | $('#bwaFileInputLoading').addClass('is-hidden'); |
|
| 26 | $('#bwaEntry').removeClass('is-hidden'); |
|
| 27 | } else { |
|
| 28 | $('#bwLoadingInfo').text('Loading file stats...'); |
|
| 29 | if (isDragDrop === true) { |
|
| 30 | $('#bwEntry').addClass('is-hidden'); |
|
| 31 | $('#bwFileInputLoading').removeClass('is-hidden'); |
|
| 32 | bwFileStats = fs.statSync(filePath); |
|
| 33 | bwFileStats['filename'] = filePath.replace(/^.*[\\\/]/, ''); |
|
| 34 | bwFileStats['humansize'] = conversions.byteToHumanFileSize(bwFileStats['size'], misc.usestandardsize); |
|
| 35 | $('#bwfLoadingInfo').text('Loading file contents...'); |
|
| 36 | bwFileContents = fs.readFileSync(filePath); |
|
| 37 | } else { |
|
| 38 | bwFileStats = fs.statSync(filePath[0]); |
|
| 39 | bwFileStats['filename'] = filePath[0].replace(/^.*[\\\/]/, ''); |
|
| 40 | bwFileStats['humansize'] = conversions.byteToHumanFileSize(bwFileStats['size'], misc.usestandardsize); |
|
| 41 | $('#bwfLoadingInfo').text('Loading file contents...'); |
|
| 42 | bwFileContents = fs.readFileSync(filePath[0]); |
|
| 43 | } |
|
| 44 | $('#bwfLoadingInfo').text('Getting line count...'); |
|
| 45 | bwFileStats['linecount'] = bwFileContents.toString().split('\n').length; |
|
| 46 | ||
| 47 | if (lookup.randomize.timebetween === true) { |
|
| 48 | bwFileStats['minestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.randomize.timebetweenmin); |
|
| 49 | bwFileStats['maxestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.randomize.timebetweenmax); |
|
| 50 | $('#bwftimebetweenmin').text('{0}ms '.format(lookup.randomize.timebetweenmin)); |
|
| 51 | $('#bwftimebetweenmax').text('/ {0}ms'.format(lookup.randomize.timebetweenmax)); |
|
| 52 | $('#bwfTableMinMaxEstimate').text('{0} to {1}'.format(bwFileStats['minestimate'], bwFileStats['maxestimate'])); |
|
| 53 | } else { |
|
| 54 | bwFileStats['minestimate'] = conversions.msToHumanTime(bwFileStats['linecount'] * lookup.timebetween); |
|
| 55 | $('#bwftimebetweenmaxtext').addClass('is-hidden'); |
|
| 56 | $('#bwftimebetweenmin').text(lookup.timebetween + 'ms'); |
|
| 57 | $('#bwfTableMinMaxEstimate').text('> {0}'.format(bwFileStats['minestimate'])); |
|
| 58 | } |
|
| 59 | ||
| 60 | ||
| 61 | ||
| 62 | bwFileStats['filepreview'] = bwFileContents.toString().substring(0, 50); |
|
| 63 | //console.log(readLines(filePath[0])); |
|
| 64 | //console.log(bwFileStats['filepreview']); |
|
| 65 | ||
| 66 | //console.log(lineCount(bwFileContents)); |
|
| 67 | $('#bwFileInputLoading').addClass('is-hidden'); |
|
| 68 | $('#bwFileInputConfirm').removeClass('is-hidden'); |
|
| 69 | ||
| 70 | // stats |
|
| 71 | $('#bwfTableFilename').text(bwFileStats['filename']); |
|
| 72 | $('#bwfTableFileLastModified').text(bwFileStats['mtime']); |
|
| 73 | $('#bwfTableFileLastAccessed').text(bwFileStats['atime']); |
|
| 74 | $('#bwfTableFileSize').text(bwFileStats['humansize'] + ' ({0} line(s))'.format(bwFileStats['linecount'])); |
|
| 75 | $('#bwfTableFilePreview').text(bwFileStats['filepreview'] + '...'); |
|
| 76 | //$('#bwTableMaxEstimate').text(bwFileStats['maxestimate']); |
|
| 77 | //console.log('cont:'+ bwFileContents); |
|
| 78 | ||
| 79 | //console.log(bwFileStats['linecount']); |
|
| 80 | } |
|
| 81 | }); |
|
| 82 | ||
| 83 | // File Input, Entry container button |
|
| 84 | $('#bwaeButtonFileInput').click(function() { |
|