minor updates to design

This commit is contained in:
Queen Bee 2018-01-19 08:25:29 -08:00
parent e1ccfb95a1
commit 7fcfe80d0a
2 changed files with 5 additions and 23 deletions

View File

@ -17,7 +17,7 @@
</form>
<label id="screenshot-path">Path:</label><br>
<button id="path-button" class="btn btn-warning">Select Path</button><br>
<button id="path-button" class="btn btn-primary">Select Path</button><br>
<button id="screen-shot" class="btn btn-primary">Take Screenshot</button>
</div>
</body>

View File

@ -1,9 +1,7 @@
const electron = require('electron');
const remote = electron.remote;
const desktopCapturer = electron.desktopCapturer;
const electronScreen = electron.screen;
const shell = electron.shell;
const dialog = remote.dialog;
const fs = require('fs');
const os = require('os');
@ -11,22 +9,9 @@ const path = require('path');
const screenshot = document.getElementById('screen-shot');
const screenshotMsg = document.getElementById('screenshot-path');
const pathButton = document.getElementById('path-button');
var screenshotPath = '';
pathButton.addEventListener('click', function(event) {
dialog.showSaveDialog(function(fileName) {
if (fileName === undefined) {
return;
}
screenshotPath = fileName;
screenshotMsg.textContent = screenshotPath;
});
});
screenshot.addEventListener('click', function(event) {
screenshotMsg.textContent = "Gathering screenshot...";
screenshotMsg.textContent = 'Gathering screenshot...';
const thumbSize = determineScreenShot();
let options = { types: ['screen'], thumbnailSize: thumbSize };
@ -35,13 +20,10 @@ screenshot.addEventListener('click', function(event) {
sources.forEach(function(source) {
if (source.name === 'Entire Screen' || source.name === 'Screen 1') {
const screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
if (screenshotPath === '') {
screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
}
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(error) {
if (error) return console.log(error.message);
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(err) {
if (err) return console.log(err.message);
shell.openExternal('file://' + screenshotPath);
var message = 'Saved screenshot to: ' + screenshotPath;