From 8836674fd8494e14352171de59160918cd23e23e Mon Sep 17 00:00:00 2001 From: DeionSi Date: Fri, 13 Jan 2023 22:43:24 +0100 Subject: [PATCH] Move button handlers from template to renderer --- assets/js/main.js | 48 ----------------------------------------- index.html | 4 ++-- renderer.js | 55 ++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 49 insertions(+), 58 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index bd875a7..9ccaa9e 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -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); \ No newline at end of file diff --git a/index.html b/index.html index dee5748..ad39e15 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,6 @@ - @@ -146,7 +145,7 @@

@@ -196,5 +195,6 @@ + \ No newline at end of file diff --git a/renderer.js b/renderer.js index 4175a43..e95b5ab 100644 --- a/renderer.js +++ b/renderer.js @@ -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'); - }); -}); \ No newline at end of file +$(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'); + }); + +}); \ No newline at end of file