Get screenshot working on Linux; use case name and timestamp in default filename.
This commit is contained in:
parent
e1ccfb95a1
commit
47ce72af8c
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# npm install likes to mess with this, also it's huge
|
||||
node_modules
|
|
@ -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>
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user