Get screenshot working on Linux; use case name and timestamp in default filename.

This commit is contained in:
Will Bradley 2018-01-06 23:47:34 -08:00
parent e1ccfb95a1
commit 47ce72af8c
3 changed files with 11 additions and 5 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# npm install likes to mess with this, also it's huge
node_modules

View File

@ -11,9 +11,9 @@
<div class="container window align-content-center">
<h1>DocumentIt</h1>
<form>
<input type="text" name="casename" placeholder="Case Name"><br>
<input type="text" name="socialmedia" placeholder="Social Media"><br>
<textarea name="description" placeholder="Incident Description..." rows="10" cols="30"></textarea>
<input type="text" id="casename" name="casename" placeholder="Case Name"><br>
<input type="text" id="socialmedia" name="socialmedia" placeholder="Social Media"><br>
<textarea id="description" name="description" placeholder="Incident Description..." rows="10" cols="30"></textarea>
</form>
<label id="screenshot-path">Path:</label><br>

View File

@ -12,8 +12,10 @@ const path = require('path');
const screenshot = document.getElementById('screen-shot');
const screenshotMsg = document.getElementById('screenshot-path');
const pathButton = document.getElementById('path-button');
const casenameField = document.getElementById('casename');
var screenshotPath = '';
var caseName = '';
pathButton.addEventListener('click', function(event) {
dialog.showSaveDialog(function(fileName) {
@ -34,10 +36,12 @@ screenshot.addEventListener('click', function(event) {
if (error) return console.log(error.message);
sources.forEach(function(source) {
if (source.name === 'Entire Screen' || source.name === 'Screen 1') {
if (source.name === 'Entire Screen' || source.name === 'Entire screen' || source.name === 'Screen 1') {
caseName = casenameField.value;
if (screenshotPath === '') {
screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
timestamp = new Date().getTime();
screenshotPath = path.join(os.tmpdir(), caseName+'-'+timestamp+'.png');
}
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(error) {