-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (45 loc) · 1.77 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
// remove trailing slash from url
window.history.pushState('', '', location.pathname.slice(0, -1));
///////////////////////////////////////////////////////////////////////
///// dynamically load modules depending on the current directory /////
///////////////////////////////////////////////////////////////////////
// root directory
if (window.location.pathname == "/") {
import("./src/modules/load-data.js").then((load) => {
load.checkSession();
load.home();
load.summary(true);
window.addEventListener("load", () => {
load.observer();
}, false);
window.addEventListener("resize", () => {
load.observer();
}, false);
});
import("./src/modules/effects.js").then((effects) => {
effects.typewriter();
let cards = document.querySelectorAll(".card");
cards.forEach(element => element.addEventListener("click", function () { effects.flip(element) }));
});
import("./src/modules/send-email.js").then((email) => {
let button = document.getElementById("sendButton");
button.addEventListener("click", function () { email.validate() });
});
}
// projects directory
else if (window.location.pathname == "/projects") {
import("./src/modules/load-data.js").then((load) => {
load.summary(false);
});
import("./src/modules/effects.js").then((effects) => {
let cards = document.querySelectorAll(".card");
cards.forEach(element => element.addEventListener("click", function () { effects.flip(element) }));
});
}
// individual project directory
else if (window.location.pathname.includes("/projects/")) {
import("./src/modules/load-data.js").then((load) => {
load.template()
load.project(window.location.pathname);
});
}