MediaWiki:Sandbox.js: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
m (Protected "MediaWiki:Sandbox.js" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
mNo edit summary
Line 3: Line 3:
*/
*/


$(function() {
$(function() {
  // pkmnList (object): List of Pokémon's Japanese names and their types.
   $('#table').children('tr:last-child').attr('style', 'border-radius: 0 0 0 10px');
  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 = tr.children('td:first-child').text();
      var check = pkmnList[name];
      console.log(name)
      if (check) {
        tr.append('<td style="color:blue">' + check.ja + '</td>');
        if (check.type2) {
          tr.append('<td style="color:red">' + check.type1 + '</td>');
          tr.append('<td style="color:green">' + check.type2 + '</td>');
        } else {
          tr.append('<td colspan="2" style="color:red">' + check.type1 + '</td>');
        }
      }
    }
  });
}());
}());

Revision as of 20:48, 4 October 2022

/* 
*  This is a sandbox.
*/

$(function() {  
  $('#table').children('tr:last-child').attr('style', 'border-radius: 0 0 0 10px');
}());