-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
81 lines (69 loc) · 2.66 KB
/
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
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
78
79
80
81
// * IMPORTANT
// ! DEPRECATED
// TODO
// ? SHOULD THIS
// @param innerHTML blah
class MyHeader extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<header>
<nav id='menu'>
<ul>
<!-- <li><a href="./index.html" target='_self'>Home</a></li> -->
<li><a href="./about.html" target='_self'>About</a></li>
<!-- <li><a href="./portfolio.html" target='_self'>Portfolio</a></li> -->
<!-- <li><a href="./media.html" target='_self'>Media</a></li> -->
<li><a href="./contactme.html" target='_self'>Contact Me</a></li>
</ul>
</nav>
</header>
`
}
}
customElements.define('my-header', MyHeader)
class MyFooter extends HTMLElement {
connectedCallback() {
this.innerHTML = `
<button onclick="topFunction()" id="bttb" title="Back to the Top">Top ↑
</button>
<footer>
<figure class='footerIcons'>
<a href='https://www.linkedin.com/in/eligio-fonseca/' target='_blank'>
<img src='./icons/footer/iconmonstr-linkedin-3.svg'>
</a>
<a href='https://github.com/eligiofonseca' target='_blank'>
<img src='./icons/footer/iconmonstr-github-1.svg'>
</a>
<a href='https://www.codecademy.com/profiles/eligiofonseca' target='_blank'>
<img src='./icons/footer/iconmonstr-learning-3.svg'>
</a>
<a href='https://www.coursera.org/learner/eligio-fonseca' target='_blank'>
<img src='./icons/footer/iconmonstr-coursera-1.svg'>
</a>
<a href='https://testautomationu.applitools.com/me.html#eligio-fonseca' target='_blank'>
<img src='./icons/footer/iconmonstr-applitools.svg'>
</a>
</figure>
© <span id="copyright-year">2023</span>. All Rights Reserved.
</footer>
`
}
}
customElements.define('my-footer', MyFooter)
document.querySelector('#copyright-year').innerText = new Date().getFullYear();
// Get the button:
let mybutton = document.getElementById("bttb");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () { scrollFunction() };
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}