This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrenderer.js
67 lines (56 loc) · 1.81 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const { ipcRenderer, remote, shell } = require('electron');
const { dialog } = remote;
const setApplicationMenu = require('./menu');
const form = document.querySelector('form');
const inputs = {
source: form.querySelector('input[name="source"]'),
destination: form.querySelector('input[name="destination"]'),
name: form.querySelector('input[name="name"]'),
fps: form.querySelector('input[name="fps"]'),
};
const buttons = {
source: document.getElementById('chooseSource'),
destination: document.getElementById('chooseDestination'),
submit: form.querySelector('button[type="submit"]'),
};
ipcRenderer.on('did-finish-load', () => {
setApplicationMenu();
});
ipcRenderer.on('processing-did-succeed', (event, html) => {
shell.openExternal(`file://${html}`);
});
ipcRenderer.on('processing-did-fail', (event, error) => {
console.error(error);
alert('Failed :\'(');
});
buttons.source.addEventListener('click', () => {
const directory = dialog.showOpenDialog({
properties: ['openDirectory'],
});
if (directory) {
inputs.source.value = directory;
}
});
buttons.destination.addEventListener('click', () => {
const directory = dialog.showOpenDialog({
properties: [
'openDirectory',
'createDirectory',
],
});
if (directory) {
inputs.destination.value = directory;
}
});
form.addEventListener('submit', (event) => {
event.preventDefault();
ipcRenderer.send('did-submit-form', {
source: inputs.source.value,
destination: inputs.destination.value,
name: inputs.name.value,
fps: inputs.fps.value,
});
});