Roulette-a-donjons/101-150/js/index.js

138 lines
3.2 KiB
JavaScript

$(document).ready(function(){
var quoteSource=[
{
quote: "Goulet du Rasboul",
name:"Silf le Rasboul Majeur"
},
{
quote:"Bibliothèque du Maître Corbac",
name:"Maître Corbac"
},
{
quote:"Donjon des Rats de Bonta",
name:"Rat Blanc"
},
{
quote:"Donjon des Rats de Brâkmar",
name:"Rat Noir"
},
{
quote:"Miausolée du Pounicheur",
name:"Pounicheur"
},
{
quote:"Antre du Blops Multicolore Royal",
name:"Blops Multicolore Royal"
},
{
quote:"Centre du Labyrinthe du Minotoror",
name:"Minotoror"
},
{
quote:"Serre du Royalmouth",
name:"Royalmouth"
},
{
quote:"Repaire des Pandikazes",
name:"Maître Pandore"
},
{
quote:"Tofulailler Royal",
name:"Tofu Royal"
},
{
quote:"Donjon des Dragoeufs",
name:"Crocabulia"
},
{
quote:"Repaire de Skeunk",
name:"Skeunk"
},
{
quote:"Mégalithe de Fraktale",
name:"Fraktale"
},
{
quote:"Donjon des Kitsounes",
name:"Tanukouï San"
},
{
quote:"Volière de la Haute Truche",
name:"Haute Truche"
},
{
quote:"Caverne d'El Piko",
name:"El Piko"
},
{
quote:"Ring du Capitaine Ekarlatte",
name:"Capitaine Ekarlatte"
},
{
quote:"Donjon des Firefoux",
name:"Péki Péki"
},
{
quote:"Clairière du Chêne Mou",
name:"Chêne Mou"
},
{
quote:"Laboratoire du Tynril",
name:"Tynrils"
},
{
quote:"Excavation du Mansot Royal",
name:"Mansot Royal"
},
{
quote:"Épave du Grolandais Violent",
name:"Ben le Ripate"
},
{
quote:"Donjon des Rats du Château d'Amakna",
name:"Sphincter Cell"
},
{
quote:"Galerie du Phossile",
name:"Phossile"
},
{
quote:"Tu devrais aussi t'intéresser au JcJ. Va donc taper un percepteur !",
name:"La Voix de la Raison"
}
];
$('#quoteButton').click(function(evt){
//define the containers of the info we target
var quote = $('#quoteContainer p').text();
var quoteGenius = $('#quoteGenius').text();
//prevent browser's default action
evt.preventDefault();
//getting a new random number to attach to a quote and setting a limit
var sourceLength = quoteSource.length;
var randomNumber= Math.floor(Math.random()*sourceLength);
//set a new quote
for(i=0;i<=sourceLength;i+=1){
var newQuoteText = quoteSource[randomNumber].quote;
var newQuoteGenius = quoteSource[randomNumber].name;
//console.log(newQuoteText,newQuoteGenius);
var timeAnimation = 500;
var quoteContainer = $('#quoteContainer');
//fade out animation with callback
quoteContainer.fadeOut(timeAnimation, function(){
quoteContainer.html('');
quoteContainer.append('<p>'+newQuoteText+'</p>'+'<p id="quoteGenius">'+'- '+newQuoteGenius+'</p>');
//fadein animation.
quoteContainer.fadeIn(timeAnimation);
});
break;
};//end for loop
});//end quoteButton function
});//end document ready