2023-04-05 11:50:05 +00:00
|
|
|
let webpSupport = false;
|
|
|
|
try {
|
|
|
|
new Image().src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=';
|
|
|
|
webpSupport = true;
|
|
|
|
} catch (e) {
|
|
|
|
webpSupport = false;
|
|
|
|
}
|
|
|
|
|
2023-03-10 11:10:43 +00:00
|
|
|
// fade in images
|
|
|
|
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-03-09 23:31:58 +00:00
|
|
|
function loadOnView() {
|
2023-04-04 14:21:16 +00:00
|
|
|
const lazyLoad = document.querySelectorAll('#lazy-load');
|
2023-03-10 11:10:43 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < lazyLoad.length; i++) {
|
|
|
|
let 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) {
|
|
|
|
image.src = image.getAttribute('data-src') + '&e=webp'
|
|
|
|
} else if (!image.src) {
|
|
|
|
image.src = image.getAttribute('data-src')
|
|
|
|
}
|
2023-03-09 23:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-10 11:10:43 +00:00
|
|
|
|
|
|
|
window.onload = function () {
|
|
|
|
loadOnView();
|
|
|
|
|
|
|
|
let times = document.querySelectorAll('.time');
|
|
|
|
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
|
|
|
|
const time = raw.split(' ')[1]
|
|
|
|
const date = raw.split(' ')[0].split('-');
|
|
|
|
|
|
|
|
// Format to YYYY/MM/DD HH:MM:SS
|
|
|
|
let formatted = date[0] + '/' + date[1] + '/' + date[2] + ' ' + time + ' UTC';
|
|
|
|
|
|
|
|
// Convert to UTC Date object
|
|
|
|
let dateTime = new Date(formatted);
|
|
|
|
|
|
|
|
// Convert to local time
|
|
|
|
times[i].innerHTML = dateTime.toLocaleDateString() + ' ' + dateTime.toLocaleTimeString();
|
|
|
|
}
|
2023-03-23 15:47:35 +00:00
|
|
|
|
|
|
|
// Top Of Page button
|
|
|
|
let topOfPage = document.querySelector('.top-of-page');
|
|
|
|
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
|
|
|
|
let 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 () {
|
|
|
|
popUpShow('OnlyLegs on Flask',
|
2023-03-30 15:51:06 +00:00
|
|
|
'Using <a href="https://phosphoricons.com/">Phosphoricons</a> and ' +
|
|
|
|
'<a href="https://www.gent.media/manrope">Manrope</a> <br>' +
|
2023-03-27 07:15:18 +00:00
|
|
|
'Made by Fluffy and others with ❤️ <br>' +
|
2023-04-06 20:07:39 +00:00
|
|
|
'<a href="https://github.com/Fluffy-Bean/onlylegs">V23.04.06</a>');
|
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-03-12 18:19:43 +00:00
|
|
|
let 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
|
|
|
|
let 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
|
|
|
};
|