-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·451 lines (394 loc) · 14 KB
/
Copy pathindex.js
File metadata and controls
executable file
·451 lines (394 loc) · 14 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
async function MELONsquad(){
await navBar();
console.log(window.location.href);
if(window.location.href.includes("%23")){
hash = window.location.href.indexOf("%");
window.location.href = window.location.href.substring(0,hash) + '#' + window.location.href.substring(hash+3);
}
//setting pos to a number so high it won't be reached
pos = 500
pos = window.location.href.indexOf("#")
pos2 = window.location.href.lastIndexOf("#");
/*for(c in window.location.href){
if(window.location.href[c] == '#' && c < pos){
console.log(c);
pos = c;
break;
}
}*/
console.log(pos);
if(pos == pos2) {
ending = window.location.href.substring(pos);
ChoosePage(ending);
}
else{
ending = window.location.href.substring(pos,pos2);
text = await ChoosePage(ending);
if(text == "events"){
theEvent = window.location.href.substring(pos2 + 1).toLowerCase();
SelectEvent(theEvent);
}
else{
anchor = window.location.href.substring(pos2 + 1).toLowerCase();
console.log("second: " + anchor);
scrollSmoothTo(anchor);
}
}
console.log("ending: " + ending);
}
function scrollSmoothTo(elementId) {
var element = document.getElementById(elementId);
element.scrollIntoView({
block: 'start',
behavior: 'smooth'
});
}
async function ChoosePage(ending){
switch(ending.toLowerCase()){
case "#about":
About()
return "about"
case "#team":
await TeamMembers();
return "squad"
case "#squad":
await TeamMembers();
return "squad"
case "#gang":
await TeamMembers();
return "squad"
case "#history":
await History();
return "history"
case "#art":
await Art();
return "art"
case "#event":
await Events();
return "events"
case "#events":
await Events();
return "events"
case "#recipes":
await Recipes();
return "recipes"
case "#schedule":
await Schedule();
return "schedule"
case "#join":
JoinSquad();
return "join"
case "#join-us":
JoinSquad();
return "join"
default:
MELON();
break;
}
}
async function navBar(){
navList = document.getElementById('list');
//console.log("list");
const response = await fetch("JSON/navbar.json")
.then(response => response.json());
json = response;
//console.log(json);
for(link in json){
//console.log(link)
navList.innerHTML += `<a href="#${json[link].link}"><li onclick="${json[link].onclick}">${json[link].text}</li></a>`
}
navList.innerHTML += `<li id="audioSwapButton" onclick="AudioSwap()" style="margin-top:2vh;">Play Audio</li>`
}
function AudioSwap(){
currentText = document.getElementById("audioSwapButton").innerHTML;
if(currentText == "Pause Audio"){
document.getElementById("audioSwapButton").innerHTML = "Play Audio";
document.getElementById("background").pause();
}
if(currentText == "Play Audio"){
document.getElementById("audioSwapButton").innerHTML = "Pause Audio";
document.getElementById("background").play();
}
}
function APause(){
console.log("pause");
document.getElementById("audioSwapButton").innerHTML = "Play Audio";
document.getElementById("background").pause();
}
function APlay(){
console.log("play");
document.getElementById("audioSwapButton").innerHTML = "Pause Audio";
document.getElementById("background").play();
}
function MELON(){
section.innerHTML = `
<h1 id="sectionHeading">MELONsquad</h1>
<h1>🍉🦈</h1>
<img src="Assets/BLAHAJ.gif" id="blahajpic">
`
}
function About(){
section.innerHTML = "<h1 id=\"sectionHeading\">About - Coming soon...</h1>"
}
async function TeamMembers(){
console.log("team");
section.innerHTML = `
<h1 id="sectionHeading">The Squad</h1>
<audio id="eventMusic" autoplay onplay="APause()" onended="APlay()">
<source src="Assets/Music/Wow.mp3" Type="audio/mpeg">
</audio>
`
team = await AddImageBoxes("Team", "team");
section.innerHTML += team;
}
async function History(){
section.innerHTML = `
<h1 id="sectionHeading">History</h1>
<h2>It's time to make history by winning Local Hack Day: Share together!</h2>
<h2>Find below some of the historical hackathon prizes our MELONsquad members have won... this is why we will be the best squad at LHD: Share!</h2>
`
hHistory = await HackathonHistory();
section.innerHTML += hHistory;
}
async function Art(){
section.innerHTML = `<h1 id=\"sectionHeading\">Art</h1>
<audio id="asmr" autoplay>
<source src="Assets/Music/Will ASMR.mp3" type="audio/mpeg">
</audio>
`
art = await AddImageBoxes("Art", "art", true);
section.innerHTML += art;
}
async function Events(){
section.innerHTML = `
<h1 id=\"sectionHeading\">Events</h1>
<select id="eventSelector" name="event" onchange="ChangeEvent()"></select>
<div id="eventContent"></div>
`
const response = await fetch("JSON/events.json")
.then(response => response.json());
events = response;
console.log(events);
var select = document.getElementById("eventSelector");
var option = document.createElement("option");
option.value = "Default";
option.id = "default";
option.innerHTML = "Select an Event";
select.appendChild(option);
for(eventOption in events){
var option = document.createElement("option");
option.innerHTML = events[eventOption].name;
option.value = eventOption;
select.appendChild(option);
};
}
async function ChangeEvent(){
document.getElementById("default").disabled = "disabled";
var eventSection = document.getElementById("eventContent")
const response = await fetch("JSON/events.json")
.then(response => response.json());
events = response;
console.log(window.location.href)
pos1 = window.location.href.indexOf("#")
pos2 = window.location.href.lastIndexOf("#");
console.log(pos1 + ' ' + pos2)
if(pos1 == pos2){
window.location.href = window.location.href + '#' + events[document.getElementById("eventSelector").value].name.toLowerCase()[0]
}
else{
window.location.href = window.location.href.substring(0,pos2) + '#' + events[document.getElementById("eventSelector").value].name.toLowerCase()[0];
}
console.log(document.getElementById("eventSelector").value)
console.log(events[document.getElementById("eventSelector").value].name)
eventSection.innerHTML = `
<h2>${events[document.getElementById("eventSelector").value].name}</h2>
<p>${events[document.getElementById("eventSelector").value].description}</p>
`
if(events[document.getElementById("eventSelector").value].src == "local"){
console.log("audio")
eventSection.innerHTML += `
<audio id="eventMusic" autoplay onplay="APause()" onended="APlay()">
<source src="Assets/Music/${events[document.getElementById("eventSelector").value].sounds}" type="audio/mpeg">
</audio>
`
}
else{
eventSection.innerHTML += `
<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/${events[document.getElementById("eventSelector").value].sounds}?controls=0&autoplay=1\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen onplay="APause()" onended="APlay()"></iframe>`
}
for(image in events[document.getElementById("eventSelector").value].images){
console.log(image)
eventSection.innerHTML += `
<siv id="outerEventImage">
<div id="eventImage">
<a target="_blank" href="Assets/Graphics/${events[document.getElementById("eventSelector").value].name}/${events[document.getElementById("eventSelector").value].images[image]}.png">
<img src="Assets/Graphics/${events[document.getElementById("eventSelector").value].name}/${events[document.getElementById("eventSelector").value].images[image]}.png">
</a>
</div>
</div>
`
}
}
function SelectEvent(theEvent){
console.log(theEvent);
var select = document.getElementById("eventSelector");
console.log("before switchin")
console.log(theEvent.toLowerCase()[0])
switch(theEvent.toLowerCase()[0]){
case 'a':
console.log("asmr")
select.selectedIndex = 1;
break;
case 'b':
console.log("bake")
select.selectedIndex = 2;
break;
case 'e':
console.log("espresso")
select.selectedIndex = 3;
break;
case 'k':
console.log("karaoke")
select.selectedIndex = 4;
break;
case 'v':
console.log("pizza")
select.selectedIndex = 5;
break;
}
ChangeEvent();
}
async function Recipes(){
section.innerHTML = "<h1 id=\"sectionHeading\">Recipes</h1>"
const response = await fetch("JSON/recipes.json")
.then(response => response.json());
json = response
console.log(json.mlb.name);
recipeString = "<ol>"
for(s in json.mlb.steps){
console.log(json.mlb.steps[s]);
recipeString += "<li>"
recipeString += json.mlb.steps[s];
recipeString += "</li>"
}
recipeString += "</ol>"
section.innerHTML += recipeString;
}
// created by Ayush
async function Schedule() {
console.log("schedule");
section.innerHTML = "<h1 id=\"sectionHeading\">LHD Share Schedule - Coming soon...</h1>"
section.innerHTML = "";
hHistory = await innerSchedule();
section.innerHTML += hHistory;
}
async function innerSchedule() {
const response = await fetch("JSON/schedule.json")
.then((response) => response.json());
json = response;
historystring = "";
for (hacker in json) {
historystring += `
<div id="historyOuter">
<h2>${json[hacker].name}</h2>
`;
for (hackathon in json[hacker].hackathons) {
historystring += `<a href="${json[hacker].hackathons[hackathon].link}" target="_blank" id="noformat">`;
historystring += AddImageBox(
"Graphics/LHD.png",
json[hacker].hackathons[hackathon].name,
json[hacker].hackathons[hackathon].prize
);
historystring += `</a>`;
}
historystring += `</div>`;
//console.log(historystring);
}
//console.log(historystring);
return historystring;
}
function JoinSquad(){
section.innerHTML = `
<h1 id="sectionHeading">Join us!</h1>
<div>
<h2>Instructions</h2>
<ol>
<li>Visit <a href="https://discord.mlh.io" target="_blank">discord.mlh.io</a>
<li>Click Sign in with Discord</li>
<li>Log in</li>
<li>Click Edit Profile</li>
<li>Scroll to Guild Membership</li>
<li>Select guild BLAHAJGang</li>
<li>Visit the BLAHAJgang Discord Channel</li>
<li>Add the melon and shark emoji to your nickname (🍉🦈)</li>
<li>Optional - ask to be added to the <a href="#squad" target="_blank">website</a></li>
</ol>
</div>
`;
}
async function News(){
console.log("news");
section.innerHTML = "<h1 id=\"sectionHeading\">MELONsquad & BLAHAJgang in the News - Coming soon...</h1>"
}
async function AddImageBoxes(imageDirectory, jsonFile, link = false){
const response = await fetch("JSON/" + jsonFile + '.json')
.then(response => response.json());
json = response
team = "";
for(user in json){
if(!Array.isArray(json[user].image)){
imageurl = json[user].image;
} else {
//console.log(json[user].image.length);
imgNum = Math.floor(Math.random() * (json[user].image.length));
console.log(imgNum);
imageurl = json[user].image[imgNum];
}
team += AddImageBox(imageDirectory + "/" + imageurl, json[user].name, json[user].caption, user, link);
}
return team;
}
function AddImageBox(imageSrc, title, caption, user, link){
box = "";
if(link){
box += `<a id="noformat" href="Assets/${imageSrc}" target="_blank">`
}
box += `
<div class="wideBox" id="${user}">
<div id="boxImg">
<img src="Assets/${imageSrc}">
</div>
<p id="title">${title}</p>
<p id="caption">${caption}</p>
</div>
`
if(link){
box += `</a>`
}
return box;
}
async function HackathonHistory(){
const response = await fetch("JSON/wins.json")
.then(response => response.json());
json = response;
historystring = "";
for(hacker in json){
//console.log(json[hacker]);
//console.log(json[hacker].hackathons[0].name);
historystring += `
<div id="historyOuter">
<h2>${json[hacker].name}</h2>
`
for(hackathon in json[hacker].hackathons){
historystring += `<a href="${json[hacker].hackathons[hackathon].link}" target="_blank" id="noformat">`;
historystring += AddImageBox("Hackathons/" + json[hacker].hackathons[hackathon].name + ".png", json[hacker].hackathons[hackathon].name, json[hacker].hackathons[hackathon].prize);
historystring += `</a>`;
}
historystring += `</div>`;
//console.log(historystring);
}
//console.log(historystring);
return historystring;
}
function Links(){
}