2020-12-10 05:51:35 +00:00
|
|
|
const BACKGROUND_IMAGES = [
|
2020-12-28 00:42:33 +00:00
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-allis.jpg",
|
|
|
|
description: "Allis Engine #4, Metropolitan Waterworks Museum",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-boston.jpg",
|
|
|
|
description: "Charles River Basin and Skyline",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-denver.jpg",
|
|
|
|
description: "Mile-High City Skyline",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-geese.jpg",
|
|
|
|
description: "Geese and Goslings on the banks of the Charles River",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-hotel.jpg",
|
|
|
|
description: "Bay Point Hotel, Lake Winnipesaukee",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-lawrencedam.jpg",
|
|
|
|
description: "Hydroelectric Dam on the St. Lawrence River",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-letchworth.jpg",
|
|
|
|
description: "The Middle Falls in Letchworth State Park",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-library.jpg",
|
|
|
|
description: "Robert W. Woodruff Library at Emory University",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-lighthouse.jpg",
|
|
|
|
description: "Nubble Lighthouse",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-mbta.jpg",
|
|
|
|
description: "Old vs New MBTA Green Line",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-rockyshore.jpg",
|
|
|
|
description: "Icy Stormy Shoreline at Brenton Point",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-rt112.jpg",
|
|
|
|
description: "Northern end of the Route 112 Scenic Byway",
|
|
|
|
source: ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://cdn.enp.one/img/backgrounds/cl-photo-startrek.jpg",
|
|
|
|
description: "Enterprise Engineering Systems at the Star Trek Set Museum",
|
|
|
|
source: ""
|
|
|
|
}
|
2020-12-10 05:51:35 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
function selectBackground() {
|
|
|
|
let max = BACKGROUND_IMAGES.length - 1
|
|
|
|
let min = 0;
|
|
|
|
index = Math.round(Math.random() * (max - min) + min);
|
2020-12-28 00:42:33 +00:00
|
|
|
console.log("Loading background #" + index + ": " + BACKGROUND_IMAGES[index].url);
|
2020-12-10 05:51:35 +00:00
|
|
|
return BACKGROUND_IMAGES[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-14 05:25:01 +00:00
|
|
|
function togglePrimaryText() {
|
|
|
|
let items = document.getElementsByClassName("article");
|
|
|
|
|
|
|
|
for (index = 0; index < items.length; index++) {
|
|
|
|
if (items[index].classList.contains("primary-text")) {
|
|
|
|
items[index].classList.remove("primary-text");
|
|
|
|
} else {
|
|
|
|
items[index].classList.add("primary-text");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let button = document.getElementById("toggle-description");
|
|
|
|
|
|
|
|
if (button.classList.contains("active")) {
|
|
|
|
button.classList.remove("active");
|
|
|
|
} else {
|
|
|
|
button.classList.add("active");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-31 23:58:33 +00:00
|
|
|
window.addEventListener("DOMContentLoaded", function () {
|
2020-12-28 00:42:33 +00:00
|
|
|
let selected = selectBackground()
|
|
|
|
|
2020-12-11 06:18:15 +00:00
|
|
|
document.getElementById(
|
|
|
|
"background-image"
|
2020-12-28 00:42:33 +00:00
|
|
|
).style.backgroundImage = "url(" + selected.url + ")";
|
2021-01-31 23:58:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2021-02-01 00:50:11 +00:00
|
|
|
window.addEventListener("load", async function () {
|
2021-04-14 05:25:01 +00:00
|
|
|
document.getElementById("toggle-description").addEventListener("click", togglePrimaryText);
|
2021-01-31 23:58:33 +00:00
|
|
|
document.getElementById("preloader").classList.add("fadeout");
|
2021-02-01 00:50:11 +00:00
|
|
|
// I don't actually know how promises or async works
|
|
|
|
// ¯\_(ツ)_/¯
|
|
|
|
// https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
|
|
|
|
await new Promise(r => setTimeout(r, 250))
|
|
|
|
document.getElementById("preloader").style.display = "none";
|
2021-01-31 23:58:33 +00:00
|
|
|
});
|