Mudanças entre as edições de "MediaWiki:Common.js"

De Wiki Gla
Ir para navegação Ir para pesquisar
Linha 632: Linha 632:
     const missingPotions = calcMissingXpInPotions();
     const missingPotions = calcMissingXpInPotions();


     let complementaryPotS, complementaryPotM;
     let complementaryPotS;
    let complementaryPotM;
     let potS = potions['small'];   
     let potS = potions['small'];   
     let potM = potions['medium'];
     let potM = potions['medium'];

Edição das 21h19min de 17 de julho de 2022

  $(document).ready(function() {
  	
  		//------- TOOLTIP IMAGE---------
  	  		/*
  	  			Tooltip image consiste em uma funcionalidade que insere uma tag IMG 
  	  			quando o usuario passa o mouse por cima de uma imagem com a classe "tooltip-image"
  	  			ao fazer é inserido no body uma tag IMG com a mesma "src" 1.3 vezes maior do que a imagem
  	  			que o usuario está com o mouse em coma, esta tag IMG terá o mesmo X e Y do mouse + um offset 
  	  			para manter um distanciamento.
  	  		*/
  	  		
  	  		//Distanciamento / margem do mouse
	  	  	const offset = { x: 20, y: 10 };
	  	  	
	  		$('.tooltip-image').on('mouseenter', 	  			
	  			function(e) {
	  				var src = $(this).attr('src');
	  				var size = $(this).width() * 1.3;
	  			
	  				$('<img src="'+ src +'" id="bigImage" />').css('left', e.pageX + offset.x).css('top', e.pageY + offset.y).css('width', size + "px").appendTo('body').hide().fadeIn(500);
	  			}).on('mouseleave',
	  				function(){
	  					$('#bigImage').remove();
	  			});
	  		
	  		$('.tooltip-image').mousemove(function(e) {
	  			$('#bigImage').css('left', e.pageX + offset.x).css('top', e.pageY + offset.y);
	  		});
  		//------- TOOLTIP IMAGE---------
  		
  		//------- FUNCIONALIDADES PACIENTES KUREHA ---------
  		const pacients = {
  			"bafo":{ image: "/images/c/ce/Bafo_static.png", gif: "/images/e/e0/Bafo.gif"},
  			"espirrando": { image: "/images/thumb/5/5b/Espirro_static.png/180px-Espirro_static.png", gif: "/images/thumb/9/90/Espirro.gif/180px-Espirro.gif", audio:"/images/2/2b/Espirrando.ogg"},
  			"enjoado": { image: "/images/thumb/5/52/Enjoado_static.png/180px-Enjoado_static.png", gif: "/images/thumb/7/76/Enjoado.gif/180px-Enjoado.gif", audio:"/images/5/5b/Vomito.ogg"},
  			"tremendo": { image: "/images/thumb/3/35/Tremendo_static.png/180px-Tremendo_static.png", gif: "/images/thumb/f/f4/Tremendo.gif/180px-Tremendo.gif"},
  			"tossindo": { image: "/images/thumb/e/ef/Tosse_static.png/180px-Tosse_static.png", gif: "/images/thumb/a/a4/Tosse.gif/180px-Tosse.gif", audio:"/images/f/f9/Tossindo.ogg"},
  			"solucando": { image: "/images/thumb/c/c0/Soluco_static.png/180px-Soluco_static.png", gif: "/images/thumb/6/67/Soluco.gif/180px-Soluco.gif", audio:"/images/e/e2/Solucando.ogg"},
  			"funk": { image: "/images/thumb/e/e8/Funkeiro_static.png/180px-Funkeiro_static.png ", gif: "/images/thumb/7/79/Funkeiro.gif/180px-Funkeiro.gif", audio:"/images/d/d2/Funk.ogg"},
  			"fedendo": { image: "/images/thumb/1/1e/Fedido_static.png/180px-Fedido_static.png", gif: "/images/thumb/c/c9/Fedido.gif/180px-Fedido.gif"},
  			"febre": { image: "/images/thumb/1/14/Febre_static.png/180px-Febre_static.png", gif: "/images/thumb/7/75/Febre.gif/180px-Febre.gif"},
  			"endemoniado": {audio: "/images/3/32/Risada_maligna.ogg"},
  			"fome": {audio: "/images/3/37/Estomago_roncando.ogg"},
  			"cardiaco": {audio: "/images/2/27/Coracao_batendo.ogg"}
  		};
  		
  		const audioPlayer = document.querySelector("#audio");
  		
  		$(".pacient-audio").on("click", function(e){
  			id = $(this).attr('id');
  			
  			if(pacients[id]){
  				audioPlayer.src = pacients[id].audio;
  				audioPlayer.play();
  			}
  				
  		});
  		
  		$('.interactive-pacient').on('mouseenter', function (e){
  			 id = $(this).attr('id');
  			 
  			 if(pacients[id])
  			 	$(this).attr('src', pacients[id].gif);
  		}).on('mouseleave', function(e){
  		 	 id = $(this).attr('id');
  			 
  			 if(pacients[id])
  			 	$(this).attr('src', pacients[id].image);
  		});
  		
  		//------- FUNCIONALIDADES PACIENTES KUREHA ---------
  	
  //------- COUNTDOWN MAINPAGE---------
  		
  		/*
  			O countdown é um codigo pega a data e hora do computador do usuario e aplica um calculo
  			para adaptar o mesmo ao fuso horario de brasilia, após isso ele verifica os eventos do
  			dia começa uma contagem regressiva com base na diferença do horario do computador do 
  			usuario com a do evento.
  		*/
  		
  		const timer = $('#event-time');
  		const eventImage = $('.event-image');  				
  		//Informações dos eventos
          /*
            0 - Sunday
            1 - Monday
            2 - Tuesday
            3 - Wednesday
            4 - Thursday
            5 - Friday
            6 - Saturday
          */
  		const eventsInfo = {
  			0: [
  				{name: 'Foxy race (ship)', time: '09:30:00', src: '/images/c/c0/Event_ship.png'},
  				{name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  				{name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  				{name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  			],
  			1: [
  				{name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  				{name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  				{name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  				{name: 'Foxy race (ship)', time: '22:00:00', src: '/images/c/c0/Event_ship.png'},
  			],
  			2: [
  				{name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  				{name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  				{name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  				{name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  			],
  			3: [
  				{name: 'Deathmatch', time: '09:30:00', src: '/images/8/84/Event_dm.png'},
  				{name: 'Foxy race (ship)', time: '15:00:00', src: '/images/c/c0/Event_ship.png'},
  				{name: 'Foxy count', time: '19:00:00', src: '/images/e/e4/Event_count.png'},
  				{name: 'Foxy quiz', time: '22:00:00', src: '/images/6/6f/Event_quiz.png'},
  			],
  			4: [
  				{name: 'Foxy race', time: '09:30:00', src: '/images/0/03/Event_race.png'},
  				{name: 'Foxy count', time: '15:00:00', src: '/images/e/e4/Event_count.png'},
  				{name: 'Foxy quiz', time: '19:00:00', src: '/images/6/6f/Event_quiz.png'},
  				{name: 'Deathmatch', time: '22:00:00', src: '/images/8/84/Event_dm.png'},
  			],
  			5: [
  				{name: 'Foxy count', time: '09:30:00', src: '/images/e/e4/Event_count.png'},
  				{name: 'Foxy quiz', time: '15:00:00', src: '/images/6/6f/Event_quiz.png'},
  				{name: 'Deathmatch', time: '19:00:00', src: '/images/8/84/Event_dm.png'},
  				{name: 'Foxy race (ship)', time: '22:00:00', src: '/images/c/c0/Event_ship.png'},
  			],
  			6: [
  				{name: 'Foxy quiz', time: '09:30:00', src: '/images/6/6f/Event_quiz.png'},
  				{name: 'Deathmatch', time: '15:00:00', src: '/images/8/84/Event_dm.png'},
  				{name: 'Foxy race', time: '19:00:00', src: '/images/0/03/Event_race.png'},
  				{name: 'Foxy count', time: '22:00:00', src: '/images/e/e4/Event_count.png'},
  			]
  		};
  		  		
		const brazilOffset = -3;
  		const eventTime = new Date(); 
	  	const eventStarting = new Date();	  	          		
  		var haveEvent = false;

  		function pad(d) {
		    return (d < 10) ? '0' + String(d) : String(d);
  		}
  		
  		function startTimer(eventTime, name){							
			interval = setInterval(function() {
				const now = new Date().getTime();
	  			const distance = eventTime.getTime() - now;
	  			
	  			if(distance > 0){
	  				const hour = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
	  				const minute = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
	  				const seconds = Math.floor((distance % (1000 * 60)) / 1000);
	  				
	  				timer.html(pad(hour) + ":" + pad(minute) + ":" + pad(seconds));                    
	  			}else {
                    haveEvent = false;
	  				setDayEvents();
	  				clearInterval(interval);
	  			}
	  		}, 1000);
		}
  		
  		function setDayEvents () {  				
			const date = new Date();
			const dayEvents = eventsInfo[date.getDay()];		            
	  		const utcTime = date.getTime() + (date.getTimezoneOffset() * 60000);
	  		const currentTime = new Date(utcTime + (3600000 * brazilOffset));            	  		

			$.each(dayEvents, function (key, item) {
  				split = item.time.split(":");
  				eventTime.setHours(split[0], split[1], split[2]);
	  			eventStarting.setHours(split[0], (Number(split[1]) + 5), split[2]);	  		

	  			if(currentTime.getTime() <= eventTime.getTime()){						
					eventImage.attr('src', item.src);	  	  							
                    haveEvent = true;
					startTimer(eventTime);

	  				return false;
	  			}else if(currentTime.getTime() > eventTime.getTime() && currentTime.getTime() < eventStarting.getTime()){
	  				eventImage.attr('src', item.src);
	  				timer.html('O evento está começando!');
					haveEvent = true;
	  				
					setTimeout(function(){
						haveEvent = false;
						return false;
					}, 300000);		
	  			}
	  		});                        
         
			if(!haveEvent){								
				eventImage.attr('src', "/images/a/a5/AnyEvent.png");
	  			timer.html('');	
			}
			
  		}
	
		if(!haveEvent)
        	setDayEvents();	

//------- COUNTDOWN MAINPAGE---------

//------- PERSONAGENS ---------

	const characters = [  
	    {name: "Bartolomew Kuma", types: ["especialist", "tank", "diamond", "break_wall"], link: "/Kuma",img: "/images/b/b5/Card-kuma.png"},
	    {name: "Boa Hancock", types: ["fighter", "dps", "diamond"], link: "/Boa_Hancock",img: "/images/4/47/Card-hancock.png"},
	    {name: "Borsalino Kizaru", types: ["especialist", "shooter", "dps", "diamond", "break_wall"], link: "/Kizaru",img: "/images/3/32/Card-kizaru.png"},
	    {name: "Brook (TS)", types: ["slasher", "support", "diamond", "bridge"], link: "/Brook_(Timeskip)",img: "/images/1/1d/Card-brookts.png"},
	    {name: "Chopper (TS) Mathzs", types: ["fighter", "support", "diamond", "break_wall"], link: "/Chopper_(Timeskip)",img: "/images/5/53/Card-chopperts.png"},
	    {name: "Doflamingo", types: ["shooter", "especialist", "dps", "diamond", "break_wall", "bridge"], link: "/Doflamingo",img: "/images/8/8d/Card-doflamingo.png"},
	    {name: "Dracule Mihawk Horus", types: ["slasher", "dps", "diamond", "break_wall"], link: "/Mihawk",img: "/images/9/91/Card-mihawk.png"},
	    {name: "Emporio Ivankov", types: ["fighter", "support", "diamond", "break_wall"], link: "/Ivankov",img: "/images/c/ca/Card-ivankov.png"},
	    {name: "Franky (TS)", types: ["shooter", "tank", "diamond", "break_wall"], link: "/Franky_(Timeskip)",img: "/images/d/d0/Card-frankyts.png"},
	    {name: "Jinbe", types: ["fighter", "tank", "diamond", "break_wall"], link: "/Jinbe",img: "/images/2/2e/Card-jinbe.png"},
	    {name: "Marshall D. Teach", types: ["especialist", "bruiser", "diamond"], link: "/Marshall_D._Teach",img: "/images/f/ff/Card-kurohige.png"},
	    {name: "Monkey D. Luffy (TS)", types: ["fighter", "dps", "diamond", "break_wall"], link: "/Luffy_(Timeskip)",img: "/images/e/ed/Card-luffyts.png"},
	    {name: "Nami (TS)", types: ["especialist", "dps", "diamond"], link: "/Nami_(Timeskip)",img: "/images/3/35/Card-namits.png"},
	    {name: "Portgas D. Ace Duduh", types: ["especialist", "shooter", "dps", "diamond"], link: "/Ace",img: "/images/4/40/Card-ace.png"},
	    {name: "Robin (TS)", types: ["especialist", "dps", "diamond", "break_wall", "bridge"], link: "/Robin_(Timeskip)",img: "/images/b/b0/Card-robints.png"},
	    {name: "Roronoa zoro (TS)", types: ["slasher", "dps", "diamond", "break_wall"], link: "/Zoro_(Timeskip)",img: "/images/7/74/Card-zorots.png"},
	    {name: "Sabo", types: ["fighter", "especialist", "dps", "diamond", "break_wall"], link: "/Sabo",img: "/images/0/04/Card-sabo.png"},
	    {name: "Shanks", types: ["slasher", "bruiser", "diamond", "break_wall"], link: "/Shanks",img: "/images/a/aa/Card-shanks.png"},
	    {name: "Usopp (TS)", types: ["shooter", "dps", "diamond", "break_wall"], link: "/Usopp_(Timeskip)",img: "/images/c/cc/Card-usoppts.png"},
	    {name: "Vinsmoke Sanji (TS)", types: ["fighter", "dps", "diamond", "break_wall"], link: "/Sanji_(Timeskip)",img: "/images/7/7a/Card-sanjits.png"},
	    {name: "Bartolomeo", types: ["especialist", "dps", "gold", "break_wall", "bridge"], link: "/Bartolomeo",img: "/images/a/a9/Card-barto.png"}, 
	    {name: "Basil Hawkins Lost", types: ["especialist", "bruiser", "gold", "bridge"], link: "/Basil_Hawkins",img: "/images/8/89/Card-hawkins.png"}, 
	    {name: "Bastille", types: ["slasher", "tank", "gold", "break_wall"], link: "/Bastille",img: "/images/1/13/Card-bastille.png"}, 
	    {name: "Bellamy", types: ["fighter", "dps", "gold", "break_wall"], link: "/Bellamy",img: "/images/7/7e/Card-bellamy.png"}, 
	    {name: "Bonney Poseidon", types: ["fighter", "support", "gold"], link: "/Bonney",img: "/images/9/91/Card-bonney.png"}, 
	    {name: "Brook", types: ["slasher", "support", "gold"], link: "/brook",img: "/images/7/76/Card-brook.png"}, 
	    {name: "Capone gang bege", types: ["shooter", "dps", "gold", "break_wall"], link: "/Capone_Bege",img: "/images/c/c0/Card-capone.png"}, 
	    {name: "Carrot", types: ["slasher", "especialist", "dps", "gold"], link: "/Carrot",img: "/images/8/8d/Card-carrot.png"}, 
	    {name: "Tony Tony Chopper", types: ["fighter", "support", "gold", "break_wall"], link: "/Chopper",img: "/images/1/19/Card-chopper.png"},
	    {name: "Crocodile", types: ["especialist", "tank", "gold", "break_wall", "bridge"], link: "/Crocodile",img: "/images/5/5d/Card-crocodile.png"},  
	    {name: "Dalmatian", types: ["slasher", "bruiser", "gold", "break_wall"], link: "/Dalmatian",img: "/images/9/99/Card-dalmatian.png"}, 
	    {name: "Franky", types: ["shooter", "bruiser", "gold", "break_wall"], link: "/Franky",img: "/images/6/61/Card-franky.png"},
	    {name: "Hina Rasky", types: ["fighter", "bruiser", "gold", "break_wall", "bridge"], link: "/Hina",img: "/images/5/57/Card-hina.png"},
	    {name: "Jesus Burguess", types: ["fighter", "tank", "gold", "break_wall"], link: "/Jesus_Burgess",img: "/images/2/28/Card-burgess.png"},
	    {name: "Eustass Kid Rag", types: ["shooter", "tank", "gold", "break_wall", "bridge"], link: "/Kid",img: "/images/9/9a/Card-kid.png"},
	    {name: "Killer", types: ["slasher", "dps", "gold"], link: "/Killer",img: "/images/b/b2/Card-killer.png"},
	    {name: "Koala Miza", types: ["fighter", "dps", "gold"], link: "/Koala",img: "/images/f/f3/Card-koala.png"},
	    {name: "Leo & Mansherry", types: ["especialist", "support", "gold", "bridge"], link: "/Leo",img: "/images/d/d9/Card-leo.png"},
	    {name: "Monkey D. Luffy", types: ["fighter", "bruiser", "gold", "break_wall"], link: "/Luffy",img: "/images/a/af/Card-luffy.png"},
	    {name: "Nami", types: ["especialist", "dps", "gold", "break_wall"], link: "/nami",img: "/images/0/08/Card-nami.png"},
	    {name: "Perona", types: ["especialist", "support", "gold", "break_wall"], link: "/Perona",img: "/images/6/6d/Card-perona.png"},
	    {name: "Rebecca", types: ["slasher", "tank", "gold"], link: "/Rebecca",img: "/images/9/91/Card-rebecca.png"},
	    {name: "Nico Robin", types: ["especialist", "dps", "gold", "break_wall", "bridge"], link: "/Robin",img: "/images/3/3f/Card-robin.png"},
	    {name: "Roronoa zoro", types: ["slasher", "bruiser", "gold", "break_wall"], link: "/Zoro",img: "/images/6/6f/Card-zoro.png"},
	    {name: "Ryuma", types: ["slasher", "dps", "gold"], link: "/Ryuma",img: "/images/a/ac/Card-ryuma.png"},
	    {name: "Scratchmen Apoo", types: ["shooter", "support", "gold"], link: "/Apoo",img: "/images/9/90/Card-apoo.png"},
	    {name: "Smoker", types: ["fighter", "tank", "gold"], link: "/Smoker",img: "/images/f/fb/Card-smoker.png"},
	    {name: "Trafalgar Law Zhao Feng", types: ["slasher", "especialist", "dps", "gold", "break_wall"], link: "/Law",img: "/images/b/b9/Card-law.png"},
	    {name: "Urouge", types: ["fighter", "tank", "gold", "break_wall"], link: "/Urouge",img: "/images/9/98/Card-urouge.png"},
	    {name: "Usopp", types: ["shooter", "dps", "gold", "break_wall"], link: "/Usopp",img: "/images/a/ac/Card-usopp.png"},
	    {name: "Van Augur", types: ["shooter", "dps", "gold", "break_wall"], link: "/Van_Augur",img: "/images/c/c7/Card-vanaugur.png"},
	    {name: "Vinsmoke Ichiji", types: ["fighter", "bruiser", "gold", "break_wall"], link: "/Ichiji",img: "/images/8/8c/Card-ichiji.png"},
	    {name: "Vinsmoke Niji", types: ["shooter", "dps", "gold"], link: "/Niji",img: "/images/6/66/Card-niji.png"},
	    {name: "Vinsmoke Reiju Athena", types: ["especialist", "support", "gold"], link: "/Reiju",img: "/images/2/23/Card-reiju.png"},
	    {name: "Vinsmoke Sanji", types: ["fighter", "dps", "gold", "break_wall"], link: "/Sanji",img: "/images/0/04/Card-sanji.png"},
	    {name: "Vinsmoke Yonji", types: ["fighter", "tank", "gold", "break_wall"], link: "/Yonji",img: "/images/7/73/Card-yonji.png"},
	    {name: "X-drake", types: ["fighter", "bruiser", "gold", "break_wall"], link: "/X_Drake",img: "/images/6/69/Card-drake.png"},
	    {name: "Arlong Bajin", types: ["fighter", "bruiser", "silver", "break_wall"], link: "/Arlong",img: "/images/1/1e/Card-arlong.png"},
	    {name: "Bepo", types: ["fighter", "dps", "silver"], link: "/Bepo",img: "/images/1/1d/Card-bepo.png"},
	    {name: "Mr.2", types: ["fighter", "dps", "silver"], link: "/mr.2",img: "/images/2/27/Card-bonchan.png"},
	    {name: "Buggy", types: ["shooter", "dps", "silver", "break_wall"], link: "/buggy",img: "/images/c/ca/Card-buggy.png"},
	    {name: "Daddy Masterson", types: ["shooter", "dps", "silver"], link: "/Daddy_Masterson",img: "/images/2/20/Card-daddy.png"},
	    {name: "mr.1 Daz Bonez Kolivier", types: ["slasher", "tank", "silver"], link: "/mr.1",img: "/images/6/61/Card-dazbonez.png"},
	    {name: "Miss Doublefinger Zala", types: ["slasher", "bruiser", "silver"], link: "/Miss_Doublefinger",img: "/images/5/5f/Card-doublefinger.png"},
	    {name: "Don Krieg", types: ["shooter", "dps", "silver"], link: "/don_Krieg",img: "/images/8/8f/Card-krieg.png"},
	    {name: "Kuro", types: ["slasher", "dps", "silver"], link: "/kuro",img: "/images/3/3d/Card-kuro.png"},
	    {name: "mr.3 Galdino", types: ["especialist", "support", "silver", "bridge"], link: "/mr.3",img: "/images/7/75/Card-mr3.png"},
	    {name: "Tashigi", types: ["slasher", "dps", "silver"], link: "/tashigi",img: "/images/b/b8/Card-tashigi.png"},
	    {name: "Nefertari Vivi", types: ["slasher", "support", "silver"], link: "/Vivi",img: "/images/9/9c/Card-vivi.png"},
	    {name: "Wapol", types: ["shooter", "tank", "silver", "break_wall"], link: "/wapol",img: "/images/b/ba/Card-wapol.png"},
	    {name: "Alvida", types: ["fighter", "support", "bronze"], link: "/Alvida",img: "/images/8/83/Card-alvida.png"},
	    {name: "Buchi & Sham", types: ["slasher", "bruiser", "bronze"], link: "/Buchi",img: "/images/0/0b/Card-buchi.png"},
	    {name: "Cabaji", types: ["slasher", "dps", "bronze"], link: "/Cabaji",img: "/images/9/9d/Card-cabaji.png"},
	    {name: "Chew", types: ["shooter", "dps", "bronze", "break_wall"], link: "/Chew",img: "/images/0/0f/Card-chew.png"},
	    {name: "Eric", types: ["shooter", "slasher", "dps", "bronze"], link: "/Eric",img: "/images/3/31/Card-eric.png"},
	    {name: "Gin", types: ["fighter", "shooter", "dps", "bronze"], link: "/Gin",img: "/images/1/18/Card-gin.png"},
	    {name: "Miss Goldenweek", types: ["support", "especialist", "bronze"], link: "/Goldenweek",img: "/images/0/0e/Card-goldenweek.png"},
	    {name: "Hatchan", types: ["slasher", "support", "bronze"], link: "/Hatchan",img: "/images/3/31/Card-hatchan.png"},
	    {name: "Jango", types: ["shooter", "support", "bronze"], link: "/Jango",img: "/images/4/48/Card-jango.png"},
	    {name: "Kuroobi", types: ["fighter", "tank", "bronze", "break_wall"], link: "/Kuroobi",img: "/images/6/6a/Card-kuroobi.png"},
	    {name: "Mohji", types: ["especialist", "bruiser", "bronze"], link: "/Mohji",img: "/images/5/58/Card-mohji.png"},
	    {name: "Morgan", types: ["slasher", "bruiser", "bronze"], link: "/Morgan",img: "/images/4/43/Card-morgan.png"},
	    {name: "Mr.4", types: ["shooter", "bruiser", "bronze"], link: "/Mr.4",img: "/images/9/90/Card-mr4.png"},
	    {name: "Mr.5", types: ["shooter", "dps", "bronze"], link: "/Mr.5",img: "/images/4/49/Card-mr5.png"},
	    {name: "Pearl", types: ["fighter", "tank", "bronze"], link: "/Pearl",img: "/images/d/de/Card-pearl.png"},
	];
	
	$(".filter--icon").on("click", function() {
			const id = $(this).attr("id");
		
		if($(this).hasClass("all")){
			$('.filter--icon.active').removeClass('active');
			$(".characters").addClass('show');
			$(".filter--icon.all").addClass('active');
			return false;
		}else {
			$(".filter--icon.all").removeClass('active');
		}
		
		if($(this).hasClass("active")){
			$(this).removeClass('active');
			actives = $('.filter--icon.active');
			query = "";
			
			$.each(actives, function(key, item){
				query += "[data-type-"+item.id+"]";
			});
			
			$(".characters"+query).addClass('show');	
		}else{
			if($(this).hasClass("tier")){ 
				$('.filter--icon.tier.active').removeClass('active');
			}
			
			$(this).addClass('active');
			$(".characters").removeClass('show');
			query = "";
			actives = $('.filter--icon.active');
			
			$.each(actives, function(key, item){
				query += "[data-type-"+item.id+"]";
			});
			
			$(".characters"+query).addClass('show');		
		}
	});
	
	$.each(characters, function (key, item) {
		data = '';
		id = item.name.replace(/\s/g,'_').toLowerCase();
		
		$.each(item.types,function(key, value){ 
			data += "data-type-"+value+" ";
		});
		
		$("#characters-container").append(
			"<div id="+id+" class='characters show' "+data+" >"+
				"<a href='https://wiki.gla.com.br/index.php"+item.link+"'>"+
					"<img src='"+item.img+"' alt='imagem de "+item.name+"' />"+
				"</a>"+
			"</div>"
		);
	});
	
	$(".filter--searchButton").on("click", function(){
		$(".filter--icon.active").removeClass('active');
		$(".characters.show").removeClass('show');
		if($("#f-input").val().toLowerCase() != ''){
			$(".characters[id*="+$("#f-input").val().toLowerCase()+"]").addClass('show');	
		}else {
				$(".characters").addClass('show');	
		}
	});

	$('#f-input').keypress(function (e) {
	 const key = e.which;
	 if(key == 13)  // the enter key code
	  {
	    $('.filter--searchButton').click();
	    return false;  
	  }
	});   

//------- PERSONAGENS ---------

//------- WANTED ---------
	const wanted_slashers = [
    	{name: "Roronoa zoro", wanteds: ["alvida", "arlong", "bepo", "buchi", "chew", "cabaji", "drake", "kid", "luffy", "mohji", "mr. 1", "mr. 4", "mr. 5",
    									 "pearl", "robin", "sanji", "usopp", "urouge", "yonji", "wapol"], img: "/images/6/6f/Card-zoro.png"},
    	{name: "Shanks", wanteds: ["alvida", "arlong", "apoo", "buggy", "bepo", "buchi", "burgess", "bellamy", "chew", "cabaji", "chopper", "capone",
    							   "drake", "franky", "gin", "hatchan", "jango", "koala", "kid", "killer", "krieg", "kuroobi", "kuro", "law", "luffy",
    							   "mohji", "mr. 1", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami", "pearl", "perona", "rebecca", "sanji", "usopp",
    							   "urouge", "ichiji", "niji", "yonji", "van augur", "wapol", "zoro"], img: "/images/a/aa/Card-shanks.png"},
    	{name: "Dracule mihawk", wanteds: ["alvida", "apoo", "buggy", "buchi", "chew", "cabaji", "capone", "drake", "franky", "hawkins", "hatchan",
    									   "jango", "krieg", "kuroobi", "law", "luffy", "mohji", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami",
    									   "pearl", "perona", "robin", "ryuma", "sanji", "usopp", "urouge", "ichiji", "niji", "yonji", "van augur",
    									   "wapol", "zoro"], img: "/images/9/91/Card-mihawk.png"},
    	{name: "Killer", wanteds: ["alvida", "buggy", "jango", "pearl", "rebecca", "van augur"], img: "/images/b/b2/Card-killer.png"},
    	{name: "Tashigi", wanteds: ["alvida", "apoo", "bonney", "bellamy", "gin", "hawkins", "koala", "kid", "killer", "luffy", "mohji", "mr. 2",
    							    "mr. 4", "mr. 5", "goldenweek", "pearl", "sanji", "urouge", "reiju", "wapol"], img: "/images/b/b8/Card-tashigi.png"},
    	{name: "Roronoa zoro (TS)", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "buchi", "brook", "chew", "chopper", "capone", "drake",
    										  "franky", "gin", "hawkins", "hatchan", "hatchan", "jango", "koala", "krieg", "kuroobi", "law", "leo",
    										  "luffy", "mohji", "mr. 1", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "perona", "robin",
    										  "sanji", "usopp", "urouge", "ichiji", "wapol"], img: "/images/7/74/Card-zorots.png"},
    	{name: "Rebbeca", wanteds: ["alvida", "buggy", "buchi", "bellamy", "chew", "cabaji", "capone", "drake", "franky", "gin", "killer", "krieg", 
    								"kuroobi", "kuro", "law", "luffy", "mr. 2", "mr. 4", "mr. 5", "nami", "pearl", "sanji", "usopp", "urouge", "niji",
    							    "yonji", "van augur", "wapol", "ryuma", "doublefinger"], img: "/images/9/91/Card-rebecca.png"},
    	{name: "Carrot", wanteds: ["alvida", "arlong", "buchi", "chew", "chopper", "capone", "drake", "franky", "hawkins", "hatchan", "jango", "kid", "krieg", 
    							   "kuroobi", "law", "leo", "luffy", "mohji", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "robin", "sanji", 
    							   "usopp", "urouge", "ichiji", "niji", "van augur", "zoro"], img: "/images/8/8d/Card-carrot.png"},
    	{name: "Ryuuma", wanteds: ["alvida", "buggy", "bepo", "buchi", "brook", "burgess", "cabaji", "chopper", "drake", "franky", "gin", "hatchan",
    							  "jango", "koala", "kid", "krieg", "kuroobi", "law", "leo", "luffy", "mohji", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami",
    							  "pearl", "perona", "sanji", "urouge", "niji", "yonji", "wapol", "zoro"], img: "/images/a/ac/Card-ryuma.png"},
    	{name: "Trafalga law", wanteds: ["alvida", "arlong", "apoo", "buggy", "buchi", "brook", "burgess", "chew", "drake", "franky", "hawkins", "hatchan",
    									 "jango", "kid", "krieg", "kuroobi", "leo", "luffy", "mohji", "mr. 1", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami",
    									 "pearl", "perona", "robin", "sanji", "usopp", "urouge", "ichiji", "niji", "reiju", "ryuma", "yonji", "wapol"], img: "/images/b/b9/Card-law.png"},
    	{name: "Mr. 1", wanteds: ["alvida", "arlong", "bepo", "buchi", "bellamy", "chew", "cabaji", "capone", "gin", "killer", "krieg", "kuroobi", "kuro",
    							  "law", "mohji", "mr. 2", "mr. 4", "mr. 5", "nami", "pearl", "perona", "niji", "doublefinger"], img: "/images/6/61/Card-dazbonez.png"},
    	{name: "Bastille", wanteds: ["alvida", "arlong", "buchi", "bellamy", "cabaji", "chopper", "gin", "kuro", "law", "mr. 5", "perona", "doublefinger"], img: "/images/1/13/Card-bastille.png"},
    	{name: "Dalmatian", wanteds: ["alvida", "buchi", "capone", "kuroobi", "mohji", "mr. 2", "mr. 4", "mr. 5", "pearl", "perona", "urouge"], img: "/images/9/99/Card-dalmatian.png"},
    	{name: "Morgan", wanteds: ["alvida"], img: "/images/4/43/Card-morgan.png"},
    	{name: "Cabaji", wanteds: ["alvida", "chew", "chopper", "drake", "gin", "hatchan", "jango", "mr. 4", "goldenweek", "nami"], img: "/images/9/9d/Card-cabaji.png"},
    	{name: "Kuro", wanteds: ["alvida", "buchi", "jango", "koala", "krieg", "mohji", "nami", "pearl"], img: "/images/3/3d/Card-kuro.png"},
    	{name: "Eric", wanteds: ["alvida", "apoo", "jango", "mr. 3", "mr. 5", "goldenweek", "usopp"], img: "/images/3/31/Card-eric.png"},
    	{name: "Miss doublefinger", wanteds: ["alvida", "bonney", "buchi", "burgess", "chopper", "capone", "drake", "hawkins", "kid", "kuroobi", "luffy",
    										  "mohji", "mr. 1", "mr. 4", "goldenweek", "doublefinger", "pearl", "rebecca", "sanji", "usopp", "urouge", "yonji", "wapol"], img: "/images/5/5f/Card-doublefinger.png"},
	];
	
	const wanted_shooters = [
		{name: "Capone gang", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "bellamy",
										"chew", "chopper", "franky", "hawkins", "hatchan", "jango", "koala", "krieg", "kuroobi", "kuro",
										"law", "leo", "luffy", "mohji", "mr. 2", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "van augur", 
										"nami", "pearl", "robin", "rebecca", "sanji", "usopp", "ichiji", "niji", "reiju", "yonji", 
										"wapol"], img: "/images/c/c0/Card-capone.png"},
		{name: "Franky", wanteds: ["alvida", "buggy", "buchi", "burgess", "cabaji", "chopper", "capone", "hawkins", "koala", "mohji",
								   "pearl", "sanji", "niji", "yonji", "wapol"], img: "/images/6/61/Card-franky.png"},
		{name: "Eustass kid", wanteds: ["alvida", "buchi", "burgess", "bellamy", "cabaji", "chopper", "capone", "gin", "hawkins","koala", 
										"kid", "krieg", "kuro", "luffy", "mr. 1", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "doublefinger",
										"pearl", "perona", "rebecca", "usopp", "ichiji", "yonji", "kid", "wapol"], img: "/images/9/9a/Card-kid.png"},
		{name: "Van augur", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "chew", 
									  "chopper", "capone", "drake", "franky", "hawkins", "hatchan", "jango", "koala", "killer", 
									  "krieg", "kuroobi", "law", "leo", "luffy", "mohji", "mr. 2", "mr. 3", "mr. 4", "mr. 5",
									  "goldenweek", "nami", "pearl", "robin", "usopp", "urouge", "ichiji", "niji", "reiju", 
									  "yonji", "van augur", "wapol"], img: "/images/c/c7/Card-vanaugur.png"},
    	{name: "Portgas D. Ace", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "bellamy",
    									   "chew", "cabaji", "chopper", "capone", "drake", "franky", "gin", "hawkins", "hatchan", "jango",
    									   "koala", "kid", "killer", "krieg", "kuroobi", "law", "leo", "luffy", "mohji", "mr. 2", "mr. 3",
    									   "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "perona", "usopp", "urouge", "ichiji", "niji",
    									   "reiju", "yonji", "van augur", "wapol", "zoro"], img: "/images/4/40/Card-ace.png"},
    	{name: "Usopp (TS)", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "bellamy", "chew",
    								   "chopper", "drake", "franky", "hawkins", "hatchan", "jango", "krieg", "kuroobi", "law", "leo", "luffy",
    								   "mohji", "mr. 2", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "perona", "rebecca", "ryuma",
    								   "ryuma", "usopp", "ichiji", "niji", "reiju", "yonji", "van augur", "wapol", "zoro"], img: "/images/c/cc/Card-usoppts.png"},
    	{name: "Doflamingo", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "burgess", "bellamy", "chew",
    								   "cabaji", "chopper", "capone", "drake", "franky", "gin", "hawkins", "hatchan", "jango", "koala", "kid", "killer",
    								   "krieg", "kuroobi", "law", "leo", "luffy", "mohji", "mr. 2", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "doublefinger",
    								   "nami", "pearl", "perona", "robin", "ryuma", "sanji", "usopp", "urouge", "ichiji", "niji", "reiju", "yonji", "van augur",
    								   "wapol", "zoro"], img: "/images/8/8d/Card-doflamingo.png"},
    	{name: "Buggy", wanteds: ["alvida", "buchi", "chew", "chopper", "mr. 5"], img: "/images/c/ca/Card-buggy.png"},
    	{name: "Niji", wanteds: ["alvida", "apoo", "buchi", "chew", "cabaji", "jango", "mr. 3", "reiju", "van augur"], img: "/images/6/66/Card-niji.png"},
    	{name: "Wapol", wanteds: ["mohji", "arlong", "buchi", "hawkins", "kid", "kuroobi", "mr. 1", "mr. 4", "pearl", "perona", "rebecca", "yonji", "wapol"], img: "/images/3/31/Card-eric.png"},
    	{name: "Franky (TS)", wanteds: ["alvida", "arlong", "buchi", "burgess", "bellamy", "cabaji", "chopper", "capone", "gin", 
    									"hawkins", "koala", "kid", "killer", "kuro", "mr. 1", "mr. 2", "mr. 4", "mr. 5", "doublefinger",
    									"pearl", "perona", "rebecca", "usopp", "ichiji", "yonji", "wapol", "zoro"], img: "/images/d/d0/Card-frankyts.png"},
    	{name: "Borsalino Kizaru", wanteds: ["alvida", "drake", "jango"], img: "/images/3/32/Card-kizaru.png"},
    	{name: "Don krieg", wanteds: ["alvida", "apoo", "bonney", "buggy", "buchi", "brook", "burgess", "chew", "chopper", "capone", "drake", "hatchan",
    								  "jango", "leo", "mohji", "mr. 3", "mr. 5", "goldenweek", "reiju"], img: "/images/8/8f/Card-krieg.png"},
    	{name: "Eric", wanteds: ["alvida", "apoo", "brook", "jango", "mr. 3", "mr. 5", "usopp"], img: "/images/3/31/Card-eric.png"},
    	{name: "Mr. 4", wanteds: ["alvida", "buchi", "burgess", "chopper", "hawkins", "zoro"], img: "/images/9/90/Card-mr4.png"},
    	{name: "Gin", wanteds: ["alvida", "buchi", "burgess", "cabaji", "chopper", "capone", "drake", "krieg", "mohji", "wapol"], img: "/images/1/18/Card-gin.png"},
    	{name: "Chew", wanteds: ["alvida"], img: "/images/0/0f/Card-chew.png"},
    	{name: "Usopp", wanteds: ["alvida", "bonney", "buchi", "chopper", "jango", "leo", "perona", "niji"], img: "/images/a/ac/Card-usopp.png"},
	];
	
	const wanted_fighters = [
    	{name: "X-Drake", wanteds: ["alvida", "arlong", "apoo", "bepo", "buchi", "brook", "burgess", "bonney", "chopper", "cabaji",
								  "capone", "drake", "franky", "gin", "hatchan", "koala", "kuroobi", "kuro", "killer", "kid", "krieg",
								  "luffy", "mohji", "mr. 1", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "perona", "pearl", "ryuma", "sanji",
								  "usopp", "urougue", "ichiji", "yonji", "van augur", "wapol", "zoro"], img: "/images/6/69/Card-drake.png"},
    	{name: "Hina", wanteds: ["alvida", "buchi", "cabaji", "killer", "pearl", "perona", "sanji", "usopp"], img: "/images/5/57/Card-hina.png"},
    	{name: "Smoker", wanteds: ["arlong", "alvida", "buggy", "bonney", "chopper", "capone", "hawkins", "krieg", "law", "luffy", "mr. 1",
    							   "mr. 2", "mr. 3", "mr. 3", "mr. 4", "mr. 5", "perona", "robin", "urouge", "van augur", "wapol", "zoro"], img: "/images/f/fb/Card-smoker.png"},
    	{name: "Bellamy", wanteds: ["arlong", "alvida", "apoo", "bepo", "buchi", "brook", "burgess", "chopper", "drake", "gin", "kuroobi", "krieg",
    								"law", "luffy", "mohji", "mr. 2", "mr. 4", "pearl", "ryuma", "rebecca", "sanji", "usopp", "urouge", "ichiji", 
    								"yonji", "van augur", "wapol", "zoro"], img: "/images/7/7e/Card-bellamy.png"},						   
		{name: "Urouge", wanteds: ["alvida", "apoo", "buchi", "cabaji", "chew", "capone", "gin", "hawkins", "hatchan", "jango", "koala",
								   "kuroobi", "kuro", "killer", "kid", "krieg", "leo", "law", "luffy", "mohji", "mr. 1", "mr. 2", "mr. 3",
								   "mr. 4", "mr. 5", "doublefinger", "goldenweek", "nami", "perona", "pearl", "robin", "ryuma", "rebecca", 
								   "sanji", "usopp", "urouge", "ichiji", "niji", "reiju", "yonji", "van augur", "wapol", "zoro"], img: "/images/9/98/Card-urouge.png"},    								
		{name: "Hancock", wanteds: ["alvida", "buggy" ,"buchi", "brook", "cabaji", "drake", "jango", "mr. 4", "mr. 5", "pearl", "ichiji", "wapol"], img: "/images/4/47/Card-hancock.png"},
		{name: "Yonji", wanteds: ["kuro"], img: "/images/7/73/Card-yonji.png"},
		{name: "Ichiji", wanteds: ["alvida", "apoo", "buggy", "buchi", "chew", "capone", "jango", "mr. 5", "pearl", "robin", "rebecca", "usopp", "wapol"], img: "/images/8/8c/Card-ichiji.png"},
		{name: "Mr. 2", wanteds: ["alvida", "bonney", "mr. 3"], img: "/images/2/27/Card-bonchan.png"},
		{name: "Sanji (TS)", wanteds: ["alvida", "arlong", "buggy", "bepo", "buchi", "burgess", "chew", "chopper", "drake", "jango", "koala", "killer", "kid", "krieg",
									   "law", "leo", "luffy", "mohji", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami", "pearl", "sanji", "usopp", "urouge",
									   "wapol"], img: "/images/7/7a/Card-sanjits.png"},
		{name: "Luffy (TS)", wanteds: ["alvida", "arlong", "buggy", "bepo", "brook", "burgess", "chopper", "capone", "drake", "franky", "hawkins", "jango", "kuro", "kid",
									   "krieg", "law", "leo", "luffy", "mohji", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "usopp",
									   "urouge", "ichiji", "yonji", "wapol", "zoro"], img: "/images/e/ed/Card-luffyts.png"},
		{name: "Koala", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "brook", "burgess", "bellamy", "chopper", "drake", "franky", "hawkins", "jango", "kuroobi",
								  "kuro", "killer", "law", "luffy", "mohji", "mr. 2", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami", "pearl", "sanji", "usopp", "urouge",
								  "reiju", "yonji", "wapol"], img: "/images/f/f3/Card-koala.png"},									   
  		{name: "Burgess", wanteds: ["alvida", "arlong", "buggy", "bepo", "buchi", "bellamy", "chew", "cabaji", "capone", "franky", "gin", "kuroobi","kuro", "killer", 
  									"kid", "law", "luffy", "mr. 1", "mr. 2", "mr. 4", "doublefinger", "pearl", "rebecca", "ryuma", "usopp", "niji", "yonji", "van augur",
								    "zoro"], img: "/images/2/28/Card-burgess.png"},
		{name: "Luffy", wanteds: ["alvida", "arlong", "apoo", "buggy", "bepo", "buchi", "brook", "burgess", "bellamy", "chew", "cabaji", "chopper", "drake", "franky",
								  "gin", "hawkins", "hatchan", "jango", "koala", "kuroobi", "kuro", "kid", "krieg", "law", "leo", "luffy", "mohji", "mr. 1", "mr. 2", 
								  "mr. 3", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "perona", "pearl", "rebecca", "ryuma", "sanji", "usopp", "urouge", "ichiji",
								  "niji", "yonji", "van augur", "wapol", "zoro"], img: "/images/a/af/Card-luffy.png"},		
		{name: "Bepo", wanteds: ["arlong", "alvida", "buchi", "cabaji", "drake", "jango", "kuro", "luffy", "mohji", "goldenweek", "pearl", "sanji", "wapol", "zoro"], img: "/images/1/1d/Card-bepo.png"},
		{name: "Sanji", wanteds: ["alvida", "buggy", "buchi", "jango", "mr. 4", "usopp", "wapol"], img: "/images/0/04/Card-sanji.png"},
		{name: "Arlong", wanteds: ["alvida"], img: "/images/1/1e/Card-arlong.png"},
		{name: "Gin", wanteds: ["alvida", "buchi", "burgess", "drake", "gin", "krieg", "mr. 5", "van augur", "wapol"], img: "/images/1/18/Card-gin.png"},
	];
	
	const wanted_especialists = [
    	{name: "Vinsmoke Reiju", wanteds: ["alvida", "arlong", "bonney", "brook", "burgess", "bellamy", "cabaji", "gin", "hatchan", "kid", "kuro", "doublefinger", 
    							  "pearl","rebecca", "urouge"], img: "/images/2/23/Card-reiju.png"},
      	{name: "Portgas D. Ace", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "bellamy",
										   "chew", "cabaji", "chopper", "capone", "drake", "franky", "gin", "hawkins", "hatchan", "jango",
										   "koala", "kid", "killer", "krieg", "kuroobi", "law", "leo", "luffy", "mohji", "mr. 2", "mr. 3",
										   "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "perona", "usopp", "urouge", "ichiji", "niji",
										   "reiju", "yonji", "van augur", "wapol", "zoro"], img: "/images/4/40/Card-ace.png"},
    	{name: "Doflamingo", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "burgess", "bellamy", "chew",
    								   "cabaji", "chopper", "capone", "drake", "franky", "gin", "hawkins", "hatchan", "jango", "koala", "kid", "killer",
    								   "krieg", "kuroobi", "law", "leo", "luffy", "mohji", "mr. 2", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "doublefinger",
    								   "nami", "pearl", "perona", "robin", "ryuma", "sanji", "usopp", "urouge", "ichiji", "niji", "reiju", "yonji", "van augur",
    								   "wapol", "zoro"], img: "/images/8/8d/Card-doflamingo.png"},
    	{name: "Borsalino Kizaru", wanteds: ["alvida", "drake", "jango"], img: "/images/3/32/Card-kizaru.png"},
    	{name: "Trafalga law", wanteds: ["alvida", "arlong", "apoo", "buggy", "buchi", "brook", "burgess", "chew", "drake", "franky", "hawkins", "hatchan",
    									 "jango", "kid", "krieg", "kuroobi", "leo", "luffy", "mohji", "mr. 1", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami",
    									 "pearl", "perona", "robin", "sanji", "usopp", "urouge", "ichiji", "niji", "reiju", "yonji", "wapol"], img: "/images/b/b9/Card-law.png"},
    	{name: "Carrot", wanteds: ["alvida", "arlong", "buchi", "chew", "chopper", "capone", "drake", "franky", "hawkins", "hatchan", "jango", "kid", "krieg", 
    							   "kuroobi", "law", "leo", "luffy", "mohji", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "robin", "sanji", 
    							   "usopp", "urouge", "ichiji", "niji", "van augur", "zoro"], img: "/images/8/8d/Card-carrot.png"},			
    	{name: "Nami (TS)", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "chew", "chopper", "drake", 
    										 "franky", "gin", "hawkins", "hatchan", "jango", "koala", "kid", "killer", "kuroobi", "kuro", "law", "leo", "luffy", 
    										 "mohji", "mr. 2", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "doublefinger", "nami", "pearl", "perona","rebecca", "ryuma", 
    										 "sanji", "urouge", "ichiji", "niji", "reiju", "yonji", "wapol", "zoro"], img: "/images/3/35/Card-namits.png"},
		{name: "Nami", wanteds: ["alvida", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "chew", "chopper", "drake", "franky","hawkins", 
								 "hatchan", "jango", "koala", "kid", "killer", "kuroobi", "kuro", "law", "leo", "luffy", "mohji", "mr. 4", "goldenweek",
								 "doublefinger", "nami", "pearl", "perona", "sanji", "urouge", "ichiji", "niji", "wapol"], img: "/images/0/08/Card-nami.png"},    										 
		{name: "Nico Robin", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "buchi", "brook", "burgess", "chew", "chopper", "drake", "franky", 
									   "hawkins", "jango", "kuroobi", "leo", "mr. 3", "mr. 4", "mr. 5", "goldenweek", "nami", "pearl", "perona", "usopp",
									   "urouge", "ichiji", "wapol",], img: "/images/3/3f/Card-robin.png"},
		{name: "Nico Robin (TS)", wanteds: ["alvida", "arlong", "apoo", "bonney", "buchi",  "chew", "jango", "leo", "mr. 3", "goldenweek", "pearl", 
											"perona",], img: "/images/b/b0/Card-robints.png"},
		{name: "Bartolomeu", wanteds: ["alvida", "arlong",  "drake", "jango", "koala", "kuroobi", "pearl", "urouge", "reiju"], img: "/images/a/a9/Card-barto.png"},									
		{name: "Marshall D. Teach", wanteds: ["alvida", "apoo", "bonney", "buggy", "buchi", "chew", "capone", "jango", "killer", "leo", "mr. 2",
											  "pearl", "perona", "perona", "robin"], img: "/images/f/ff/Card-kurohige.png"},
		{name: "Crocodile", wanteds: ["alvida", "bonney", "mr. 1", "yonji"], img: "/images/5/5d/Card-crocodile.png"},
		{name: "Bartolomew Kuma", wanteds: ["alvida", "arlong", "apoo", "bonney", "buggy", "bepo", "buchi", "brook", "burgess", "bellamy", "chew", 
										    "cabaji", "chopper", "capone", "drake", "franky", "gin", "hawkins", "hatchan", "jango", "koala", "kid",
										    "killer", "krieg", "kuroobi", "kuro", "law", "leo", "luffy", "mohji", "mr. 1", "mr. 2", "mr. 3", "mr. 4", 
										    "mr. 5", "doublefinger", "nami", "robin","rebecca", "ryuma", "sanji", "usopp", "urouge", "ichiji", "niji",
										    "reiju", "yonji", "van augur", "wapol", "zoro",], img: "/images/b/b5/Card-kuma.png"},
		{name: "Basil Hawkins", wanteds: ["alvida", "kuroobi", "luffy", "yonji"], img: "/images/8/89/Card-hawkins.png"},	
		{name: "Mohji", wanteds: ["alvida", "bonney", "buggy", "pearl", "van augur"], img: "/images/5/58/Card-mohji.png"},	
		{name: "Leo & Mansherry", wanteds: ["alvida", "bonney", "mohji"], img: "/images/d/d9/Card-leo.png"},	
	];
	
	function filterAndAppend(array, value, id){
		whoDo = array.filter(
			function(v){ 
				return v.wanteds.includes(value);
			}
		);
		
		$.each(whoDo, function (key, item) {
			$(".wantedPortraits#"+id).append(
				"<div class='wantedPortrait' >"+
					"<img src='"+item.img+"' alt='imagem de "+item.name+"' />"+
				"</div>"
			);	
		})
	}
	
	$("#selectbox-wanted").on("input", function(){
		const value = $(this).val();
		
		if($(".wantedPortrait"))
			$(".wantedPortrait").remove();
		
		filterAndAppend(wanted_shooters, value, "wanted-shooter");
		filterAndAppend(wanted_slashers, value, "wanted-slasher");
		filterAndAppend(wanted_fighters, value, "wanted-fighter");
		filterAndAppend(wanted_especialists, value, "wanted-especialist");
	});
//------- WANTED ---------

//------- SKILL TAB ---------
	$('.tab-skill').on('click', function(){ 
		$('.tab-skill.active').removeClass('active');
		$(this).addClass('active');
		const skillId = $(this).data('skill-id');
		if($(".skillInfo[data-skill-id="+ skillId +"]")){
			$(".skillInfo.active").removeClass('active');
			$(".skillInfo[data-skill-id="+ skillId +"]").addClass('active');
		}
	});
//------- SKILL TAB ---------

//------- CALCULATOR XP ---------
const maximum_level = 110;
const tier_values = {
    "diamond" : 0.5,
    "gold": 1, 
    "silver": 2,
    "bronze": 3
}

$(".calcXp--tierIcon").on("click", function() {
	$(".calcXp--tierIcon.active").removeClass('.active');
	$(this).addClass('.active');
});

$("#calculate-btn").on('click', function() {
	getNeededPotions();
});

function calcMissingXpInPotions() {
    const percentToUp = $("#char-percentToUp").val() != "" ? $("#char-percentToUp").val() : 100;
    const currentLevel = $("#char-level").val() != "" ? $("#char-level").val() : 1;
    const levelToUp = $("#char-levelToUp").val() != "" ? $("#char-levelToUp").val() : 110;
    const charTier = $(".calcXp--tierIcon.active") != null ? tier_values[$(".calcXp--tierIcon.active").attr('id')] : null;

    const currentPercentOfXp = 100 - percentToUp;
    const currentXp = ((50 * (Math.pow((currentLevel - 1), 3)) - 150 * (Math.pow((currentLevel - 1), 2)) + 400 * (currentLevel - 1)) / 3) + ((50 * Math.pow(currentLevel, 2) - 150 * currentLevel + 200) * currentPercentOfXp / 100);
    const desiredXp = (50 * (Math.pow((currentLevel - 1), 3)) - 150 * (Math.pow((currentLevel - 1), 2)) + 400 * (levelToUp - 1)) / 3;
    const missingXp = Math.round((desiredXp - currentXp) - (((1000 * charTier)) + ((10000 * charTier)) + ((100000 * charTier)) ));

    const missingPotions = {
        "small": Math.ceil((missingXp / (1000 * charTier))),
        "medium": (missingXp / (10000 * charTier)).toFixed(1),
        "big": (missingXp / (100000 * charTier)).toFixed(2)
    }

    return missingPotions;
}

function calcPotions() {
    const missingPotions = calcMissingXpInPotions();

    let complementaryPotS;
    let complementaryPotM;
    let potS = potions['small'];  
    let potM = potions['medium'];
    let potB = potions['big'];            

    if(String(potS).from(-1) == "0"){        
        potM = Math.ceil(parseFloat(potM));        
    }else{                    
        potM = Math.floor(potM);
        complementaryPotS = potS - potM * 10;
    }            
    
    if(String(potM).from(-1)== "0"){          
        potM = Math.ceil((parseFloat(potM)));
        potB = Math.floor(potB);            
    }
    else{          
        potB = Math.floor(potB)
        complementaryPotM = potM - potB * 10
    }

    const potions = {
        "small": complementaryPotS,
        "medium": complementaryPotM,
        "big": potB        
    }

    return potions;
}

function getNeededPotions() {
    const potions = calcPotions();
    console.log(potions)
}

//------- CALCULATOR XP ---------
 });