forked from farzd/keydox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
43 lines (38 loc) · 879 Bytes
/
utils.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
let currentImage = 0
let totalImages = 0
const changeImg = (img, mainWindow) => {
currentImage = img
mainWindow.webContents.executeJavaScript(
`document.querySelector("img").classList = "class${img}";`
)
}
const incrementTotalRegisteredImages = () => {
totalImages++
}
const incrementImg = mainWindow => {
currentImage++
currentImage = currentImage % totalImages
changeImg(currentImage, mainWindow)
}
const decrementImg = mainWindow => {
currentImage--
if (currentImage < 0) {
currentImage = totalImages - 1
} else {
currentImage = currentImage % totalImages
}
changeImg(currentImage, mainWindow)
}
const toggleWindow = mainWindow => {
if (mainWindow.isVisible()) {
return mainWindow.hide()
}
mainWindow.show()
}
module.exports = {
changeImg,
toggleWindow,
incrementTotalRegisteredImages,
incrementImg,
decrementImg
}