Skip to content

Commit a89f6cd

Browse files
added js compression script and updated experience
1 parent 15de9a1 commit a89f6cd

File tree

14 files changed

+482
-9
lines changed

14 files changed

+482
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ node_modules/
6464

6565
# dotenv environment variables file
6666
.env
67+
68+
# IDE files
69+
.vscode/

public/.vscode/settings.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"workbench.colorCustomizations":{
33

4-
}
4+
},
5+
"cSpell.words": [
6+
"resplit",
7+
"tablefmt",
8+
"termcolor",
9+
"Unmarks"
10+
],
11+
"[python]": {
12+
"editor.defaultFormatter": "ms-python.autopep8"
13+
},
14+
"python.formatting.provider": "none"
515
}
File renamed without changes.

public/assets/js/icons-min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/assets/js/icons.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/js/index.js

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,65 @@
1-
function toggleHamburger(e,t){let o=e.classList.contains("active");o?(e.classList.remove("active"),t.classList.remove("active")):(e.classList.add("active"),t.classList.add("active"))}function __initHamburger__(){let e=document.querySelector(".hamburger"),t=document.querySelector("nav");e.onclick=()=>{toggleHamburger(e,t)},addEventListener("resize",o=>{o.target.innerWidth>1024&&e.classList.contains("active")&&(e.classList.remove("active"),t.classList.remove("active"))}),addEventListener("scroll",()=>{window.pageYOffset>=330&&(e.classList.remove("active"),t.classList.remove("active"))})}function populateExperienceField(e){let t=document.querySelector("#experienceBoxes"),o=t.querySelector("[experienceBoxTemplate]"),n=o.content.querySelector("[experienceSubItemTemplate]");e.forEach(e=>{let l=o.content.cloneNode(!0).children[0],r=l.querySelector("ul"),c=l.querySelector("img");c.src=e.companyImageLink,c.alt=`${e.company} logo`,l.querySelector("h3").textContent=e.position,e.content.forEach(e=>{let t=n.content.cloneNode(!0).children[0],o=t.querySelectorAll("strong")[1],l=e.location;l?o.textContent=` @ ${l}`:o.style.display="none",t.querySelectorAll("strong")[0].textContent=`${e.subtitle}`,t.querySelector("span").textContent=`: ${e.description}`,r.appendChild(t)}),t.appendChild(l)}),updateCopy()}function updateCopy(){window.innerWidth<470?document.querySelectorAll(".experienceCopy").forEach(e=>{e.style.display="none"}):document.querySelectorAll(".experienceCopy").forEach(e=>{e.style.display="inline"})}function populatePortfolio(e){let t=document.querySelector("#portfolioItems"),o=t.querySelector("[portfolioItemTemplate]"),n=o.content.querySelector("[languageBoxTemplate]");e.forEach(e=>{let l=o.content.cloneNode(!0).children[0];l.querySelector("h3").textContent=e.title,l.querySelector("p").textContent=e.description;let r=l.querySelector(".languages");e.languages.forEach(e=>{let t=n.content.cloneNode(!0).children[0];t.textContent=e,r.appendChild(t)}),t.appendChild(l)})}function updateSize(){let e=0,t=document.querySelectorAll(".portfolioItem"),o=getComputedStyle(t[0]);getItemWidth=()=>o.width;let n=2*parseFloat(o.padding);t.forEach(t=>{e=Math.max(e,t.clientHeight)}),e-=n,t.forEach(t=>{t.style.height=`${e}px`})}function sleep(e){return new Promise(t=>setTimeout(t,e))}__initHamburger__(),addEventListener("load",()=>{document.querySelector("#loaderPage").style.display="none",document.querySelector("header").style.position="fixed"}),fetch("/assets/json/experiences.json").then(e=>{e.json().then(e=>{populateExperienceField(e)})}),addEventListener("resize",()=>{updateCopy()}),window.addEventListener("resize",e=>{let t=parseFloat(e.target.innerWidth);t>=1e3&&updateSize()}),window.addEventListener("load",async()=>{for(i=0;i<16;i++)try{parseFloat(window.innerWidth)>=1e3&&updateSize();break}catch(e){await sleep(10)}}),fetch("/assets/json/portfolio.json").then(e=>{e.json().then(e=>{populatePortfolio(e)})});
1+
/**
2+
* Toggles the provided hamburger.
3+
* @param {HTML Element} hamburger
4+
* @param {HTML Element} navMenu
5+
*/
6+
function toggleHamburger(hamburger, navMenu){
7+
const active = hamburger.classList.contains("active");
8+
if(active){
9+
hamburger.classList.remove("active");
10+
navMenu.classList.remove("active");
11+
} else {
12+
hamburger.classList.add("active");
13+
navMenu.classList.add("active");
14+
}
15+
}
16+
17+
/**
18+
* Handles the loading of blur elements. Prevents from loading outside of
19+
* expected loading regions.
20+
*/
21+
// function blurHandler(){
22+
// const footerBoundingRect = document.querySelector("header").getBoundingClientRect();
23+
// document.querySelectorAll(".blur").forEach(blurElement => {
24+
// const boundingRect = blurElement.getBoundingClientRect();
25+
// while(Math.abs(boundingRect.y) + boundingRect.height < Math.abs(footerBoundingRect.y) + footerBoundingRect.height) {
26+
// console.log(Math.abs(boundingRect.y) + boundingRect.height);
27+
// boundingRect.y -= boundingRect.height;
28+
// }
29+
// })
30+
// }
31+
32+
/**
33+
* Initializes the hamburger with all necessary events and listeners.
34+
*/
35+
function __initHamburger__(){
36+
const hamburger = document.querySelector(".hamburger");
37+
const navMenu = document.querySelector("nav");
38+
hamburger.onclick = () => {
39+
toggleHamburger(hamburger, navMenu);
40+
}
41+
addEventListener("resize", event => {
42+
if (event.target.innerWidth > 1024 && hamburger.classList.contains("active")) {
43+
hamburger.classList.remove("active");
44+
navMenu.classList.remove("active");
45+
}
46+
});
47+
addEventListener("scroll", () => {
48+
if(window.pageYOffset >= 330){
49+
hamburger.classList.remove("active");
50+
navMenu.classList.remove("active");
51+
}
52+
});
53+
}
54+
55+
// document.querySelectorAll(".blur").forEach(blurElement => {
56+
// addEventListener("load", () => {
57+
// blurHandler();
58+
// });
59+
// });
60+
__initHamburger__();
61+
62+
addEventListener("load", () => {
63+
document.querySelector("#loaderPage").style.display = "none";
64+
document.querySelector("header").style.position = "fixed";
65+
});

