MediaWiki:Sandbox.js: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 3: | Line 3: | ||
*/ | */ | ||
// pkmnList (object): List of Pokémon's Japanese names and their types. | $(function() { | ||
var pkmnList = { | // 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" } | ||
}; | |||
// name (string): Gets the Pokémon's English name written in the parameter "Pokémon". | |||
var name = $('#name').text(); | // name (string): Gets the Pokémon's English name written in the parameter "Pokémon". | ||
var name = $('#name').text(); | |||
// Shows the selected Pokémon's Japanese name and their types in the table. | |||
$.each(pkmnList, function(k, v) { | // Shows the selected Pokémon's Japanese name and their types in the table. | ||
$.each(pkmnList, function(k, v) { | |||
if (k == name) { | |||
$('#pkmn').append('<td>' + v.ja + '</td>'); | |||
if (v.type2) { | |||
$('#pkmn').append('<td>{{TypePKMN|' + v.type1 + '}}</td>'); | |||
$('#pkmn').append('<td>{{TypePKMN|' + v.type2 + '}}</td>'); | |||
} else { | |||
$('#pkmn').append('<td colspan="2">{{TypePKMN|' + v.type1 + '}}</td>'); | |||
} | |||
} | } | ||
} | }); | ||
}); | }); |
Revision as of 13:59, 2 October 2022
/*
* 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" }
};
// name (string): Gets the Pokémon's English name written in the parameter "Pokémon".
var name = $('#name').text();
// Shows the selected Pokémon's Japanese name and their types in the table.
$.each(pkmnList, function(k, v) {
if (k == name) {
$('#pkmn').append('<td>' + v.ja + '</td>');
if (v.type2) {
$('#pkmn').append('<td>{{TypePKMN|' + v.type1 + '}}</td>');
$('#pkmn').append('<td>{{TypePKMN|' + v.type2 + '}}</td>');
} else {
$('#pkmn').append('<td colspan="2">{{TypePKMN|' + v.type1 + '}}</td>');
}
}
});
});