Welcome to IOPWiki, Commander.
We are searching for new editors to keep track of Girls' Frontline 2 content, as well as veteran players to complete the data of Girls' Frontline and Project Neural Cloud characters.
You can contribute without an account. Learn how to contribute and join our Discord server.

MediaWiki:Gadget-Common.js: Difference between revisions

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search
Initial setup
 
m Using RLQ to make sure jQuery is loaded
Line 1: Line 1:
/** Common JavaScript functions used over all skins and platforms. */
/** Common JavaScript functions used over all skins and platforms. */


$(document).ready(function() {
RLQ.push(['jquery', function () {
  var lazyImages = [].slice.call(document.querySelectorAll(".lazy-img"));
$(document).ready(function() {
  console.log("Images to lazy load:", lazyImages.length);
  var lazyImages = [].slice.call(document.querySelectorAll(".lazy-img"));
  if ("IntersectionObserver" in window) {
  console.log("Images to lazy load:", lazyImages.length);
    var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
  if ("IntersectionObserver" in window) {
      entries.forEach(function(entry) {
    var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
        if (entry.isIntersecting) {
      entries.forEach(function(entry) {
          var lazyImage = entry.target;
        if (entry.isIntersecting) {
          if (lazyImage.dataset.src) { lazyImage.src = lazyImage.dataset.src; }
          var lazyImage = entry.target;
          if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset; }
          if (lazyImage.dataset.src) { lazyImage.src = lazyImage.dataset.src; }
          lazyImage.classList.remove("lazy-img");
          if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset; }
          lazyImageObserver.unobserve(lazyImage);
          lazyImage.classList.remove("lazy-img");
        }
          lazyImageObserver.unobserve(lazyImage);
      });
        }
    });
      });
 
    });
    lazyImages.forEach(function(lazyImage) {
      lazyImageObserver.observe(lazyImage);
    lazyImages.forEach(function(lazyImage) {
    });
      lazyImageObserver.observe(lazyImage);
  } else {
    });
    // Possibly fall back to event handlers here
  } else {
    console.log("Lazy Loading seems to have failed.");
    // Possibly fall back to event handlers here
  }
    console.log("Lazy Loading seems to have failed.");
});
  }
});
}]);

Revision as of 01:02, 19 June 2024

/** Common JavaScript functions used over all skins and platforms. */

RLQ.push(['jquery', function () {
	$(document).ready(function() {
	  var lazyImages = [].slice.call(document.querySelectorAll(".lazy-img"));
	  console.log("Images to lazy load:", lazyImages.length);
	  if ("IntersectionObserver" in window) {
	    var lazyImageObserver = new IntersectionObserver(function(entries, observer) {
	      entries.forEach(function(entry) {
	        if (entry.isIntersecting) {
	          var lazyImage = entry.target;
	          if (lazyImage.dataset.src) { lazyImage.src = lazyImage.dataset.src; }
	          if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset; }
	          lazyImage.classList.remove("lazy-img");
	          lazyImageObserver.unobserve(lazyImage);
	        }
	      });
	    });
	
	    lazyImages.forEach(function(lazyImage) {
	      lazyImageObserver.observe(lazyImage);
	    });
	  } else {
	    // Possibly fall back to event handlers here
	    console.log("Lazy Loading seems to have failed.");
	  }
	});
}]);