-
Notifications
You must be signed in to change notification settings - Fork 2
/
slot.js
172 lines (141 loc) · 5.02 KB
/
slot.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*NE RADI*/
/*import { createRequire } from 'module';
const require = createRequire(import.meta.url);
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "casino"
});*/
const apple = 'apple.png';
const cherry = 'cherry.png';
const lemon = 'lemon.png';
const grape = 'grape.png';
const seven = 'seven.png';
const diamond = 'diamond.png';
const heart = 'heart.png';
const orange = 'orange.png';
const slike = [apple, cherry, lemon, grape, seven, diamond, heart, orange];
var counter1 = 0;
var counter2 = 0;
var counter3 = 0;
var time = 1400;
function start() {
x = setInterval(slot_one, 10);
y = setInterval(timer, 10);
}
function pocetak() {
slot_a = Math.floor(Math.random() * slike.length);
var img1 = new Image();
img1.src = slike[slot_a];
img1.width = "200";
img1.height = "200";
document.getElementById('slika1').appendChild(img1);
slot_b = Math.floor(Math.random() * slike.length);
var img2 = new Image();
img2.src = slike[slot_b];
img2.width = "200";
img2.height = "200";
document.getElementById('slika2').appendChild(img2);
slot_c = Math.floor(Math.random() * slike.length);
var img3 = new Image();
img3.src = slike[slot_c];
img3.width = "200";
img3.height = "200";
document.getElementById('slika3').appendChild(img3);
}
function slot_one() {
document.getElementById("cestitka").innerHTML = "";
counter1++;
console.log(counter1);
if(counter1 === 60) {
slot_a = Math.floor(Math.random() * slike.length);
document.getElementById('slika1').innerHTML = "";
var img = new Image();
img.src = slike[slot_a];
img.width = "200";
img.height = "200";
document.getElementById('slika1').appendChild(img);
/*clearInterval(x);*/
}
counter2++;
if(counter2 === 100) {
slot_b = Math.floor(Math.random() * slike.length);
document.getElementById('slika2').innerHTML = "";
var img = new Image();
img.src = slike[slot_b];
img.width = "200";
img.height = "200";
document.getElementById('slika2').appendChild(img);
/*clearInterval(y);*/
}
counter3++;
if(counter3 === 140) {
slot_c = Math.floor(Math.random() * slike.length);
document.getElementById('slika3').innerHTML = "";
var img = new Image();
img.src = slike[slot_c];
img.width = "200";
img.height = "200";
document.getElementById('slika3').appendChild(img);
counter1 = 0;
counter2 = 0;
counter3 = 0;
clearInterval(x);
if(slot_a === slot_b && slot_a === slot_c && slot_b === slot_c) {
document.getElementById("cestitka").innerHTML = "Čestitamo + 1000$";
var objXMLHttpRequest = new XMLHttpRequest();
objXMLHttpRequest.onreadystatechange = function() {
if(objXMLHttpRequest.readyState === 4) {
if(objXMLHttpRequest.status === 200) {
alert(objXMLHttpRequest.responseText);
} else {
alert('Error Code: ' + objXMLHttpRequest.status);
alert('Error Message: ' + objXMLHttpRequest.statusText);
}
}
}
objXMLHttpRequest.open('GET', 'update_balance_win.php');
objXMLHttpRequest.send();
} else {
document.getElementById("cestitka").innerHTML = "";
var objXMLHttpRequest = new XMLHttpRequest();
objXMLHttpRequest.onreadystatechange = function() {
if(objXMLHttpRequest.readyState === 4) {
if(objXMLHttpRequest.status === 200) {
/*alert(objXMLHttpRequest.responseText);*/
} else {
/*alert('Error Code: ' + objXMLHttpRequest.status);
alert('Error Message: ' + objXMLHttpRequest.statusText);*/
}
}
}
objXMLHttpRequest.open('GET', 'update_balance_lose.php');
objXMLHttpRequest.send();
/*NE RADI*/
/*con.connect(function(err) {
if (err) throw err;
var sql = "UPDATE balance SET balance = '-20' WHERE username = $_SESSION['username']";
con.query(sql, function (err, result) {
if (err) throw err;
console.log(result.affectedRows + " record(s) updated");
});
});*/
}
}
}
function timer() {
document.getElementById("timer").innerHTML = "";
time -= 10;
document.getElementById("timer").innerHTML = time;
if(time === 0) {
document.getElementById("timer").innerHTML = "DONE";
time = 1400;
clearInterval(y);
}
}
function balance() {
setInterval(function() {
}, 0);
}