-
Notifications
You must be signed in to change notification settings - Fork 7
/
uiCommon.js
68 lines (37 loc) · 1.36 KB
/
uiCommon.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
68
/****************************************************************************
* uiCommons.js
* openacousticdevices.info
* February 2021
*****************************************************************************/
/* Functions which control elements common to the expansion and split windows */
const electron = require('electron');
const nightMode = require('../nightMode.js');
const fileButton = document.getElementById('file-button');
function getSelectedRadioValue (radioName) {
return parseInt(document.querySelector('input[name="' + radioName + '"]:checked').value);
}
exports.getSelectedRadioValue = getSelectedRadioValue;
/* Pause execution */
exports.sleep = (milliseconds) => {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
};
electron.ipcRenderer.on('night-mode', (e, nm) => {
if (nm !== undefined) {
nightMode.setNightMode(nm);
} else {
nightMode.toggle();
}
});
/* Update text on selection button to reflect selection mode (file or folder selection) */
exports.updateButtonText = () => {
const selectionType = getSelectedRadioValue('selection-radio');
if (selectionType === 0) {
fileButton.innerText = 'Select Files';
} else {
fileButton.innerText = 'Select Folders';
}
};