web/static/res/js/incchoice.js
changeset 45 f7bfdc49982b
parent 43 21a791340354
child 46 542252e0c615
equal deleted inserted replaced
44:f905a56cc7e6 45:f7bfdc49982b
     2 
     2 
     3 function IncChoice()
     3 function IncChoice()
     4 {
     4 {
     5 	this.currentWorldIndex = 0;
     5 	this.currentWorldIndex = 0;
     6 	this.canSelectWord = true;
     6 	this.canSelectWord = true;
       
     7 	this.image1;
       
     8 	this.image2;
       
     9 	this.image3;
     7 
    10 
     8 	this.setMosaicEffect = function(images1, images2)
    11 	this.setMosaicImages = function(images1, images2, images3)
     9 	{
    12 	{
    10 		// Choose 2 image for the effect
    13 		// Choose 2 image for the effect
    11 		var image1 = images1[incMosaic.randomInt(0, images1.length)];
    14 		this.image1 = images1[incMosaic.randomInt(0, images1.length)];
    12 		var image2 = images2[incMosaic.randomInt(0, images2.length)];
    15 		this.image2 = images2[incMosaic.randomInt(0, images2.length)];
    13         incMosaic.addImageUrl("static/res/img/" + image1);
    16 		this.image3 = images3[incMosaic.randomInt(0, images3.length)];
    14         incMosaic.addImageUrl("static/res/img/" + image2);
       
    15 
    17 
    16         // Start mosaic effect
    18 	    incMosaic.addImageUrl("static/res/img/" + this.image1);
    17     	incMosaic.start("mosaic", effectSpeed, 9, 5, false, true, function() {incChoice.effectIsDone();});        
    19 	    incMosaic.addImageUrl("static/res/img/" + this.image2);
       
    20 	    incMosaic.addImageUrl("static/res/img/" + this.image3);
       
    21 
       
    22 	    incMosaic.start("mosaic", effectSpeed, 9, 5, true, true, function() {incChoice.effectIsDone();});		
    18 	};
    23 	};
    19 
    24 
    20 	this.setWords = function(choiceIndex)
    25 	this.setWordsAndEffect = function(choiceIndex)
    21 	{
    26 	{
    22 		if (choiceIndex == 0) {
    27 		if (choiceIndex == 0) {
    23 			$("#mot1").html("famille");
    28 			$("#mot1").html("famille");
    24 			$("#mot2").html("amour");
    29 			$("#mot2").html("amour");
    25 			$("#mot3").html("travail");
    30 			$("#mot3").html("travail");
    26 			$("#mot4").html("international");
    31 			$("#mot4").html("international");
    27 			$("#mot5").html("dieu");
    32 			$("#mot5").html("dieu");
    28 			$("#mot6").html("president");
    33 			$("#mot6").html("president");
    29 
    34 
       
    35 			// Set images for effect
       
    36 			//incMosaic.clear();
       
    37 	        //incMosaic.addImageUrl("static/res/img/" + this.image1);
       
    38 	        //incMosaic.addImageUrl("static/res/img/" + this.image2);
       
    39 
    30 		} else if (choiceIndex == 1) {
    40 		} else if (choiceIndex == 1) {
    31 			$("#mot1").html("actif");
    41 			$("#mot1").html("actif");
    32 			$("#mot2").html("passif");
    42 			$("#mot2").html("passif");
    33 			$("#mot3").html("corps");
    43 			$("#mot3").html("corps");
    34 			$("#mot4").html("charité");
    44 			$("#mot4").html("charite");
    35 			$("#mot5").html("patrie");
    45 			$("#mot5").html("patrie");
    36 			$("#mot6").html("politique");
    46 			$("#mot6").html("politique");
       
    47 
       
    48 			// Set images for effect
       
    49 			//incMosaic.clear();
       
    50 	        //incMosaic.addImageUrl("static/res/img/" + this.image2);
       
    51 	        //incMosaic.addImageUrl("static/res/img/" + this.image3);
    37 
    52 
    38 		} else {
    53 		} else {
    39 			$("#mot1").html("spleen");
    54 			$("#mot1").html("spleen");
    40 			$("#mot2").html("ideal");
    55 			$("#mot2").html("ideal");
    41 			$("#mot3").html("origines");
    56 			$("#mot3").html("origines");
    42 			$("#mot4").html("peur");
    57 			$("#mot4").html("peur");
    43 			$("#mot5").html("desir");
    58 			$("#mot5").html("desir");
    44 			$("#mot6").html("bonheur");
    59 			$("#mot6").html("bonheur");
       
    60 
       
    61 			// Set images for effect
       
    62 			//incMosaic.clear();
       
    63 	        //incMosaic.addImageUrl("static/res/img/" + this.image3);
       
    64 	        //incMosaic.addImageUrl("static/res/img/" + this.image1);			
    45 		}
    65 		}
       
    66 
       
    67 	    //incMosaic.start("mosaic", effectSpeed, 9, 5, false, true, function() {incChoice.effectIsDone();});        					
    46 	};
    68 	};
    47 
    69 
    48 	this.selectWord = function(wordIndex)
    70 	this.selectWord = function(wordIndex)
    49 	{
    71 	{
    50 		if (!this.canSelectWord) {
    72 		if (!this.canSelectWord) {
    53 		}
    75 		}
    54 
    76 
    55 		this.canSelectWord = false;
    77 		this.canSelectWord = false;
    56 
    78 
    57 		// Start the mosaic effect
    79 		// Start the mosaic effect
    58 		incMosaic.goEffect();
    80 		incMosaic.UnpauseEffect(true);
    59 
    81 
    60 		// Fade the text
    82 		// Fade the text
    61 		$('.big_txt').animate({opacity: 0}, 20000 * 1 / effectSpeed);
    83 		$('.big_txt').animate({opacity: 0}, 20000 * 1 / effectSpeed);
    62 
    84 
    63 		// Save the word
    85 		// Save the word
    67 	this.effectIsDone = function()
    89 	this.effectIsDone = function()
    68 	{
    90 	{
    69 		this.canSelectWord = true;
    91 		this.canSelectWord = true;
    70 		++this.currentWorldIndex;
    92 		++this.currentWorldIndex;
    71 
    93 
    72 		// Change list of words
    94         // Set the list of words and the mosaic effect
    73 		this.setWords(this.currentWorldIndex);
    95 		this.setWordsAndEffect(this.currentWorldIndex);
       
    96 
       
    97 		// Stop the mosaic effect
       
    98 		incMosaic.UnpauseEffect(false);
    74 
    99 
    75 		// Fade the text
   100 		// Fade the text
    76 		$('.big_txt').animate({opacity: 1}, 20000 * 1 / effectSpeed);
   101 		$('.big_txt').animate({opacity: 1}, 20000 * 1 / effectSpeed);
    77 
   102 
    78 		if (this.currentWorldIndex == 3) {
   103 		if (this.currentWorldIndex == 3) {