2020-05-19 11:21:12 +02:00
|
|
|
const {ipcRenderer, remote, shell} = require('electron');
|
2020-05-19 10:54:00 +02:00
|
|
|
|
|
|
|
let currentVersion;
|
|
|
|
let updateStatus;
|
2020-05-19 11:21:12 +02:00
|
|
|
let updateInfo;
|
|
|
|
let updateButton;
|
2020-05-20 17:13:33 +02:00
|
|
|
let config;
|
|
|
|
|
|
|
|
let securityButtonField, homeButtonField, backButtonField, forwardButtonField, refreshButtonField;
|
2020-05-19 10:54:00 +02:00
|
|
|
|
|
|
|
ipcRenderer.on('current-version', (e, version) => {
|
|
|
|
currentVersion.innerText = `Version: ${version.version}`;
|
|
|
|
});
|
|
|
|
|
2020-05-20 17:13:33 +02:00
|
|
|
ipcRenderer.on('config', (e, c) => {
|
|
|
|
config = c;
|
|
|
|
securityButtonField.checked = config.securityButton;
|
|
|
|
homeButtonField.checked = config.homeButton;
|
|
|
|
backButtonField.checked = config.backButton;
|
|
|
|
forwardButtonField.checked = config.forwardButton;
|
|
|
|
refreshButtonField.checked = config.refreshButton;
|
|
|
|
});
|
|
|
|
|
2020-05-19 10:54:00 +02:00
|
|
|
ipcRenderer.on('updateStatus', (e, available, version) => {
|
2020-05-19 11:21:12 +02:00
|
|
|
console.log(available, version);
|
|
|
|
updateInfo = version;
|
2020-05-19 10:54:00 +02:00
|
|
|
if (available) {
|
2020-05-19 11:21:12 +02:00
|
|
|
updateStatus.innerHTML = 'A new update is available!';
|
|
|
|
updateButton.classList.remove('hidden');
|
2020-05-19 10:54:00 +02:00
|
|
|
} else {
|
|
|
|
updateStatus.innerText = 'Tabs is up to date.';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function save() {
|
|
|
|
const formData = new FormData(document.querySelector('form'));
|
2020-05-20 17:13:33 +02:00
|
|
|
|
|
|
|
config.securityButton = formData.get('security-button') === 'on';
|
|
|
|
config.homeButton = formData.get('home-button') === 'on';
|
|
|
|
config.backButton = formData.get('back-button') === 'on';
|
|
|
|
config.forwardButton = formData.get('forward-button') === 'on';
|
|
|
|
config.refreshButton = formData.get('refresh-button') === 'on';
|
|
|
|
|
|
|
|
ipcRenderer.send('save-config', config);
|
2020-05-19 10:54:00 +02:00
|
|
|
remote.getCurrentWindow().close();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
currentVersion = document.getElementById('current-version');
|
|
|
|
updateStatus = document.getElementById('update-status');
|
2020-05-19 11:21:12 +02:00
|
|
|
updateButton = document.getElementById('download-button');
|
|
|
|
updateButton.addEventListener('click', () => {
|
2020-05-19 11:46:34 +02:00
|
|
|
shell.openExternal(`https://github.com/ArisuOngaku/tabs/releases/download/v${updateInfo.version}/${updateInfo.path}`)
|
2020-05-19 11:21:12 +02:00
|
|
|
.catch(console.error);
|
|
|
|
});
|
2020-05-19 10:54:00 +02:00
|
|
|
|
2020-05-20 17:13:33 +02:00
|
|
|
securityButtonField = document.getElementById('security-button');
|
|
|
|
homeButtonField = document.getElementById('home-button');
|
|
|
|
backButtonField = document.getElementById('back-button');
|
|
|
|
forwardButtonField = document.getElementById('forward-button');
|
|
|
|
refreshButtonField = document.getElementById('refresh-button');
|
|
|
|
|
2020-05-19 10:54:00 +02:00
|
|
|
ipcRenderer.send('syncSettings');
|
|
|
|
ipcRenderer.send('checkForUpdates');
|
|
|
|
});
|