2023-03-10 11:10:43 +00:00
|
|
|
// fade in images
|
2023-04-08 19:46:03 +00:00
|
|
|
function imgFade(obj, time = 250) {
|
2023-04-02 22:07:14 +00:00
|
|
|
obj.style.transition = `opacity ${time}ms`;
|
|
|
|
obj.style.opacity = 1;
|
2023-01-26 14:43:08 +00:00
|
|
|
}
|
2023-03-10 11:10:43 +00:00
|
|
|
// Lazy load images when they are in view
|
2023-04-08 19:46:03 +00:00
|
|
|
function loadOnView() {
|
2023-04-04 14:21:16 +00:00
|
|
|
const lazyLoad = document.querySelectorAll('#lazy-load');
|
2023-04-07 14:51:03 +00:00
|
|
|
const webpSupport = checkWebpSupport();
|
2023-03-10 11:10:43 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < lazyLoad.length; i++) {
|
2023-04-19 18:04:32 +00:00
|
|
|
const image = lazyLoad[i];
|
2023-03-09 23:31:58 +00:00
|
|
|
if (image.getBoundingClientRect().top < window.innerHeight && image.getBoundingClientRect().bottom > 0) {
|
2023-04-05 11:50:05 +00:00
|
|
|
if (!image.src && webpSupport) {
|
2023-04-19 17:55:41 +00:00
|
|
|
image.src = `${image.getAttribute('data-src')}&e=webp`;
|
2023-04-05 11:50:05 +00:00
|
|
|
} else if (!image.src) {
|
2023-04-19 17:55:41 +00:00
|
|
|
image.src = image.getAttribute('data-src');
|
2023-04-05 11:50:05 +00:00
|
|
|
}
|
2023-03-09 23:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-10 11:10:43 +00:00
|
|
|
|
|
|
|
window.onload = function () {
|
|
|
|
loadOnView();
|
|
|
|
|
2023-04-19 17:55:41 +00:00
|
|
|
const times = document.querySelectorAll('.time');
|
2023-03-10 11:10:43 +00:00
|
|
|
for (let i = 0; i < times.length; i++) {
|
|
|
|
// Remove milliseconds
|
|
|
|
const raw = times[i].innerHTML.split('.')[0];
|
|
|
|
|
|
|
|
// Parse YYYY-MM-DD HH:MM:SS to Date object
|
2023-04-19 17:55:41 +00:00
|
|
|
const time = raw.split(' ')[1];
|
2023-03-10 11:10:43 +00:00
|
|
|
const date = raw.split(' ')[0].split('-');
|
|
|
|
|
2023-04-19 17:55:41 +00:00
|
|
|
// Format to YYYY/MM/DD HH:MM:SS and convert to UTC Date object
|
|
|
|
const dateTime = new Date(`${date[0]}/${date[1]}/${date[2]} ${time} UTC`);
|
2023-03-10 11:10:43 +00:00
|
|
|
|
|
|
|
// Convert to local time
|
2023-04-19 17:55:41 +00:00
|
|
|
times[i].innerHTML = `${dateTime.toLocaleDateString()} ${dateTime.toLocaleTimeString()}`;
|
2023-03-10 11:10:43 +00:00
|
|
|
}
|
2023-03-23 15:47:35 +00:00
|
|
|
|
|
|
|
// Top Of Page button
|
2023-04-19 17:55:41 +00:00
|
|
|
const topOfPage = document.querySelector('.top-of-page');
|
2023-03-23 15:47:35 +00:00
|
|
|
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
|
|
|
topOfPage.classList.add('show');
|
|
|
|
} else {
|
|
|
|
topOfPage.classList.remove('show');
|
|
|
|
}
|
|
|
|
topOfPage.onclick = function () {
|
|
|
|
document.body.scrollTop = 0;
|
|
|
|
document.documentElement.scrollTop = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Info button
|
2023-04-19 17:55:41 +00:00
|
|
|
const infoButton = document.querySelector('.info-button');
|
2023-03-27 07:15:18 +00:00
|
|
|
if (infoButton) {
|
|
|
|
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
|
|
|
infoButton.classList.remove('show');
|
|
|
|
} else {
|
|
|
|
infoButton.classList.add('show');
|
|
|
|
}
|
|
|
|
infoButton.onclick = function () {
|
2023-04-08 17:00:04 +00:00
|
|
|
popUpShow('OnlyLegs',
|
2023-04-20 16:57:28 +00:00
|
|
|
'<a href="https://github.com/Fluffy-Bean/onlylegs">v0.1.2</a> ' +
|
2023-04-08 19:46:03 +00:00
|
|
|
'using <a href="https://phosphoricons.com/">Phosphoricons</a> and Flask.' +
|
|
|
|
'<br>Made by Fluffy and others with ❤️');
|
2023-03-27 07:15:18 +00:00
|
|
|
}
|
2023-03-23 15:47:35 +00:00
|
|
|
}
|
2023-03-10 11:10:43 +00:00
|
|
|
};
|
|
|
|
window.onscroll = function () {
|
|
|
|
loadOnView();
|
|
|
|
|
2023-03-23 15:47:35 +00:00
|
|
|
// Top Of Page button
|
2023-04-19 17:55:41 +00:00
|
|
|
const topOfPage = document.querySelector('.top-of-page');
|
2023-03-10 11:10:43 +00:00
|
|
|
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
2023-03-12 18:19:43 +00:00
|
|
|
topOfPage.classList.add('show');
|
2023-03-10 11:10:43 +00:00
|
|
|
} else {
|
2023-03-12 18:19:43 +00:00
|
|
|
topOfPage.classList.remove('show');
|
2023-03-10 11:10:43 +00:00
|
|
|
}
|
2023-03-23 15:47:35 +00:00
|
|
|
|
|
|
|
// Info button
|
2023-04-19 17:55:41 +00:00
|
|
|
const infoButton = document.querySelector('.info-button');
|
2023-03-27 07:15:18 +00:00
|
|
|
if (infoButton) {
|
|
|
|
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
|
|
|
|
infoButton.classList.remove('show');
|
|
|
|
} else {
|
|
|
|
infoButton.classList.add('show');
|
|
|
|
}
|
2023-03-23 15:47:35 +00:00
|
|
|
}
|
2023-03-10 11:10:43 +00:00
|
|
|
};
|
|
|
|
window.onresize = function () {
|
|
|
|
loadOnView();
|
2023-03-23 12:54:00 +00:00
|
|
|
};
|