Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m (fixed noto) |
(fix) |
||
(One intermediate revision by the same user not shown) | |||
Line 138: | Line 138: | ||
} else { | } else { | ||
// Set stats back to Normal | // Set stats back to Normal | ||
− | hpCell.innerText = Math.round( | + | hpCell.innerText = Math.round(originalHP); |
− | atkCell.innerText = Math.round( | + | atkCell.innerText = Math.round(originalAtk * purifiedMultiplier); |
− | defCell.innerText = Math.round( | + | defCell.innerText = Math.round(originalDef * purifiedMultiplier); |
− | spaCell.innerText = Math.round( | + | spaCell.innerText = Math.round(originalSpa * purifiedMultiplier); |
− | spdCell.innerText = Math.round( | + | spdCell.innerText = Math.round(originalSpd * purifiedMultiplier); |
speCell.innerText = Math.round(originalSpe * purifiedMultiplier); | speCell.innerText = Math.round(originalSpe * purifiedMultiplier); | ||
var total = | var total = |
Revision as of 10:07, 18 October 2024
/* Any JavaScript here will be loaded for all users on every page load. */ $('.itemicon').on('error', function() { // Check if the image is already the default image to avoid infinite loop if ($(this).attr('src') !== 'https://pokegenrpg.com/images/items/shining_chest.png') { // Replace with your default image link $(this).attr('src', 'https://pokegenrpg.com/images/items/shining_chest.png'); // Replace with your default image link } }); function filterByType() { var selectedType = document.getElementById("typeFilter").value; var rows = document.querySelectorAll(".pokemonList tr"); rows.forEach(function(row, index) { var typeCell = row.cells[2]; if (index === 0) { row.style.display = ""; } else if (selectedType === "All" || typeCell.innerText.includes(selectedType)) { row.style.display = ""; } else { row.style.display = "none"; } }); } // Get the current month number, 0=jan var today = new Date().getMonth(); var logoUrl = ''; // Set the logo based on the month switch (today) { case 9: // October logoUrl = 'https://pokegenrpg.com/images/pokemon/Normal/249xd.png'; break; case 11: logoUrl = 'https://pokegenrpg.com/images/pokemon/Golden/947_1.png'; break; default: logoUrl = './logo.png'; break; } // Apply the selected logo to the .mw-wiki-logo element $('.mw-wiki-logo').css({ 'background-image': 'url("' + logoUrl + '")', 'background-size': 'contain', // Ensures the logo fits properly 'width': '160px', // Adjust based on your logo's dimensions 'height': '160px' // Adjust based on your logo's dimensions }); /* * This script dynamically updates Pokémon stats based on variant and gender. * * Created by Hoopy. * Copyright © Hoopy. All rights reserved. */ function updateStats() { var formType = document.getElementById("formType").value; // Get the selected form (Normal or Shiny) var rows = document.querySelectorAll(".pokemonList tr"); // Get all rows of the stat table var purifiedType = document.getElementById("genderselector").value; // Get the selected purified state (Normal or Purified) rows.forEach(function(row, index) { if (index !== 0) { // Skip the header row var hpCell = row.querySelector(".basestathp"); var atkCell = row.querySelector(".basestatatk"); var defCell = row.querySelector(".basestatdef"); var spaCell = row.querySelector(".basestatspa"); var spdCell = row.querySelector(".basestatspd"); var speCell = row.querySelector(".basestatspe"); var totalCell= row.querySelector(".basestattotal"); var purifiedMultiplier = (purifiedType === "Purified") ? 1.15 : 1; // 15% increase for Purified form (except HP) // Get original stat values from data attributes var originalHP = parseFloat(hpCell.getAttribute("data-original")); var originalAtk = parseFloat(atkCell.getAttribute("data-original")); var originalDef = parseFloat(defCell.getAttribute("data-original")); var originalSpa = parseFloat(spaCell.getAttribute("data-original")); var originalSpd = parseFloat(spdCell.getAttribute("data-original")); var originalSpe = parseFloat(speCell.getAttribute("data-original")); if (formType === "Shiny") { // Apply the stat increase for Shiny hpCell.innerText = Math.round(originalHP * 1.08); atkCell.innerText = Math.round(originalAtk * purifiedMultiplier * 1.08); defCell.innerText = Math.round(originalDef * purifiedMultiplier * 1.08); spaCell.innerText = Math.round(originalSpa * purifiedMultiplier * 1.08); spdCell.innerText = Math.round(originalSpd * purifiedMultiplier * 1.08); speCell.innerText = Math.round(originalSpe * purifiedMultiplier * 1.04); var total = parseInt(hpCell.innerText) + parseInt(atkCell.innerText) + parseInt(defCell.innerText) + parseInt(spaCell.innerText) + parseInt(spdCell.innerText) + parseInt(speCell.innerText); totalCell.innerText = total; } else if (formType === "Golden") { hpCell.innerText = Math.round(originalHP * 1.16); atkCell.innerText = Math.round(originalAtk * purifiedMultiplier * 1.16); defCell.innerText = Math.round(originalDef * purifiedMultiplier * 1.16); spaCell.innerText = Math.round(originalSpa * purifiedMultiplier * 1.16); spdCell.innerText = Math.round(originalSpd * purifiedMultiplier * 1.16); speCell.innerText = Math.round(originalSpe * purifiedMultiplier * 1.08); var total = parseInt(hpCell.innerText) + parseInt(atkCell.innerText) + parseInt(defCell.innerText) + parseInt(spaCell.innerText) + parseInt(spdCell.innerText) + parseInt(speCell.innerText); totalCell.innerText = total; } else if (formType === "Midnight") { // Apply the stat increase for Shiny hpCell.innerText = Math.round(originalHP); atkCell.innerText = Math.round(originalAtk * purifiedMultiplier * 1.2); defCell.innerText = Math.round(originalDef * purifiedMultiplier * 0.85); spaCell.innerText = Math.round(originalSpa * purifiedMultiplier * 1.2); spdCell.innerText = Math.round(originalSpd * purifiedMultiplier * 0.85); speCell.innerText = Math.round(originalSpe * purifiedMultiplier * 1.1); var total = parseInt(hpCell.innerText) + parseInt(atkCell.innerText) + parseInt(defCell.innerText) + parseInt(spaCell.innerText) + parseInt(spdCell.innerText) + parseInt(speCell.innerText); totalCell.innerText = total; } else if (formType === "Snow") { hpCell.innerText = Math.round(originalHP*1.17); atkCell.innerText = Math.round(originalAtk * purifiedMultiplier); defCell.innerText = Math.round(originalDef * purifiedMultiplier * 1.15); spaCell.innerText = Math.round(originalSpa * purifiedMultiplier); spdCell.innerText = Math.round(originalSpd * purifiedMultiplier * 1.15); speCell.innerText = Math.round(originalSpe * purifiedMultiplier * 0.94); var total = parseInt(hpCell.innerText) + parseInt(atkCell.innerText) + parseInt(defCell.innerText) + parseInt(spaCell.innerText) + parseInt(spdCell.innerText) + parseInt(speCell.innerText); totalCell.innerText = total; } else { // Set stats back to Normal hpCell.innerText = Math.round(originalHP); atkCell.innerText = Math.round(originalAtk * purifiedMultiplier); defCell.innerText = Math.round(originalDef * purifiedMultiplier); spaCell.innerText = Math.round(originalSpa * purifiedMultiplier); spdCell.innerText = Math.round(originalSpd * purifiedMultiplier); speCell.innerText = Math.round(originalSpe * purifiedMultiplier); var total = parseInt(hpCell.innerText) + parseInt(atkCell.innerText) + parseInt(defCell.innerText) + parseInt(spaCell.innerText) + parseInt(spdCell.innerText) + parseInt(speCell.innerText); totalCell.innerText = total; } } }); }