web/static/res/js/incchoice.js
author Edwin Razafimahatratra <edwin@robotalismsoft.com>
Tue, 11 Dec 2012 17:39:04 +0100
changeset 42 01415303372e
child 43 21a791340354
permissions -rw-r--r--
écran choix

var effectSpeed = 8;

function IncChoice()
{
	this.currentWorldIndex = -1;
	this.lastWorldIndex = -1;

	this.setMosaicEffect = function(images1, images2, nextUrl)
	{
		// Choose 2 image for the effect
		var image1 = images1[incMosaic.randomInt(0, images1.length)];
		var image2 = images2[incMosaic.randomInt(0, images2.length)];
        incMosaic.addImageUrl("static/res/img/" + image1);
        incMosaic.addImageUrl("static/res/img/" + image2);

        // Start mosaic effect
    	incMosaic.start("mosaic", effectSpeed, 9, 5, false, true, function() { location.href = nextUrl;});        
	};

	this.selectWord = function(word)
	{
		if (this.currentWorldIndex == this.lastWorldIndex) {
			// Don't set the word 2 times
			return;
		}

		// Start the mosaic effect
		incMosaic.goEffect();

		// Fade the text
		$('.big_txt').animate({opacity: 0}, 20000 * 1 / effectSpeed);

		// Save the word
		this.setCookie("niv1_world" + this.currentWorldIndex, word);
		this.lastWorldIndex = this.currentWorldIndex;
		//++this.currentWorldIndex;
	};

	this.setCookie = function(name, value)
	{
		$.removeCookie(name);
		$.cookie(name, value, { expires: 7, path: '/' });    	
    };

	this.getCookie = function(name) {
		return $.cookie(name);
	};
}

var incChoice = new IncChoice();