d48ee08d2c55c643d82c125250742dec2b4b6a46
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
27 let downDelay
= _downDelay
32 const navUpdate
= () => {
33 if (window
.matchMedia("(orientation: portrait)").matches
) {
34 if (window
.scrollY
< oldScrollY
) /* up */ {
36 downDelay
= _downDelay
37 else if (upDelay
-- <= 0) {
38 top
= Math
.min(top
+ (oldScrollY
- window
.scrollY
), 0)
39 nav
.style
.top
= top
+ 'px'
42 else if (window
.scrollY
> oldScrollY
) /* down */{
43 if (downDelay
-- <= 0) {
44 top
= Math
.max(top
- (window
.scrollY
- oldScrollY
), -nav
.offsetHeight
)
45 nav
.style
.top
= top
+ 'px'
49 window
.requestAnimationFrame(navUpdate
)
56 downDelay
= _downDelay
58 setTimeout(navUpdate
, 1000)
60 oldScrollY
= window
.scrollY
65 const resizeIFrame
= (iframe
) => {
66 iframe
.style
.height
= 0
67 iframe
.style
.height
= (iframe
.contentWindow
.document
.body
.scrollHeight
* 1.2) + 'px';