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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Kargulator PKLi</title>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<script type="text/javascript">
<!--
function valiuc(x,y){
if( !(x.value==null || x.value=='') ){
x.value = x.value.replace(',','.');
if( isFinite(x.value)){
if( y==1 ){
if( document.getElementsByName("typ")[0].checked ){
document.getElementById("izw").value = x.value;
} else {
if( document.getElementsByName("typ")[1].checked ){
document.getElementById("izw").value = 2 * x.value;
} else {
if( document.getElementsByName("typ")[2].checked ){
document.getElementById("izw").value = 4 * x.value;
}
}
}
}
if( y>=2 ){
if (y==2) x = document.getElementById("swk");
var z = document.getElementById('izw');
var srednieWk = x.value/z.value;
if(srednieWk < 0.15) srednieWk = 0.15;
document.getElementById('srd').value = srednieWk;
}
return true;
} else {
alert(x.value+' to nie liczba!');
x.select();
x.focus();
return false;
}
}
}
function typtur(x){
var t = document.getElementById("iuc");
var z = document.getElementById("izw");
if( t.value!=null && t.value!='' && isFinite(t.value) ){
z.value = x * t.value;
}
document.getElementById('izw').readOnly = (x < 4);
}
function loader(show) {
document.getElementById("loader").style.display = show ? 'block' : 'none';
document.getElementById("sqlbuttons").style.display = show ? 'none' : 'block';
document.getElementById("pkltablebox").style.display = show ? 'none' : 'block';
}
function display() {
if (this.status != 200) {
alert(this.responseText);
} else {
var response = JSON.parse(this.responseText);
var sqlPary = ['UPDATE `dodatki` SET `pkl` = 0;'];
var sqlTeamy = ['UPDATE `addons` SET `mastr` = 0;'];
var pklHTML = ['<tr><td class="t">Miejsce</td><td class="t"> PKL </td></tr>'];
for (var place = 1; place <= parseInt(document.getElementsByName('iuc')[0].value); place++) {
sqlPary.push('UPDATE `dodatki` SET `pkl` = ' + response.points[place] + ' WHERE `miejsce` = ' + place + ';');
sqlTeamy.push('UPDATE `addons` SET `mastr` = ' + response.points[place] + ' WHERE `place` = ' + place + ';');
pklHTML.push('<tr><td class="t">' + place + '</td><td class="t">' + response.points[place] + '</td></tr>');
}
pklHTML.push('<tr><td class="p">SUMA PKL</td><td class="t">' + response.sum + '</td></tr>');
document.getElementById('outsql').innerHTML = sqlPary.join("\n");
document.getElementById('outsql2').innerHTML = sqlTeamy.join("\n");
document.getElementById("pkltable").innerHTML = pklHTML.join("");
}
loader(false);
}
function sendit(form) {
var params = {
type: parseInt(form.typ.value),
contestants: parseInt(form.iuc.value),
players: parseInt(form.izw.value),
title_sum: parseFloat(form.swk.value),
tournament_rank: 8-form.rng.value,
over39_boards: parseInt(form.rozdan.value)
}
var tourtypes = ['tk', 'to', 'tp', 'ok', 'ok1', 'ot', 'gp', 'gg'];
tourtypes[101] = 'kmp';
params['manual[players_coefficient]'] = parseFloat(form.zaw.value);
params['manual[min_points]'] = parseInt(form['min' + (8-params.tournament_rank) + (params.over39_boards ? '_' : '')].value);
params['manual[tournament_weight]'] = parseInt(form['r' + tourtypes[params.tournament_rank] + (params.over39_boards ? '_' : '')].value);
for (var i = 0; i < 2; i++) {
params['manual[points_cutoffs]['+i+'][0]'] = parseFloat(form['pru'+(i+1)].value) / 100;
params['manual[points_cutoffs]['+i+'][1]'] = parseFloat(form['prp'+(i+1)].value) / 100;
}
params['manual[points_cutoffs][2][0]'] = parseFloat(form.pru3.value) / 100;
params['manual[points_cutoffs][2][1]'] = 0;
var paramString = [];
for (var param in params) {
paramString.push(param + '=' + params[param]);
}
loader(true);
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', display);
xhr.open('POST', 'api.php', true);
xhr.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
xhr.send(paramString.join('&'));
}
function submitit(ev){
if( document.getElementsByName("typ")[0].checked ||
document.getElementsByName("typ")[1].checked ||
document.getElementsByName("typ")[2].checked ){
if( document.getElementsByName("rng")[0].checked ||
document.getElementsByName("rng")[1].checked ||
document.getElementsByName("rng")[2].checked ||
document.getElementsByName("rng")[3].checked ||
document.getElementsByName("rng")[4].checked ||
document.getElementsByName("rng")[5].checked ||
document.getElementsByName("rng")[6].checked ||
document.getElementsByName("rng")[7].checked ||
document.getElementsByName("rng")[8].checked ||
document.getElementsByName("rng")[9].checked ){
var t = document.getElementById("iuc")
if( t.value!=null && t.value!='' && isFinite(t.value) ){
t = document.getElementById("izw");
if( t.value!=null && t.value!='' && isFinite(t.value) ){
t = document.getElementById("swk");
if( t.value!=null && t.value!='' && isFinite(t.value) ){
sendit(ev);
} else {
alert('Brak sumy WK!');
t.select();
}
} else {
alert('Brak liczby zawodników!');
t.select();
}
} else {
alert('Brak liczby uczestników!');
t.select();
}
} else {
alert('Wybierz rangę turnieju');
document.getElementsByName("rng")[0].select();
}
} else {
alert('Wybierz typ turnieju');
document.getElementsByName("typ")[0].select();
}
}
-->
</script>
</head>
<body style="background-color: #F0F0F0; background-image: none">
<form id="pkl">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/logo_pzbs.gif"></td>
<td colspan="3" align="center"><h3>KALKULATOR PKLI W TURNIEJACH PZBS<br>
zgodny z <span style="color:#d00">nowym regulaminem (obowiązującym od 01.11.2018)</span></h3>
Przejdź do <a href="pkle2014.php"><b>kalkulatora zgodnego ze starym regulaminem</b></a>!
<br><br>
Możesz eksperymentować ze wszystkimi (prawie) parametrami.<br>
Dla przywrócenia stanu regulaminowego otwórz ponownie stronę.</td>
<td><img src="images/logo_pzbs.gif"></td>
</tr>
<tr><td colspan="5"> </td></tr>
<tr>
<td align="center" colspan="2"><b>turniej do 39 rozdań</b></td>
<td align="center" colspan="2"><b>turniej od 40 rozdań</b></td>
</tr>
<tr>
<td align="right">WAGA<br>turnieju</td><td align="left">MINIMUM<br>za 1sze miejsce</td>
<td align="right">WAGA<br>turnieju</td><td align="left">MINIMUM<br>za 1sze miejsce</td>
<td align="left" colspan="3">WSP:</td>
</tr>
<tr>
<td align="right" rowspan="3">
OTP<sup>∗∗∗∗</sup>: <input type="text" id="rgg" name="rgg" maxlength="3" style="width:30px" value="25"><br />
OTP<sup>∗∗∗</sup>: <input type="text" id="rgp" name="rgp" maxlength="3" style="width:30px" value="15"><br />
OTP<sup>∗∗</sup>: <input type="text" id="rot" name="rot" maxlength="3" style="width:30px" value="10"><br />
OTP<sup>∗</sup>: <input type="text" id="rok1" name="rok1" maxlength="3" style="width:30px" value="7"><br />
OTP: <input type="text" id="rok" name="rok" maxlength="3" style="width:30px" value="5"><br />
Regionalny: <input type="text" id="rtp" name="rtp" maxlength="3" style="width:30px" value="4"><br />
Okręgowy: <input type="text" id="rto" name="rto" maxlength="3" style="width:30px" value="2"><br />
Klubowy: <input type="text" id="rtk" name="rtk" maxlength="3" style="width:30px" value="1">
<input type="hidden" id="rkmp" name="rkmp" value="1">
</td>
<td align="left" rowspan="3">
<input type="text" id="min1" name="min1" maxlength="3" style="width:30px" value="200"><br />
<input type="text" id="min2" name="min2" maxlength="3" style="width:30px" value="150"><br />
<input type="text" id="min3" name="min3" maxlength="3" style="width:30px" value="75"><br />
<input type="text" id="min4" name="min4" maxlength="3" style="width:30px" value="50"><br />
<input type="text" id="min5" name="min5" maxlength="3" style="width:30px" value="0"><br />
<input type="text" id="min6" name="min6" maxlength="3" style="width:30px" value="0"><br />
<input type="text" id="min7" name="min7" maxlength="3" style="width:30px" value="0"><br />
<input type="text" id="min8" name="min8" maxlength="3" style="width:30px" value="0">
<input type="hidden" id="min-93" name="min-93" value="0"></td>
<td align="right" rowspan="3">
OTP<sup>∗∗∗∗</sup>: <input type="text" id="rgg_" name="rgg_" maxlength="3" style="width:30px" value="40"><br />
OTP<sup>∗∗∗</sup>: <input type="text" id="rgp_" name="rgp_" maxlength="3" style="width:30px" value="25"><br />
OTP<sup>∗∗</sup>: <input type="text" id="rot_" name="rot_" maxlength="3" style="width:30px" value="15"><br />
OTP<sup>∗</sup>: <input type="text" id="rok1_" name="rok1_" maxlength="3" style="width:30px" value="10"><br />
OTP: <input type="text" id="rok_" name="rok_" maxlength="3" style="width:30px" value="7"><br />
Regionalny: <input type="text" id="rtp_" name="rtp_" maxlength="3" style="width:30px" value="5"><br />
Okręgowy: <input type="text" id="rto_" name="rto_" maxlength="3" style="width:30px" value="3"><br />
Klubowy: <input type="text" id="rtk_" name="rtk_" maxlength="3" style="width:30px" value="2">
<input type="hidden" id="rkmp_" name="rkmp_" value="1">
</td>
<td align="left" rowspan="3">
<input type="text" id="min1_" name="min1_" maxlength="3" style="width:30px" value="300"><br />
<input type="text" id="min2_" name="min2_" maxlength="3" style="width:30px" value="200"><br />
<input type="text" id="min3_" name="min3_" maxlength="3" style="width:30px" value="100"><br />
<input type="text" id="min4_" name="min4_" maxlength="3" style="width:30px" value="70"><br />
<input type="text" id="min5_" name="min5_" maxlength="3" style="width:30px" value="0"><br />
<input type="text" id="min6_" name="min6_" maxlength="3" style="width:30px" value="0"><br />
<input type="text" id="min7_" name="min7_" maxlength="3" style="width:30px" value="0"><br />
<input type="text" id="min8_" name="min8_" maxlength="3" style="width:30px" value="0">
<input type="hidden" id="min-93_" name="min-93_" value="0"></td>
<td align="left" valign="top"><input type="text" id="zaw" name="zaw" maxlength="5" style="width:30px" value="0.05"></td>
<td valign="top" colspan="2">PKL za 1 m = <b>śr.WK×WAGA + il.zaw×WSP</b></td>
</tr>
<tr>
<td align="right" valign="top"><br /><br /><br /><br /><input type="text" id="prp1" name="prp1" style="width:18px" value="90">%<br /><input type="text" id="prp2" name="prp2" style="width:18px" value="20">%</td>
<td colspan="2" align="left"><img src="images/pkle.png"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><table cellspacing="0" cellpadding="0"><tr><td align="right" style="width:50px"><input type="text" id="pru1" name="pru1" style="width:18px" value="2">%</td><td align="right" style="width:25px"><input type="text" id="pru2" name="pru2" style="width:18px" value="20">%</td><td align="right" style="width:55px"><input type="text" id="pru3" name="pru3" style="width:18px" value="50">%</td></tr></table></td>
</tr>
<tr><td colspan="5"> </td></tr>
<tr>
<td valign=top rowspan="2">TYP ZAWODÓW<br />
<input type="radio" name="typ" id="tp1" value="1" onclick="typtur(1)"><label for="tp1"> Indywiduel</label><br />
<input type="radio" name="typ" id="tp2" value="2" onclick="typtur(2)"><label for="tp2"> Pary</label><br />
<input type="radio" name="typ" id="tp3" value="4" onclick="typtur(4)"><label for="tp3"> Teamy</label>
<br><br>LICZBA ROZDAŃ<br>
<input type="radio" name="rozdan" id="rozdan0" value="0"><label for="rozdan0"> do 39</label><br />
<input type="radio" name="rozdan" id="rozdan1" value="1"><label for="rozdan1"> od 40</label>
</td>
<td valign=top rowspan="2">RANGA ZAWODÓW<br />
<input type="radio" name="rng" id="rg_kmp" value="-93"><label for="rg_kmp"> KMP</label><br />
<input type="radio" name="rng" id="rg1" value="1"><label for="rg1"> OTP<sup>∗∗∗∗</sup></label><br />
<input type="radio" name="rng" id="rg2" value="2"><label for="rg2"> OTP<sup>∗∗∗</sup></label><br />
<input type="radio" name="rng" id="rg3" value="3"><label for="rg3"> OTP<sup>∗∗</sup></label><br />
<input type="radio" name="rng" id="rg4" value="4"><label for="rg4"> OTP<sup>∗</sup></label><br />
<input type="radio" name="rng" id="rg5" value="5"><label for="rg5"> OTP</label><br />
<input type="radio" name="rng" id="rg6" value="6"><label for="rg6"> Regionalny</label><br />
<input type="radio" name="rng" id="rg7" value="7"><label for="rg7"> Okręgowy</label><br />
<input type="radio" name="rng" id="rg8" value="8"><label for="rg8"> Klubowy</label>
</td>
<td align="CENTER" valign=top>UCZESTNIKÓW<br />
<input type="text" id="iuc" name="iuc" maxlength="3" style="width:50px" onblur="valiuc(this,1)"><br />
<small>W zależności od typu<br />ilość indywidualistów,<br />par lub teamów</small></td>
<td align="CENTER" valign=top>ZAWODNIKÓW<br />
<input type="text" id="izw" name="izw" readonly="readonly" maxlength="4" style="width:50px" onblur="valiuc(this,2)"><br />
<small>To pole jest wyliczane<br />automatycznie, ale możesz poprawić je<br />dla teamów nieczterosobowych.</small></td>
<td align="CENTER" valign=top>SUMA WK<br />
<input type="text" id="swk" name="swk" maxlength="7" style="width:70px" onblur="valiuc(this,3)"><br />
<small>Suma WK wszystkich<br />zawodników.</small></td>
</tr>
<tr>
<td align="CENTER" colspan="3">Średnie WK zawodnika w turnieju:
<input type="text" id="srd" name="srd" readonly="readonly"><br />
</td>
</tr>
<tr><td colspan="5"> </td></tr>
<tr>
<td align="CENTER" colspan="2">
<input type="button" value="Policz PKLe" onclick="submitit(this.form)"></td>
<td colspan="3">
<div id="sqlbuttons">
<input type="button" value="SQL dla JFR Pary" onclick="document.getElementById('outsql').style.display=(document.getElementById('outsql').style.display=='none') ? 'block' : 'none';document.getElementById('outsql2').style.display='none'"><input type="button" value="SQL dla JFR Teamy" onclick="document.getElementById('outsql2').style.display=(document.getElementById('outsql2').style.display=='none') ? 'block' : 'none';document.getElementById('outsql').style.display='none'">
</div>
</td>
</tr>
<tr><td colspan="2" align="center">
<div id="pkltablebox">
<table id="pkltable"><tr><td class="t">Miejsce</td><td class="t"> PKL </td></tr>
<tr><td class="p">SUMA PKL</td><td class="t"></td></tr>
</table>
</div>
</td><td colspan="3" valign="top"><pre id="outsql" style="display: none"></pre></td>
<td colspan="3" valign="top"><pre id="outsql2" style="display: none"></pre></td></tr>
<tr><td colspan="5" align="center"><small>Gdyby coś nie działało, spróbuj <a href="pkle2018-old.php">poprzedniej wersji kalkulatora</a>.</small></td></tr>
<tr><td colspan="5" class="copyright">©'2009, Jan Romański dla PZBS</td></tr>
</table>
</form>
<div id="loader">Cierpliwości, liczę...</div>
</body>
</html>
|