I am trying to make a countdown for a really basic app in electron. I created a button in my .html file that is listed below. I also created an empty function called startTimer. How do I go about making a timer that will begin once I press the button? I assume that this needs to be done in my render.js file? Thanks in advance!
<button onclick="startTimer()">Start Timer</button>
main.js :
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('index.html')
win.webContents.openDevTools()
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body>
<button onclick="startTimer()">Start Timer</button>
<script src="./render.js"></script>
</body>
</html>