From 47ce72af8ca2bdd5d624c785cb27a16f4413b165 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Sat, 6 Jan 2018 23:47:34 -0800 Subject: [PATCH] Get screenshot working on Linux; use case name and timestamp in default filename. --- .gitignore | 2 ++ index.html | 6 +++--- renderer.js | 8 ++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48d8ae3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# npm install likes to mess with this, also it's huge +node_modules diff --git a/index.html b/index.html index 23c35e1..1a169b8 100644 --- a/index.html +++ b/index.html @@ -11,9 +11,9 @@

DocumentIt

-
-
- +
+
+

diff --git a/renderer.js b/renderer.js index 836fc80..4522603 100644 --- a/renderer.js +++ b/renderer.js @@ -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) {