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
Line 5: Line 5:
$(function () {
$(function () {
   var pkmn = {
   var pkmn = {
     "Bulbasaur": { ja: "フシギダネ", type1: "Grass", type2: "Poison"},
     "Bulbasaur": { ja: "フシギダネ", type1: "Grass" },
     "Ivysaur": { ja: "フシギソウ", type1: "Grass", type2: "Poison" },
     "Ivysaur": { ja: "フシギソウ", type1: "Grass" },
     "Venusaur": { ja: "フシギバナ", type1: "Grass", type2: "Poison" }
     "Venusaur": { ja: "フシギバナ", type1: "Grass", type2: "Poison" }
   };
   };
Line 13: Line 13:
   $.each(pkmn, function(key, value) {
   $.each(pkmn, function(key, value) {
     if (key == name) {
     if (key == name) {
       $('#ja').text(value.ja);
       $('#name').html('<td>' + value.ja + '</td>);
       $('#type1').html('{{TypePKMN|' + value.type1 + '}}');
       $('#name').html('<td>{{TypePKMN|' + value.type1 + '}}</td>');
       if (value.type2) {
       if (value.type2) {
         $('#type2').html('{{TypePKMN|' + value.type2 + '}}');
         $('#name').html('<td>{{TypePKMN|' + value.type2 + '}}</td>');
       }
       }
     }
     }
   });
   });
});
});

Revision as of 13:29, 2 October 2022

/* 
*  This is a sandbox.
*/

$(function () {
  var pkmn = {
    "Bulbasaur": { ja: "フシギダネ", type1: "Grass" },
    "Ivysaur": { ja: "フシギソウ", type1: "Grass" },
    "Venusaur": { ja: "フシギバナ", type1: "Grass", type2: "Poison" }
  };
  var name = $('#name').text();

  $.each(pkmn, function(key, value) {
    if (key == name) {
      $('#name').html('<td>' + value.ja + '</td>);
      $('#name').html('<td>{{TypePKMN|' + value.type1 + '}}</td>');
      if (value.type2) {
        $('#name').html('<td>{{TypePKMN|' + value.type2 + '}}</td>');
      }
    }
  });
});