User:Hachimitsu/common.js

From Ylvapedia
< User:Hachimitsu
Revision as of 07:30, 23 July 2024 by Hachimitsu (talk | contribs) (Created page with "importScript('MediaWiki:jquery.js'); $(document).ready(function () { // Define the keywords for pink, blue, and green text var pinkValues = ["Slightly Moist", "Moist", "Fatty", "Juicy", "Bursting with Juice","Bursting",]; var blueValues = ["Pumpkin-sized", "Putit-sized", "Monster-sized", "Mammoth-sized", "Titan-sized"]; var greenValues = ["Almost Moving", "Moving", "Lively", "Very Lively","Alive",]; // Loop through each cell in the specified table...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
importScript('MediaWiki:jquery.js');

$(document).ready(function () {
    // Define the keywords for pink, blue, and green text
    var pinkValues = ["Slightly Moist", "Moist", "Fatty", "Juicy", "Bursting with Juice","Bursting",];
    var blueValues = ["Pumpkin-sized", "Putit-sized", "Monster-sized", "Mammoth-sized", "Titan-sized"];
    var greenValues = ["Almost Moving", "Moving", "Lively", "Very Lively","Alive",];

    // Loop through each cell in the specified table 
    $('.Food td').each(function () {


        // Check if cell text contains any pinkValues
        var isPink = pinkValues.some(function(value) {
            return cellText.indexOf(value) !== -1;
        });
        if (isPink) {
            $(this).css('background-color', 'pink');
        }

        // Check if cell text contains any blueValues
        var isBlue = blueValues.some(function(value) {
            return cellText.indexOf(value) !== -1;
        });
        if (isBlue) {
            $(this).css('background-color', 'lightblue');
        }
        
        // Check if cell text contains any greenValues
        var isGreen = greenValues.some(function(value) {
            return cellText.indexOf(value) !== -1;
        });
        if (isGreen) {
            $(this).css('background-color', 'lightgreen');
        }
    });
});