MediaWiki:Common.js: Difference between revisions

From The Skullgirls Wiki
Jump to navigation Jump to search
mNo edit summary
(forcing chat gpt to kill kyle cut idk how to code this shit)
Line 9: Line 9:
         return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
         return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
       }).join(' ');
       }).join(' ');
      // Add the new categories as classes to the body
       $(document.body).addClass(newClasses);
       $(document.body).addClass(newClasses);
     }
     }
   };
   };
   if (document.body) {
   if (document.body) {
     fn();
     fn();
Line 21: Line 24:
/*Kyle image down there*/
/*Kyle image down there*/
$(document).ready(function() {
$(document).ready(function() {
     // Create a div element for the image
     // Get categories for the current page
    var imageDiv = document.createElement('div');
    var cats = mw.config.get('wgCategories');
    imageDiv.className = 'bottom-left-image';
 
   
    // Check if the page belongs to the "SG" category
    // Add the image markup to the div with CSS for size adjustment
    if (cats && !cats.includes("SG")) {
    imageDiv.innerHTML = '<a href="Kyle" title="Image"><img src="https://skullgirlz.wiki/images/1/1f/Kyle_Bloodworth-Thomason2.png" style="width: 115px; height: auto;" /></a>';
        // Create a div element for the image
   
        var imageDiv = document.createElement('div');
    // Append the div to the body
        imageDiv.className = 'bottom-left-image';
    document.body.appendChild(imageDiv);
 
        // Add the image markup to the div with CSS for size adjustment
        imageDiv.innerHTML = '<a href="Kyle" title="Image"><img src="https://skullgirlz.wiki/images/1/1f/Kyle_Bloodworth-Thomason2.png" style="width: 115px; height: auto;" /></a>';
 
        // Append the div to the body
        document.body.appendChild(imageDiv);
    }
});
});

Revision as of 12:37, 5 December 2024

/* Any JavaScript here will be loaded for all users on every page load. */

/*style based on category*/
(function($, mw) {
  var fn = function() {
    var cats = mw.config.get('wgCategories'), newClasses;
    if (cats) {
      newClasses = $.map(cats, function(el) {
        return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
      }).join(' ');

      // Add the new categories as classes to the body
      $(document.body).addClass(newClasses);
    }
  };

  if (document.body) {
    fn();
  } else {
    $(fn);
  }
})(jQuery, mw);

/*Kyle image down there*/
$(document).ready(function() {
    // Get categories for the current page
    var cats = mw.config.get('wgCategories');

    // Check if the page belongs to the "SG" category
    if (cats && !cats.includes("SG")) {
        // Create a div element for the image
        var imageDiv = document.createElement('div');
        imageDiv.className = 'bottom-left-image';

        // Add the image markup to the div with CSS for size adjustment
        imageDiv.innerHTML = '<a href="Kyle" title="Image"><img src="https://skullgirlz.wiki/images/1/1f/Kyle_Bloodworth-Thomason2.png" style="width: 115px; height: auto;" /></a>';

        // Append the div to the body
        document.body.appendChild(imageDiv);
    }
});