-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
206 lines (178 loc) · 6.41 KB
/
app.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
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
document.addEventListener("DOMContentLoaded", () => {
window.location.href = "/about.html";
});
//initialize the current section as the about-section
let slides;
let slideIndex = 1;
const soundcloudEmbed = `<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/1029461755&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe><div style="font-size: 10px; color: #cccccc;line-break: anywhere;word-break: normal;overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-family: Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif;font-weight: 100;"><a href="https://soundcloud.com/higgzmadethebeat" title="HIGGZ (Humblegawwd)" target="_blank" style="color: #cccccc; text-decoration: none;">`;
const videographyEmbed = `<iframe width="560" height="315" src="https://www.youtube.com/embed/ESZ74OzpG7U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`;
let $soundcloud = document.createElement("div");
$soundcloud.innerHTML = soundcloudEmbed;
let skills = {};
const getExamples = (skillTopic) => {
let examples = [];
for (let i = 1; i < 7; i++) {
examples.push({
img: `./src/skills/${skillTopic}/${i}.jpg`,
description: skillTopic + "-" + "image" + "-" + i,
id: i,
name: "picture",
});
}
return examples;
};
skillsTopics.forEach((skillTopic) => {
skills[skillTopic] = getExamples(skillTopic);
});
const goToPageHandler = (initialLoad = false) => {
return (() => {
if (initialLoad) {
newSectionName = "about";
} else {
newSectionName = event.target.id.replace("-nav", ""); //converts button name to 'about', 'projects' ect..
}
newSection = document.getElementById(newSectionName + "-section"); //identifies the new section's name
$currentSection.className = "do-not-display"; //hides the old current selection
$currentSection = newSection; // updates the current selection
$currentSection.className = ""; //undoes the do-not-display
loadSection(newSectionName)();
})();
};
function loadSection(section) {
return {
about: loadAbout,
projects: loadProjects,
skills: loadSkills,
contact: loadContact,
}[section];
}
const loadAbout = () => {
addSlideShow("about", aboutPictures);
};
const loadProjects = () => {};
const loadSkills = () => {
clearSlides();
clearDropDown();
addSlideShow("skills", skills.Photography);
addDropDown("skills-section", Object.keys(skills));
};
const clearDropDown = () => {
if (document.getElementById("dropdown-section")) {
document.querySelector("#dropdown-section").remove();
}
};
const addDropDown = (parentNodeID, items) => {
let $parentNode = document.getElementById(parentNodeID);
let $dropDown = document.createElement("div");
let $button = document.createElement("button");
let $myDropDown = document.createElement("div");
$button.className = "dropbtn";
$button.addEventListener("click", showDropDown);
$button.innerText = "Check out my other skills ";
$myDropDown.className = "dropdown-content";
$myDropDown.id = "myDropdown";
items.forEach((item) => {
$myDropDown.innerHTML += `<a href="#" onclick="showSkill('${item}')">${item}</a>`;
});
$dropDown.append($button, $myDropDown);
$dropDown.id = "dropdown-section";
$parentNode.append($dropDown);
};
function showSkill(item) {
return {
"Live Performance": () => showiframe(livePerformanceEmbed.sample()),
"Music Production": () => showiframe(soundcloudEmbed),
Photography: showPhotography,
Videography: () => showiframe(videographyEmbed),
Beats: () => showiframe(beatsEmbed.sample()),
}[item]();
}
function showiframe(iframeElement) {
clearSlides();
let $container = document.querySelector("#skills-slideshow");
$container.innerHTML += iframeElement;
}
function showVideography() {
let $container = document.querySelector("#skills-slideshow");
$container.innerHTML += soundcloudEmbed;
}
function showPhotography() {
clearSlides();
addSlideShow("skills", skills.Photography);
let $container = document.querySelector("#skills-slideshow");
showSlides(1);
}
function showDropDown() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches(".dropbtn")) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains("show")) {
openDropdown.classList.remove("show");
}
}
}
};
const loadContact = () => {
console.log("loading Contact");
};
const addSlideShow = (section, array) => {
const $slideShow = document.getElementById(section + "-slideshow");
const slides = array.map((picture) => createSlide(picture, $slideShow));
slides.forEach((slide) => {
$slideShow.append(slide);
});
$slideShow.innerHTML =
$slideShow.innerHTML +
`<a
class="prev"
onclick="plusSlides(-1)"
>
❮
</a>
<a
class="next"
onclick="plusSlides(1)"
>
❯
</a>`;
showSlides(1);
};
const createSlide = (image, slideshow) => {
let $div = document.createElement("div");
let $caption = document.createElement("div");
let $numberText = document.createElement("div");
let $image = document.createElement("img");
$numberText.className = "numbertext";
$numberText.innerText = image.id;
$image.src = image.img;
$caption.className = "text";
$caption.innerText = image.description;
$div.className = "mySlides fade";
$div.append($numberText);
$div.append($image);
$div.append($caption);
return $div;
};
// clearSlides
function clearSlides() {
if (document.querySelector("iframe") !== null) {
document.querySelector("iframe").remove();
}
range(0, slides.length - 1).forEach(() => {
if (document.querySelector(".mySlides") !== null) {
const slide = document.querySelector(".mySlides");
slide.remove();
}
});
let soundcloud = document.querySelector("iframe");
if (soundcloud !== null) {
document.querySelector("iframe").remove();
// console.log(document.querySelector('iframe').remove())
}
}