forked from hgraph-io/nft-ecosystem-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
26 lines (22 loc) · 828 Bytes
/
main.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
import {renderGraphs, renderSingleMetrics} from './modules/ui.js'
// render when select menus change
document.querySelectorAll('select').forEach((e) => {
e.onchange = (e) => {
renderGraphs(e.target)
}
})
// switch between USD and HBAR
document.getElementById('switch').onchange = (e) => {
renderSingleMetrics(!e.target.checked)
renderGraphs(e.target)
}
// see if DOM is already available then render inital state
if (document.readyState === 'complete' || document.readyState === 'interactive') {
setTimeout(renderGraphs, 1)
setTimeout(renderSingleMetrics, 1)
} else {
document.addEventListener('DOMContentLoaded', renderGraphs)
document.addEventListener('DOMContentLoaded', renderSingleMetrics)
}
document.addEventListener('resize', renderGraphs)
document.addEventListener('resize', renderSingleMetrics)