$(document).ready(function() { /****** Generations ******/ var G1 = [1, 151]; var G2 = [152, 251]; var G3 = [252, 386]; var G4 = [387, 493]; var G5 = [494, 649]; var G6 = [650, 721]; var G7 = [722, 809]; var G8 = [810, 905]; var G9 = [906, 908]; var MEGA = [909, 958]; var GIGA = [959, 990]; var REG = [991, 1043]; /************ GAME *************/ /*******************************/ // loading json file var json = $.getJSON('pokemon.json', function(pk) { $('article #container #game #loading').hide(); var pklist = pk; $('article #container #flashdex_config .all').click(function() { if ($(this).hasClass("unselected")) { for (i = 1; i < 10; ++i) $('input[name="'+i+'g"]').prop('checked', true); $('input[name="mega"]').prop('checked', true); $('input[name="regional"]').prop('checked', true); $('input[name="gigantamax"]').prop('checked', true); $(this).removeClass("unselected").addClass("selected"); $(this).text("Unselect all"); } else { for (i = 1; i < 10; ++i) $('input[name="'+i+'g"]').prop('checked', false); $('input[name="mega"]').prop('checked', false); $('input[name="regional"]').prop('checked', false); $('input[name="gigantamax"]').prop('checked', false); $(this).removeClass("selected").addClass("unselected"); $(this).text("Select all"); } }) // start the game when clicking on start game $('article #container .button input.start').click(function() { $('article #container #game #loading').show(); $('article #container #game #flashdex').empty(); var lang = $('article select.lang option:selected').attr('id'); var gen_list = new Array(); var pokemon_generation_list = new Array(); generations(); $('article #container #game #flashdex').hide(); function getFormText(pkmn) { if (pkmn["origin"] == "Kanto") return '' else if (pkmn["origin"] == "Johto") return '' else if (pkmn["origin"] == "Hoenn") return '' else if (pkmn["origin"] == "Sinnoh") return '' else if (pkmn["origin"] == "Unova") return '' else if (pkmn["origin"] == "Kalos") return '' else if (pkmn["origin"] == "Alola") return '' else if (pkmn["origin"] == "Galar") return '' else if (pkmn["origin"] == "Hisui") return '' else if (pkmn["origin"] == "9G") return '' else if (pkmn["type"] == "mega") return ''; else if (pkmn["type"] == "giga") return ''; return ''; } function getFormattedNumber(num) { if (num[0] == 'M' || num[0] == 'R' || num[0] == 'G') return num.substring(1, num.length); return num; } for (i in pokemon_generation_list) { $('article #container #game #flashdex').append( '