-
Notifications
You must be signed in to change notification settings - Fork 0
/
booms.js
executable file
·78 lines (68 loc) · 2.36 KB
/
booms.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Jedna zmienna wystarczy
var numerWiersza = 1;
// Komora losująca
function komoraLosujaca(n) {
return Math.floor(Math.random() * (n));
}
// Podstaw wylosowane frazy do htmla
function podstawRzeczy(n) {
$(".v1").html(rzeczy[n][0]);
$(".v3").html(rzeczy[n][1]);
}
function podstawBombe(n) {
$(".v2a").html(bomby[n][0]);
$(".v2b").html(bomby[n][1]);
$(".v2c").html(bomby[n][2]);
$(".v2d").html(bomby[n][3]);
}
// Jedziemy
$(document).ready(function () {
"use strict";
function booms() {
switch(numerWiersza) {
// Case 1+2+3 to wiersze z repetytorium, więc stałe wartości
// setTimeout czeka ze zmianą treści aż fadeout się dopełni
case 1:
podstawRzeczy(0);
podstawBombe(0);
$(".vliczba").html(numerWiersza);
numerWiersza = numerWiersza + 1;
break;
case 2:
$(".generator").fadeOut();
setTimeout(function(){
podstawRzeczy(1);
podstawBombe(1);
$(".vliczba").html(numerWiersza);
numerWiersza = numerWiersza + 1;
$(".generator").fadeIn();
}, 500);
break;
case 3:
$(".generator").fadeOut();
setTimeout(function(){
podstawRzeczy(2);
podstawBombe(2);
$(".vliczba").html(numerWiersza);
numerWiersza = numerWiersza + 1;
$(".generator").fadeIn();
}, 500);
break;
default:
$(".generator").fadeOut();
setTimeout(function(){
// Losujemy frazy i podstawiamy je
var wylosowanaRzecz = komoraLosujaca(maksimumRzecz),
wylosowanaBomba = komoraLosujaca(maksimumBomba);
podstawRzeczy(wylosowanaRzecz);
podstawBombe(wylosowanaBomba);
$(".vliczba").html(numerWiersza);
numerWiersza = numerWiersza + 1;
$(".generator").fadeIn();
}, 500);
}
// CZAS JEDNEGO WIERSZA = 10000ms
setTimeout(booms, 10000);
}
booms();
});