MediaWiki:Sandbox.js: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(18 intermediate revisions by 2 users not shown)
Line 2: Line 2:
*  This is a sandbox.
*  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) {
    var tr = $(this).attr('id', 'line' + k);
    if (k > 1) {
      var name = $('#line' + k + ' 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;
        } else {
          console.log(name, k)
        }
      });
    }
  });
}());

Latest revision as of 19:07, 24 May 2023

/* 
*  This is a sandbox.
*/