const { ipcRenderer } = require('electron'); const root = document.querySelector('#root'); const { version: appVersion } = ipcRenderer.sendSync( 'get-bootstrap-data' ); const iconPath = __dirname + '/../icons/icon.png'; root.style.display = 'flex'; root.style.flexDirection = 'column'; root.style.alignItems = 'center'; root.style.padding = '10px'; root.innerHTML = ` Actual
Version ${appVersion}
© 2020 Shift Reset LLC
`; const container = root.querySelector('#container'); container.style.height = '45px'; container.style.textAlign = 'center'; const updateEl = root.querySelector('#update-check'); const applyUpdateEl = root.querySelector('#apply-update'); applyUpdateEl.style.display = 'none'; const successEl = root.querySelector('#success'); successEl.style.display = 'none'; successEl.style.textAlign = 'center'; const errorEl = root.querySelector('#error'); errorEl.style.display = 'none'; root.querySelector('#update-check button').addEventListener('click', () => { ipcRenderer.send('check-for-update'); }); root.querySelector('#apply-update button').addEventListener('click', () => { ipcRenderer.send('apply-update'); }); ipcRenderer.on('update-checking', () => { updateEl.style.display = 'none'; successEl.innerHTML = 'Checking...'; successEl.style.display = 'block'; errorEl.style.display = 'none'; }); ipcRenderer.on('update-available', () => { updateEl.style.display = 'none'; successEl.innerHTML = 'Update available! Downloading...'; successEl.style.display = 'block'; }); ipcRenderer.on('update-downloaded', () => { updateEl.style.display = 'none'; successEl.style.display = 'none'; applyUpdateEl.style.display = 'block'; }); ipcRenderer.on('update-not-available', () => { updateEl.style.display = 'none'; successEl.innerHTML = 'All up to date!'; successEl.style.display = 'block'; }); ipcRenderer.on('update-error', (event, msg) => { updateEl.style.display = 'block'; successEl.style.display = 'none'; let text; if (msg.domain === 'SQRLUpdaterErrorDomain' && msg.code === 8) { text = ` Error updating the app. It looks like it's running outside of the applications folder and can't be written to. Please install the app before updating. `; } else { text = 'Error updating the app. Please try again later.'; } // prettier-ignore errorEl.innerHTML = `
${text}
`; errorEl.style.display = 'block'; }); document.addEventListener('keydown', e => { // Disable zoom with keys + and - if (e.keyCode === 187 || e.keyCode === 189) { e.preventDefault(); } });