Merge pull request #4 from zyphlar/issue2
Get screenshot working on Linux; case name & timestamp in default filename
This commit is contained in:
commit
51c9f4504b
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">
|
<div class="container window align-content-center">
|
||||||
<h1>DocumentIt</h1>
|
<h1>DocumentIt</h1>
|
||||||
<form>
|
<form>
|
||||||
<input type="text" name="casename" placeholder="Case Name"><br>
|
<input type="text" id="casename" name="casename" placeholder="Case Name"><br>
|
||||||
<input type="text" name="socialmedia" placeholder="Social Media"><br>
|
<input type="text" id="socialmedia" name="socialmedia" placeholder="Social Media"><br>
|
||||||
<textarea name="description" placeholder="Incident Description..." rows="10" cols="30"></textarea>
|
<textarea id="description" name="description" placeholder="Incident Description..." rows="10" cols="30"></textarea>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<label id="screenshot-path">Path:</label><br>
|
<label id="screenshot-path">Path:</label><br>
|
||||||
|
|
|
@ -12,8 +12,10 @@ const path = require('path');
|
||||||
const screenshot = document.getElementById('screen-shot');
|
const screenshot = document.getElementById('screen-shot');
|
||||||
const screenshotMsg = document.getElementById('screenshot-path');
|
const screenshotMsg = document.getElementById('screenshot-path');
|
||||||
const pathButton = document.getElementById('path-button');
|
const pathButton = document.getElementById('path-button');
|
||||||
|
const casenameField = document.getElementById('casename');
|
||||||
|
|
||||||
var screenshotPath = '';
|
var screenshotPath = '';
|
||||||
|
var caseName = '';
|
||||||
|
|
||||||
pathButton.addEventListener('click', function(event) {
|
pathButton.addEventListener('click', function(event) {
|
||||||
dialog.showSaveDialog(function(fileName) {
|
dialog.showSaveDialog(function(fileName) {
|
||||||
|
@ -34,10 +36,12 @@ screenshot.addEventListener('click', function(event) {
|
||||||
if (error) return console.log(error.message);
|
if (error) return console.log(error.message);
|
||||||
|
|
||||||
sources.forEach(function(source) {
|
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 === '') {
|
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) {
|
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user