-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
128 lines (117 loc) · 4.04 KB
/
script.js
File metadata and controls
128 lines (117 loc) · 4.04 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function transition() {
highlightCurrentPage();
setupSelection();
if (window.location.href.includes("Contact.html")) {
setLinks();
}
document.querySelector("img[src='../img/SiteName.png']").addEventListener("click", function () {
window.location.href = "https://svonk.me";
});
}
function highlightCurrentPage() {
window.addEventListener("load", transition);
pageId = window.location.href.split("?")[0].split("/")[
window.location.href.split("/").length - 2
];
pageId = pageId.replace("About", "About_Me");
if (pageId != "" && pageId != "404") {
document.getElementById(pageId).style =
"background-color: var(--accent-transparent) !important; transition: background-color 0.25s;";
document.getElementById(pageId + "2").style =
"background-color: var(--accent-transparent) !important; transition: background-color 0.25s;";
} else {
pageId = "Contact";
document.getElementById(pageId).style =
"background-color: var(--accent-transparent) !important; transition: background-color 0.25s;";
}
}
function clearSelections() {
var selections = document.querySelectorAll("[original-content]");
selections.forEach(function (selection) {
selection.innerHTML = selection.getAttribute("original-content");
});
}
function setupSelection() {
document.body.addEventListener("mousedown", function () {
if (document.body.classList.contains("selections-enabled")) {
document.body.classList.remove("selections-enabled");
clearSelections();
}
});
}
function toGit() {
window.location.href = "https://github.com/sandervonk";
console.log("toGit called");
}
function toMail() {
window.location.href = "mailto:sander.c.vonk@gmail.com";
console.log("toMail called");
}
function setLinks() {
console.log("settingLinks");
document.getElementById("git-parent").onclick = toGit;
document.getElementById("mail-parent").onclick = toMail;
const element1 = document.querySelector("#git-parent");
const element2 = document.querySelector("#mail-parent");
element1.addEventListener("mouseover", (event) => {
element2.style =
"transform: translate(-50%, -50%) rotate(-130deg) translate(180px) rotate(130deg);";
});
element1.addEventListener("mouseout", (event) => {
element2.style.transform = "";
});
element2.addEventListener("mouseover", (event) => {
element1.style =
"transform: translate(-50%, -50%) rotate(-179deg) translate(180px) rotate(179deg);";
});
element2.addEventListener("mouseout", (event) => {
element1.style.transform = "";
});
}
//totally not an easter egg
var allowedKeys = {
37: "left",
38: "up",
39: "right",
40: "down",
65: "a",
66: "b",
};
var konamiCode = ["up", "up", "down", "down", "left", "right", "left", "right", "b", "a"];
var konamiCodePosition = 0;
document.addEventListener("keydown", function (e) {
var key = allowedKeys[e.keyCode];
var requiredKey = konamiCode[konamiCodePosition];
if (key == requiredKey) {
konamiCodePosition++;
if (konamiCodePosition == konamiCode.length) {
activateCheats();
konamiCodePosition = 0;
}
} else {
konamiCodePosition = 0;
}
});
function activateCheats() {
document.body.style.backgroundSize = "cover";
document.body.style.backgroundPosition = "center";
document.body.style.backgroundRepeat = "no-repeat";
document.body.style.minHeight = "100vh";
document.body.style.backgroundImage = "url('/img/header.png')";
document.body.style.backdropFilter = "blur(10px)";
document.body.style.backgroundAttachment = "fixed";
var audio = new Audio("/audio/coin.mp3");
audio.play();
alert("totally not an easter egg 🙃");
}
//for alt menu
function myFunction(x) {
x.classList.toggle("change");
}
window.addEventListener("load", transition);
//handler for "data-href" attribute
document.addEventListener("click", function (e) {
if (e.target.hasAttribute("data-href")) {
window.location.href = e.target.getAttribute("data-href");
}
});