Fix bad inline javascript usage

This commit is contained in:
Alice Gaudon 2020-05-26 10:54:47 +02:00
parent bc620f0892
commit 9a71005014
4 changed files with 15 additions and 5 deletions

View File

@ -16,7 +16,7 @@
</head> </head>
<body> <body>
<form action="javascript: save();"> <form>
<div class="form-header"> <div class="form-header">
<h1>Loading...</h1> <h1>Loading...</h1>
</div> </div>
@ -78,7 +78,7 @@
<div class="form-footer"> <div class="form-footer">
<div class="form-group" id="buttons"> <div class="form-group" id="buttons">
<button id="cancel-button">Cancel</button> <button id="cancel-button" type="button">Cancel</button>
<button type="submit">Save</button> <button type="submit">Save</button>
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@
</head> </head>
<body> <body>
<form action="javascript: save();"> <form>
<div class="form-header"> <div class="form-header">
<h1>Settings</h1> <h1>Settings</h1>
</div> </div>

View File

@ -65,6 +65,11 @@ document.addEventListener('DOMContentLoaded', () => {
remote.getCurrentWindow().close(); remote.getCurrentWindow().close();
}); });
document.querySelector('form')?.addEventListener('submit', e => {
e.preventDefault();
save();
});
ipcRenderer.send('sync-settings'); ipcRenderer.send('sync-settings');
document.getElementById('userAgentAutoFill')?.addEventListener('click', () => { document.getElementById('userAgentAutoFill')?.addEventListener('click', () => {
@ -170,7 +175,7 @@ function loadServiceValues() {
} }
} }
(window as any).save = () => { function save() {
let form = document.querySelector('form'); let form = document.querySelector('form');
if (!form) return; if (!form) return;
const formData = new FormData(form); const formData = new FormData(form);

View File

@ -36,7 +36,7 @@ ipcRenderer.on('updateStatus', (e, available, version) => {
} }
}); });
(window as any).save = () => { function save() {
let form = document.querySelector('form'); let form = document.querySelector('form');
if (!form) return; if (!form) return;
const formData = new FormData(form); const formData = new FormData(form);
@ -71,6 +71,11 @@ document.addEventListener('DOMContentLoaded', () => {
remote.getCurrentWindow().close(); remote.getCurrentWindow().close();
}); });
document.querySelector('form')?.addEventListener('submit', e => {
e.preventDefault();
save();
});
ipcRenderer.send('syncSettings'); ipcRenderer.send('syncSettings');
ipcRenderer.send('checkForUpdates'); ipcRenderer.send('checkForUpdates');
}); });