-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
77 lines (65 loc) · 2.08 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { currentPanel, popCurrentPanel, setCurrentPanel, navigateMusicVideos } from './modules/renderer/renderer-globals.js'
import { getSettings } from './modules/renderer/renderer-settings.js'
/**
* Convert all `a` link elements to open in the user's default browser.
*/
function captureLinks() {
const links = document.getElementsByTagName('a')
for (const link of links) {
link.addEventListener('click', (event) => {
event.preventDefault()
window.electronAPI.openLink(event.target.href)
})
}
}
/**
* Initializes the app by creating the media upload elements of the `video` panel and then
* displaying the initial panel view based on whether or not a `appSettings.homeFolder` has been saved in
* the app configuration file. Also captures all links so they open in the default browser.
*/
async function startup() {
await getSettings()
}
captureLinks()
// Home Screen Buttons
document.getElementById('action-list').addEventListener('click', () => {
setCurrentPanel('videos')
})
document.getElementById('action-settings').addEventListener('click', () => {
setCurrentPanel('settings')
})
document.getElementById('action-about').addEventListener('click', () => {
setCurrentPanel('about')
})
// Footer Buttons
document.getElementById('nav-about').addEventListener('click', () => {
if (currentPanel === 'about') {
popCurrentPanel()
} else {
setCurrentPanel('about')
}
})
document.getElementById('nav-settings').addEventListener('click', () => {
if (currentPanel === 'settings') {
popCurrentPanel()
} else {
setCurrentPanel('settings')
}
})
document.getElementById('nav-back').addEventListener('click', () => {
popCurrentPanel()
})
document.getElementById('nav-prev').addEventListener('click', () => {
if (!document.getElementById('nav-prev').classList.contains('disabled')) {
navigateMusicVideos(-1)
}
})
document.getElementById('nav-next').addEventListener('click', () => {
if (!document.getElementById('nav-next').classList.contains('disabled')) {
navigateMusicVideos(1)
}
})
document.addEventListener('DOMContentLoaded', () => {
console.log('DOM loaded')
startup()
})