-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael W.
committed
Oct 25, 2024
1 parent
b6a81e6
commit 3cb1faa
Showing
16 changed files
with
1,542 additions
and
80 deletions.
There are no files selected for viewing
Binary file removed
BIN
-2.34 KB
apicache/0c28bbdde90ce46c40c2adaf87f7339ec19a729dcb00249ff42f41f8dc1f8142
Binary file not shown.
Binary file removed
BIN
-1.32 KB
apicache/3153446787d457631aa6ec636af843866c871f5f56b09283e0246b7b9b7addba
Binary file not shown.
Binary file removed
BIN
-7.3 KB
apicache/51852b6e6c8ad5c02d87b0d5c643324a490c00b02cb5151c3423567416b6418a
Binary file not shown.
Binary file removed
BIN
-67.9 KB
apicache/6c747ab03ef6057844368f3b049a1404d70481ded4bac6d14a1eb12f2c9177dd
Binary file not shown.
Binary file removed
BIN
-1.12 KB
apicache/7f19f9d02421f697179c40f256cc2bc26874d465db53e709c6554e645592b0a1
Binary file not shown.
Binary file removed
BIN
-31.1 KB
apicache/9f4738a9683ad8317eccf68a9f0ac99733ad245f8591f27775196ff85281262f
Binary file not shown.
Binary file removed
BIN
-4.82 KB
apicache/c8cfa01cfa3d31d40333531ef714e97d7a0ded341ad1ee57a084cb1ede53f371
Binary file not shown.
Binary file removed
BIN
-6.46 KB
apicache/e87d1f5aa0e9fc68dbb97d738cde91273e2ed3281fc390f8420535e7b0548f79
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// Backup from 10/25 before adding jobs table | ||
const jobslist = document.getElementById('jobslist'); | ||
const searchBar = document.getElementById('searchBar'); | ||
const mainCategory = document.getElementById('mainCategory'); | ||
let jobData = []; | ||
|
||
// Event listener for the search bar | ||
searchBar.addEventListener('keyup', (e) => { | ||
const searchString = e.target.value.toLowerCase(); | ||
const searchWords = searchString.split(' ').filter(word => word.length > 0); | ||
|
||
if (searchWords.length === 0) { | ||
displayJobs(jobData.flatMap(category => { | ||
return Object.entries(category.jobs).map(([jobTitle, job]) => ({ | ||
main_category: category.main_category, | ||
jobTitle, | ||
job | ||
})); | ||
})); | ||
return; | ||
} | ||
|
||
const filteredJobs = jobData.flatMap(category => { | ||
return Object.entries(category.jobs) | ||
.filter(([jobTitle, job]) => { | ||
const jobTitleMatch = searchWords.some(word => jobTitle.toLowerCase().includes(word)); | ||
const linksMatch = job.links.some(link => | ||
searchWords.some(word => | ||
link.url.toLowerCase().includes(word) || | ||
link.category.toLowerCase().includes(word) | ||
) | ||
); | ||
return jobTitleMatch || linksMatch; | ||
}) | ||
.map(([jobTitle, job]) => ({ | ||
main_category: category.main_category, | ||
jobTitle, | ||
job | ||
})); | ||
}); | ||
|
||
displayJobs(filteredJobs); | ||
}); | ||
|
||
// Function to load jobs data | ||
const loadJobs = async () => { | ||
try { | ||
const res = await fetch('jobs.json'); // Adjust the path if necessary | ||
jobData = await res.json(); // Load all categories and jobs | ||
displayJobs(jobData.flatMap(category => { | ||
return Object.entries(category.jobs).map(([jobTitle, job]) => ({ | ||
main_category: category.main_category, | ||
jobTitle, | ||
job | ||
})); | ||
})); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
|
||
const displayJobs = (jobs) => { | ||
let lastCategory = ''; | ||
const htmlString = jobs.map(({ main_category, jobTitle, job }) => { | ||
const isNewCategory = main_category !== lastCategory; | ||
lastCategory = main_category; | ||
|
||
const linksHtml = job.links.map(link => { | ||
return ` | ||
<li class="link"> | ||
<span class="category">${link.category}</span> | ||
<a href="${link.url}" target="_blank">${link.url}</a> | ||
</li> | ||
`; | ||
}).join(''); | ||
|
||
const videosHtml = job.videos.map(video => { | ||
const videoId = extractVideoId(video.url); | ||
const thumbnailUrl = `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`; | ||
|
||
return ` | ||
<div class="video-wrapper" data-video-id="${videoId}" style="margin-bottom: 20px;"> | ||
<img src="${thumbnailUrl}" class="video-thumbnail" alt="Video thumbnail" style="cursor: pointer;" /> | ||
</div> | ||
`; | ||
}).join(''); | ||
|
||
// Display degree required in a separate text box next to the job title | ||
return ` | ||
${isNewCategory ? `<h2 class="main-category">${main_category}</h2>` : ''} | ||
<div class="job-section"> | ||
<h3 class="job-title">${jobTitle}</h3> | ||
<span class="degree-box">Degree Required: ${job.degree_required}</span> <!-- Degree info in a separate box --> | ||
<ul class="links-list">${linksHtml}</ul> | ||
<div class="videos-container">${videosHtml}</div> | ||
</div> | ||
`; | ||
}).join(''); | ||
|
||
jobslist.innerHTML = htmlString; | ||
updateMainCategory(jobs); | ||
|
||
// Add event listeners for lazy loading videos | ||
document.querySelectorAll('.video-thumbnail').forEach(thumbnail => { | ||
thumbnail.addEventListener('click', function() { | ||
const videoWrapper = this.closest('.video-wrapper'); | ||
const videoId = videoWrapper.dataset.videoId; | ||
|
||
const iframe = document.createElement('iframe'); | ||
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1`; | ||
iframe.setAttribute('frameborder', '0'); | ||
iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'); | ||
iframe.setAttribute('allowfullscreen', true); | ||
iframe.setAttribute('loading', 'lazy'); | ||
|
||
videoWrapper.innerHTML = ''; // Clear the thumbnail | ||
videoWrapper.appendChild(iframe); | ||
}); | ||
}); | ||
}; | ||
|
||
// Function to update the main category display | ||
const updateMainCategory = (jobs) => { | ||
const firstJob = jobs[0]; | ||
if (firstJob) { | ||
mainCategory.textContent = firstJob.main_category; | ||
} else { | ||
mainCategory.textContent = ''; // Clear the main category if no jobs | ||
} | ||
}; | ||
|
||
// Function to extract the YouTube video ID from the URL | ||
const extractVideoId = (url) => { | ||
const urlParams = new URLSearchParams(new URL(url).search); | ||
return urlParams.get('v') || url.split('/').pop(); | ||
}; | ||
|
||
// Load jobs data when the page is ready | ||
document.addEventListener('DOMContentLoaded', loadJobs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
// 10/25/24 backup | ||
const jobslist = document.getElementById('jobslist'); | ||
const searchBar = document.getElementById('searchBar'); | ||
const mainCategory = document.getElementById('mainCategory'); | ||
let jobData = []; | ||
|
||
// Event listener for the search bar | ||
searchBar.addEventListener('keyup', (e) => { | ||
const searchString = e.target.value.toLowerCase(); | ||
const searchWords = searchString.split(' ').filter(word => word.length > 0); | ||
|
||
if (searchWords.length === 0) { | ||
displayJobs(jobData.flatMap(category => { | ||
return Object.entries(category.jobs).map(([jobTitle, job]) => ({ | ||
main_category: category.main_category, | ||
jobTitle, | ||
job | ||
})); | ||
})); | ||
return; | ||
} | ||
|
||
const filteredJobs = jobData.flatMap(category => { | ||
return Object.entries(category.jobs) | ||
.filter(([jobTitle, job]) => { | ||
const jobTitleMatch = searchWords.some(word => jobTitle.toLowerCase().includes(word)); | ||
const linksMatch = job.links.some(link => | ||
searchWords.some(word => | ||
link.url.toLowerCase().includes(word) || | ||
link.category.toLowerCase().includes(word) | ||
) | ||
); | ||
return jobTitleMatch || linksMatch; | ||
}) | ||
.map(([jobTitle, job]) => ({ | ||
main_category: category.main_category, | ||
jobTitle, | ||
job | ||
})); | ||
}); | ||
|
||
displayJobs(filteredJobs); | ||
}); | ||
|
||
// Function to load jobs data | ||
const loadJobs = async () => { | ||
try { | ||
const res = await fetch('jobs.json'); // Adjust the path if necessary | ||
jobData = await res.json(); // Load all categories and jobs | ||
displayJobs(jobData.flatMap(category => { | ||
return Object.entries(category.jobs).map(([jobTitle, job]) => ({ | ||
main_category: category.main_category, | ||
jobTitle, | ||
job | ||
})); | ||
})); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
|
||
const displayJobs = (jobs) => { | ||
let lastCategory = ''; | ||
const htmlString = jobs.map(({ main_category, jobTitle, job }) => { | ||
const isNewCategory = main_category !== lastCategory; | ||
lastCategory = main_category; | ||
|
||
const linksHtml = job.links.map(link => { | ||
return ` | ||
<li class="link"> | ||
<span class="category">${link.category}</span> | ||
<a href="${link.url}" target="_blank">${link.url}</a> | ||
</li> | ||
`; | ||
}).join(''); | ||
|
||
const videosHtml = job.videos.map(video => { | ||
const videoId = extractVideoId(video.url); | ||
const thumbnailUrl = `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`; | ||
|
||
return ` | ||
<div class="video-wrapper" data-video-id="${videoId}" style="margin-bottom: 20px;"> | ||
<img src="${thumbnailUrl}" class="video-thumbnail" alt="Video thumbnail" style="cursor: pointer;" /> | ||
</div> | ||
`; | ||
}).join(''); | ||
|
||
// Check if a jobs table exists for the job | ||
const jobsTableHtml = job.jobs_table ? job.jobs_table : ''; | ||
|
||
// Display degree required in a separate text box next to the job title | ||
return ` | ||
${isNewCategory ? `<h2 class="main-category">${main_category}</h2>` : ''} | ||
<div class="job-section"> | ||
<h3 class="job-title">${jobTitle}</h3> | ||
<span class="degree-box">Degree Required: ${job.degree_required}</span> | ||
<ul class="links-list">${linksHtml}</ul> | ||
<div class="videos-container">${videosHtml}</div> | ||
<!-- Add the job table if it exists --> | ||
<div class="jobs-table">${jobsTableHtml}</div> | ||
</div> | ||
`; | ||
}).join(''); | ||
|
||
jobslist.innerHTML = htmlString; | ||
updateMainCategory(jobs); | ||
|
||
// Add event listeners for lazy loading videos | ||
document.querySelectorAll('.video-thumbnail').forEach(thumbnail => { | ||
thumbnail.addEventListener('click', function() { | ||
const videoWrapper = this.closest('.video-wrapper'); | ||
const videoId = videoWrapper.dataset.videoId; | ||
|
||
const iframe = document.createElement('iframe'); | ||
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1`; | ||
iframe.setAttribute('frameborder', '0'); | ||
iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'); | ||
iframe.setAttribute('allowfullscreen', true); | ||
iframe.setAttribute('loading', 'lazy'); | ||
|
||
videoWrapper.innerHTML = ''; // Clear the thumbnail | ||
videoWrapper.appendChild(iframe); | ||
}); | ||
}); | ||
}; | ||
|
||
// Function to update the main category display | ||
const updateMainCategory = (jobs) => { | ||
const firstJob = jobs[0]; | ||
if (firstJob) { | ||
mainCategory.textContent = firstJob.main_category; | ||
} else { | ||
mainCategory.textContent = ''; // Clear the main category if no jobs | ||
} | ||
}; | ||
|
||
// Function to extract the YouTube video ID from the URL | ||
const extractVideoId = (url) => { | ||
const urlParams = new URLSearchParams(new URL(url).search); | ||
return urlParams.get('v') || url.split('/').pop(); | ||
}; | ||
|
||
// Load jobs data when the page is ready | ||
document.addEventListener('DOMContentLoaded', loadJobs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.