Move button handlers from template to renderer

This commit is contained in:
DeionSi 2023-01-13 22:43:24 +01:00
parent d809f5ffcc
commit 8836674fd8
3 changed files with 49 additions and 58 deletions

View File

@ -183,52 +183,4 @@
}
});
// Button handlers
$(document).on('click', '#btnChoosePort', function(event) {
event.preventDefault();
$("[href='#port']").trigger('click');
});
$(document).on('click', '#btnBasetune', function(event) {
event.preventDefault();
$("[href='#basetunes']").trigger('click');
});
$(document).on('click', '#btnLoader', function(event) {
event.preventDefault();
$("[href='#loader']").trigger('click');
});
$(document).on('click', '#btnDetails', function(event) {
event.preventDefault();
refreshDetails();
$("[href='#details']").trigger('click');
});
$(document).on('click', '#btnInstall', function(event) {
event.preventDefault();
$("[href='#progress']").trigger('click');
uploadFW();
});
$(document).on('click', '#btnReinstall', function(event) {
event.preventDefault();
$("[href='#progress']").trigger('click');
uploadFW();
});
$(document).on('click', '#btnDownloadBasetune', function(event) {
event.preventDefault();
$("[href='#basetunewarning']").trigger('click');
const select = document.getElementById('basetunesSelect');
const selectedTune = select.options[select.selectedIndex];
document.getElementById("tuneBoard").innerHTML = selectedTune.dataset.board;
});
$(document).on('click', '#btnDownloadCancel', function(event) {
event.preventDefault();
$("[href='#basetunes']").trigger('click');
});
})(jQuery);

View File

@ -11,7 +11,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="assets/css/main.css" />
<script src="renderer.js" ></script>
</head>
<body>
@ -146,7 +145,7 @@
</div>
<ul class="actions">
<li><input type='button' id="btnDownloadBasetune" value="Download tune" /></li>
<li><input type='button' value="Exit" id="btnExit2" /></li>
<li><input type='button' value="Exit" id="btnExit" /></li>
</ul>
</p>
</div>
@ -196,5 +195,6 @@
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
<script src="renderer.js"></script>
</body>
</html>

View File

@ -630,11 +630,50 @@ window.onload = function () {
};
window.addEventListener('DOMContentLoaded', () => {
document.getElementById('btnExit').addEventListener('click', () => {
ipcRenderer.invoke('quit-app');
});
document.getElementById('btnExit2').addEventListener('click', () => {
ipcRenderer.invoke('quit-app');
});
});
$(function(){
// Button handlers
$(document).on('click', '#btnChoosePort', function(event) {
$("[href='#port']").trigger('click');
});
$(document).on('click', '#btnBasetune', function(event) {
$("[href='#basetunes']").trigger('click');
});
$(document).on('click', '#btnLoader', function(event) {
$("[href='#loader']").trigger('click');
});
$(document).on('click', '#btnDetails', function(event) {
refreshDetails();
$("[href='#details']").trigger('click');
});
$(document).on('click', '#btnInstall', function(event) {
$("[href='#progress']").trigger('click');
uploadFW();
});
$(document).on('click', '#btnReinstall', function(event) {
$("[href='#progress']").trigger('click');
uploadFW();
});
$(document).on('click', '#btnDownloadBasetune', function(event) {
const select = document.getElementById('basetunesSelect');
const selectedTune = select.options[select.selectedIndex];
document.getElementById("tuneBoard").innerHTML = selectedTune.dataset.board;
$("[href='#basetunewarning']").trigger('click');
});
$(document).on('click', '#btnDownloadCancel', function(event) {
$("[href='#basetunes']").trigger('click');
});
$(document).on('click', '#btnExit', function(event) {
ipcRenderer.invoke('quit-app');
});
});