minecraft-monitor/web/js/load-map.js

13 lines
516 B
JavaScript
Raw Normal View History

2019-03-19 04:10:11 +00:00
// only load the map viewer when it's visible (and javascript is enabled)
document.addEventListener('DOMContentLoaded', (event) => {
const setMap = () => { document.querySelector('#map').src = 'map/' }
const details = document.querySelector('details:last-child')
// if <details> is not supported (looking at you, Edge), the frame will be
// visible by default, so just set the target immediately
if ('open' in details)
details.addEventListener('toggle', setMap, { once: true })
else
setMap()
})