5 this.currentWorldIndex = 0; |
5 this.currentWorldIndex = 0; |
6 this.canSelectWord = true; |
6 this.canSelectWord = true; |
7 this.image1; |
7 this.image1; |
8 this.image2; |
8 this.image2; |
9 this.image3; |
9 this.image3; |
|
10 this.prefixCookieChosenWords = "niv1_ChosenWords"; |
|
11 this.prefixCookieChosenVideos = "niv1_ChosenVideos"; |
|
12 this.prefixCookiePlayedVideos = "niv1_PlayedVideos"; |
|
13 this.prefixCookieSingleVideo = "niv1_SingleVideo"; |
|
14 this.prefixCookieHD = "niv1_HD"; |
|
15 this.prefixCookieSeekTime = "niv1_SeekTime"; |
|
16 |
|
17 //---------------------------------------------------------------------------------------------------------------------------- |
|
18 // Words display |
|
19 //---------------------------------------------------------------------------------------------------------------------------- |
10 |
20 |
11 this.setMosaicImages = function(images1, images2, images3) |
21 this.setMosaicImages = function(images1, images2, images3) |
12 { |
22 { |
13 // Choose 2 image for the effect |
23 // Choose 2 image for the effect |
14 this.image1 = images1[incMosaic.randomInt(0, images1.length)]; |
24 this.image1 = images1[incMosaic.randomInt(0, images1.length)]; |
28 $("#mot1").html("famille"); |
38 $("#mot1").html("famille"); |
29 $("#mot2").html("amour"); |
39 $("#mot2").html("amour"); |
30 $("#mot3").html("travail"); |
40 $("#mot3").html("travail"); |
31 $("#mot4").html("international"); |
41 $("#mot4").html("international"); |
32 $("#mot5").html("dieu"); |
42 $("#mot5").html("dieu"); |
33 $("#mot6").html("president"); |
43 $("#mot6").html("président"); |
34 |
44 |
35 // class |
45 // class |
36 // by default there is the calss blue |
46 // by default there is the class blue |
37 |
47 |
38 } else if (choiceIndex == 1) { |
48 } else if (choiceIndex == 1) { |
39 $("#mot1").html("actif"); |
49 $("#mot1").html("actif"); |
40 $("#mot2").html("passif"); |
50 $("#mot2").html("passif"); |
41 $("#mot3").html("corps"); |
51 $("#mot3").html("corps"); |
42 $("#mot4").html("charite"); |
52 $("#mot4").html("charité"); |
43 $("#mot5").html("patrie"); |
53 $("#mot5").html("patrie"); |
44 $("#mot6").html("politique"); |
54 $("#mot6").html("politique"); |
45 |
55 |
46 // class |
56 // class |
47 $("#choix").removeClass("blue").addClass("white"); |
57 $("#choice").removeClass("blue").addClass("whiteN"); |
48 |
58 |
49 } else { |
59 } else { |
50 $("#mot1").html("spleen"); |
60 $("#mot1").html("spleen"); |
51 $("#mot2").html("ideal"); |
61 $("#mot2").html("idéal"); |
52 $("#mot3").html("origines"); |
62 $("#mot3").html("origines"); |
53 $("#mot4").html("peur"); |
63 $("#mot4").html("peur"); |
54 $("#mot5").html("desir"); |
64 $("#mot5").html("désir"); |
55 $("#mot6").html("bonheur"); |
65 $("#mot6").html("bonheur"); |
56 |
66 |
57 // class |
67 // class |
58 $("#choix").removeClass("white").addClass("red"); |
68 $("#choice").removeClass("whiteN").addClass("red"); |
59 } |
69 } |
60 }; |
70 }; |
|
71 |
|
72 this.effectIsDone = function() |
|
73 { |
|
74 this.canSelectWord = true; |
|
75 |
|
76 // Set the list of words and the mosaic effect |
|
77 this.setWordsAndEffect(this.currentWorldIndex); |
|
78 |
|
79 // Stop the mosaic effect |
|
80 incMosaic.UnpauseEffect(false); |
|
81 |
|
82 // Fade the text |
|
83 $('.big_txt').animate({opacity: 1}, 10000 * 1 / effectSpeed); |
|
84 }; |
|
85 |
|
86 //---------------------------------------------------------------------------------------------------------------------------- |
|
87 // Selected Words |
|
88 //---------------------------------------------------------------------------------------------------------------------------- |
61 |
89 |
62 this.selectWord = function(wordIndex) |
90 this.selectWord = function(wordIndex) |
63 { |
91 { |
64 if (!this.canSelectWord) { |
92 if (!this.canSelectWord) { |
65 // Don't set the word 2 times |
93 // Don't set the word 2 times |
84 // Fade the text |
113 // Fade the text |
85 $('.big_txt').animate({opacity: 0}, 20000 * 1 / effectSpeed); |
114 $('.big_txt').animate({opacity: 0}, 20000 * 1 / effectSpeed); |
86 } |
115 } |
87 }; |
116 }; |
88 |
117 |
89 this.effectIsDone = function() |
|
90 { |
|
91 this.canSelectWord = true; |
|
92 |
|
93 // Set the list of words and the mosaic effect |
|
94 this.setWordsAndEffect(this.currentWorldIndex); |
|
95 |
|
96 // Stop the mosaic effect |
|
97 incMosaic.UnpauseEffect(false); |
|
98 |
|
99 // Fade the text |
|
100 $('.big_txt').animate({opacity: 1}, 10000 * 1 / effectSpeed); |
|
101 }; |
|
102 |
|
103 this.getChoosenWords = function() |
118 this.getChoosenWords = function() |
104 { |
119 { |
105 return [this.getCookie("niv1_world0"), this.getCookie("niv1_world1"), this.getCookie("niv1_world2")]; |
120 var words = []; |
106 }; |
121 for (var i = 0; i < 3; ++i) { |
|
122 words.push(this.getCookie(this.prefixCookieChosenWords + i)); |
|
123 } |
|
124 return words; |
|
125 }; |
|
126 |
|
127 //---------------------------------------------------------------------------------------------------------------------------- |
|
128 // Random Chosen Videos |
|
129 //---------------------------------------------------------------------------------------------------------------------------- |
|
130 |
|
131 this.saveChosenVideos = function(indexs) |
|
132 { |
|
133 for (var i = 0; i < indexs.length; ++i) { |
|
134 this.setCookie(this.prefixCookieChosenVideos + i, indexs[i]); |
|
135 } |
|
136 }; |
|
137 |
|
138 this.getChosenVideos = function() |
|
139 { |
|
140 var indexs = []; |
|
141 for (var i = 0; i < 3; ++i) { |
|
142 var n = this.getCookie(this.prefixCookieChosenVideos + i); |
|
143 if (n !== null) { |
|
144 n = parseInt(n); |
|
145 if (n != -1) { |
|
146 indexs.push(n); |
|
147 } |
|
148 } |
|
149 } |
|
150 return indexs; |
|
151 }; |
|
152 |
|
153 //---------------------------------------------------------------------------------------------------------------------------- |
|
154 // All time played videos |
|
155 //---------------------------------------------------------------------------------------------------------------------------- |
|
156 |
|
157 this.getChoosenVideosFlags = function() |
|
158 { |
|
159 var var32bits = []; |
|
160 |
|
161 // Get previous used videos |
|
162 for (var i = 0; i < 3; ++i) { |
|
163 var v32 = this.getCookie(this.prefixCookiePlayedVideos + i); |
|
164 v32 = v32 === null ? 0 : parseInt(v32); |
|
165 var32bits.push(v32); |
|
166 } |
|
167 |
|
168 return var32bits; |
|
169 }; |
|
170 |
|
171 this.savePlayedVideos = function(indexs, markPlayed) |
|
172 { |
|
173 // This function used 3 values of 32 bits to records used videos |
|
174 // This means we can record the state of 32 * 3 = 96 videos |
|
175 |
|
176 // Get previous used videos |
|
177 var var32bits = this.getChoosenVideosFlags(); |
|
178 |
|
179 // Update 32 bits flags var |
|
180 var i; |
|
181 for (i = 0; i < indexs.length; ++i) { |
|
182 var index = indexs[i]; |
|
183 for (var j = 0; j < var32bits.length; ++j) { |
|
184 var indexMax = (j+1)*32; |
|
185 if (index < indexMax) { |
|
186 var flag = 1 << (index - indexMax + 32); |
|
187 if (markPlayed) { |
|
188 var32bits[j] = var32bits[j] | flag; |
|
189 } else { |
|
190 var32bits[j] = var32bits[j] & ~flag; |
|
191 } |
|
192 break; |
|
193 } |
|
194 } |
|
195 } |
|
196 |
|
197 // Save updated flags |
|
198 for (i = 0; i < 3; ++i) { |
|
199 this.setCookie(this.prefixCookiePlayedVideos + i, var32bits[i]); |
|
200 } |
|
201 }; |
|
202 |
|
203 this.IsThisVideoWasPlayed = function(var32bits, index) |
|
204 { |
|
205 for (var j = 0; j < var32bits.length; ++j) { |
|
206 var indexMax = (j+1)*32; |
|
207 if (index < indexMax) { |
|
208 return var32bits[j] & (1 << (index - indexMax + 32)); |
|
209 } |
|
210 } |
|
211 return false; |
|
212 } |
|
213 |
|
214 this.clearAllVideosChoices = function() |
|
215 { |
|
216 for (i = 0; i < 3; ++i) { |
|
217 this.removeCookie(this.prefixCookiePlayedVideos + i); |
|
218 } |
|
219 }; |
|
220 |
|
221 //---------------------------------------------------------------------------------------------------------------------------- |
|
222 // Single video |
|
223 //---------------------------------------------------------------------------------------------------------------------------- |
|
224 |
|
225 this.saveSingleVideo = function(name) |
|
226 { |
|
227 this.setCookie(this.prefixCookieSingleVideo, name); |
|
228 }; |
|
229 |
|
230 this.getSingleVideo = function() |
|
231 { |
|
232 return this.getCookie(this.prefixCookieSingleVideo); |
|
233 }; |
|
234 |
|
235 //---------------------------------------------------------------------------------------------------------------------------- |
|
236 // Hd |
|
237 //---------------------------------------------------------------------------------------------------------------------------- |
|
238 |
|
239 this.setHD = function(state) |
|
240 { |
|
241 this.setCookie(this.prefixCookieHD, state); |
|
242 }; |
|
243 |
|
244 this.getHD = function() |
|
245 { |
|
246 var hd = this.getCookie(this.prefixCookieHD); |
|
247 if (hd == "0") { |
|
248 return false; |
|
249 } |
|
250 return true; |
|
251 }; |
|
252 |
|
253 this.setSeekTime = function(time) |
|
254 { |
|
255 this.setCookie(this.prefixCookieSeekTime, time); |
|
256 }; |
|
257 |
|
258 this.getSeekTime = function() |
|
259 { |
|
260 var time = this.getCookie(this.prefixCookieSeekTime); |
|
261 if (time === null) { |
|
262 return 0; |
|
263 } |
|
264 return time; |
|
265 }; |
|
266 |
|
267 //---------------------------------------------------------------------------------------------------------------------------- |
|
268 // Cookies tools |
|
269 //---------------------------------------------------------------------------------------------------------------------------- |
107 |
270 |
108 this.setCookie = function(name, value) |
271 this.setCookie = function(name, value) |
109 { |
272 { |
110 $.removeCookie(name); |
273 this.removeCookie(name); |
111 $.cookie(name, value, { expires: 7, path: '/' }); |
274 $.cookie(name, value, { expires: 7, path: '/' }); |
112 }; |
275 }; |
113 |
276 |
114 this.getCookie = function(name) { |
277 this.getCookie = function(name) |
|
278 { |
115 return $.cookie(name); |
279 return $.cookie(name); |
116 }; |
280 }; |
|
281 |
|
282 this.removeCookie = function(name) |
|
283 { |
|
284 $.removeCookie(name, { path: '/' }); |
|
285 }; |
117 } |
286 } |
118 |
287 |
119 var incChoice = new IncChoice(); |
288 var incChoice = new IncChoice(); |