diff -r f2123b4487e9 -r 01415303372e web/static/res/js/incchoice.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/static/res/js/incchoice.js Tue Dec 11 17:39:04 2012 +0100 @@ -0,0 +1,50 @@ +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(); \ No newline at end of file