Skip to content

Commit

Permalink
Improved shortcut handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Apr 9, 2022
1 parent 67c874f commit 0c0439b
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 199 deletions.
16 changes: 8 additions & 8 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,23 +317,23 @@ <h4 data-loc>Reset the search bar after you copied a code. Useful if you copy an

<!-- shortcuts -->
<div id="shortcuts" class="tabcontent part hidden">
<h3 data-loc>Shortcuts</h3>
<h4 data-loc>You can modify the shortcuts here, read the documentation for more information. Shortcuts not work on this tab, go to any other settings tab to reactivate them!</h4>
<div class="shortcutsDiv">
<!-- shortcuts -->
</div>
<hr />
<h3 data-loc>Global shortcuts</h3>
<h4 data-loc>You can modify the global shortcuts here, read the documentation for more information. Shortcuts not work on this tab, go to any other settings tab to reactivate them!</h4>
<h4 data-loc>You can use these shortcuts everywhere, even outside the application. Use english characters only, during editing shortcuts don't work.</h4>
<div class="globalShortcutsDiv">
<!-- global shortcuts -->
</div>
<hr />
<h3 data-loc>Shortcuts</h3>
<h4 data-loc>You can use these shortcuts inside the application only. Use english characters only, during editing shortcuts don't work.</h4>
<div class="shortcutsDiv">
<!-- shortcuts -->
</div>
</div>

<!-- experimental -->
<div id="experimental" class="tabcontent part hidden">
<div class="mx-auto mt-5 rounded-2xl bg-gray-800 md:w-4/5 lg:w-2/3">
<h3 class="relative top-7">Experimental features</h3>
<h3 class="relative top-7" data-loc>Experimental features</h3>
<h4 class="pt-5" data-loc>These features are under development and can be unstable! Use it at your own risk!</h4>
<button class="buttoni mb-8" onclick="experimentalDocs()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
Expand Down
34 changes: 4 additions & 30 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ if (settings.security.require_password === null && settings.security.password ==
}, 100)
}

// Get current window
const currentWindow = BrowserWindow.getFocusedWindow()

/**
* Elements
*/
Expand Down Expand Up @@ -329,8 +326,10 @@ const toggleWindowCaptureSwitch = () => {
* Clear all data
*/
const clearData = () => {
const current_window = BrowserWindow.getFocusedWindow()

dialog
.showMessageBox(currentWindow, {
.showMessageBox(current_window, {
title: "Authme",
buttons: [lang.button.yes, lang.button.no],
defaultId: 1,
Expand All @@ -342,7 +341,7 @@ const clearData = () => {
.then((result) => {
if (result.response === 0) {
dialog
.showMessageBox(currentWindow, {
.showMessageBox(current_window, {
title: "Authme",
buttons: [lang.button.yes, lang.button.no],
defaultId: 1,
Expand Down Expand Up @@ -747,7 +746,6 @@ const hide = () => {
*/
document.querySelector(".general").disabled = true
document.querySelector(".general").classList.add("buttonmselected")
let shortcut = false

/**
* Remove menu button styles
Expand Down Expand Up @@ -782,12 +780,6 @@ const menu = (name) => {
window.location = `${`${window.location}`.replace(/#[A-Za-z0-9_]*$/, "")}#header`

shortcut = true

setTimeout(() => {
checkForIssuers()
}, 100)

ipc.send("shortcuts")
} else if (name === "general") {
storage.settings_page = "general"

Expand All @@ -801,12 +793,6 @@ const menu = (name) => {
document.querySelector(".codes").disabled = false

window.location = `${`${window.location}`.replace(/#[A-Za-z0-9_]*$/, "")}#header`

if (shortcut === true) {
ipc.send("shortcuts")

shortcut = false
}
} else if (name === "experimental") {
storage.settings_page = "experimental"

Expand All @@ -820,12 +806,6 @@ const menu = (name) => {
document.querySelector(".codes").disabled = false

window.location = `${`${window.location}`.replace(/#[A-Za-z0-9_]*$/, "")}#header`

if (shortcut === true) {
ipc.send("shortcuts")

shortcut = false
}
} else if (name === "codes") {
storage.settings_page = "codes"

Expand All @@ -839,12 +819,6 @@ const menu = (name) => {
document.querySelector(".codes").disabled = true

window.location = `${`${window.location}`.replace(/#[A-Za-z0-9_]*$/, "")}#header`

if (shortcut === true) {
ipc.send("shortcuts")

shortcut = false
}
}

const tabcontent = document.getElementsByClassName("tabcontent")
Expand Down
Loading

0 comments on commit 0c0439b

Please sign in to comment.