Repository navigation
Expand file tree
/
Copy pathpreload.js
More file actions
60 lines (56 loc) · 2.21 KB
/
Copy pathpreload.js
File metadata and controls
60 lines (56 loc) · 2.21 KB
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
const {ipcRenderer, contextBridge} = require('electron')
//This event runs when the HTML is loaded
window.addEventListener('DOMContentLoaded', () => {
//Get the app version information from the main process and applies to the title
ipcRenderer.invoke("get-app-version").then(function (result) {
document.title = "투표 / 뽑기 프로그램 v" + result
splashScreen()
})
})
//Save CSV vote result
contextBridge.exposeInMainWorld("externalfunctions", {
saveCSV: (csvdata) => {
ipcRenderer.send("save-csv", csvdata)
},
exitApp: () => { ipcRenderer.send("exit-app") },
saveInputData: (data) => {
ipcRenderer.send("save-input", data)
}
})
//Splash screen
async function splashScreen() {
document.getElementById("splash-title").innerText = "";
await wait(200);
document.getElementById("splash-title").innerText += "투"
await wait(200);
document.getElementById("splash-title").innerText += "표"
await wait(200);
document.getElementById("splash-title").innerText += "및"
await wait(200);
document.getElementById("splash-title").innerText += " 뽑"
await wait(200);
document.getElementById("splash-title").innerText += "기"
await wait(200);
document.getElementById("splash-title").innerText += " 프"
await wait(200);
document.getElementById("splash-title").innerText += "로"
await wait(200);
document.getElementById("splash-title").innerText += "그"
await wait(200);
document.getElementById("splash-title").innerText += "램"
await wait(200);
/**
document.getElementById("splash-loading-text").classList.remove("d-none")
await wait(2000);
**/
document.getElementById("splash").classList.add("d-none")
document.getElementById("setUpScreen").classList.remove("d-none")
ipcRenderer.invoke("is-dev").then(function (result) {
if (result) {
document.getElementById("devModeAlert").style.display = "initial"
document.getElementById("devModeAlert").classList.add("splash-loading-text")
}
})
}
//Wait promise
const wait = (timeToDelay) => new Promise((resolve) => setTimeout(resolve, timeToDelay))