Skip to content

Commit

Permalink
Create index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinedu25 committed Jun 21, 2021
0 parents commit 7278faa
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<head>
<title> Testing Electron Updater</title>
<style>
body{
box-sizing: border-box;
margin: 0;
padding: 20px;
font-family: sans-serif;
background-color: #eaeaea;
text-align: center;
}

#notification {
position: fixed;
bottom: 20px;
left: 20px;
width: 200px;
padding: 20px;
border-radius: 5px;
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.hidden {
display: none;
}
</style>
</head>
<body>
<h1>Testing Electron Updater</h1>
<p id = "app-version"></p>
<div id="notification" class="hidden">
<p id="message"></p>
<button id="close-button" onClick="closeNotification()">
Close
</button>
<button id="restart-button" onClick="restartApp()" class="hidden">
Restart
</button>
</div>
<script>
const {ipcRenderer} = require('electron');
const version = document.getElementById('app-version');

ipcRenderer.send('app_version');
ipcRenderer.on('app_version', (event, arg) => {
ipcRenderer.removeAllListeners('app_version');
version.innerText = 'Version ' + arg.version;
});

const notification = document.getElementById('notification');
const message = document.getElementById('message');
const restartButton = document.getElementById('restart-button');

ipcRenderer.on('update_available', () => {
ipcRenderer.removeAllListeners('update_available');
message.innerText = 'A new update is available. Downloading now...';
notification.classList.remove('hidden');
});
ipcRenderer.on('update_downloaded', () => {
ipcRenderer.removeAllListeners('update_downloaded');
message.innerText = 'Update Downloaded. It will be installed on restart. Restart now?';
restartButton.classList.remove('hidden');
notification.classList.remove('hidden');
});

function closeNotification() {
notification.classList.add('hidden');
}
function restartApp() {
ipcRenderer.send('restart_app');
}

ipcMain.on('restart_app', () => {
autoUpdater.quitAndInstall();
});

</script>
</body>

0 comments on commit 7278faa

Please sign in to comment.