big ass front end cleanup
This commit is contained in:
parent
6924c76f4c
commit
5322c99183
29 changed files with 4787 additions and 4562 deletions
74
src/renderer/main/events.js
Normal file
74
src/renderer/main/events.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
const Events = {
|
||||
InitEvents() {
|
||||
const app = window.app
|
||||
// Key binds
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.keyCode === 70 && e.ctrlKey) {
|
||||
app.$refs.searchInput.focus()
|
||||
app.$refs.searchInput.select()
|
||||
}
|
||||
});
|
||||
|
||||
// add event listener for when window.location.hash changes
|
||||
window.addEventListener("hashchange", function () {
|
||||
app.appRoute(window.location.hash)
|
||||
});
|
||||
|
||||
// Key bind to unjam MusicKit in case it fails: CTRL+F10
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.ctrlKey && event.keyCode == 121) {
|
||||
try {
|
||||
app.mk._services.mediaItemPlayback._currentPlayer.stop()
|
||||
} catch (e) {
|
||||
}
|
||||
try {
|
||||
app.mk._services.mediaItemPlayback._currentPlayer.destroy()
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("mouseup", (e) => {
|
||||
if (e.button === 3) {
|
||||
e.preventDefault()
|
||||
app.navigateBack()
|
||||
} else if (e.button === 4) {
|
||||
e.preventDefault()
|
||||
app.navigateForward()
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.ctrlKey && event.keyCode == 122) {
|
||||
try {
|
||||
ipcRenderer.send('detachDT', '')
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Hang Timer
|
||||
app.hangtimer = setTimeout(() => {
|
||||
if (confirm("Cider is not responding. Reload the app?")) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 10000)
|
||||
|
||||
// Refresh Focus
|
||||
function refreshFocus() {
|
||||
if (document.hasFocus() == false) {
|
||||
app.windowFocus(false)
|
||||
} else {
|
||||
app.windowFocus(true)
|
||||
}
|
||||
setTimeout(refreshFocus, 200);
|
||||
}
|
||||
|
||||
app.getHTMLStyle()
|
||||
|
||||
refreshFocus();
|
||||
}
|
||||
}
|
||||
|
||||
export {Events}
|
Loading…
Add table
Add a link
Reference in a new issue