MediaWiki:Sandbox.js

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 15:48, 2 October 2022 by Adkuate (talk | contribs)
Jump to navigation Jump to search

CSS and Javascript changes must comply with the wiki design rules.


Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
/* 
*  This is a sandbox.
*/

$(function() {
  // pkmnList (object): List of Pokémon's Japanese names and their types.
  var pkmnList = {
    Bulbasaur: { ja: "フシギダネ", type1: "Grass" },
    Ivysaur: { ja: "フシギソウ", type1: "Grass" },
    Venusaur: { ja: "フシギバナ", type1: "Grass", type2: "Poison" }
  };
  
  // Shows the selected Pokémon's Japanese name and their types in the table.
  $.each($('#pkmn tr'), function(k, v) {
    if (k > 1) {
      var tr = $(this).attr('id', 'row_' + (k - 1));
      var name = $('#row_' + (k - 1) + ' td:first-child').text();
      $.each(pkmnList, function(k, v) {
        if (name == k) {
          tr.append('<td style="color:blue">' + v.ja + '</td>');
          if (v.type2) {
            tr.append('<td style="color:red">' + v.type1 + '</td>');
            tr.append('<td style="color:green">' + v.type2 + '</td>');
          } else {
            tr.append('<td colspan="2" style="color:red">' + v.type1 + '</td>');
          }
          return true;
        }
      });
    }
  });
}());