5 * @copyright 2018 - Ken Grimes
6 * @summmary Script for populating text to summary box on svg:hover
9 window
.onload
= () => {
10 const header
= document
.body
.getElementsByTagName('header').item(0)
11 const nav
= document
.body
.getElementsByTagName('nav').item(0)
12 const main
= document
.body
.getElementsByTagName('main').item(0)
13 const navAnchors
= Array
.from(nav
.getElementsByTagName('div').item(0).getElementsByTagName('a'))
14 const pageDisplay
= nav
.getElementsByTagName('footer').item(0)
15 const currentPageName
= `${pageDisplay.innerHTML}`
16 const updateNav
= () => navAnchors
.forEach((a
) => {
17 const summary
= a
.getElementsByTagName('summary').item(0).innerHTML
18 const svg
= a
.getElementsByTagName('svg').item(0)
19 a
.addEventListener('mouseover', () => pageDisplay
.innerHTML
= summary
)
20 a
.addEventListener('mousedown', () => pageDisplay
.innerHTML
= summary
)
21 a
.addEventListener('mouseout', () => pageDisplay
.innerHTML
= currentPageName
)
25 let oldScrollY
= window
.scrollY
29 let upDelay
= _upDelay
30 const navUp
= () => nav
.style
.top
= Math
.min(parseInt(nav
.style
.top
,10) + (oldScrollY
- window
.scrollY
), 0) + 'px'
31 const navDown
= () => nav
.style
.top
= Math
.max(parseInt(nav
.style
.top
,10) - (window
.scrollY
- oldScrollY
), -nav
.offsetHeight
) + 'px'
32 nav
.style
.top
= 0 + 'px'
33 window
.onscroll
= () => {
34 if (window
.matchMedia("(orientation: portrait)").matches
) {
35 if (window
.scrollY
< oldScrollY
) /* up */ {
37 downDelay
= _downDelay
47 oldScrollY
= window
.scrollY
52 const resizeIFrame
= (iframe
) => {
53 iframe
.style
.height
= 0
54 iframe
.style
.height
= (iframe
.contentWindow
.document
.body
.scrollHeight
* 1.2) + 'px';