-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
72 lines (65 loc) · 1.92 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
function openProj(proj){
window.open("../projects/" + proj + ".html", "_self");
}
function openBlog(blog){
window.open("../blogs/" + blog + ".html", "_self");
}
function loadPage(page){
window.open("../pages/" + page + ".html", "_self");
}
function loadResume(){
window.open('../files/Tianyi-Zhao.pdf', '_self')
}
function updateMenuTag(page){
document.getElementById("menu-" + page).setAttribute("class", "menu-content-selected");
}
function contactEmail(){
window.open('mailto:ziutinyat@gmail.com', '_self');
}
function contactGithub(){
window.open('https://github.com/ZiuTinyat', '_blank');
}
function contactFacebook(){
window.open('https://www.facebook.com/profile.php?id=100006528554451', '_blank');
}
function contactLinkedin(){
window.open('https://www.linkedin.com/in/tianyi-zhao-018ba9154/', '_blank');
}
class FilterGroup{
constructor(rootElement, filterClass){
this.root = rootElement;
this.filterClass = filterClass;
var childrenCollection = this.root.getElementsByClassName("filter");
this.children = {};
for (var i = 0; i < childrenCollection.length; i++){
var e = childrenCollection[i];
this.children[e.getAttribute("name")] = e;
}
}
applyFilterElement(childElement){
this.deselectAllChildren();
childElement.classList.add("filter-selected");
this.filterClassType(childElement.getAttribute("name"));
}
applyFilterName(name){
this.deselectAllChildren();
this.children[name].classList.add("filter-selected");
this.filterClassType(name);
}
deselectAllChildren(){
for (var i in this.children){
this.children[i].classList.remove("filter-selected");
}
}
filterClassType(type){
var elements = document.getElementsByClassName(this.filterClass);
for (var i = 0; i < elements.length; i++){
var e = elements[i];
if (type == "" || e.getAttribute("filter")?.split(' ').includes(type)){
e.style.display = "";
} else {
e.style.display = "none";
}
}
}
}