Repository navigation
Expand file tree
/
Copy pathJavascript.js
More file actions
211 lines (162 loc) · 7.82 KB
/
Copy pathJavascript.js
File metadata and controls
211 lines (162 loc) · 7.82 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// [}EVSOC_ logo on index.html animation
const codeStrings = [
`[}EVSOC_`,
`Code`,
`Chat`,
`Game`,
]
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function initRotate(spanElement, period, strings = codeStrings) {
while(true) {
for (string of strings) {
let viewedStr = ""
// Repeatedly add a char onto the displayed string
for (char of string.split("")) {
viewedStr += char
spanElement.innerHTML = `<span class="wrap">${viewedStr}<span>`;
await sleep(200 - Math.random() * 100);
}
await sleep(period);
// Repeatedly "delete" the rightmost char
for (let i = string.length; i > 0; i--) {
spanElement.innerHTML = `<span class="wrap">${string.substring(0, i)}<span>`;
await sleep(100 - Math.random() * 50);
}
}
}
}
async function useJsonData() {
fetch("ImageData.json")
.then(response => response.json())
.then(json => {
// Committee
json.Committee.forEach(member => {
//creates html elements with classes and etc
console.log(`${member.Name} - ${member.About}`);
const MainUserContainer = document.getElementById("imageContainer");
const ImageContainer = document.createElement("div");
ImageContainer.classList.add("col-lg-3", "my-2")
const PersonBox = document.createElement("div");
PersonBox.classList.add("bg-custom", "p-3", "text-center", "rounded", "box");
const Picture = document.createElement("img");
Picture.classList.add("img-responsive", "rounded-circle");
Picture.src = member.Image;
Picture.style.width = "100px";
Picture.style.height = "100px";
const Name = document.createElement("h2");
Name.classList.add("mt-3", "name");
Name.textContent = member.Name;
const Course = document.createElement("span");
Course.classList.add("work", "d-block");
Course.textContent = member.Course;
const br = document.createElement("br");
const About = document.createElement("div")
About.classList.add("mt-4", "about");
const span = document.createElement("span");
const strong = document.createElement("strong");
strong.textContent = "About & Interests:";
const br2 = document.createElement("br");
span.append(strong);
span.append(br2);
span.append(member.About);
const LinkBox = document.createElement("div");
LinkBox.classList.add("mt-4");
const link = document.createElement("a");
link.href = member.Link;
const ProfileLinkText = document.createElement("h6");
ProfileLinkText.textContent = "View Profile";
//append all elements together to display
link.appendChild(ProfileLinkText);
LinkBox.appendChild(link);
About.appendChild(span);
PersonBox.appendChild(Picture);
PersonBox.appendChild(Name);
PersonBox.appendChild(Course);
PersonBox.appendChild(br);
PersonBox.appendChild(About);
PersonBox.appendChild(LinkBox);
ImageContainer.appendChild(PersonBox);
MainUserContainer.appendChild(ImageContainer)
});
// Events
json.Events.forEach(event => {
console.log(`${event.Name} @ ${event.Time} in ${event.Place}`);
const MainEventContainer = document.getElementById("imageContainer2");
const ImageContainer = document.createElement("div");
ImageContainer.classList.add("row", "mt-4", "mb-4", "mx-4", "justify-content-center");
const ImageContainer2 = document.createElement("div");
ImageContainer2.classList.add("col-lg-4", "my-2");
const ImageContainer3 = document.createElement("div");
ImageContainer3.classList.add("card", "card-shadow");
const Picture = document.createElement("img");
Picture.classList.add("card-img-top");
Picture.src = event.Image;
Picture.style.width = "auto";
Picture.style.height = "250px";
Picture.style.objectFit = "cover";
const CardContainer = document.createElement("div");
CardContainer.classList.add("card-body");
const Title = document.createElement("h5");
Title.classList.add("card-title");
Title.textContent = event.Name;
const Description = document.createElement("p");
Description.classList.add("card-text");
Description.textContent = event.About;
Description.style.whiteSpace = "pre-line";
const Time = document.createElement("p");
Time.classList.add("card-text", "text-right");
Time.textContent = event.Time;
const Place = document.createElement("p");
Place.classList.add("card-text", "text-right");
Place.textContent = event.Place;
const link = document.createElement("a");
link.href = event.Link;
link.classList.add("btn", "btn-dark", "float-right");
link.textContent = "Details";
CardContainer.appendChild(Title);
CardContainer.appendChild(Description);
CardContainer.appendChild(Time);
CardContainer.appendChild(Place);
CardContainer.appendChild(link);
ImageContainer3.appendChild(Picture);
ImageContainer3.appendChild(CardContainer);
ImageContainer2.appendChild(ImageContainer3);
ImageContainer.appendChild(ImageContainer2);
MainEventContainer.appendChild(ImageContainer);
});
})
}
window.onload = function() {
for (element of document.getElementsByClassName('typewrite')) {
var period = element.getAttribute('data-period');
initRotate(element, period);
}
// INJECT CSS
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
document.body.appendChild(css);
// Auto change current date based on year and month
const field = document.getElementById("curAcademicYr");
const curDate = (((new Date()).getFullYear()).toString()).slice(-2);
// If below september then last year and current year
if (new Date().getMonth() < 9) {
field.innerHTML += (curDate-1) + "-" + curDate;
}
// If after september then current year then next year
else
field.innerHTML += curDate + "-" + (parseInt(curDate)+1);
useJsonData();
};
// Warning for closed events
$('#warning').click(function (e) {
e.preventDefault()
$('#messageWarning').html('<div class="alert alert-danger fade-in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">×</button><strong>Alert:</strong> This event has ended. Try another one! :)</div>');
})
// Warning for pending events
$('#pending').click(function (e) {
e.preventDefault()
$('#messagePending').html('<div class="alert alert-success fade-in"><button type="button" class="close close-alert" data-dismiss="alert" aria-hidden="true">×</button><strong>Alert:</strong> Event details are pending. Try again later! :)</div>');
})