Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
update v1.0
  • Loading branch information
margregorioschurch authored Dec 21, 2024
1 parent 94c9b01 commit c47a1a4
Showing 1 changed file with 110 additions and 2 deletions.
112 changes: 110 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,110 @@
!function(o){"use strict";setTimeout(function(){o("#spinner").length>0&&o("#spinner").removeClass("show")},2000),new WOW().init(),o(window).scroll(function(){o(this).scrollTop()>660?o(".navbar").addClass("sticky-top shadow-lg"):o(".navbar").removeClass("sticky-top shadow-sm")});let t=o(".dropdown"),n=o(".dropdown-toggle"),e=o(".dropdown-menu"),s="show";o(window).on("load resize",function(){this.matchMedia("(min-width: 992px)").matches?t.hover(function(){let t=o(this);t.addClass(s),t.find(n).attr("aria-expanded","true"),t.find(e).addClass(s)},function(){let t=o(this);t.removeClass(s),t.find(n).attr("aria-expanded","false"),t.find(e).removeClass(s)}):t.off("mouseenter mouseleave")}),o(window).scroll(function(){o(this).scrollTop()>500?o(".back-to-top").fadeIn("slow"):o(".back-to-top").fadeOut("slow")}),o(".back-to-top").click(function(){return o("html, body").animate({scrollTop:0},1700,"easeInOutExpo"),!1}),o('[data-toggle="counter-up"]').counterUp({delay:10,time:2e3}),o(document).ready(function(){var t;o(".btn-play").click(function(){t=o(this).data("src")}),console.log(t),o("#videoModal").on("shown.bs.modal",function(n){o("#video").attr("src",t+"?autoplay=1&modestbranding=1&showinfo=0")}),o("#videoModal").on("hide.bs.modal",function(n){o("#video").attr("src",t)})}),o(".testimonial-carousel").owlCarousel({autoplay:!0,smartSpeed:1e3,center:!0,margin:24,dots:!0,loop:!0,nav:!1,responsive:{0:{items:1},768:{items:2},992:{items:3}}})}(jQuery);
//const countEll=document.getElementById("CounterVisitorNo");function viewVisitCount(){fetch("https://api.countapi.xyz/get/mgm/visits/").then(o=>o.json()).then(o=>{countEll.innerHTML=o.value})}viewVisitCount();
!function(o) {
"use strict";

// Remove spinner immediately after page load
if(o("#spinner").length > 0) {
o("#spinner").removeClass("show");
}

// Initialize WOW.js
new WOW().init();

// Sticky navbar on scroll
o(window).scroll(function() {
if (o(this).scrollTop() > 660) {
o(".navbar").addClass("sticky-top shadow-lg");
} else {
o(".navbar").removeClass("sticky-top shadow-sm");
}
});

// Dropdown hover functionality (only for large screens)
let dropdown = o(".dropdown"),
dropdownToggle = o(".dropdown-toggle"),
dropdownMenu = o(".dropdown-menu"),
showClass = "show";

o(window).on("load resize", function() {
if (this.matchMedia("(min-width: 992px)").matches) {
dropdown.hover(function() {
let dropdownItem = o(this);
dropdownItem.addClass(showClass);
dropdownItem.find(dropdownToggle).attr("aria-expanded", "true");
dropdownItem.find(dropdownMenu).addClass(showClass);
}, function() {
let dropdownItem = o(this);
dropdownItem.removeClass(showClass);
dropdownItem.find(dropdownToggle).attr("aria-expanded", "false");
dropdownItem.find(dropdownMenu).removeClass(showClass);
});
} else {
dropdown.off("mouseenter mouseleave");
}
});

// Back to top button
o(window).scroll(function() {
if (o(this).scrollTop() > 500) {
o(".back-to-top").fadeIn("slow");
} else {
o(".back-to-top").fadeOut("slow");
}
});

o(".back-to-top").click(function() {
return o("html, body").animate({scrollTop: 0}, 1700, "easeInOutExpo"), false;
});

// Counter-up functionality
o('[data-toggle="counter-up"]').counterUp({
delay: 10,
time: 2000
});

// Video modal handling
var videoSrc;
o(".btn-play").click(function() {
videoSrc = o(this).data("src");
});

console.log(videoSrc); // Just to check the value
o("#videoModal").on("shown.bs.modal", function(n) {
o("#video").attr("src", videoSrc + "?autoplay=1&modestbranding=1&showinfo=0");
});

o("#videoModal").on("hide.bs.modal", function(n) {
o("#video").attr("src", videoSrc);
});

// Initialize testimonial carousel
o(".testimonial-carousel").owlCarousel({
autoplay: true,
smartSpeed: 1000,
center: true,
margin: 24,
dots: true,
loop: true,
nav: false,
responsive: {
0: { items: 1 },
768: { items: 2 },
992: { items: 3 }
}
});

// Fetch and display visit count (this part was commented out in your original code)
const countEll = document.getElementById("CounterVisitorNo");

function viewVisitCount() {
fetch("https://api.countapi.xyz/get/mgm/visits/")
.then(o => o.json())
.then(o => {
countEll.innerHTML = o.value;
})
.catch(err => console.error("Error fetching visit count:", err));
}

// Call the viewVisitCount function to display the current visit count
viewVisitCount();

}(jQuery);

0 comments on commit c47a1a4

Please sign in to comment.