-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
with great baby comes great responsibility umm yeah.
- Loading branch information
1 parent
d839df5
commit 465a696
Showing
5 changed files
with
67 additions
and
9 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,15 +1,67 @@ | ||
// Fetch the content of the content HTML file | ||
fetch('./content.html') | ||
// Get the container element for the images | ||
const imageContainer = document.getElementById('image-container'); | ||
|
||
// Get all the image elements inside the container | ||
const imageElements = Array.from(imageContainer.getElementsByTagName('img')); | ||
|
||
// Create an array of promises for each image element | ||
const imagePromises = imageElements.map(image => { | ||
// Return a new promise that resolves when the image loads or is already cached | ||
return new Promise((resolve, reject) => { | ||
// Check if the image is already cached | ||
if (image.complete) { | ||
// Resolve immediately | ||
resolve(); | ||
} else { | ||
// Add event listeners for load and error | ||
image.addEventListener('load', resolve); | ||
image.addEventListener('error', reject); | ||
} | ||
}) | ||
.catch(error => { | ||
// Handle the error | ||
console.error(error); | ||
alert('Something went wrong. Please try again.'); | ||
// You can also try to reload the image here, or skip it and resolve anyway | ||
}); | ||
}); | ||
|
||
// Wait for all the promises to resolve | ||
Promise.all(imagePromises).then(() => { | ||
// All the images have loaded or failed gracefully or were already cached | ||
console.log('All images handled'); | ||
|
||
// Fetch the content of the content HTML file | ||
fetch('/human/content.html') | ||
.then(response => response.text()) | ||
.then(html => { | ||
// Insert the content HTML into the container | ||
document.getElementById('page-content').innerHTML = html; | ||
// Insert the content HTML into the container | ||
document.getElementById('page-content').innerHTML = html; | ||
|
||
// Execute JavaScript code within the container | ||
const scriptElements = Array.from(document.getElementById('page-content').getElementsByTagName('script')); | ||
scriptElements.forEach(script => { | ||
// Execute JavaScript code within the container | ||
const scriptElements = Array.from(document.getElementById('page-content').getElementsByTagName('script')); | ||
scriptElements.forEach(script => { | ||
const newScript = document.createElement('script'); | ||
newScript.textContent = script.textContent; | ||
document.body.appendChild(newScript); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
|
||
window.onload = function() { | ||
var currentURL = window.location.href; | ||
if (!currentURL.endsWith("#Oh-ma-Gaad-Noo-Wayyyayyaayyy")) { | ||
var newURL = currentURL + "#Oh-ma-Gaad-Noo-Wayyyayyaayyy"; | ||
history.replaceState({}, null, newURL); | ||
} | ||
}; | ||
|
||
window.onpopstate = function(event) { | ||
var currentURL = window.location.href; | ||
if (currentURL.endsWith("##Oh-ma-Gaad-Noo-Wayyyayyaayyy")) { | ||
var newURL = currentURL.replace("##Oh-ma-Gaad-Noo-Wayyyayyaayyy", ""); | ||
history.replaceState({}, null, newURL); | ||
} | ||
}; |
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
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