MediaWiki:Common.js: Difference between revisions

From Ylvapedia
Jump to navigation Jump to search
mNo edit summary
m (Separation of autocoloration by partial match for full line (equipment) or strict match for food tables to stop issues with sweetfish, bitterling, and class-race table contamination)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
importScript('MediaWiki:jquery.js');
importScript('MediaWiki:jquery.js');


$(document).ready(function () {
$(document).ready(function () {
     // Define the values for red and green text
     // Define the values for red and green text
     var redValues = ["Dry", "Fairy-Sized", "Dead", "Stinky", "Boring", "Crunchy", "Bitter", "Tarnished", "Bland", "Coarse", "Rustic", "Dull Color", "Harmful Substance", "Squishy", "Tasteless", "Ugly","Dangerous","Hallucinogenic", "decreases"];
     var redValues = ["Dry", "Fairy-Sized", "Dead", "Stinky", "Boring", "Crunchy", "Bitter", "Tarnished", "Bland", "Coarse", "Rustic", "Dull Color", "Harmful Substance", "Squishy", "Tasteless", "Ugly","Dangerous","Hallucinogenic", "decreases"];
   var greenValues = ["Slightly moist", "Moist", "Fatty", "Juicy", "Bursting with Juice", "Pumpkin-Sized", "Putit-Sized", "Monster-Sized", "Mammoth-Sized", "Titan-Sized", "Moving", "Lively", "Very Lively", "Faint Aroma", "Pleasant Smell", "Fragrant", "Highly Fragrant", "Heavenly Scent","Unusual", "Rare", "Super Rare", "Slightly Firm", "Stretchy", "Chewy", "Resilient", "Sweet", "Clearly Sweet", "Extremely Sweet", "Sugar Bomb", "Concerning", "Eye-Catching", "Cute", "Beautiful", "Creepy Cute", "Collagen Rich", "Creamy", "Mellow", "Thick", "Velvety", "Dense", "Very Dense", "Concentrated", "Ultra Concentrated", "Rough", "Delicate", "Extremely Delicate","Pale Color", "Colorful", "Bright", "Trace Vitamins", "Small Vitamins", "Moderate Vitamins", "Large Vitamins", "A treasure trove of vitamins", "Flaky", "Crispy", "Very Crispy", "Snappy", "Spicy", "Very Spicy", "Extremely Spicy", "Intensely Spicy", "Glossy", "Bright", "Shiny", "Lustrous", "Bewitchingly Shiny", "increases", "grants you", "float", "enhances", "better", "additional", "easier", "sustains", "slows the process of decay", ];
   var greenValues = ["Slightly moist", "Moist", "Fatty", "Juicy", "Bursting with Juice", "Pumpkin-Sized", "Putit-Sized", "Monster-Sized", "Mammoth-Sized", "Titan-Sized", "Moving", "Lively", "Very Lively", "Faint Aroma", "Pleasant Smell", "Fragrant", "Highly Fragrant", "Heavenly Scent","Unusual", "Rare", "Super Rare", "Slightly Firm", "Stretchy", "Chewy", "Resilient", "Sweet", "Clearly Sweet", "Extremely Sweet", "Sugar Bomb", "Concerning", "Eye-Catching", "Cute", "Beautiful", "Creepy Cute", "Collagen Rich", "Creamy", "Mellow", "Thick", "Velvety", "Dense", "Very Dense", "Concentrated", "Ultra Concentrated", "Rough", "Delicate", "Extremely Delicate","Pale Color", "Colorful", "Bright", "Trace Vitamins", "Small Vitamins", "Moderate Vitamins", "Large Vitamins", "A treasure trove of vitamins", "Flaky", "Crispy", "Very Crispy", "Snappy", "Spicy", "Very Spicy", "Extremely Spicy", "Intensely Spicy", "Glossy", "Bright", "Shiny", "Lustrous", "Bewitchingly Shiny"];
 
    // Loop through each Food table cell in wikitable
    $('.wikitable Food td').each(function () {
        var cellText = $(this).text().trim();
 
        // Check if cell text is exactly equal to any redValues
        if (redValues.includes(cellText)) {
            $(this).css('color', 'red');
        }
 
        // Check if cell text is exactly equal to any greenValues
        if (greenValues.includes(cellText)) {
            $(this).css('color', 'green');
        }
    });
});
 
// Script for auto coloration of text in equipment tables
$(document).ready(function () {
    // Define the values for red and green text
    var redValues = ["decreases"];
  var greenValues = ["increases", "grants you", "float", "enhances", "better", "additional", "easier", "sustains", "slows the process of decay", ];


     // Loop through each table cell in wikitable
     // Loop through each Equipment table cell in wikitable
     $('.wikitable td').each(function () {
     $('.wikitable Equipment td').each(function () {
         var cellText = $(this).text().trim();
         var cellText = $(this).text().trim();


         // Check if cell text contains any redValues partially
         // Check if cell text contains redValues  
         if (redValues.some(function (value) {
         if (redValues.some(function (value) {
             return cellText.indexOf(value) !== -1;
             return cellText.indexOf(value) !== -1;
Line 18: Line 42:
         }
         }


         // Check if cell text contains any greenValues partially
         // Check if cell text contains greenValues  
         if (greenValues.some(function (value) {
         if (greenValues.some(function (value) {
             return cellText.indexOf(value) !== -1;
             return cellText.indexOf(value) !== -1;

Revision as of 02:44, 3 March 2024

/* Any JavaScript here will be loaded for all users on every page load. */
importScript('MediaWiki:jquery.js');


$(document).ready(function () {
    // Define the values for red and green text
    var redValues = ["Dry", "Fairy-Sized", "Dead", "Stinky", "Boring", "Crunchy", "Bitter", "Tarnished", "Bland", "Coarse", "Rustic", "Dull Color", "Harmful Substance", "Squishy", "Tasteless", "Ugly","Dangerous","Hallucinogenic", "decreases"];
   var greenValues = ["Slightly moist", "Moist", "Fatty", "Juicy", "Bursting with Juice", "Pumpkin-Sized", "Putit-Sized", "Monster-Sized", "Mammoth-Sized", "Titan-Sized", "Moving", "Lively", "Very Lively", "Faint Aroma", "Pleasant Smell", "Fragrant", "Highly Fragrant", "Heavenly Scent","Unusual", "Rare", "Super Rare", "Slightly Firm", "Stretchy", "Chewy", "Resilient", "Sweet", "Clearly Sweet", "Extremely Sweet", "Sugar Bomb", "Concerning", "Eye-Catching", "Cute", "Beautiful", "Creepy Cute", "Collagen Rich", "Creamy", "Mellow", "Thick", "Velvety", "Dense", "Very Dense", "Concentrated", "Ultra Concentrated", "Rough", "Delicate", "Extremely Delicate","Pale Color", "Colorful", "Bright", "Trace Vitamins", "Small Vitamins", "Moderate Vitamins", "Large Vitamins", "A treasure trove of vitamins", "Flaky", "Crispy", "Very Crispy", "Snappy", "Spicy", "Very Spicy", "Extremely Spicy", "Intensely Spicy", "Glossy", "Bright", "Shiny", "Lustrous", "Bewitchingly Shiny"];

    // Loop through each Food table cell in wikitable
    $('.wikitable Food td').each(function () {
        var cellText = $(this).text().trim();

        // Check if cell text is exactly equal to any redValues
        if (redValues.includes(cellText)) {
            $(this).css('color', 'red');
        }

        // Check if cell text is exactly equal to any greenValues
        if (greenValues.includes(cellText)) {
            $(this).css('color', 'green');
        }
    });
});

	// Script for auto coloration of text in equipment tables
	
$(document).ready(function () {
    // Define the values for red and green text
    var redValues = ["decreases"];
   var greenValues = ["increases", "grants you", "float", "enhances", "better", "additional", "easier", "sustains", "slows the process of decay", ];

    // Loop through each Equipment table cell in wikitable
    $('.wikitable Equipment td').each(function () {
        var cellText = $(this).text().trim();

        // Check if cell text contains redValues 
        if (redValues.some(function (value) {
            return cellText.indexOf(value) !== -1;
        })) {
            $(this).css('color', 'red');
        }

        // Check if cell text contains greenValues 
        if (greenValues.some(function (value) {
            return cellText.indexOf(value) !== -1;
        })) {
            $(this).css('color', 'green');
        }
    });
});