function printUpdatedAt(defaultFormat) {
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
const now = new Date();
const formats = {
1: `${months[now.getMonth()]} ${now.getDate()}`,
2: `${months[now.getMonth()]} ${now.getDate()}, ${now.getFullYear()}`,
3: `${months[now.getMonth()]} ${now.getFullYear()}`,
4: `${now.getFullYear()}`,
}
document.querySelectorAll('*[data-date]').forEach((item) => {
let format = defaultFormat || item.getAttribute('data-date') || 1;
if (!Object.keys(formats).includes(format)) {
format = 1;
}
item.textContent = formats[format];
});
}
$(document).ready(function () {
printUpdatedAt();
$(".header-menu-area button, .footer-menu-open").on('click', function () {
$(this).next().slideToggle(300);
});
if ($(".sale-popup").length > 0) {
(function popSale() {
var state = ["California", "Ohio", "Florida", "Texas", "Michigan", "Washington", "Nevada", "Arizona", "Georgia", "Pennsylvania", "Virginia", "Minnesota", "New York", "Wisconsin", "New Jersey", "Illinois", "Oregon", "Maine", "Utah", "Delaware"];
var name = ["Mark", "Olivia", "Philip", "Amelia", "Declan", "Khloe", "Jay", "Scarlett", "Thomas", "Isabella", "Bradley", "Madison", "Zac", "Sarah", "Shawn", "Jodie", "Toby", "Emilia", "Isaac", "Summer"];
function randInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
setTimeout(function () {
var time_format = randInt(0, 1) == 1 ? "seconds" : "minutes";
var number = randInt(5, 59);
$(".sale-popup-who").html(name[randInt(0, name.length - 1)] + " from " + state[randInt(0, state.length - 1)]);
$(".sale-popup-date").html(number + " " + time_format + " " + " ago | top5fitnesstracker.com");
$(".sale-popup").animate({bottom: "20px"}, 500, function () {
setTimeout(function () {
$(".sale-popup").dequeue().animate({bottom: "-150px"}, 500, popSale());
}, 4000);
});
}, randInt(30000, 55000));
})();
$(".sale-popup-close").on('click', function () {
$(".sale-popup").dequeue().animate({bottom: "-150px"}, 500);
});
}
$(".load-more-btn").on('click', function () {
var $this = $(this);
var btn_txt = $(".load-more-text");
if (btn_txt.html() == "See the rest of the list") {
$(".fadeToggle").each(function (i) {
$(this).dequeue().delay(i * 500).fadeIn(250);
});
btn_txt.html("Show top 3");
$this.html('');
} else {
$($(".fadeToggle").get().reverse()).each(function (i) {
$(this).delay(i * 500).fadeOut(250);
});
btn_txt.html("See the rest of the list");
$this.html('');
}
});
$(".scroll-down-entry").on('click', function () {
$("html, body").animate({
scrollTop: $(".entry-content").offset().top
}, 750);
});
if (typeof hash_target !== 'undefined') {
setTimeout(function () {
$("html, body").animate({
scrollTop: $(hash_target).offset().top
}, 1500, function () {
window.location.hash = hash_target;
});
}, 250);
}
var mousecount = 0;
$(document).mouseleave(function () {
if (event.clientY <= 0) {
if (mousecount < 1) {
$(".exit-popup").fadeIn(200, function () {
$("body").addClass("openpop");
});
mousecount = mousecount + 1;
}
}
});
$(".pop-off, .exit-popup-close, .exit-popup-href").on('click', function () {
$(".exit-popup").fadeOut(200, function () {
$("body").removeClass("openpop");
});
});
});