public/assets/js/master.js

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,161 @@
11
/**
2+
* Populates the content in the experience blocks using the HTML template
3+
* @param {JSON Array} experienceData
4+
*/
5+
function populateExperienceField(experienceData){
6+
const experienceInjectPoint = document.querySelector("#experienceBoxes");
7+
const experienceTemplate = experienceInjectPoint.querySelector("[experienceBoxTemplate]");
8+
const subItemTemplate = experienceTemplate.content.querySelector("[experienceSubItemTemplate]");
9+
experienceData.forEach(experience => {
10+
const currExperienceTemplate = experienceTemplate.content.cloneNode(true).children[0];
11+
const subItemInjectPoint = currExperienceTemplate.querySelector("ul");
12+
const companyImage = currExperienceTemplate.querySelector("img");
13+
companyImage.src = experience["companyImageLink"];
14+
companyImage.alt = `${experience.company} logo`;
15+
currExperienceTemplate.querySelector("h3").textContent = experience["position"];
16+
experience["content"].forEach(subItem => {
17+
const currSubItemTemplate = subItemTemplate.content.cloneNode(true).children[0];
18+
const locationField = currSubItemTemplate.querySelectorAll("strong")[1];
19+
const location = subItem["location"];
20+
if (location) {
21+
locationField.textContent = ` @ ${location}`;
22+
} else {
23+
locationField.style.display = "none";
24+
}
25+
currSubItemTemplate.querySelectorAll("strong")[0].textContent = `${subItem["subtitle"]}`;
26+
currSubItemTemplate.querySelector("span").textContent = `: ${subItem["description"]}`;
27+
subItemInjectPoint.appendChild(currSubItemTemplate);
28+
});
29+
experienceInjectPoint.appendChild(currExperienceTemplate);
30+
// experienceInjectPoint.querySelectorAll(".experienceBox").forEach(experienceBox => {
31+
// const img = experienceBox.querySelector("img");
32+
// img.onload = () => {
33+
// const currHeight = parseFloat(window.getComputedStyle(experienceBox).height);
34+
// experienceBox.style.height = `${currHeight + img.height}px`;
35+
// updateExperienceHeights();
36+
// }
37+
// });
38+
});
39+
updateCopy();
40+
}
41+
42+
/**
43+
* Updates the copy of the experience elements depending on screen width.
44+
*/
45+
function updateCopy(){
46+
if(window.innerWidth < 470){
47+
document.querySelectorAll(".experienceCopy").forEach(copySection => {
48+
copySection.style.display = "none";
49+
});
50+
} else {
51+
document.querySelectorAll(".experienceCopy").forEach(copySection => {
52+
copySection.style.display = "inline";
53+
});
54+
}
55+
}
56+
/**
57+
* Updates the heights of the experience blocks to allow use of gradient border
58+
* needs to be called AFTER company images load (present issue)
59+
* Can be done by implementing eager loading on headers, but ideally not implemented that way;
60+
*/
61+
// function updateExperienceHeights(){
62+
// let currLargestBlock = 0;
63+
// document.querySelectorAll(".experienceBox").forEach(experienceBlock => {
64+
// currLargestBlock = Math.max(currLargestBlock, parseFloat(window.getComputedStyle(experienceBlock).height));
65+
// });
66+
// document.querySelectorAll(".experienceBox").forEach(experienceBlock => {
67+
// experienceBlock.style.height = `${currLargestBlock}px`;
68+
// });
69+
// }
70+
71+
fetch("/assets/json/experiences.json").then(response => {
72+
response.json().then(data => {
73+
populateExperienceField(data);
74+
});
75+
});
76+
77+
addEventListener("resize", () => {
78+
updateCopy();
79+
});/**
80+
* Populates the Portfolio items with content.
81+
* @param {JSON Array} portfolioData
82+
*/
83+
function populatePortfolio(portfolioData){
84+
const portfolioItemInjectPoint = document.querySelector("#portfolioItems");
85+
const portfolioItemTemplate = portfolioItemInjectPoint.querySelector("[portfolioItemTemplate]");
86+
const languageBoxTemplate = portfolioItemTemplate.content.querySelector("[languageBoxTemplate]");
87+
portfolioData.forEach(portfolioElement => {
88+
const currPortfolioItemTemplate = portfolioItemTemplate.content.cloneNode(true).children[0];
89+
currPortfolioItemTemplate.querySelector("h3").textContent = portfolioElement.title;
90+
currPortfolioItemTemplate.querySelector("p").textContent = portfolioElement.description;
91+
const languageInjectPoint = currPortfolioItemTemplate.querySelector(".languages");
92+
portfolioElement.languages.forEach(language => {
93+
const currLanguageTemplate = languageBoxTemplate.content.cloneNode(true).children[0];
94+
currLanguageTemplate.textContent = language;
95+
languageInjectPoint.appendChild(currLanguageTemplate);
96+
});
97+
portfolioItemInjectPoint.appendChild(currPortfolioItemTemplate);
98+
});
99+
}
100+
101+
/**
102+
* Updates the size of the elements in the portfolio section.
103+
*/
104+
function updateSize(){
105+
let maxItemHeight = 0;
106+
const portfolioItems = document.querySelectorAll('.portfolioItem');
107+
const firstItemStyle = getComputedStyle(portfolioItems[0]);
108+
getItemWidth = () => {return firstItemStyle.width}
109+
const paddingOffset = parseFloat(firstItemStyle.padding) * 2;
110+
portfolioItems.forEach(item => {
111+
maxItemHeight = Math.max(maxItemHeight, item.clientHeight);
112+
});
113+
114+
maxItemHeight -= paddingOffset;
115+
116+
portfolioItems.forEach(item => {
117+
item.style.height = `${maxItemHeight}px`;
118+
});
119+
}
120+
121+
/**
122+
* Sleeps for a certain period of time.
123+
* @param {int} ms how many ms to sleep for.
124+
* @returns {Promise<Function>} sleep event.
125+
*/
126+
function sleep(ms) {
127+
return new Promise(resolve => setTimeout(resolve, ms));
128+
}
129+
130+
// Adds the event listeners to enforce these constraints.
131+
132+
window.addEventListener('resize', (event) => {
133+
const widthPx = parseFloat(event.target.innerWidth);
134+
if(widthPx >= 1000){
135+
updateSize();
136+
}
137+
});
138+
139+
window.addEventListener('load', async () => {
140+
for(i = 0; i < 16; i++){
141+
try {
142+
if(parseFloat(window.innerWidth) >= 1000){
143+
updateSize();
144+
}
145+
break;
146+
} catch(err){
147+
await sleep(10);
148+
}
149+
}
150+
});
151+
152+
// Requests data and populates portfolio.
153+
154+
fetch("/assets/json/portfolio.json").then(response => {
155+
response.json().then(portfolioData => {
156+
populatePortfolio(portfolioData);
157+
});
158+
});/**
2159
* Toggles the provided hamburger.
3160
* @param {HTML Element} hamburger
4161
* @param {HTML Element} navMenu

public/assets/js/master.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)