summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2020-05-13 18:10:12 +0200
committeremkael <emkael@tlen.pl>2020-05-13 18:11:41 +0200
commita99cc025c68f4e1d7df0a20db8f2fe80cd19ce71 (patch)
treebcb3883bdcb42ddb837d83edbfff5285519efbc8
parenteaa70b734619af7dfbc316642c1a17c623ad6e1f (diff)
New API version
-rw-r--r--http/api-inc.php5
-rw-r--r--http/index.php2
-rw-r--r--http/pkle.php2
-rw-r--r--http/pkle2020a.php299
4 files changed, 305 insertions, 3 deletions
diff --git a/http/api-inc.php b/http/api-inc.php
index 96c9ca7..c2336af 100644
--- a/http/api-inc.php
+++ b/http/api-inc.php
@@ -32,7 +32,8 @@ function run($parameters) {
$versionClasses = array(
'1' => 'ApiPklV1', // RegKlas 2018.11.01
'2' => 'ApiPklV2', // RegKMP 2020.01.01
- '_default' => 'ApiPklV2'
+ '3' => 'ApiPklV3', // local BNET 2020.05.01
+ '_default' => 'ApiPklV3'
);
$version = isset($parameters['version']) ? $parameters['version'] : '_default';
$apiClass = isset($versionClasses[$version]) ? $versionClasses[$version] : $versionClasses['_default'];
@@ -234,4 +235,6 @@ class ApiPklV2 extends ApiPklV1 {
}
+class ApiPklV3 extends ApiPklV2 {}
+
?>
diff --git a/http/index.php b/http/index.php
index 0bc46be..13594c7 100644
--- a/http/index.php
+++ b/http/index.php
@@ -1,3 +1,3 @@
<?php
-Header('location: pkle2020.php');
+Header('location: pkle2020a.php');
die();
diff --git a/http/pkle.php b/http/pkle.php
index 0bc46be..13594c7 100644
--- a/http/pkle.php
+++ b/http/pkle.php
@@ -1,3 +1,3 @@
<?php
-Header('location: pkle2020.php');
+Header('location: pkle2020a.php');
die();
diff --git a/http/pkle2020a.php b/http/pkle2020a.php
new file mode 100644
index 0000000..682edf8
--- /dev/null
+++ b/http/pkle2020a.php
@@ -0,0 +1,299 @@
+<!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">&nbsp;&nbsp;&nbsp;PKL&nbsp;&nbsp;&nbsp;</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 = {
+ version: 3, // the 2020 local B**eNET edition
+ 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><br>
+ oraz <span style="color:#d00">nowym regulaminem KMP (obowiązującym od 01.01.2020)</span></h3>
+ Przejdź do <a href="pkle2018.php"><b>kalkulatora zgodnego ze starym regulaminem KMP</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">&nbsp;</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>&lowast;&lowast;&lowast;&lowast;</sup>: <input type="text" id="rgg" name="rgg" maxlength="3" style="width:30px" value="25"><br />
+ OTP<sup>&lowast;&lowast;&lowast;</sup>: <input type="text" id="rgp" name="rgp" maxlength="3" style="width:30px" value="15"><br />
+ OTP<sup>&lowast;&lowast;</sup>: <input type="text" id="rot" name="rot" maxlength="3" style="width:30px" value="10"><br />
+ OTP<sup>&lowast;</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>&lowast;&lowast;&lowast;&lowast;</sup>: <input type="text" id="rgg_" name="rgg_" maxlength="3" style="width:30px" value="40"><br />
+ OTP<sup>&lowast;&lowast;&lowast;</sup>: <input type="text" id="rgp_" name="rgp_" maxlength="3" style="width:30px" value="25"><br />
+ OTP<sup>&lowast;&lowast;</sup>: <input type="text" id="rot_" name="rot_" maxlength="3" style="width:30px" value="15"><br />
+ OTP<sup>&lowast;</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&times;WAGA + il.zaw&times;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>&nbsp;</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">&nbsp;</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">&nbsp;Indywiduel</label><br />
+ <input type="radio" name="typ" id="tp2" value="2" onclick="typtur(2)"><label for="tp2">&nbsp;Pary</label><br />
+ <input type="radio" name="typ" id="tp3" value="4" onclick="typtur(4)"><label for="tp3">&nbsp;Teamy</label>
+ <br><br>LICZBA ROZDAŃ<br>
+ <input type="radio" name="rozdan" id="rozdan0" value="0"><label for="rozdan0">&nbsp;do 39</label><br />
+ <input type="radio" name="rozdan" id="rozdan1" value="1"><label for="rozdan1">&nbsp;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">&nbsp;KMP</label><br />
+ <input type="radio" name="rng" id="rg1" value="1"><label for="rg1">&nbsp;OTP<sup>&lowast;&lowast;&lowast;&lowast;</sup></label><br />
+ <input type="radio" name="rng" id="rg2" value="2"><label for="rg2">&nbsp;OTP<sup>&lowast;&lowast;&lowast;</sup></label><br />
+ <input type="radio" name="rng" id="rg3" value="3"><label for="rg3">&nbsp;OTP<sup>&lowast;&lowast;</sup></label><br />
+ <input type="radio" name="rng" id="rg4" value="4"><label for="rg4">&nbsp;OTP<sup>&lowast;</sup></label><br />
+ <input type="radio" name="rng" id="rg5" value="5"><label for="rg5">&nbsp;OTP</label><br />
+ <input type="radio" name="rng" id="rg6" value="6"><label for="rg6">&nbsp;Regionalny</label><br />
+ <input type="radio" name="rng" id="rg7" value="7"><label for="rg7">&nbsp;Okręgowy</label><br />
+ <input type="radio" name="rng" id="rg8" value="8"><label for="rg8">&nbsp;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:&nbsp;
+ <input type="text" id="srd" name="srd" readonly="readonly"><br />
+ </td>
+ </tr>
+ <tr><td colspan="5">&nbsp;</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">&nbsp;&nbsp;&nbsp;PKL&nbsp;&nbsp;&nbsp;</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" class="copyright">&copy;'2009, Jan Romański dla PZBS</td></tr>
+ </table>
+ </form>
+ <div id="loader">Cierpliwości, liczę...</div>
+ </body>
+</html>